• Advertisement

Archived

This topic is now archived and is closed to further replies.

Music?

This topic is 5734 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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!

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
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.

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
Thanks all (especialy CrazedGenius) for all your help i am well on my way to making this game now.

Thanks again.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
I don''t think so, but I could be wrong. It''s been awhile since I worked with DS, but it should go something like this:

Read samples from the wave file
Send them to DS
Send them to the FFT
Get frequencies back -> do something
repeat

make sure you keep DS well fed, otherwise you''ll hear skips in your audio.

Share this post


Link to post
Share on other sites
[If you're reading this "kalolsemon" I would suggest you read my response a little farther down -Michalson]

[edited by - michalson on June 8, 2002 4:06:32 PM]

Share this post


Link to post
Share on other sites
Woah, woah, woah, WOAH!

I mean, all of these would technically work, but the first question should have been: Are you allowing user-imported songs?

If yes, then these more complex techniques are totally necessary- ignore me.

If not, why wouldn''t you just markup each song/level with the BPM by figuring it out beforehand? You could even get schnazzier and mark the section changes/beat structure etc. in some fashion. . . in any case, this takes almost no time at all. (give me 15 seconds and I can approximate the bpm of any dance song within a couple beats. . . two minutes and I''ll give you a 100% accurate figure)

You guys are making this more complicated than it is, I think. No need to spread the computational muscle thin if it can be precomputed.

If you see the Buddha on the road, Kill Him. -apocryphal

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
this is true, but just figuring out the b.p.m. greatly increases the chance that everything could get out of sync. yes, you could get palm trees to sway at 110 b.p.m., but all in all, would they dance with the music, or only with the tempo, but not on the actual beat? With FFT, you can analyze exactly when a beat is occurring and then have your program act accordingly. If you wanna do it right, do it right. if you just wanna make the game, you could do that too. From what it sounds like, though, this is a pretty integral part of the game, and I would wanna do it right.

Share this post


Link to post
Share on other sites
quote:
Original post by kalolsemon
hi dude

i found kazaa best music share pogramm and i think u find your music there.


Since all your email addresses are just fly by night hotmail accounts I''ll have to post this here and hope you see it (your loss if you don''t).

Stop creating accounts and posting kazaa spam. Your other thread was closed for a reason. This is not even a related discussion. If you do not stop creating fake accounts to spam with you will simply be banned, including the 2 semi-legimate accounts you created to post answers in other threads.

Share this post


Link to post
Share on other sites
Assuming you work with a PCM wave (wav, mp3 after decompression, etc):

In my opinion, your better option is pre-mark the music, you can do a program that plays and mark the beats pressing the spacebar. Calculating only the BPM and the first beat is incorrect since it is possible that some songs have little variations in time (not most dance music, however).

Calculating beats in realtime is impossible. The best you can get is something like winamp or other plugins do. You can apply a FFT but the resolution in realtime is not enough. I''ve worked with this last year for my Data Transmision Subject.

Actually, computers can''t handle sounds and distinguish anything with a little of acuracy. Plus, some songs mark the beats not with drums, but with bass and other instruments which make a funcional analisys impossible (well, maybe one day... but this is not an issue for a game).

I would premark all the beats and maybe some other information (crescendos, little stops, etc.). You can always add more songs later.

Real programers are not afraid from maths! (but I am)
JJpRiVaTe (Private Zone)

Share this post


Link to post
Share on other sites
Thanks thats what i have decided to do.

I have an .ini file to mark the beats of each song because i couldnt do anything with FFT, but at least i know what it is now.

Thanks to everyone who replyed.

Share this post


Link to post
Share on other sites

  • Advertisement