Author Topic: Play live input thru two or more devices  (Read 1801 times)

SoundMike

  • Posts: 331
Play live input thru two or more devices
« on: 16 Jan '07 - 01:26 »
I want to take live input (via BASS_Record...) and play it back directly thru two or more devices simultaneously. I've looked at the LiveFX example, where a single playback stream pulls data from the recording channel via the streamproc callback. Is there a way in which that data could be passed to a second (, third, ...) playback stream? I did think about upmixing using BASS_Mixer but unless I'm mistaken a BASS Mixer only supports a single output device.

Thanks,
Mike

Ian @ un4seen

  • Administrator
  • Posts: 20437
Re: Play live input thru two or more devices
« Reply #1 on: 16 Jan '07 - 13:28 »
You'll have to buffer the data from the recording channel, so that you can feed it to all the output streams. For example, if using BASS_ChannelGetData to get the recorded data (as in LIVEFX), your STREAMPROC could look something like this...

Code: [Select]
DWORD CALLBACK StreamProc(HSTREAM handle, void *buf, DWORD len, DWORD user)
{
if (!user) recbuflen=BASS_ChannelGetData(hrecord, recbuf, len); // get recording data
if (len>recbuflen) len=recbuflen; // restrict length to buffered amount
memcpy(buf, recbuf, len); // copy data from recording
return len;
}

...where "user" is set to the output number (0=first). Note this is untested, and the buffer may need some read/write pointers to ensure all outputs get all the data.

SoundMike

  • Posts: 331
Re: Play live input thru two or more devices
« Reply #2 on: 17 Jan '07 - 09:17 »
Thanks, Ian. Initial testing looks promising - just having fun trying to get my read and write pointers correct! This is necessary, as you indicated, as the streamproc's for the various outputs are not necessarily called in order, and may have differing 'length' settings.

Mike