XNA Creators Club Online
Page 1 of 1 (4 items)
Sort Posts: Previous Next

Can you set a percentage of a Volume?

Last post 10/9/2009 4:09 AM by MarkMacumber. 3 replies.
  • 10/8/2009 11:24 PM

    Can you set a percentage of a Volume?

    Hi All,

    I have a requirement to make an application that interacts with a users click on a rectangle and play sounds that "blend" with each other.

    The theory behind it goes like this:

    With a rectangle of width 500px and height 200px, there needs to be 4 different sections evenly divided horizontally to play notes: G1, G2, G3 and G4 (i.e. the G1 section would be from 0->50px, G2 would be from 50->100px etc...).

    As the user moves the mouse along the X axis I want to increase the volume of the note that the user is playing, so if the users click at point x: 10, and y 5, G1 would be played at 10% volume level. Up to this point I can do.

    But where it gets tricky is when I want to start to "blend" over the notes, so in the middle of the G1 and G2 section on the Y axis, I want to play 50% of G1 and 50% of G2, BUT and here's the interesting part, it needs to be 50% OF the volume level on the X axis.

    For example, if the user clicks at the point x: 25, y: 50, I would want the app to play G1 and G2 at 50% of (25% of the overall Volume).

    How the heck would you do that!?!?

    I really appreciate any input anyone could give here in getting this done... I will play for now, and report back if I find out anything of use.

    P.S. I am familiar with RPC and Variables, etc...

    Cheers,
    Mark
  • 10/9/2009 3:25 AM In reply to

    Re: Can you set a percentage of a Volume?

    Hey Mark



    O.k. Mark, your problem is tricky, but not unsolvable

    What you have to do, is put each of the Notes into their own cue variables, and then put all the notes into one larger global variable.

    I shall try to explain.

    Give each of your notes an individual cue variable, ranging 1-3.  
    Then create the Volume Variable preset for each variable cue create a fast logarithmic curve starting with 0% volume at 1, and ending with 100% volume on 3.

    Next set all of those notes into a global cue Ranging 1-100
    Create a global volume preset with a linear curve, which starts at 0% at 1, and ends with 100% at 100



    Then the programming portion comes in

    Everytime a new note is reached.
    - First the global variable must be increased however how much % you need it to raise, so in your case you wanted 10%
    - The Cue variable for that specific note must set to 3, so it is at full volume, and all other cue variables must be -1
    - The note must be called as a sound,

    This way every new note you hit will increase by 10% overall volume, and the previous note will decrease by 50% of it's current volume

    It's a bit of extra work, and might need some minor tweaking on the Overall Volume, but should work.

    Hope this helps.

    If you need any help with setting up the project, just shoot me an e-mail.


    Silentcomposition@yahoo.com





    [ E-mail - Silentcomposition@yahoo.com ] [ Website - http://www.danielgooding.me/indi ]
    [ As Of Dec 8 2009 ] - (Total Indi Games – 33) (Total Music Tracks Made – 177) (Total SFX Made – Over 1350) (Currently Uploaded Tracks On Webpage– 113)
    Some Teams I've worked with recently (http://manabomb.com/) (http://www.talryyngames.com/) (http://retroburngames.com/)
  • 10/9/2009 3:46 AM In reply to

    Re: Can you set a percentage of a Volume?

    Oh hey again Mark.


    I Just read over your message again, and I realized that you wanted to attach a moving variable to the Y-Axis
    which seperates the volume level between the two notes.  Which changes things.

    Change from the last message I sent you.

    [[Give each of your notes an individual cue variable, ranging 1-3.  
    Then create the Volume Variable preset for each variable cue create a fast logarithmic curve starting with 0% volume at 1, and ending with 100% volume on 3.]]

    Give each of your notes an individual cue variable, ranging 1-100
    Then Create the Volume Variable preset for each variable cue to create a Linear Curve starting with 100% Volume at 1, and Ending with 0% Volume on 100

    - The Cue variable for that specific note must set to 3, so it is at full volume, and all other cue variables must be -1

    You must sync the distance of Y, to the variable of every note, so as the y gradually decreases as it grows closer, it will eventually increase in volume.
    Therefor if you have a y between two notes, then it should be playing them at an even volume between them.

    At that point you just have to call play for the new note, wherever you want it to be called, and it will correspond in volume.


    I realize all of this sounds rediculous.

    Once again if you need any help shoot me an e-mail



    Silentcomposition@yahoo.com


    [ E-mail - Silentcomposition@yahoo.com ] [ Website - http://www.danielgooding.me/indi ]
    [ As Of Dec 8 2009 ] - (Total Indi Games – 33) (Total Music Tracks Made – 177) (Total SFX Made – Over 1350) (Currently Uploaded Tracks On Webpage– 113)
    Some Teams I've worked with recently (http://manabomb.com/) (http://www.talryyngames.com/) (http://retroburngames.com/)
  • 10/9/2009 4:09 AM In reply to

    Re: Can you set a percentage of a Volume?


    Thanks for taking the time to help me out.

    What I did end up doing was to create a Sound with 4 tracks, each track having each of the notes G1, G2, G3 and G4.

    Then I made 4 different Cue Instance Variables, Vol1, Vol2, Vol3 and Vol4.

    I then created a new RPC Preset "VolRPC" and added the Sound with the 4 tracks to it.

    Once that was done, I then assigned each of the 4 VolX variables to each of the track parameters from within the RPC window (i.e. Variable Vol1 used Object "Track 1" with a Volume parameter) and adjusted the Volumes according to the Variables values (0 indicated a Volume of -50 and 100 indicated a Volume of 0)

    Then using some funky c-sharping code, I "set" the Cue parameters to each have a percentage based on the users Y position relative to the quadrant that the user is in...

    After all that I created one more Variable called OverallVolume that I applied to the Sound used above, and hooked this up using a different RPC, and setting the Volume Parameter of the Sound Object.

    This did seem to work ok, but I need to tweak my C# code a bit more.

    I will take a look at your suggestion and give that one a go too! (If i have time :))

    Thanks again, I appreciate the help!

    Mark
Page 1 of 1 (4 items) Previous Next