Author Topic: 2 channels mixing  (Read 462 times)

Henning

  • Guest
2 channels mixing
« on: 29 Jul '19 - 18:16 »
Hi Ian, Hi @ all,

I'am working on the following:
I create two streams from two mp3-files with

Code: [Select]
        Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_CPSPEAKERS, IntPtr.Zero, Nothing)
        chan2 = Bass.BASS_StreamCreateFile(Pfad2, 0, 0, BASSFlag.BASS_STREAM_AUTOFREE Or BASSFlag.BASS_STREAM_PRESCAN)
        Bass.BASS_ChannelPlay(chan1, False)

and  the same for ... chan2.

I can change the volumen of those two channels via trackbars seperately:

Code: [Select]
        Dim VolumeSlider1 As Single
        VolumeSlider1 = Convert.ToSingle(TrkVol1.Value / 100)
        Bass.BASS_ChannelSetAttribute(chan1, BASSAttribute.BASS_ATTRIB_VOL, VolumeSlider1)

Finaly I could if i want to change GobelVolume of all stream with:

Code: [Select]
Bass.BASS_SetConfig(BASSConfig.BASS_CONFIG_GVOL_STREAM, TrkGvol.Value)
All that seems to work fine!!!

My Question is can I now create a MixerStream from chan1 & chan2 and then use the parametric EQ on this mixStream.

Code: [Select]
       
Public mixer As Integer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_SAMPLE_FLOAT)
' finally we plug them into the mixer (no downmix, since we assume the sources to be stereo)
        Dim okA As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, chan1, BASSFlag.BASS_DEFAULT)
        Dim okB As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, chan2, BASSFlag.BASS_DEFAULT)
        ' and play it...
        Bass.BASS_ChannelPlay(mixer, False)

-----------------
Work flow of my project must be like this:
choose file1 -> play it -> set volumen for file1  //same time// file2 is played -> volumen is set for file 2 seperatly while u can hear both streams.

Now I would like to run a EQ affecting the MixStream of chan1 & chan2. Is the direction of my solution correct?




Ian @ un4seen

  • Administrator
  • Posts: 22253
Re: 2 channels mixing
« Reply #1 on: 30 Jul '19 - 14:36 »
Yes, that looks fine. You would just need to add the BASS_STREAM_DECODE flag on the file streams, so that they can be plugged into the mixer.

If you aren't playing anything else (or you want the EQ applied to that too) then another option could be to apply the EQ to the BASS output, instead of using a mixer. You can do that by using BASS_StreamCreate with proc=STREAMPROC_DEVICE to get the device stream and setting the EQ on that. This has the advantage of adding no latency to the file stream volume changes (a mixer would add latency to that).

Henning

  • Guest
Re: 2 channels mixing
« Reply #2 on: 30 Jul '19 - 15:43 »
How do I  ....add the BASS_STREAM_DECODE flag on the file streams

this returns a "false"

Code: [Select]
Dim okA As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, chan1, BASSFlag.BASS_DEFAULT And BASSFlag.BASS_STREAM_DECODE)

Ian @ un4seen

  • Administrator
  • Posts: 22253
Re: 2 channels mixing
« Reply #3 on: 30 Jul '19 - 16:02 »
The BASS_STREAM_DECODE flag needs to be set in the BASS_StreamCreateFile call. It isn't possible to toggle that flag after stream creation.

Henning

  • Guest
Re: 2 channels mixing
« Reply #4 on: 30 Jul '19 - 16:21 »


Code: [Select]
chan1 = Bass.BASS_StreamCreateFile(Pfad1, 0, 0, BASSFlag.BASS_STREAM_PRESCAN And BASSFlag.BASS_STREAM_DECODE)and
Code: [Select]
Dim okA As Boolean = BassMix.BASS_Mixer_StreamAddChannel(mixer, chan1, BASSFlag.BASS_DEFAULT)
still result in "false"

------------

Wouldn't I lose the volume change if I free/close chan1 and restrart it with the flag decode?
I start chan1 and listen to it ... change volume ...then wanted to mix it with chan2 and later EQ the result of the mix.

Ian @ un4seen

  • Administrator
  • Posts: 22253
Re: 2 channels mixing
« Reply #5 on: 30 Jul '19 - 16:53 »
You need to use "Or" (instead of "And") to combine flags, like this:

Code: [Select]
chan1 = Bass.BASS_StreamCreateFile(Pfad1, 0, 0, BASSFlag.BASS_STREAM_PRESCAN Or BASSFlag.BASS_STREAM_DECODE)

You could create the mixer from the start and only add the 1st stream to it initially, and add the 2nd one later. But, if you aren't playing anything else at the same time (or you want the EQ applied to that too) then I would suggest going the device stream (STREAMPROC_DEVICE) route instead.

Henning

  • Guest
Re: 2 channels mixing
« Reply #6 on: 30 Jul '19 - 17:09 »
seems I can't wrap my head around it?

Would like to change Vol of channel 1 and change Vol of channnel 2 after that I would like to join that signal to one (mix it) and run this through the EQ.

If I mix the 2 signals at start how do I change the 2 signals seperatly after using mix?

Henning

  • Guest
Re: 2 channels mixing
« Reply #7 on: 30 Jul '19 - 17:41 »
I think I got it:

I mix the 2 Channels at start and still can modify the volume of the 1st and 2st channel after mixing and it still has the effect.
 
Code: [Select]
Bass.BASS_ChannelSetAttribute(streamA, BASSAttribute.BASS_ATTRIB_VOL, 0.2)
Thank you for yout help and time