Discussing how to make a rhythm game

Started by Kinoko, Tue 21/08/2007 07:18:06

Previous topic - Next topic

Kinoko

I'm interested in having a discussion with both music and mostly programmer types about making a rhythm game with AGS (or any other software if it comes down to it).

This is not some secret project or anything, but I've been thinking of doing a rhythm game for awhile and I had a good, long think about it today. This is my thinking summed up:

As far as just a basic engine goes, let's imagine just a background with some kind of interactive music staff across it, with birds (representing the notes) flying across the screen. Different keys represent the 5 notes and when the notes hit a certain line in the middle of the screen, the player must hit the appropriate key.

Simple, simple, simple.

So, as far as the engine goes, we need those notes to match up with a music track being played, otherwise it's not much of a rhythm game. This is the tricky part and the bit where I need to get a little dialogue going.

In my imagination, ideally, I see it working like this.

You have a musical program with which you create a simple track of music, comprised of, for simplicity's sake, 5 notes. This software has the ability to produce a text document representing your music with, you know, letters and numbers and such which correspond to the notes and timing.

Then, you write your game engine to be able to read and intepret these text files and have the game mechanics correspond.

That's my imagination. That's the way I see it happening, but I don't have the knowledge of programming nor audio software to know if this can be done.

Is this possible OR is there another way? I'm really interested in YOUR thoughts on this.

Gregjazz

How about having an MIDI file alongside the audio file, and using the PlaySilentMIDI function you can get its beat number.

In fact, if the fastest note was an eighth note, just put the BPM of the MIDI file to match that pulse. (let me know if you need elaboration on this)

Then you have a text file alongside that has the beat numbers that have a note assigned to them, and the value of the note.

I think that'd be the easiest way to do this apart from making your own plugin.

Kinoko

Interesting, I see your basic idea but I'm a little lost on the details. How does PlaySilentMidi find a beat number fro a Midi?

Gregjazz

So you have a MIDI file that's sync'd to the original audio file. Then you use the PlaySilentMIDI function to silently play the MIDI file (start the MIDI file at the same time as the audio file). Then this allows you to use the GetMIDIPosition function to return the beat number.

Radiant

A reasonably easy way of coding this is the following:

(1) create WAV files for, say, eight notes
(2) create a textfile that tells you when to play them (e.g. tick 100 = C, 110 = D, 120 = E, 130 = C, and we get Frere Jacques)
(3) read the textfile using File IO functions in AGS
(4) make a repeatedly_execute loop that increments some counter, and plays the next WAV as appropriate if the counter hits the given value
(5) check for keypresses in the same function, using IsKeyPressed()
(6) ???
(7) profit!

Kinoko

I agree with your idea, Radiant, but surely the problem lies in the creation of the text file itself. If I want to have any kind of music more complicated than Three Blind Mice, this sort of thing would take me hours.

Gregjazz: I see! So I would essentially create the musical track, then 5 (or however many notes I wanted to play with) MIDI files corresponding to the notes to be hit by different keys, right?

That's actually a better idea than mine in many ways because it allows for personal flexibility in terms of which notes in any given musical track that I want to be 'playable'. I can have music as complicated as I like, theoretically.

Stupot

to allow for the fact that most players wont have a 100% sense of rhythm you'd have to programme in some kind of sytem where say if the user gets it dead on the note they gets a "perfect", then if they are slightly off the get "good" if they are reasonably close they get a "nice try" and if they are way off they get a "fuck off", or something similar...

you could then have some kind of scoring system where:
Perfect = 5
Good = 3
Nice try = 1
Fuck off = -1

or something to that effect.

Kinoko

Yep, I've thought of that ^_^ Though I like your "fuck off".

Nikolas

Ok.

I'll be blunt here...  :-[

I don't think that your whole idea is really interesting... (It does remind me of Lumines a little bit as a concept).

The problem for me, music wise, and game design wise is that it will be boring! with the restriction of 5 notes, it's reather difficult not to be boring in music.

Either way, the things you need to be cautious of:

You need to be able to sync everything. if you have any kind of pulse/beat/drumsn'bass then you will need to be absolutely sure that every "note" that plays, it's at it's right place, sync/tempo wise. Otherwise you might as well write a track, put 5 notes as sfx, and play them, right? And last time I checked AGS was not perfect at that. Not with mp3/wav files eitherway.

One thing to keep in mind, with mp3s, is that they insert small small gap silences, at the begining and end of any track, so if you have a track synced at 2", you could probably end up at 2.04" or something, which in the long run will screw the sync. It is my understanding that ogg files don't have that (and wav/aif either).

Now in order to sync something, you need to be able to count (actually have the program count). just in case that you don't know, I'll explain shortly what BPM means.
BPM: Beats Per Minute. How many "beats" fit in one minute. This is also called the tempo in music. The easiest tempos to go are 120 and 60. 60 will equal 1 beat=1 sec, since there are 60 in a minute. 120 is 0.5 sec per beat. Easy maths, easy counting, easy everything.

So, syncing. I think that AGS (and certainly all somewhat complicated engines) have the internal clock thing, where 18 (or whatever number really  :-[) cycles equal 1 sec, right? I do recall that in The Forgotten Element, 30 cycles is 1 sec, and this is how we crossfade musics and stuff, but I don't know if this is defawult in AGS, or just something that Lemmy101 added.

Eitherway. Having a sort of counter to keep track on what time it is, how many times you have played something (a loop), what place of the bar/loop it is, can be very useful.

Music moves usually in "square" distances. In 2,4,8,16s it doesn't change every 5, or every 7. At least 90% of the time. In order for any beat to sound a bit logical you do need to take into account also that fact.

I would be far more interested, if I could change, as a player, the music to a new dynamic level, the better I was doing, or the higher score I was having, or something. It would be highly rewarding to hear the music turning into one furious beat, little by little, not because of the linearity of the program, but because I was doing better.


I know that I'm not making much sense, you will need to decrypt my post, but what the heck. I'm typing as I think it... Sorry


Loops. You will need loops. Plenty of loops. Loops to play for ever, as the background music. Other loops to give variation, other loops to play when something big happens, for example. Etc.


I think I'm getting more and more complicated, and maybe with no good reason. Let me know...

Stupot

It doesn't have to be as complicated as that.  Of course your gonna have to make it sync, and that's gonna be a trial and error process, that could take a lot of patience, but if and when it works it will be so rewarding.

5 notes is more than enough to make the game addictive and fun... hell, the guitar game on PSP only has 4 or 5 and that's brilliant.  You can make it more exciting by having the birds appear increasingly more frequently and songs getting faster and faster.

Even if you only had 5-6 songs, the addictiveness would come from trying to get a perfect score and then brag about it on the AGS boards.

And heres an idea.... Each song has a prize, an easter egg, for gaining 100% score.

song...... prize
1.............credits
2.............artwork and sketches
3.............a signed photo of Kinoko
4.............a date with kinoko
5.............kinoko's hand in marriage
6..............A preview of the sequel.

Kinoko

I think some of you need to keep in mind that this is NOT a game idea! I'm not telling any of you what my actual plans for a game would be if I do indeed decide to do this. I'm simply trying to work out how to get: MUSIC -> GAME ENGINE programming wise.

Your comments are, however, -well- appreciated Nik ^_^ If there's anyone I want to ask about music, it's you and you make a lot of good points. Lumines is an exceptional game and I could only dream of emulating it in some way. The problem with Lumines is that it's such a beautifully designed game, there's no need really to try and remake it. It's pretty close to perfect. I adore that game. I'm more than happy to take lessons learnt from it though, and from yourself.

However, I do disagree with you that just 5 notes would be boring. I think there's a lot of potential in a simple concept to be turned into a fun game. It's not for everyone, of course. I've been getting more and more into various rhythm games lately and the top of my list goes without any shadow of a doubt to Lumines, Rhythm Tengoku (or Rhythm Heaven), Space Channel 5, Ouendan and Cool Cool Toon.

I'm not trying to make another one of those though, I'm simply playing with the concept for the time being and I want to know if it -can- be done. Even if all I do is make one little engine which is barely a "game" at all, perhaps others will be inspired to take it further, or myself.

Your points about synching are of course on the mark and that will be a problem. Depending on the methods used, I'm sure it'll be a lot of trial and error.

Still, what I'm trying to figure out more than anything right now is just the basics and the best way to make a bare-bones engine that connects music to programming.

Thankyou -so- much already everyone! This has been really interesting and helpful so far ^_^ I rather hope someone else is inspired to give this a shot too.

Radiant

Quote from: Kinoko on Tue 21/08/2007 08:15:13
I agree with your idea, Radiant, but surely the problem lies in the creation of the text file itself. If I want to have any kind of music more complicated than Three Blind Mice, this sort of thing would take me hours.

Actually, it isn't all that bad, because what I described is almost exactly how a MIDI file works (except of course that it's binary rather than text). There's plenty of FAQs on the web about reading MIDI syntax.

Nikolas, note that AGS does 40 cycles per second by default, and can easily go up to at least 60 on semi-new systems.

Oh yeah, I'll have to look it up, but I found a game somewhere that is a combination of a space shooter and a MOD player, basically it has enemies appear with each MOD sample.

OneDollar

I'm fairly sure that no rhythm game asks you to play the exact notes of the music playing, just a pattern that fits with the song. This means that you would need a really simple background song to just be able to convert it - and I reckon when you compare a song with literally 5 notes to some things in, say, Guitar Hero it'd just be boring.

What you might find worthwhile looking at is Frets on Fire; a free, open-source Guitar Hero clone for the PC. That works with three files - an Ogg Vorbis format backing track that always plays on each song, an Ogg for the guitar track that plays when you are hitting the notes and a small MIDI file that stores all the notes you need to hit. The MIDI (presumably, I don't really have anything that will let me investigate, but this is how I would do it) has the notes A to E that correspond to buttons 1 to 5, and the pattern of these notes is the pattern of buttons you need to hit. When you make a song in-game you write the button sequence in to match the music yourself then the game converts that pattern to the MIDI. Extending this you can have multiple difficulties in one MIDI. This system allows you to have whatever you want as the song but you can't just convert it directly to button patterns.

I don't know what sort of MIDI analysis AGS is capable of, but I guess you could do something similar with a text document

RickJ

Quote
I agree with your idea, Radiant, but surely the problem lies in the creation of the text file itself. If I want to have any kind of music more complicated than Three Blind Mice, this sort of thing would take me hours.
Radiant is on the right track here.  Just add the ability to record the text file by playing the desired tune using the same keys as the player would.   This could be a developer only tool or an extra feature of the game.   

The thing I would be concerned about playing and then syncing to an MP3 or other format file is that unless you are implementing the low level code that actually plays the file you don't have any control over how or when it's done.  You could have a situation where it works fine on one computer or OS and poorly or not at all on another.   The other thing to note in this kind of setup is that sync error is cummulative so that the longer the track the larger the error.

If one could persuade oneself that the game engine keeps adequate pace with the music player or if one devises a way of periodiacly re-synching  everything then the above key recording method could also be used here to create the text file.

If a key recording method is used to create the text files then you may want to consider using a binary file.  You could create a struc
to define the attributes of each note and then read and write these to the file.  The file would be smaller, more efficient,  and less hackable.
struct beat {
   int note;
   int duration;
   int other;
}


Gregjazz

Quote from: Kinoko on Tue 21/08/2007 08:15:13
Gregjazz: I see! So I would essentially create the musical track, then 5 (or however many notes I wanted to play with) MIDI files corresponding to the notes to be hit by different keys, right?

That's actually a better idea than mine in many ways because it allows for personal flexibility in terms of which notes in any given musical track that I want to be 'playable'. I can have music as complicated as I like, theoretically.

Almost. Basically the MIDI file is the time keeper, sync'd to the music. This is essential, because many times songs don't have a nice round number as the BPM, and a lot of times they vary tempo in parts. Therefore, the MIDI file acts as the 'tempo map'. Then you have another data file which has the beat numbers and their corrosponding notes.

What you're talking about is essentially a Guitar Hero style game, right?

Kinoko

Do you know, I don't know. I have never played Guitar Hero. I live in Japan, where we play cute little rhythm games on tiny little pink machines. Guitar Hero seems to be what everyone is playing overseas.

I think I'd prefer to aim for something more like Rhythm Tengoku though.

Radiant


CodeJunkie

Only ever heard of Guitar Hero in the UK, but I've just tried out Frets On Fire and it's fantastic.  There goes the rest of my spare time..

OneDollar

I made a rock version of the Monkey Island theme tune into a Frets on Fire song...

R4L

You want to make a game like Guitar Hero?

That would require being able to get MIDI tracks, like Lead and Bass, and find the BPM and such.

Guitar Hero uses a grid on the fretboard to make out the BPM. The closer each line is, the higher the BPM, meaning less Hammer Ons and Pull Offs, and more notes that have to be strummed.

Frets on Fire uses Audio/Video delay to sync up the notes and the music. As OneDollar said, Frets on Fire uses ogg files for song backing tracks.

Sorry, I'm very addicted to Guitar Hero and Frets on Fire, as I play them both at least 5 hours a day.  :)

Quote from: SimB on Wed 22/08/2007 12:05:05
Only ever heard of Guitar Hero in the UK, but I've just tried out Frets On Fire and it's fantastic.  There goes the rest of my spare time..

With extra mods and other features, you can have the best open-source Guitar Hero based game ever.


SMF spam blocked by CleanTalk