Author Topic: Bass_ChannelIsActive  (Read 1251 times)

gtg429f

  • Posts: 7
Bass_ChannelIsActive
« on: 12 Feb '14 - 04:08 »
I have a relatively simple question...

Once I have a while loop checking for BASS_ACTIVE_PLAYING is there a way to reset the stream back to the beginning and start the stream over again?

Small example:
Code: [Select]
         public int getPeak(int mix)
        {
            int peak = 0;
            Bass.BASS_ChannelSetPosition(mix, 0);
            while (Bass.BASS_ChannelIsActive(mix) == BASSActive.BASS_ACTIVE_PLAYING)
            {
                int level = Bass.BASS_ChannelGetLevel(mix);
                int right = (byte) (level >> 8);
                int left = (byte)(level & 0xff);
                if (peak < left) peak = left;
                if (peak < right) peak = right;
            }
            if (peak > 32767) peak = 32767;
            Console.Out.WriteLine(peak);
            return peak;
        }

After calling this function if I try to call another function to render the file out to mp3 I can never get the BASS_ChannelIsActive back to BASS_ACTIVE_PLAYING. Even after setting Bass.BASS_ChannelSetPosition(mix, 0) before render.

Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: Bass_ChannelIsActive
« Reply #1 on: 12 Feb '14 - 14:39 »
BASS_ChannelSetPosition with pos=0 will rewind a file stream, but from its name, it sounds like the "mix" variable may be a mixer handle? If so, you would need to rewind the mixer's source(s) too, as they will still be at the end. The BASS_ChannelSetPosition call on the mixer will reset the mixer's state, but then it will immediately end (assuming BASS_MIXER_END is enabled) due to its source(s) being at the end.

gtg429f

  • Posts: 7
Re: Bass_ChannelIsActive
« Reply #2 on: 12 Feb '14 - 15:05 »
OK I think I see where you are going...
Yes the mix in the code is a mixer handle...
Say I have 10 channels in my mixer...

How do I "rewind" the different channels back to the start for all of the channels in the mixer?

Should I remove the BASS_MIXER_END?

Thanks for you help.  It is very appreciated.

Ian @ un4seen

  • Administrator
  • Posts: 20433
Re: Bass_ChannelIsActive
« Reply #3 on: 12 Feb '14 - 17:09 »
In that case, you will need to call BASS_ChannelSetPosition on each of the mixer's sources too, to rewind them. For example, if you have their handles in a "mixsource" array...

Code: [Select]
for (int a=0; a<mixsourcecount; a++)
    Bass.BASS_ChannelSetPosition(mixsource[a], 0);

You should keep the BASS_MIXER_END flag, as it'll otherwise never leave the "while" loop :)