Control Sound Volume by Expression Editor?

QuinnZoneStudiosQuinnZoneStudios 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

Comments

  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    you can change the atttribute device audio sound to 0 to turn the volume all the way down, cahnge it to 1 to turn the volume all the way up, and it can be change to decimal places between 0 and 1 such as .5 for half volume

    cheers
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Thanks John!
    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.....
  • BSideGamesBSideGames Member Posts: 392
    Hey mike you could have each of the buttons access the sound attributes through the current scene/layer/your sound actor.
    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
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Ahh interesting Asher,
    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
  • PhoticsPhotics Member Posts: 4,172
    Don't use a boolean.
    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! :)
  • BSideGamesBSideGames Member Posts: 392
    @Photics you are correct about the real vs. boolean I just say true/false, but I only use 0 and 1.

    @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)
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Oh you are most welcome for the review Photics!
    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!!!
  • BSideGamesBSideGames Member Posts: 392
    Mike email me at asher.ryan@yahoo.com with a copy of your project and I'll do it up real quick for you.
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Okay I think I'm starting to get it.
    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!!!
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Hey Photics,
    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???
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    I dont really get what the issue is here. do you need some thing more than this?
    image

    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?
  • JohnPapiomitisJohnPapiomitis Member Posts: 6,256
    yes what tendrmer showed is what u want.

    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
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    YESSS!!!!
    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
  • PhoticsPhotics Member Posts: 4,172
    MikeQuinn said:
    Hey Photics,
    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.....

    The sound volume is not like a typical stereo. It doesn't go from 0 to 10. It goes from 0 to 1. So .5 is half volume.

    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.
  • QuinnZoneStudiosQuinnZoneStudios Member Posts: 452
    Gotcha! 0-1 and .1's in between - THANKS!!!!

    Woo-hooo!!!
  • BSideGamesBSideGames Member Posts: 392
    You got to do every job I dreamed of as a child.

    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
  • tenrdrmertenrdrmer Member, Sous Chef, Senior Sous-Chef Posts: 9,934
    MikeQuinn said:
    YESSS!!!!
    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

    Wow Nice Credit List.
    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
Sign In or Register to comment.