ID:903954
 
Keywords: music, mute, sound, system, volume
(See the best response by DarkCampainger.)
Code:
mob
Login()
usr.GameTheme=1
GameTheme()
proc
GameTheme()
if(usr.GameTheme==1)
usr << theme1()
usr.Sound="Theme-01"
GameTheme()
else
if(usr.GameTheme==2)
usr << theme2()
usr.Sound="Turtle-island"
GameTheme()
else
GameTheme()
theme1()
usr << 'Theme-01.mid'
sleep(980)
if(usr.Sound=="Theme-01")
usr << GameTheme()
theme2()
usr << 'Turtle-island.mid'
sleep(830)
if(usr.Sound=="Turtle-island")
usr << GameTheme()
turf
music
BeginnerstownEnd
Entered(O)
usr.GameTheme=2
usr.loc = locate(/turf/Locations/TurtleIslandTutorialOut)
usr << sound(null)
usr.GameTheme()


Problem description:
Hi guys,

I have a question i made this simple sound system for my game it works just fine but now i had a request from some players to make a mute button and a button to lower the music volume or make it higher. I tried reading about it but the things i tried arent working so i thought i try it at the forums.

I placed my code up here maybe someone can help me with this one.
So its basically just going to be a Volume proc.

Greetings,

Chaokai

GameTheme() has no return value, so doing usr << GameTheme() won't do anything. You also shouldn't use usr in procs in most cases.

You're going to cause some major loops because of the way you programmed this. It looks like you weren't even paying attention to what you were typing.

As for volume, BYOND can't play sounds from a certain point. As such, if you want to change the volume, it will have to start again from the beginning. Press F1 in Dream Maker, go to the Topic tab, and type in "sound". Double click the entry that says "sound proc" and volume is covered right there.
well actually usr << GameTheme() calls the proc again once the music is done so it just repeats itself but okay lets say the volume cant be changed from a certain point how about muting it? or should i better just make a proc for stopping it and then starting it again?
I wrote this as a volume control
    mute()
set hidden = 1
if(winget(usr,"mute","is-checked") == "true")
usr.Vol = 0
else
usr.Vol = round(t2n(winget(usr,"Vol","value")),1)
winset(usr,"Volume","text=Vol_[usr.Vol]")
return
Volume()
set hidden = 1
usr.Vol = round(t2n(winget(usr,"Vol","value")),1)
winset(usr,"Volume","text=Vol_[usr.Vol]")
return

and when output a sound
usr << sound('boom.wav', volume=usr.Vol)


Prf X
Best response
You can't set the sound to a specific position, but you can update it without restarting it. You just have to use the SOUND_UPDATE status flag and re-output the sound with the new values (I think you need to have a channel set for it to know which sound to affect).

There's also a SOUND_MUTE flag, but that's for muting the sound while it continues to play. You can implement it that way, if you think players just want to temporarily stop sounds; or you can just not play the sound in the first place.