SomeVerbThatPlaysSongs()
world << sound( "" ) // Stops any music currently playing
var/sound/S = sound( "SomeSong.mid", repeat, 0, 100, 100 ) // Sets up some song on channel 100 via var S
S.frequency = 1.2 // Sets S to play at 1.2 default speed
//S.y = 50 // Commented out; changes 3D effect
usr << S // Play the song at 1.2 times normal speed
//S.y = 0 // Commented out; restores default 3D effect, but only when the sound is updated successfully
sleep( 10 ) // Wait for just a second
S.status = SOUND_UPDATE // SHOULD update S even while it's playing; FAILS to do so. Why?
usr << S // My second attempt to update S, by playing it after setting the status to update; when this line is executed, S continues to play but the frequency seems to have multiplied by itself, becoming 1.2 * 1.2 = 1.44
usr << S.frequency // Curiously, this value is STILL equal to 1.2 although I can hear a change in the frequency. WTF?
Problem description:
In short, I want this verb to change the song's attributes WHILE the song is playing. The code is a bit messy because I've been playing around with it, attempting to get things to work. From experimenting, I noted another issue which struck my curiosity. The frequency (originally set to 1.2) seems to be shifted to 1.44 (or around there) after the sound update (this takes place one second after the first time the music is played), which itself seems to fail entirely. I don't understand how the frequency can so clearly sound altered, and yet the frequency output still reads 1.2 after the modifications to the sound are all said and done. To sample my problem further, please note the comments associated with the above lines of code.
So the /sound object's vars don't necessarily correlate with the client's playing sound. It's similar to outputting an icon file to a label, then modifying that icon (in effect creating a new, altered icon) and expecting the label display to update to reflect the changes.
To update an existing sound, you need to output a sound object with the SOUND_UPDATE status flag, the changes you want and the same channel and file as the sound you're updating had. Here's a post with an example: [link]
I'm not sure how much of the rather messy-looking code you've tried or not and how exactly. var/sound/S = sound( "SomeSong.mid", repeat, 0, 100, 100 ) doesn't look like it'd compile, or it would compile erroneously, unless you have a repeat var declared within the scope. Additionally, 100 shouldn't be a valid channel.