Author Topic: Capture audio from output device1 and play in output device2 ? (wasapi)  (Read 148 times)

euflasio

  • Posts: 6
Hi,

Can someone give me a example of how capture audio from output device 1  and play it in output device 2 , in real time , using Bass wasapi ?

Thanks very much !!

Ian @ un4seen

  • Administrator
  • Posts: 26093
BASS uses WASAPI itself by default, so you probably don't really need the BASSWASAPI add-on for this. You would record from device1's "loopback" and play the captured data on device2. It could look something like this:

Code: [Select]
BASS_Init(outdevice, 44100, 0, 0, 0); // initialize output device
BASS_RecordInit(indevice); // initialize input "loopback" device
inchan = BASS_RecordStart(0, 0, BASS_SAMPLE_FLOAT, 0, 0); // start recording in native format
BASS_CHANNELINFO info;
BASS_ChannelGetInfo(inchan, &info); // get the format
outchan = BASS_StreamCreate(info.freq, info.chans, BASS_SAMPLE_FLOAT, StreamProc, 0); // create stream with same format
BASS_ChannelSetAttribute(outchan, BASS_ATTRIB_BUFFER, 0); // disable playback buffering for lower latency
BASS_ChannelStart(outchan); // start it

...

DWORD CALLBACK StreamProc(HSTREAM handle, void *buffer, DWORD length, void *user)
{
return BASS_ChannelGetData(inchan, buffer, length); // fetch data from the recording
}

You can use BASS_GetDeviceInfo and BASS_RecordGetDeviceInfo to enumerate the available devices and get the "outdevice" and "indevice" values. Note that loopback devices have the BASS_DEVICE_LOOPBACK flag set. Please see the documentation for details on the mentioned functions.

euflasio

  • Posts: 6
thanks very much :)