Linking sounds playback pitch (speed) to other attributes..

lbc4everlbc4ever Member Posts: 18
edited March 2012 in Working with GS (Mac)
Hi all. Got another poser for you..

I'm working on a game which requires the pitch of some sounds to react actively to player touch inputs.

Eg: Touching at position X = Playback at 3 times the normal pitch
Touching at position Y = Playback at a fraction of normal speed

There is an expression editor in the sound playback field so what I'm wondering is..
Can I constrain the pitch (speed) of playback to any other attribute? If so how?

Cheers guys / gals..

Lbc4ever

Comments

  • CloudsClouds Member Posts: 1,599
    edited March 2012
    There is an expression editor in the sound playback field so what I'm wondering is..
    Can I constrain the pitch (speed) of playback to any other attribute? If so how?
    You've already answered your own question . . . ?

    You know how to use attributes ? You've already pointed out there's an expression editor for pitch ?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited March 2012
    I was thinking that but decided not to say it. Do the work and experiment and then come back and share your findings with us all. We look forward to your contributions to this forum and community.
  • lbc4everlbc4ever Member Posts: 18
    Thanks for the nudge guys.. Here's what I did.

    1. Created a game attribute (integer) and called it sound pitch
    2. Created a rule which changes that attribute to mouse.position x whenever a certain actor is touched, then put it in a timer to update every 0.01 seconds.
    3. Created a play sound rule and in the expression editor set pitch to game.sound pitch divided by 10.

    It works like a charm. I'm in the process of adjusting the maths to have 0 pitch in the middle of the actor and not on the far left. Then
    I will import a reversed duplicate of the sound and repeat the process, giving a "DJ scratch" effect in the game.

    I appreciate your taking the time. Getting there bit by bit.

    Lbc4ever.


  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    Great! And the most important thing you learned was that you can do it. That is true power to be able to trust in your own abilities. You should be proud!
  • CloudsClouds Member Posts: 1,599
    Thanks for the nudge guys.. Here's what I did.

    1. Created a game attribute (integer) and called it sound pitch
    2. Created a rule which changes that attribute to mouse.position x whenever a certain actor is touched, then put it in a timer to update every 0.01 seconds.
    3. Created a play sound rule and in the expression editor set pitch to game.sound pitch divided by 10.
    It works like a charm. I'm in the process of adjusting the maths to have 0 pitch in the middle of the actor
    Using 'Integer' will quantise values to whole numbers, dividing by 10 will, obviously, give you 0.1 as your finest value, the pitch value in GS refers to whole octaves (1=1 octave, 2=2 octaves etc) . . . and 0.1% of an octave is more than a whole tone . . . So, if you want a smoother / pitch bendyer sound use 'real' rather than 'interger'.


  • lbc4everlbc4ever Member Posts: 18
    OK,
    I will have a look at that. Will changing the attribute to "real" have any impact on performance? (It's stingy I know but I like to try to keep resource usage to a minimum).

    @ FryingBacon, you're quite right about learning what it's possible to achieve but it'll be a while before I'm proud of my "extensive" Gsalad knowledge :)

    Thanks again guys,

    Lbc4ever.


Sign In or Register to comment.