Pulse screen to a beat [Solved]

General discussion about LÖVE, Lua, game development, puns, and unicorns.
Post Reply
User avatar
bobbymcbobface
Citizen
Posts: 78
Joined: Tue Jun 04, 2019 8:31 pm

Pulse screen to a beat [Solved]

Post by bobbymcbobface » Sat Nov 16, 2019 1:37 pm

Hi all,

I'd like to know how i would go about

A. detecting when a beat is played in real time from any uploaded sound file
B. pulse the screen when the beat is detected

baring in mind i can't resize the screen then revert it back to normal size as a pulse effect

Thankyou
Last edited by bobbymcbobface on Sun Dec 01, 2019 10:48 am, edited 1 time in total.
I make games that run on potatoes :P

User avatar
zorg
Party member
Posts: 3006
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Pulse screen to a beat

Post by zorg » Sat Nov 16, 2019 5:35 pm

Representing pulsing can be done in a million ways, if you don't want to move the window itself (which wouldn't work on handhelds anyway), maybe doing a zoom when it happens, or invert the colors on the screen, or do any other effect (Quadrant does many of these effects to a beat, check it out on steam, it's a Löve game)

Detection's harder unless you can define the tempo of the song at start (if it changes, then defining multiple tempos at specific time offsets) along with the first beat's offset from the start; this would be a very simple implementation.

A harder one is to pre-process the audio file, going through all sample-points (44100 * 60 smp-s for one minute of 44.1kHz rate file) and applying some kind of beat detection algorithm on it.

Both of those are not solutions if you wanna do this real-time for some reason; in which case, you need to apply the beat detection in real time, which is both inefficient and probably not what you really want to do.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: Pulse screen to a beat

Post by raidho36 » Sat Nov 16, 2019 6:11 pm

Beat detection is generally unreliable AND difficult to implement. You should make beats manually; make a simple tool that will allow you to synchronize beats with audio and export beat tracks. Then you can use these beat tracks together with audio tracks in game.

User avatar
ivan
Party member
Posts: 1619
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Pulse screen to a beat

Post by ivan » Sat Nov 16, 2019 6:13 pm

I'm not an expert in this area but I have dabbled a little bit with rhythm-based gameplay and audio visualizations.
For starters, you need to make sure that you understand the difference between beat detection and more simple ways of analyzing the raw audio input. For example this is an oscilloscope made with Love2D (audio by Jarobeam) running in real-time via queued audio sources:

Building an oscilloscope like that should be a good starting point for you. Beat detection is more complicated - it will probably require some sort of pre-processing and it may not work as you expect with "any uploaded sound file". For example, certain forms of classical music don't have "beats" at all. Also, input files could be noisy or could contain compression artifacts.

User avatar
ivan
Party member
Posts: 1619
Joined: Fri Mar 07, 2008 1:39 pm
Contact:

Re: Pulse screen to a beat

Post by ivan » Sat Nov 16, 2019 6:26 pm

raidho36 wrote:
Sat Nov 16, 2019 6:11 pm
Beat detection is generally unreliable AND difficult to implement. You should make beats manually; make a simple tool that will allow you to synchronize beats with audio and export beat tracks. Then you can use these beat tracks together with audio tracks in game.
Yes, you can build your game around a pre-defined audio loop and try changing the pitch to control the pacing. There are similar techniques that will allow you to make a COOL rhythm-based game WITHOUT using beat detection.

User avatar
bobbymcbobface
Citizen
Posts: 78
Joined: Tue Jun 04, 2019 8:31 pm

Re: Pulse screen to a beat

Post by bobbymcbobface » Sat Nov 16, 2019 7:36 pm

Thanks for the help guys! :) - I'll get back to you whether I still have any problems or not

Edit: thanks for the oscilloscope and the example with quadrant this has given me a vast amount of help on ideas of executing this so far
I make games that run on potatoes :P

User avatar
bobbymcbobface
Citizen
Posts: 78
Joined: Tue Jun 04, 2019 8:31 pm

Re: Pulse screen to a beat [Solved]

Post by bobbymcbobface » Sun Dec 15, 2019 10:06 am

I know this topics solved (and I'm double posting) but i thought this would be important for anyone browsing this forum
https://github.com/Ulydev/wave
is a great place to start with beat detection just make sure you use "true files" (as i call them) these are basically files that aren't converted i.e mp4 to mp3 because love2d can't read their parse data (i think)

and that's all for now, any questions - ping me or the owner of the github page :)
I make games that run on potatoes :P

User avatar
zorg
Party member
Posts: 3006
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Pulse screen to a beat [Solved]

Post by zorg » Sun Dec 15, 2019 12:49 pm

bobbymcbobface wrote:
Sun Dec 15, 2019 10:06 am
...just make sure you use "true files" (as i call them) these are basically files that aren't converted i.e mp4 to mp3 because love2d can't read their parse data (i think)
Löve can (and the library itself should be able to) parse wav, ogg and mp3 files (and maybe flac), along with all module formats libmodplug supports (the lib itself uses static sources if i read the code right, so it'll all be converted to samplepoints anyway) but not mp4 files as audio, as far as i know.

Also, to make an addendum to my earlier post here, while moving the window itself is not really easy nor suggested, a screen shake effect based on the beat could work.
Me and my stuff :3True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.

User avatar
bobbymcbobface
Citizen
Posts: 78
Joined: Tue Jun 04, 2019 8:31 pm

Re: Pulse screen to a beat [Solved]

Post by bobbymcbobface » Sun Dec 15, 2019 12:51 pm

yeah but for some reason on my computer it raised an error when i converted an mp4 to an mp3 and then tried to play it with love whereas all my other mp3's worked fine (I'm thinking i may have not converted it right or something)
I make games that run on potatoes :P

Post Reply

Who is online

Users browsing this forum: No registered users and 57 guests