Author Topic: slave mixer added to primary mixer, BASS_ChannelGetLevel problem on slave mixer  (Read 220 times)

serkanp

  • Posts: 112
Hi ,
i am trying to create multiple mixers connected to a master mixer.
each mixer have its own features (mp3 playback, announcements, icecast, multi channels etc)
each mixer will have its own volume settings. so i must use multiple mixers.
i need to visualize the volume levels on screen..
 
when i want to get slave mixer's volume levels but getting problems..
i can get master mixer's volume levels correctly but not slave mixer's

issue 1:
normally , the master mixer is a mixer channel, so i have to get it with BASS_Mixer_ChannelGetLevel,
but it gives -1 , when i use Bass.BASS_ChannelGetLevel on master mixer i can get the levels.

issue 2:
on slave mixer, its a mixer channel too, so i have to get it with BASS_Mixer_ChannelGetLevel too,
but it gives -1 again. when i use Bass.BASS_ChannelGetLevel on slave mixer i can get the levels but the audio output is 2x faster.

can someone show me correct way to do it? (ex: wrong flags, incorrect method etc..)
 :) ;)

Code: [Select]
var init = Bass.BASS_Init(-1, 44100, BASSInit.BASS_DEVICE_DEFAULT, IntPtr.Zero);
           
            //create primary mixer
            var primaryMixer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_DEFAULT);
            Bass.BASS_ChannelPlay(primaryMixer, true);

            //create slave mixer
            var slaveMixer = BassMix.BASS_Mixer_StreamCreate(44100, 2, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
            //add slave to primary
            BassMix.BASS_Mixer_StreamAddChannel(primaryMixer,slaveMixer, BASSFlag.BASS_STREAM_DECODE |BASSFlag.BASS_SAMPLE_FLOAT);

            //open file
            var chan = Bass.BASS_StreamCreateFile("test1.mp3", 0, 0, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT);
            //add file to slave mixer
            var res1 = BassMix.BASS_Mixer_StreamAddChannel(slaveMixer, chan, BASSFlag.BASS_DEFAULT);// same happens when used BASS_STREAM_DECODE
            var err1 = Bass.BASS_ErrorGetCode(); //there is no error

            BASSTimer tmr = new BASSTimer(100);
            tmr.Tick += (object sender, EventArgs e) =>
             {
                 var level1 = Bass.BASS_ChannelGetLevel(primaryMixer); // this gives result
                 var level2 = BassMix.BASS_Mixer_ChannelGetLevel(primaryMixer); // this gives -1 result
                 var level3 = BassMix.BASS_Mixer_ChannelGetLevel(slaveMixer); // this does not give result -1
                 var level4 = Bass.BASS_ChannelGetLevel(slaveMixer); //this gives result but makes output playback 2x faster
                 Console.WriteLine($"{level1} - {level2}- {level3} - {level4}");
             };
« Last Edit: 4 Jan '22 - 12:02 by serkanp »

MB_SOFT

  • Posts: 417
you must add the BASS_MIXER_CHAN_BUFFER flag there

BASS_Mixer_StreamAddChannel(primaryMixer,slaveMixer, BASSFlag.BASS_STREAM_DECODE |BASSFlag.BASS_SAMPLE_FLOAT);
 
so you can get the level with BASS_Mixer_ChannelGetLevel(slavemixer)

BASS_Mixer_ChannelGetLevel is only for getting levels of a source, not for the final mix.

For the final mix just use BASS_ChannelGetLevel

 

serkanp

  • Posts: 112
thanks for the suggestion , that gave me inspiration..
maybe you misspelled BASS_MIXER_CHAN_BUFFER , it must be BASS_MIXER_BUFFER

i changed the line as :

Code: [Select]
BassMix.BASS_Mixer_StreamAddChannel(primaryMixer, slaveMixer, BASSFlag.BASS_STREAM_DECODE | BASSFlag.BASS_SAMPLE_FLOAT | BASSFlag.BASS_MIXER_BUFFER);
and get the vumeters like this without any distorsion:
Code: [Select]
var level1 = Bass.BASS_ChannelGetLevel(primaryMixer);
//because its a decoding channel now
var level2 = BassMix.BASS_Mixer_ChannelGetLevel(slaveMixer);

MB_SOFT

  • Posts: 417
BASS_MIXER_BUFFER has been renamed as BASS_MIXER_CHAN_BUFFER in the latest versions of BASS ...however the value is the same...kolay gelsin

serkanp

  • Posts: 112
:)) aaaa :)) çok teşekkür ederim.. kolay gelsin..