FreeAudio bug
BlitzMax Forums/BlitzMax Programming/FreeAudio bug
| ||
This shows the issue:?win32 SetAudioDriver("FreeAudio") 'Comment this line to see the bug disapear on windows (DirectSound works well, but free audio does not). ? Local chan:TChannel = AllocChannel() Local music:TSound = LoadSound("music.ogg") Local playing:Int = False Graphics(800, 600) While Not KeyHit(KEY_ESCAPE) Cls DrawText("Press SPACE to toggle music on/off ESC - Exit", 0, 0) Flip If KeyHit(KEY_SPACE) If playing Then chan.Stop() playing = False Else music.Play(chan) playing = True End If End If Wend When a channel is Stoped with the Stop() command once, it stops reproduction properly, when the channel is reused for playback and another stop() arrives, the music never stops. With DirectSound there are non issues, it seems to be happening only on FreeAudio (wich is a problem for me on the Mac version of the game I'm working on). |
| ||
Not tested - just read the code - but I think this is not a bug. StopChannel DESTROYS the 'channel', and your next instruction (Music.Play(channel)) I believe creates a new one channel. Function StopChannel( channel:TChannel ) Description Stop an audio channel Information Shuts down an audio channel. Further commands using this channel will have no effect. (it's early morning here - maybe I'm wrong....) |
| ||
Ok, from the docs: Shuts down an audio channel. Further commands using this channel will have no effect. So it may not be a bug but the way audio engine is designed... then... mm... I will have to redesign part of my game... Can anybody confirm this is how it is meant to work? |
| ||
I would guess it is by design, given that there is also PauseChannel. The name is misleading. Something like KillChannel might be more appropriate than StopChannel. |
| ||
I use this, which i think lets you do what you wantFunction sound:TChannel(insound:TSound, channel:TChannel, volume:Float = 1, rate:Float = 1) StopChannel channel channel = AllocChannel() SetChannelRate channel, rate SetChannelVolume channel, volume PlaySound insound, channel Return channel End Function |
| ||
@jkrankie: Yes, that's what I ended with more or less. Thanks! |