Using game clock to match BPM of music clips..

lbc4everlbc4ever Member Posts: 18
edited March 2012 in Working with GS (Mac)
Hello all,

I'm working on a game which revolves (quite literally) around music & need to figure out a way to start different loops in time with each other. Each loop has a button & will play when pressed. First off I thought I'd just start them all as soon as the level began at Zero volume then use the buttons to set their volumes from 0 to 1. All nice and synced. Easy. Turns out gamesalad can't adjust a single sounds volume on the fly.. I've spent 2 days trying to no avail.. SO..

My next method was to calculate the time it took for 8 beats at 120bpm (4000ms) and have the audio start at 4 second intervals (ie: at the start of a bar) thus keeping everything timed properly.

My question to you all is this. How do I tell gamesalad to..
1 : Generate a flag every 4 seconds (or more or less depending on BPM of the track)
2 : Delay any instructions to play audio clip until it sees that flag
3 : Start playback the moment it spots it
4 : Apply those instructions to 7 or 8 clips in the same scene

Call me a dope here but I been at this for days.. Tried various combinations of timers, rules and attributes and got no closer to a solution.. Help?

Once we crack it I will put a template up online as BPM matched instructions would be a handy tool for a tonne of different games.

Tanx guys :)

Lbc4ever

Comments

  • MotherHooseMotherHoose Member Posts: 2,456
    edited March 2012
    1. you can interpolate an attribute's value with Duration of 4
    2. use that attributes condition in a rule to play another sound

    EX: create an Attribute index type playSound#
    on actor
    Rule: when
    Attribute: game/actor.playSound# = 0
    --Play Sound:
    --Interpolate: playSound# To: 1 Duration 4
    (you could use a table for durationTime… and exp. tableCellValue(table,row,col) … but there is no row or column)

    Rule: when
    Attribute: playSound# > 0
    --Rule: when
    --Attribute: playSound# = 1
    ---Play Sound:
    ---Interpolate: playSound# To: 2 Duration 4 (or whatever the cellValue)
    --Rule: when
    --Attribute: playSound# = 2
    ---Play Sound:
    ---Interpolate: playSound# To: 3 Duration 4 (or whatever the cellValue)

    and do an option+drag of those rules to nest them in the > 0 rule … changing the values as needed

    @};- MH
  • lbc4everlbc4ever Member Posts: 18
    Thanks MH,
    That sounds like an effective approach. I will try it this afternoon & report back.

    lbc4ever
  • lbc4everlbc4ever Member Posts: 18
    OK,
    So far it works great so long as there is only 1 clip in a scene. The 2nd / 3rd etc etc play as soon as you touch their respective buttons regardless of
    any rules that I have set up.

    Here's how I'm trying to prove the concept..
    I have a game control actor (offscreen) containing the PlaySound attribute and the rules to interpolate it to a value of 1
    I have 3 game attributes (boolean). Play 1, Play 2 & Play3
    I have 3 buttons onscreen that change the above booleans to true when touched
    Inside the game controller are rules that state.. When self.Playsound=1 AND Game.Play1=true Play sound x
    When self.Playsound=1 AND Game.Play2=true Play sound y
    When self.Playsound=1 AND Game.Play3=true Play sound z

    Am I missing something?

    Lbc4ever
  • lbc4everlbc4ever Member Posts: 18
    Yep.. I was missing something.

    I just needed to tie the clip volume to an actor attribute.

    Wally.
    Thx for the help MH :)
  • MotherHooseMotherHoose Member Posts: 2,456
    edited March 2012
    it is a wonder I could help =)) … that is nothing like I thought you were doing! =))

    thought it was sequential play! … like what you did and, how you got that worked out to sync with touchButtons

    @};- MH
  • aumaum Member Posts: 8


    Once we crack it I will put a template up online as BPM matched instructions would be a handy tool for a tonne of different games.

    Lbc4ever
    Hi Lbc4ever, sounds like you guys have cracked it but you didn't put up the template, as I am quite new to all of this it would be great to see one in action to be able to learn and understand the logic involved :)

    ONELOVE
Sign In or Register to comment.