🎉 Celebrating 25 Years of GameDev.net! 🎉

Not many can claim 25 years on the Internet! Join us in celebrating this milestone. Learn more about our history, and thank you for being a part of our community!

Music?

Started by
15 comments, last by Marty15 22 years ago
I am making a dancing game and i was wondering what the best way of finding the Beat/Rythem of the music i''m using, so that i can change the background and stuff. Thanks
Advertisement
No simple way, you need to analyse the sound buffer using some basic DSP (digital signal processing).

It depends on how advanced you want the app to be. If the music has a strong beat (prominent drum say) you could just test based on amplitude analysis.

This isn''t a simple task though and DSP isn''t the easiest of topics!
<a href="http://www.purplenose.com>purplenose.com
You could look up "fast fourier transforms"

there is source code here (http://www.relisoft.com/Science/Physics/sound.html) that can get you started.
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
I dont want to sound stupid but i have not got a clue what your talkiing about, and i definatly dont know what that site is about

sorry. but thanks all the same
as far as i know. DSP is... using effects and so forth.
i believe what Marty wanted, was some sort of program which could establish the beat of the music he was using, so that it would control another part of his program. or something like that... the amplitude test is a good one, as the music grows louder, ur app could recognise that, maybe frequency response or something else like that...

since dance music tends to start with a bass line and drums, whilst they mid and high ranges come in later, so..... its ur call.




Purple Hamster
Helped and be helped!
David J Franco__________________________visit www.davidjfranco.com
I dont know what type of music format you are using, but if you use midi i think it would be pretty simple. or if you make the music yourelf or have access to the notes used in it. you could store the timing of each note and work with that.
Fast fourier transforms are used to decompose a signal so that you can look at it's frequency content. They map signal data from the time domain to the frequency domain.

Huh???

Imagine you and a friend get together. You hum a tone at a constant frequency and he/she hums a tone at a different frequency. The result looks like two superimposed sine waves. (You can experiment with this sort of thing in Sound Recorder).
There's not a whole lot you can easily discern from that wave.

Now, imagine you take a handful of samples (say 1024 at a time) from your little jam session and send it through a fourier transform. What you will end up with is a set of samples that describe the frequency content of that handful of samples. In the scenario, you'd see one peak at your frequency and one at your friend's.

Now, imagine sending a handful of samples in which your friend does not hum. The frequency plot for that batch would have only one peak where your "signal" was. So, you could use this system to see when your friend was humming and when he/she wasn't.

So???

Your drum beat probably occupies an easily separable frequency range. Therefore, you could send your music through the FFT in 1024 sample intervals and watch when you get frequencies in that range. When you do, there be a drum beat.

It sounds very hard, I know, but it's the right way to solve your problem. It'll be worth the investment to look into this. I've found that the code at Relisoft (http://www.relisoft.com/Freeware/source.zip) can be reused relatively easily. You could probably use their code (check their stance on this) without truly understanding exactly what's going on. If you do want to learn more, there are plenty of places on the web that talk about this.
http://www.jjj.de/fxt/

[edited by - CrazedGenius on May 31, 2002 1:40:41 AM]
Author, "Real Time Rendering Tricks and Techniques in DirectX", "Focus on Curves and Surfaces", A third book on advanced lighting and materials
Thanks all (especialy CrazedGenius) for all your help i am well on my way to making this game now.

Thanks again.
If you''re working with audio data, and I presume as much, since MIDI tempo is VERY easy to resolve, head to www.alanmyers.com and grab "sample to metronome" from the downloads section. You can load the .wav file you''re working with, tell it how many beats are in the .wav file, and it will give you the tempo.

Ed Lima - ELM&M
ed@edlima.com
http://www.edlima.com
Ed Lima - ELM&Med@edlima.comhttp://www.edlima.com
Is there any way to split the frequencys or something in DirectSound so that i can do that FFT stuff?

Thanks

P.S. I am using a .wav file.

This topic is closed to new replies.

Advertisement