Control Sound Volume by Expression Editor?
QuinnZoneStudios
Member Posts: 452
Hey all,
I'm hoping someone here knows how to create some math in the expression editor.
What I need to do is control Sound volume (not music) in the "Play Sound" behavior. The reason for this is I have more than one sound playing continuously and have buttons to switch the volume of each sound to 1 or 0. Doing it any other way seems to play the sound from the start, therefore adjusting volume seems to be the way to go, as I want the audio to continue and not start from the top.
Everything else is set up correctly I believe. I have a Boolean for each sound and when the button is pressed the Boolean changes to True. So what I need to figure out is how to have that True or False Boolean turn the sound slider to 1 or 0, within the Play Sound Expression Editor.
I'm pretty sure this is possible and most likely simple but after lots of poking around I just don't know how to enter the math correctly.
If anyone has a spare moment to suggest something I will be forever indebted to you
Thanks in advance and Happy Friday!
Mike
I'm hoping someone here knows how to create some math in the expression editor.
What I need to do is control Sound volume (not music) in the "Play Sound" behavior. The reason for this is I have more than one sound playing continuously and have buttons to switch the volume of each sound to 1 or 0. Doing it any other way seems to play the sound from the start, therefore adjusting volume seems to be the way to go, as I want the audio to continue and not start from the top.
Everything else is set up correctly I believe. I have a Boolean for each sound and when the button is pressed the Boolean changes to True. So what I need to figure out is how to have that True or False Boolean turn the sound slider to 1 or 0, within the Play Sound Expression Editor.
I'm pretty sure this is possible and most likely simple but after lots of poking around I just don't know how to enter the math correctly.
If anyone has a spare moment to suggest something I will be forever indebted to you
Thanks in advance and Happy Friday!
Mike
Comments
cheers
The problem with using "Device Audio" is it globally turns all Sound Volume down on all actors. The beauty of using the volume within the Play Sound behavior is it will only affect that actor sound. Hence trying to figure out the expression to enter under that big ol' "E" button next to Volume.
I just know there's a way.
Hope that makes sense.....
I would have two rules that say if X is true volume 1 if X is false volume 0
That's the way I would go about it.
Hope that can help a bit
Asher Scott
B-Side Games
I hadn't even thought to look in current scene etc.
In layer, I see my sound actor but I see no way to access its own volume as it doesn't show any sound properties there.
Still poking around as I know the answer is hiding somewhere.
Thanks a big bunch!
If anyone else has any thoughts I'm all earholes!
Mike
Use real.
Use 0 and 1 as false and true.
Use math
sound.attribute.volume*sound.trigger
So, if you have a game setting of .7 for the overall volume of the game, and then the sound trigger is false, it would be 0.7 * 0... which equals zero or no sound.
I'm using crazy little math tricks like that all over the place in BOT. It helps with customization.
This is the part where I usually mention the textbook... but you already have it. HA HA!
http://gamesalad.com/forums/topic.php?id=19875
Nice review Mike!
@Mike What I was meaning was make an attribute in each of your sound actors.
Then put a rule the states if attribute is true play sound at volume 1
Then put in the otherwise if attribute is false play sound at volume 0,.5 or what every level you want.
Then access that actors attribute with your button.
BTW Photics math idea is a great way to go about it also.(I still shy away from math, it's next on my list of things to learn)
Can't wait for BOT to kick BUT
Thanks for the assistance here. I'm not quite sure how to put all this together. Does your formula go into the Play Sound expression editor? Can't quite get it to work yet but perhaps I'm over complicating it.
I'm basically trying to control volume on sounds simultaneously, so some will be on and some off determined interactively by the player, rather than the entire game sound level. It sounds like what you suggested will do what I need if I can implement it correctly.
Brain's hurting... Yeee-hawwww!!!
Thank you so very much both Photics and AsherScott!
The only thing I'm still having trouble with now is getting the sound to continue when volume is turned up, but right now it starts from the beginning.
I'll go ahead and send you a zipped file of it so you can see the mess AsherScott, lol!
Looks like it may be a happy weekend in the QuinnZone after all!!!
In your GS Textbook you show an example of an expression being used within the sound volume itself.
How can I tell it to to play at full volume when an attribute is "1" and play at 0 when an attribute is 0?
Just at a loss what that should look like.
I think that's all I need to get this working.....
What do ya thunk???
Im mean this setup will make that sounds volume be what ever that game attribute is. I guess maybe I missing something from your question?
you make your own attriubte called sound or wahtever
then in the volume for the play sound behavior have that attribute
then change that attribute between 0 to 1 to control volume whenever you like
That was the answer tenrdrmer! I just had to put the correct attribute in there and it works perfectly.
so dag-blamed simple. lol!!!
Thank you so very much. Now I'm in business.
I owe you all a big favor for helping me here. Seriously.
Star Wars Nien Nunb autograph perhaps???
http://muppet.wikia.com/wiki/Mike_Quinn
Just email or PM me here as I want to repay and show my gratitude.
Mike
Although, having a sound play at zero is not exactly efficient. Rules wouldn't be better for this?
Example... footsteps...
If player, overlaps or collides with rocky terrain
play sound rocky terrain footsteps.
Woo-hooo!!!
Fraggle Rock was one of my favorite shows never miss an episode.
I hope the files I sent you can help.
BTW this project looks real good so far
Asher
I may make you fell old but I watched basically all fraggle rocks when it aired as lil kid. Of course I was in the US so may not have seen any of your fraggles. LOL
Glad it solved your issue