Author Topic: Fade stream for a few seconds at the end of the stream  (Read 877 times)


  • Posts: 31
Hi, I'd like to fade out only the last 5 Seconds of a stream but I don't get it to work (The song plays, but without fading out).
This is my approach:

Code: [Select]
// Get notified at the end of the stream to get the next stream
Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_END, 0, _channelFinishedSyncProc, IntPtr.Zero);

// Get the the pos where the fade shall start
double fadeFromSeconds = lengthInSeconds - fadeFor;
if (fadeFromSeconds < 0)
    fadeFromSeconds = 0;

long fadeFromByte = Bass.BASS_ChannelSeconds2Bytes(stream, fadeFromSeconds);

_channelStartFadeOutSyncProc = new SYNCPROC(BeginFadeOut);
Bass.BASS_ChannelSetSync(stream, BASSSync.BASS_SYNC_POS, fadeFromByte, _channelStartFadeOutSyncProc, IntPtr.Zero);
Bass.BASS_ChannelPlay(stream, false);

        private static void BeginFadeOut(int handle, int channel, int data, IntPtr user)
            // in this example FadeSongsFor is 2 => 2*1000 = 2000 ms
            int fadeDuration = Convert.ToInt32(EinstellungenHelper.GetEinstellungen().FadeSongsFor * 1000);
            Bass.BASS_ChannelSlideAttribute(handle, BASSAttribute.BASS_ATTRIB_VOL, 0f, fadeDuration);

Can anyone tell me what I am doing wrong?

Ian @ un4seen

  • Administrator
  • Posts: 20437
The "handle" parameter received by your BeginFadeOut function will be the handle of the sync. You should use the "channel" parameter in the BASS_ChannelSlideAttribute call instead of that. If it still doesn't work, please check the return values to see if any of the calls are failing, and if any are, use BASS_ErrorGetCode to find out why.


  • Posts: 31
Thanks :).