Author Topic: Is it possible to add a Mixer to another Mixer  (Read 201 times)

Chris Oakley

  • Posts: 32
I just wondered if it's possible to add a new mixer to another mixer. I'm wanting to do this because I'm having trouble resampling a recording channel coming in on 48khz. I want to encode it at different rates and changing it is proving to be a pain.

Ian @ un4seen

  • Administrator
  • Posts: 20764
Re: Is it possible to add a Mixer to another Mixer
« Reply #1 on: 2 May '18 - 14:50 »
Yes, mixers can be plugged into other mixers. You just need to set the BASS_STREAM_DECODE flag on the mixer(s) that you want to plug into another mixer.

Chris Oakley

  • Posts: 32
Re: Is it possible to add a Mixer to another Mixer
« Reply #2 on: 2 May '18 - 16:38 »
What if the mixer you're plugging into, let's call it the master mixer, is already a BASS_STREAM_DECODE mixer? Will that work?

Ian @ un4seen

  • Administrator
  • Posts: 20764
Re: Is it possible to add a Mixer to another Mixer
« Reply #3 on: 2 May '18 - 17:07 »
Yes, that is fine. It allows you to have a mixer plugged into a mixer, plugged into a mixer, etc.

Chris Oakley

  • Posts: 32
Re: Is it possible to add a Mixer to another Mixer
« Reply #4 on: 2 May '18 - 17:35 »
Thanks Ian. It must be going wrong somewhere further down the chain then as when I try to start an encoder on the new sub mixer it doesn't recognise the Khz on the server and drops.

This is essentially what I'm doing. First I create the main mixer. This is the mixer that hosts everything:

Code: [Select]
MixerChan = BassMix.BASS_Mixer_StreamCreate(DeviceFrequency, Channels, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_MIXER_NONSTOP)
BassMix.BASS_Mixer_StreamAddChannel(MixerChan, RChan, BASSFlag.BASS_MIXER_BUFFER Or BASSFlag.BASS_MIXER_LIMIT)

Then I create the sub mixer, which I want to use to take the main mixer feed but resample it to the specified sample rate:

Code: [Select]
LocalMixer = BassMix.BASS_Mixer_StreamCreate(Frequency, Channels, BASSFlag.BASS_STREAM_DECODE Or BASSFlag.BASS_MIXER_NONSTOP)
BassMix.BASS_Mixer_StreamAddChannel(LocalMixer, MixerChan, BASSFlag.BASS_MIXER_BUFFER Or BASSFlag.BASS_MIXER_LIMIT)

I then try and start an encoder and use the new sub mixer:

Code: [Select]
Com = "lame.exe -r -s " & DeviceFrequency / 1000 & " --cbr --flush -h -b " & Bitrate & " --resample " & Frequency / 1000 & " - -
Encoder = BassEnc.BASS_Encode_Start(LocalMixer, Com, BASSEncode.BASS_ENCODE_NOHEAD Or BASSEncode.BASS_ENCODE_FP_16BIT, _myEndProc, IntPtr.Zero)

For ref in the above code - DeviceFrequency = 48000 and Frequency = 44100 (or some other user set frequency)

« Last Edit: 2 May '18 - 17:42 by Chris Oakley »

Chris Oakley

  • Posts: 32
Re: Is it possible to add a Mixer to another Mixer
« Reply #5 on: 2 May '18 - 19:42 »
I think I've solved why it wasn't working. I need to get the data from the mixer. However, that gives me another problem in that the sound runs too fast if I'm getting data for both mixers.

Chris Oakley

  • Posts: 32
Re: Is it possible to add a Mixer to another Mixer
« Reply #6 on: 3 May '18 - 09:43 »
Anyone got any thoughts on this? As it stands if I don't grab channel data from the second mixer then it doesn't do anything, but if I grab the data from the second mixer (I'm already grabbing it from the main mixer) then the resulting sound ends up double speed.

I can't grab the channel data from the second mixer because it's not always functioning and I could end up having a few secondary mixers taking a feed from the main mixer because the user can set different sample rates, so in theory I'd have to take channel data from each of them which would no doubt really screw up the overall sound.

Ian @ un4seen

  • Administrator
  • Posts: 20764
Re: Is it possible to add a Mixer to another Mixer
« Reply #7 on: 3 May '18 - 13:36 »
Which mixer are you currently getting data from, by calling BASS_ChannelGetData on it? You should only need to do that on the final mixer ("LocalMixer"). It will automatically pull data from any other mixers that are plugged into it.

Chris Oakley

  • Posts: 32
Re: Is it possible to add a Mixer to another Mixer
« Reply #8 on: 3 May '18 - 13:49 »
I'm getting data from the main mixer. I can pull the data from the LocalMixer, but the problem I have is that the LocalMixer isn't always there and equally I might have more than one other sub mixer which I'm plugging the main mixer into.

From what you're saying, I just need to get one of the sub mixers and it will pull data through all the submixers?

For ref I've attached a diagram of the layout. Bear in mind that the sample rate and amount of the submixer will vary.

Ian @ un4seen

  • Administrator
  • Posts: 20764
Re: Is it possible to add a Mixer to another Mixer
« Reply #9 on: 3 May '18 - 17:10 »
If you will be plugging the main mixer into multiple other mixers then you should use splitter streams, ie. BASS_Split_StreamCreate. You would create a splitter each time you want to plug the main mixer into another mixer, and plug the splitter (not the main mixer) into the mixer. That will allow all of the other mixers to receive all of the data from the main mixer (so long as they don't drift too far apart - see BASS_CONFIG_SPLIT_BUFFER). Note you should then never call BASS_ChannelGetData (or BASS_ChannelGetLevel) directly on the main mixer, as the data used in that call will not be received by the splitters.

Chris Oakley

  • Posts: 32
Re: Is it possible to add a Mixer to another Mixer
« Reply #10 on: 5 May '18 - 13:12 »
Thanks so much Ian - that's sorted it :) Happy Days