ID:162813
 
I know there is a way to change the volume of a mid or wav file that is played through byond, When first playing it. But is it possible to alter the volume of a midi or wav while its being played? Like.. If somthing was to happen during the game and i want background music to become lower so other sounds can be heard, Can i do this without restarting the file? Thnx.
Bladeshifter wrote:
I know there is a way to change the volume of a mid or wav file that is played through byond, When first playing it. But is it possible to alter the volume of a midi or wav while its being played? Like.. If somthing was to happen during the game and i want background music to become lower so other sounds can be heard, Can i do this without restarting the file? Thnx.

Though I've never used it, there is a sound datum that you might be able to take advantage of here. This isn't tested, but you might be able to do something like this...

var/sound/mySound = sound('mysong.mid') // Create the sound datum
src << mySound // Send the sound to src
sleep(50) // Wait for 5 seconds
mySound.volume = 50 // Halve the default 'volume' value.


I'm not sure if changing the sound's variables while it is playing works like that, but you could give it a shot just in case -- I've never really used many sounds in my projects.
In response to Volte
Nah no good, I dont believe its possible... :/. Wich sucks, Ive recently made a demo that allows mp3s to be played via html through the client.. Im thinking there may be a way to use that for the music, and maybe a way to edit volume using html, Know any html for media players embeded? :P.
Make your changes to the sound datum. Set its status to SOUND_UPDATE. Send the sound datum to the listeners again.
In response to ACWraith
Wouldnt that end up reseting the song?
In response to Bladeshifter
It shouldn't. It's the whole point of the SOUND_UPDATE status. =)
In response to ACWraith
Ah your right, Just read it in the guide what its used for. But im kinda not sure how to add it in coding, Is it used as a proc, or hows that work? xD.
In response to Bladeshifter
It's just a var with a bit flag setting. It would be something like:
mySound.status |= SOUND_UPDATE
In response to ACWraith
mob/Login()
src << mySound



var/sound/mySound = sound('hometown.mid')



mob/verb/LOWERVOLUME()
mySound.volume-=10
mySound.status |= SOUND_UPDATE
usr<<mySound


Resets the sound but at a lower volume, WHatd i do worng? :P. Thnx for having patience with me xD.
In response to Bladeshifter
Ah, we forgot the channel. The help file says to specify it. It's the fourth argument in the sound() proc.

By default, it's 0, which means that it takes a somewhat random free channel. When you send it again with the 0, it may be confused about which channel to update. A least, that's my theory at the moment. ;)

(I did this sort of thing with Crass Grave, but it's been a while.)
In response to ACWraith
So just change the channel and resend it to the src? Will that do it? :P.
In response to Bladeshifter
I got it to work, thanks works perfect :P. Thnx for your help.