[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

[pygame] Music



Hi, everyone!

I am looking into adding music to my game, but, more importantly,
making that music actually do something/matter.

I have read the pygame documentation on mixer, and have googled
additional tutorials on adding music through mixer, accessing music
from a cd, and PyMedia (although for my current purposes I'm not sure
I would need any of that stuff quite yet).

The first step will be adding a background song to my level.  I'm
fairly confident I can do that.  It might take some prodding to figure
out how to loop it nicely, but that'll come in time (although any
suggestions/tutorials/helpful pointers are always appreciated).

My real question is this:

"Real" music (that's what I'll call it, for my present purposes),
composed in the real world, is made up of a bunch of individual
elements - notes, chords, crashes, sounds, what have you.  In my house
growing up, a lot of these elements resulted in Little Brother Noise. 
In other places, they result in what people would call music. ;)

But when I have a music *file* - let's say an mp3 - it is one...
"thing."  I load that one thing, I play it, I can pause it or stop it
or fade it out into another thing.  I read that in pygame you can only
have one music file at a time (not a bunch of overlain tracks? that
would be cool...), so in my understanding you have this one thing
playing and that's it.  The actual sound that comes out of it might be
made of a bunch of things you hear as distinct elements, but to the
computer it's just one thing.

Correct me if I'm wrong.

What I'd *like* is to be able to listen for certain individual
elements in the song, and make them game events.  In theory I could do
this when the song ended, make something happen and replay the song,
but I couldn't do it, for example, every time a high C was played, or
a drum beat, etc.

Can pygame do anything like this? (or anything else, for that matter?)
the closest thing I've seen so far is finding the position in the
song, so that if you knew you had a high C (for example) every x
number of miliseconds, you could make an event happen at every x
number of miliseconds. They wouldnt exactly be tied (and you'd pretty
much have to create some boring music), but I can't find much else.

Anybody who's played something like Lumines, O2Jam, Band Brothers, or
I'm assuming DDR (i've never played but believe it's tied to events in
the music) will know the kind of tie I'm talking about.

Has anyone looked into this, or know where I could find out more? Any
pointers would be much appreciated!

~Denise