Author Topic: mono webcam audio not converted as expected in WASAPI  (Read 270 times)

MikeV

  • Posts: 181
Adding a WASAPI input to my mixer works fine, except for (multiple) webcams that have a mono channel which end up sounding like Donald Duck. Is this a bug or am I doing something wrong?

// create input
BASS_WASAPI_Init(index, 0, 0, BASS_WASAPI_BUFFER, 0.1, 0.0,
WasapiInputProc, &structWasapiInputProc);
BASS_WASAPI_GetDeviceInfo(structWasapiInputProc.input, &info); // mixfreq returns 48000, mixchans 2
// stream
BASS_StreamCreate(info.mixfreq, info.mixchans, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE, STREAMPROC_PUSH, this);

Ian @ un4seen

  • Administrator
  • Posts: 21211
There should generally be a mixer between the WASAPI output and the source stream, to handle any necessary sample format conversion. The mixer would have the same sample format as the WASAPI output, while the source stream has the format of the source data, ie. mono in this case. The code could be modified something like this:

Code: [Select]
// create input
BASS_WASAPI_Init(index, 0, 0, BASS_WASAPI_BUFFER, 0.1, 0.0,
WasapiInputProc, &structWasapiInputProc);
BASS_WASAPI_GetDeviceInfo(structWasapiInputProc.input, &info); // mixfreq returns 48000, mixchans 2
// mixer
mixer=BASS_Mixer_StreamCreate(info.mixfreq, info.mixchans, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE);
// stream
source=BASS_StreamCreate(sourcefreq, sourcechans, BASS_SAMPLE_FLOAT|BASS_STREAM_DECODE, STREAMPROC_PUSH, this);
BASS_Mixer_StreamAddChannel(mixer, source, 0);

MikeV

  • Posts: 181
As I mentioned the stream is plugged into a mixer, I omitted that code for clarity. However I now understand the problem: WASAPI does not convert the data to mixfreq/chans and so for the correct stream settings I need to get that info from BASS_WASAPI_GetInfo. Thanks, it works fine now :).