23 May '13 - 14:31 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
 
   Home   Help Search Login Register  
Pages: [1]
  Reply  |  Print  
Author Topic: Playing songs one after another with crossfade  (Read 665 times)
axisdj
Posts: 10


« on: 19 Jun '11 - 18:47 »
Reply with quoteQuote

Cannot get this to work, Looked through out the forum, and all responses explaing how to mix the first two, my issues is how to continue after that:
here is some code (vb6)

here is where I preload the next song

"picknextsong"

if activeplayer = 1 then

If newPlayer1 <> 0 Then
        Call BASS_ChannelStop(newPlayer1)
        Call BASS_StreamFree(newPlayer1)
    End If
    If newPlayer1 = 0 Then
       newPlayer1 = BASS_StreamCreateFile(BASSFALSE, StrPtr(nextSong1), 0, 0, BASS_STREAM_DECODE)
    End If
end if

elseif activepalyer =2 then

If newPlayer2 <> 0 Then
        Call BASS_ChannelStop(newPlayer2)
        Call BASS_StreamFree(newPlayer2)
    End If
    If newPlayer2 = 0 Then
        newPlayer2 = BASS_StreamCreateFile(BASSFALSE, StrPtr(nextSong2), 0, 0, BASS_STREAM_DECODE)
    End If
end if



here is where I start the next song, this works the first two, but after that it gives me error code 5 invalid handle
Startnextsong gets called when 1 second of the currently playign song is reached

"StartnextSong"

if activeplayer = 1 then
If newPlayer2 <> 0 Then
        Call BASS_Mixer_StreamAddChannel(mixer, newPlayer2, BASS_STREAM_AUTOFREE) '' add the 2nd recording
        Call BASS_ChannelPlay(newPlayer2, 0)
        Call BASS_ChannelSetAttribute(newPlayer2, BASS_ATTRIB_VOL, 1)
        Call BASS_ChannelSetSync(newPlayer2, BASS_SYNC_SLIDE, 0, AddressOf newPlayer2FadeOutDone, 0)
        activePlayer = 2
        If newPlayer1 <> 0 Then
            Call BASS_ChannelSlideAttribute(newPlayer1, BASS_ATTRIB_VOL, -100, 1000) '''fade out other song
        End If
    End If
elseif activeplayer = 2 or activeplayer 0 then
    If newPlayer1 <> 0 Then       
        Call BASS_Mixer_StreamAddChannel(mixer, newPlayer1, BASS_STREAM_AUTOFREE) '' add the 2nd recording
        call BASS_ChannelPlay(newPlayer1, 0)       
        Call BASS_ChannelSetAttribute(newPlayer1, BASS_ATTRIB_VOL, 1)
        Call BASS_ChannelSetSync(newPlayer1, BASS_SYNC_SLIDE, 0, AddressOf newPlayer1FadeOutDone, 0)
        activePlayer = 1
        If newPlayer2 <> 0 Then
            Call BASS_ChannelSlideAttribute(newPlayer2, BASS_ATTRIB_VOL, -100, 1000) ''fade out other song
        End If
    End If
end if


in the newPlayer1FadeOutDone and newPlayer2FadeOutDone callback functions I call "picknextsong"

My thought is after a stream is created using BASS_StreamCreateFile can I just change the file it is playing or do I have to create a new instance?

Thanks
Logged
Ian @ un4seen
Administrator
Posts: 15269


« Reply #1 on: 20 Jun '11 - 15:33 »
Reply with quoteQuote

Please confirm which function is giving the BASS_ERROR_HANDLE error. The BASS_STREAM_AUTOFREE flag in the BASS_Mixer_StreamAddChannel call tells the mixer to free the stream when it reaches the end, at which point the handle will become invalid and you will get a BASS_ERROR_HANDLE error if you try to do anything with it.

To play one song after another, you would generally use BASS_SYNC_END syncs, which will inform you of when a stream ends (you can then start the next one).
Logged
axisdj
Posts: 10


« Reply #2 on: 21 Jun '11 - 04:07 »
Reply with quoteQuote

I figured most of it out,

The callback was crashing the app so I trigger a one shot timer to pick the next song now which works great, I think that was most of the problem.

I just wanted to make sure I was taking the right approach.

Thanks for the response, I appreciate it.
Logged
Pages: [1]
  Reply  |  Print  
 
Jump to:  

Powered by SMF 1.1.18 | SMF © 2013, Simple Machines