Author Topic: Objects pulsing/animating to music?  (Read 2332 times)

Hop

  • Wannabe
  • Posts: 43
  • HopPros on Twitch
  • OS:
  • Mac OS X 10.9.5 Mac OS X 10.9.5
  • Browser:
  • Chrome 46.0.2490.80 Chrome 46.0.2490.80
    • View Profile
  • Playstyle: Keyboard
Objects pulsing/animating to music?
« on: November 16, 2015, 11:18:16 AM »
Not sure if this is something that is possible, but I was thinking it would be cool to have spikes or something similar pulse along with the beat of a song. Is this doable? I've only been playing with Game Maker for a few weeks so I do not know much about it.  Thanks!

TheGamerGuy500

  • Cherry Eater
  • Posts: 62
  • I'm a gamer and a guy, video-game-music junkie...
  • OS:
  • Mac OS X 10.9.5 Mac OS X 10.9.5
  • Browser:
  • Chrome 46.0.2490.86 Chrome 46.0.2490.86
    • View Profile
    • TheGamerGuy500 HQ
  • Playstyle: Keyboard
Re: Objects pulsing/animating to music?
« Reply #1 on: November 16, 2015, 03:55:11 PM »
You'd have to know the exact timings of the music for it to work.
You could...
Split the music file into a set of files that just contain the beats at the start of each file...
Set a timeline and have it pulsate with specific intervals, but on laggier computers, it would quickly desync. You'd have to make it so the music goes at a speed relative to the game's actual speed and current FPS for that case.
Get an extension that can somehow do that.

I'm sure there's a foolproof method out there somewhere
Pro tip: you gotta run and jump at the same time!
Notice: She doesn't stop spinning.

:KappaHD:

lawatson

  • The Kid
  • Posts: 331
  • I do things and I make things.
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 46.0.2490.86 Chrome 46.0.2490.86
    • View Profile
  • Playstyle: Keyboard
Re: Objects pulsing/animating to music?
« Reply #2 on: November 16, 2015, 05:00:38 PM »
Try getting the BPM of the song/sound, multiplying that by 5/6, and then making a value increase by that much until it gets over an amount of beats and then setting it back to 0 and doing the action. It's been done a lot with avoidances in timelines and stuff.
(click to show/hide)

smoke weed everyday

Stepcore

  • Cherry Eater
  • Posts: 87
  • Dreamer of Wizard
  • OS:
  • Windows 7/Server 2008 R2 Windows 7/Server 2008 R2
  • Browser:
  • Chrome 46.0.2490.86 Chrome 46.0.2490.86
    • View Profile
  • Playstyle: Keyboard
Re: Objects pulsing/animating to music?
« Reply #3 on: November 17, 2015, 08:07:36 AM »
Sure it is, Fun Jumps 2 does it.
You need an object that counts up by 1 for every beat so you need to find the bpm and then find the amount of frames per beat as lawatson said. Of course, this object should be persistent.
Code: [Select]
framesPerBeat = (framerate*60)/(BPM)or
Code: [Select]
framesPerBeat = framerate/(/BPM/60)I think.

I would recommend instead of setting it back to 0, just having it count up and use MOD to find the beat to move on. Then you can find any specific beat in the song and do stuff there. You should probably reset it to 0 when the song loops though.
With this method if you need every beat just MOD 1, every other beat MOD 2 and so on, like this:

Code: [Select]
if (beat mod 2 == 0) pulse=true;Of course only check this once per beat, not once per frame.
Code: [Select]
if (beat!=previousbeat && beat mod 2 == 0){
pulse=true;
previousbeat=beat;
}

This will desync if you use show_message or in any way pause the game, change the music etc without regard for the beat timer. So remember to keep track of this.

There is probably a better way but I think this is more or less how I did it.
« Last Edit: November 17, 2015, 09:09:39 AM by Stepcore »
:PogChamp:

Hop

  • Wannabe
  • Posts: 43
  • HopPros on Twitch
  • OS:
  • Mac OS X 10.9.5 Mac OS X 10.9.5
  • Browser:
  • Chrome 46.0.2490.80 Chrome 46.0.2490.80
    • View Profile
  • Playstyle: Keyboard
Re: Objects pulsing/animating to music?
« Reply #4 on: November 17, 2015, 04:58:42 PM »
Thanks for the suggestions! I'll have to try that out.