Author Topic: BassMix and WASAPI, DirectSound not resampling  (Read 282 times)

Chris Oakley

  • Posts: 59
Hi, I read that having a BassMix mixer and adding a WASAPI recording channel to it or a DirectSound recording channel to it will cause the added channels to resample to the rate of the mixer, but I'm not getting that behaviour at all. Have I missed something?

I create my mixer like this:

Code: [Select]
iMixerChan = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_MIXER_NONSTOP)
and then add the channel like this:

Code: [Select]
BassMix.BASS_Mixer_StreamAddChannel(iMixerChan, RChan, BASSFlag.BASS_MIXER_BUFFER Or BASSFlag.BASS_MIXER_LIMIT)
I don't want to recreate the mixer with the new channels sample rate because I've other things tied to it like a recorder, and to recreate the mixer would mean I would need to re setup the recorder.

Note that I could be adding a WASAPI channel which could have a sample rate of 48000.

Chris Oakley

  • Posts: 59
Re: BassMix and WASAPI, DirectSound not resampling
« Reply #1 on: 20 Feb '18 - 10:21 »
Just further to this, I discovered if I apply this command:

Code: [Select]
Bass.BASS_ChannelSetAttribute(RChan, BASSAttribute.BASS_ATTRIB_FREQ, 44100)
then as long as I set my mixer up in 44100 then it get's resampled to the correct rate. Is this the right way to do things or will this lead to potential problems?

Ian @ un4seen

  • Administrator
  • Posts: 21130
Re: BassMix and WASAPI, DirectSound not resampling
« Reply #2 on: 20 Feb '18 - 16:19 »
Is the source sounding like it's being played at the wrong speed, ie. too fast or slow? If so, it is probable that at least one of the "iMixerChan" and "RChan" channels' sample rate doesn't match the corresponding device's rate. If both are using WASAPI devices via BASSWASAPI, check that the "freq" parameters in the BASS_Mixer_StreamCreate and BASS_StreamCreate calls match the device's rate, which you can get from BASS_WASAPI_GetInfo. Also check that you're using BASS_WASAPI_SetDevice to set the device context appropriately first, ie. it should be the output device for the BASS_Mixer_StreamCreate call and the input device for the BASS_StreamCreate call.

Chris Oakley

  • Posts: 59
Re: BassMix and WASAPI, DirectSound not resampling
« Reply #3 on: 20 Feb '18 - 16:42 »
Thanks Ian, I went down this route. Yes, it was sounding like it was too fast. The issue I have is that I create the mixer on startup, and I don't want to recreate it because I'm recording it and monitoring it for silence, so I needed a way to accomodate.

Using the ATTRIB solved the problem, but as I say I never know I'm doing things properly or if this is a dirty fix.

Ian @ un4seen

  • Administrator
  • Posts: 21130
Re: BassMix and WASAPI, DirectSound not resampling
« Reply #4 on: 20 Feb '18 - 17:31 »
It sounds like the mixer's sample rate doesn't match the output device, in which case, changing the input stream's BASS_ATTRIB_FREQ setting to compensate is indeed a bit of a dirty fix :)

Are you using exclusive mode WASAPI output? If not, I would recommend using normal BASS output instead of BASSWASAPI for the mixer, ie. remove the BASS_STREAM_DECODE flag from it and call BASS_ChannelPlay to start it.

Chris Oakley

  • Posts: 59
Re: BassMix and WASAPI, DirectSound not resampling
« Reply #5 on: 21 Feb '18 - 14:57 »
What I've not said is that I'm using the mixer as a source for an encoder for casting so I'm not sure I can remove the DECODE. I'm not using WASAPI in exclusive mode.

Ian @ un4seen

  • Administrator
  • Posts: 21130
Re: BassMix and WASAPI, DirectSound not resampling
« Reply #6 on: 21 Feb '18 - 17:08 »
The output change shouldn't make any difference to encoding, as the mixer will still be played, but by BASS instead of BASSWASAPI. The encoder/caster will be receiving the mixer output as it is generated for playback in both cases.