I start playing a song using sound(), caching the sound object on the server. In order to try and fade it, I set its status to SOUND_UPDATE, change variables (in this case, volume), and re-send it to the player. However, this appears to have the unintended side effect of causing the sound to restart playing, instead of merely applying the updates.
Numbered Steps to Reproduce Problem:
1. Store output of sound() to variable
2. Output variable to world
3. Attempt to fade the sound out
Code Snippet (if applicable) to Reproduce Problem:
if (client.Pressed["Insert"])
PlayingSound = sound('THUNDERDOME.ogg', 0, 0, 4, 100)
PlayingSound.status = SOUND_STREAM
world << PlayingSound
if (client.Pressed["Delete"])
spawn
PlayingSound.status = SOUND_UPDATE
while (PlayingSound.volume)
PlayingSound.volume -= 5
world << PlayingSound
sleep(1)
PlayingSound.status = SOUND_PAUSED | SOUND_UPDATE
world << PlayingSound
Expected Results:
Sound fades out smoothly
Actual Results:
Soudn fades out, but restarts playback on every fade step
Does the problem occur:
Every time? Or how often? Every time
In other games? Not tested
In other user accounts? Not tested
On other computers? Not tested
When does the problem NOT occur?
Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.)
Workarounds:
I tried to use a null sound as follows, but this only resulted in immediately stopping the track. A global (null sound to channel 0) fade worked, but that works against what I'm planning to do.
if (client.Pressed["Insert"])
PlayingSound = sound('THUNDERDOME.ogg', 0, 0, 4, 100)
PlayingSound.status = SOUND_STREAM
world << PlayingSound
if (client.Pressed["Delete"])
spawn
var/sound/FadeTrack = sound()
FadeTrack.channel = PlayingSound.channel
DebugText("[FadeTrack.channel]")
FadeTrack.volume = 100
FadeTrack.status = SOUND_UPDATE
while (FadeTrack.volume)
FadeTrack.volume -= 5
world << FadeTrack
sleep(1)
FadeTrack.status = SOUND_PAUSED | SOUND_UPDATE
world << FadeTrack