A music equalizer visualization?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

A music equalizer visualization?

Post by Kingdaro »

I've always wondered if it would be possible to make an equalizer visualization in love2d, since I've tried adobe aftereffects and that was just too much headache inducing work. It'd honestly be much easier for me if I could do it in lua or if you can think of another alternate method, go ahead and suggest that.

the kind of thing I'm thinking about is how you see some of those videos where you have different bars that react to specific frequencies in the music. example:
http://www.youtube.com/watch?v=oGgIxtoeFCc

I tried it in the past with SoundData but I just kept getting a white screen with "not responding", I was probably doing it wrong, haha
[hr]
Also, please be light on the terminology as I am no expert with love, just yesterday I found out you could find the width of an image object, haha.
User avatar
Adamantos
Prole
Posts: 27
Joined: Sun May 16, 2010 10:47 pm

Re: A music equalizer visualization?

Post by Adamantos »

hey there,

in an equilizer every single bar represents a specific frequency (or better a range, for example 220Hz-250Hz)
In order to get this information you have to analyse the music on the fly. This is called "fourier transformation"
(see wikipedia for more information)

These calculation can be very fast and efficient (fast fourier - FFT), but still be a big effort.
Handling all these algorithms in lua is some heavy lifting and I don't think this is possible in real time....

If you are still interested, have a look at "LuaFFT"
http://www.mindfarming.de/luafft/
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: A music equalizer visualization?

Post by thelinx »

Well, there's this.
Lovechild
Prole
Posts: 9
Joined: Wed Mar 07, 2012 4:13 am

Re: A music equalizer visualization?

Post by Lovechild »

Well if you are really intent on coding an equalizer, then there are two solutions I present that are not of the moon, but from a drop of milk.

Milkdrop 2.x, with free testing available from foobar2000's Spheck plugin (Windows)

Or if you take the more open route, a ProjectM visualizer. ProjectM is very similar to Milkdrop -- and is in fact made by the same guy (Ryan Geiss) -- that utilizes the PulseAudio sound server for people on systems using PulseAudio (e.g.Ubuntu) as an audio manager.

If you're really, truly intent on coding an Lua/Love visualization, then the code has to get the sound data from SOMEWHERE and interpret it. I would say target ALSA, OSS or Jack first (if sound data can be extracted from them, might be easier aiming for PulseAudio) and go for what Windows and Mac uses later once you have a working prototype on one of the more open sound solutions. So instead of letting Lua do all the heavy work, other components more specialized handle it and all your little app will do is interpret that output.
User avatar
Kingdaro
Party member
Posts: 395
Joined: Sun Jul 18, 2010 3:08 am

Re: A music equalizer visualization?

Post by Kingdaro »

well I was able to make something:
equalizer.love
(14.04 KiB) Downloaded 605 times
though it only works efficiently on smaller sound files, bigger files just show random spazzing lines that don't go with the music at all. at times I have to multiply dt by 2 for the music and visuals to sync, I'm not sure how to fix this.
bitshifter
Prole
Posts: 1
Joined: Sun Apr 22, 2012 12:25 pm

Re: A music equalizer visualization?

Post by bitshifter »

Kingdaro wrote:though it only works efficiently on smaller sound files, bigger files just show random spazzing lines that don't go with the music at all. at times I have to multiply dt by 2 for the music and visuals to sync, I'm not sure how to fix this.
I think I've fixed both the equalizer getting out of sync and needing to sometimes multiply dt by 2.

Rather than trying to keep track time to determine what sample the music is up to, you can just do:

Code: Select all

local curSample = music:tell('samples')
The reason you would have had to multiply dt by 2 is because you aren't handling multiple channels (i.e. stereo). For stereo you'll have to deal with two samples for each channel:

Code: Select all

for i=curSample, (curSample+(size-1) / 2) do
     local sample = (sound:getSample(i * 2) + sound:getSample(i * 2 + 1)) * 0.5
     table.insert(wave,complex.new(sample,0))
end
Attachments
equalizer.love
(14.29 KiB) Downloaded 531 times
Post Reply

Who is online

Users browsing this forum: No registered users and 17 guests