A downloadable asset pack

Buy Now$2.99 USD or more

Hello! Welcome to my coolest asset yet!

BPM - The Music Synchronization Machine

Many of us wanted to synchronize the music to the things that happens in our games. Let's say things like moving the sprite of the character to the beat of the song, or making strobe light synchronized, let alone make games like the fantastic Crypt of the Necrodancer. Well, this asset should make your life much easier. Now, all you need to do is input the BPM of the song and the time signature. That is ALL. The code will synchronize a metronome and it will handle all the beats. Then it will send signal to custom events for each beat of the measure and you can customize it like you want!

Not only that, but, to show a little bit of what this thing can do, I made a demo room which contains things like sprites changing their colours with each beat, strobe lights on major beats, balls that jump on time with the music, and most of all: A character that you can move but it will only move synchronized with the music. Is just a set of arrows as a proof of concept, but the possibilities with this are endless!


Features

  • Easy to use: Just put start_metronome(), pass the bpm and time signature, and you are good to go!
  • Easy to customize: Make the custom events that you want and run them to the sound of the beat!
  • Fully compatible: This does not require any DLL so you can keep up to the beat on any platform!
  • Fully docummented: Everything done here is explained!
  • Fully musical: If you want to make rythm based games, or want to sync music with the game at all, you need this.

How does it work? 

First, we start with a metronome object. With some equations and accounting the delta_time of each PC as well as the frames, it runs a timer against a threshold that's constantly raising on each beat. Then, when it register a beat, it checks whether is the first beat of the measure or any other (easy to change this) and runs an event on a separate object (so it doesn't interfere with the bpm step event). That object, called an activator or event handler, runs whatever you want every time it receives an activation by the metronome.

But is it accurate?

Given that the games normally refresh at a rate of 60 times per second, this things normally aren't that accurate. But the way I programmed is simple yet effective, and any margin of error that could case some milliseconds of delay on a beat are fixed on the next one, thus making it always synchronized. That's why I've put the demo song. Just check it for yourself!

Is it compatible with X device?

 Yes it is! It doesn't use any DLL or code outside plain ol' GML.

Is it slowdown proof? 

The code is fast enough (I've even included a start_metronome_fast() version of the script) but it should be slowdown proof, because the code also takes into account the delta_time.

Is there a demo to see this working? 

Yes it is, download this here!


If you like this asset, you can check the rest of my assets, including my Echo/delay effect for GMS2. You can also follow me here!

If you have any doubt or want to contact me about something, feel free to send me an email to joaquinmedrano1@gmail.com

Bye for now! <3

-Floyd

Purchase

Buy Now$2.99 USD or more

In order to download this asset pack you must purchase it at or above the minimum price of $2.99 USD. You will get access to the following files:

BPMMusicSync.yymp (Drag and drop to your GMS2 project window) 14 MB

Download demo

Download
BPM - Music Sync. Machine.zip (DEMO) 9 MB

Comments

Log in with itch.io to leave a comment.

Hello 

I need assistance with implementing this in my game please.

Hey, am I allowed to use this in an open-source project, or must any of my works that use this script be closed-source?

Thanks,
- Rossiter

Bueno he visto que sí respondes en español, así que procedo xd

Estoy haciendo un juego tipo shooter runner, y los enemigos quiero que salgan al compás de la música, a veces si, a veces no, etc.. he intentado  usar un codigo que encontré en el foro oficial donde agarra el audio_sound_get_track_position(), hace un módulo con los SEGUNDOS y si da < 0.1 entonces entra en la conducción, esto condicionado por un booleano para que no se ejecute repetidas veces por eso de los decimales... Para sacar los SEGUNDOS que dura cada "beat" he usado webs online que te dicen los BPM de una canción, agarro ese BPM y lo divido entre 60 (1 min en segundos)... Parece encajar bien, pero a la larga los eventos se adelantan a la canción y ya no sé que hacer... Perdón por el largo texto, en resumen, necesito el tiempo (en steps) EXACTO entre beat y beat... No sé si esto me servirá, y si me sirve, quiero saber si recibiré ayuda en el caso de no conseguir implementarlo como necesito, gracias.

Si el BPM del track es igual o mayor a 60 bpm, entonces este asset deberia funcionar sin adelantarse.

(+1)

Thanks for making this! Works perfectly, and it's very easy to use :)

(+1)

Absolutely awesome asset. Cheers!

Hola Floyd!

Quería hacerte una consulta acerca de la implementación. Supongamos que yo quiero que se ejecute un script en la 4ta corchea del 3er compás de una canción... Por lo que vi en la demo, lo tienes resuelto. ¿Puedes comentarme cómo se usaría el asset en un caso así?

Muchas gracias!

(+1)

Hola! Primero que nada mil disculpas por tardar en responder. Estoy muy desactualizado. 

Si, efectivamente, si por ejemplo yo tengo una cancion que va a 4/4, puedo hacer un script distinto para cada golpe. La documentacion esta dentro del codigo, incluyendo el demo y su codigo fuente comentado para entenderlo. Si lo que queres hacer es que un evento se ejecute en un unico compas, deberias agregar algunas lineas de codigo, uno para la cantidad de compases de la cancion, otro del marcador de compas actual en 0, uno que checkee cuantos compases va asi resetea a 0, y despues en el evento que crees para que suene en la 4ta corchea, podes hacer un if diciendo "si esta en este compas, ejecuta este otro script".