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

Re: Soundtrack rough draft



On Friday 05 March 2004 06:23 pm, Jens Granseuer wrote:
> Ok, b) would not exactly be mutually exclusive but it would raise the
> barrier for soundtrack contributions considerably. With regard to the
> implementation, how would the game determine when to switch from "boring"
> to "movingalong"? When the excitement level rises to 5, of course, but how
> does it figure out the beat on which to switch? It's not reasonable to
> assume that the tracks fit together at every given moment, right? Do we
> need a waveform analyzer?

Ok, I'm finally alert enough again to answer this.  :)

It's a very complicated setup, what I've got in mind.

First, the person composing the soundtrack determines a phrase length and a 
tempo and provides that in the fancy xml file I mentioned.  So they would 
decide, for example "8 bar phrases at 140bpm".  The game engine would use 
that to calculate where the soundtrack is at any point in time, if it's 
needed.  At the end of each phrase the game engine would calculate it's level 
of exciting (well, since this is likely to be in a different thread, you 
could calculate level of exciting with each turn and just store it in a 
variable somewhere that the music thread can just read to figure out what to 
play next).

Second, each theme, assuming more than one, gets assigned a label, such as 
<theme name="main">, <theme name="second">, <theme name="victory">.  There 
could be some predefined themes, such as victory, and when victory conditions 
are satisfied on the map the game plays the victory theme.

Now, you may have noticed those xml tags being the start of block tags.  So in 
each of these theme blocks you further define other elements of the theme.  
The idea is that the soundtrack should be split into 2-4 tracks and the game 
engine would mix them together during playback.  So more tags in the block 
would look like:

<accompaniment exciting=%value% src="somefile.mid" />
<percussion exciting=%value% src="somepercussiontrack.mid" />

There would be a <transition exciting=%value%> block as well, which would 
define each type of track for transitions.  Then the game engine, by 
specification or by direction from the file, would play the soundtrack as 
Theme then transition, and loop that pattern over and over until done.  If no 
transition exists for a theme, then it would just play the theme over and 
over.

Of course the <transition> block gets a closing tag </transition> and the 
<theme> block gets a closing tag </theme>.

In this fashion, the game engine would dynamically create the soundtrack, so 
it really would be different every time.  For best results, each track's 
level of exciting should overlap with the ones around it, so that a random 
element would be used to choose different tracks at different points.  It 
would be up to the musician making the soundtrack to ensure that every 
possible configuration of the tracks available will always sound good (this 
isn't as hard as it sounds, musicians reuse riffs and passages just like 
programmers reuse code, it just makes more sense that way ;)  ).

Also, each theme, assuming more than one in the file, should be tied to 
milestones on the map.  Much discussion will be required for this, though.  
:)  Say the musician decides that the milestones are based on unit numbers, 
and there are three themes, then when 1/3 of the units have been killed it 
would switch to the second theme.  When 2/3 of the units have been killed it 
switches to the third theme.  But, yeah, the idea is that it would switch 
themes based on milestones achieved on the map.

There are two decisions that need to be made, or rather, two base decisions 
that need to be made if this setup is desired.  1.  Maximum number of tracks 
and their names (I can think of at least 6 tracks that I'd like to have 
available, but mixing 6 tracks in realtime on my computer is close to its 
limit).  The main reason for this is because as a game we don't want to spend 
all of our precious CPU cycles playing the soundtrack.  2.  I forgot what the 
second one is.  Oh yeah, now i remember it.  The master level of all tracks 
mixed together must be determined.  I can grab some code from Audacity that 
we can plug in to do processing that ensures the soundtrack levels will 
always be low enough.  Thing is, there has to be enough room for sound 
effects to be played without clipping and still being heard loudly and 
nicely.

Now, even with this really fancy and really rockin' soundtrack setup, there 
should be a generic fallback to a complete file that just loops, like what 
I've been working on.  The reasons we need a fallback are several:

1.  To keep the barrier low for musical contributions while still allowing for 
really complex and kick-ass soundtracks.

2.  If the user doesn't have a lot of CPU cycles available, we want to 
fallback to something less CPU-intensive anyway.

3.  Maybe the user just likes the longer, less dynamic music.

My original proposal was less detailed than this mostly 'cause I was tired 
when I wrote it, sorry.  The main flaw in that proposal is that if something 
happens that the game doesn't move along to the different levels of exciting, 
then it would just loop the same thing over and over and over, like if the 
user ran off and made coffee or something.  Among the reasons for having the 
game mix the tracks itself is to make sure that in the event the user is off 
doing something else, the soundtrack still sounds somewhat varied, even 
though it's looping at a standstill.  (Also, a provision for recording the 
soundtrack played during playing might be pretty cool, because it would allow 
the user to play back the soundtrack he heard during a particular game)

Dave

-- 
Visit my website!
http://www.davefancella.com/?event=em

You will think of something funnier than this to add to the fortunes.