Hard Light Productions Forums
Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: Ransom on July 16, 2004, 11:45:22 am
-
Er... how exactly do you add new soundtracks to the music table? I've got the music playing in-game, but at the beginning of each track there's a bit of... weirdness, stopping and starting a couple of times, but the rest of the track plays fine. I think it's something to do with the num_measures and/or samples_per_measure, or I just did something wrong with the .wav's. Any help?
-
[wiki] blah [/wiki]
Check the wiki link in the above bit of auto text, I'm pretty sure it's in there.
-
Already checked the wiki - couldn't find anything on it. The Music Table section remains completely untouched...
-
*bump*
Anyone?
-
It's a bit of hit or miss with the numbers as far as I can tell (know that I haven't researched this table much). I usually use the length of the track in seconds as the last of the two mystery-numbers. Works reasonably well... Not perfect (arrivals are dreadful), but it isn't horrible.
-
Ok, here's my take on this...
Fact
When sound is digitized into something like a wave file, there is an x number of data pieces taken which hold the info about the sound at that very movent. This is called the frequency of a wave file, because the frequency number is the number of times each second that a data piece, called a sample is taken. For CD quality music, this is about 44100 hz (aka 44.1 khz). Freespace 2's sound files mostly use 22050 hz.
My guess, based on the code
Freespace 2 uses a sound system which fades in between different loaded music files when an event occurs. An enemy ship warps in, for example. To make this *sound* right, it needs to know when it can fade out the file rather than just fading it indiscriminately.
So, each song in Freespace 2 is divided up into measures. At the beginning or end of a measure, Freespace 2 will fade to a different song if it's needed.
This means that to set the two variables correctly, samples_per_measure must be set to the number of samples per section of music. num_measures is the total number of sections for the music file.
So say you had a simple drumbeat - abaab - that was 2 seconds long, recorded at 22050 hz, repeating over a 30 second music file. To find the number of samples per measure, you would use the equation (frequency * measure time) or in this case (22050 * 2). To find the number of measures, you would use the equation (music time / measure time) or (30 / 2)
-
That guess sounds a whole lot better than mine. I'll go with that. *Takes note*
-
*points to the wiki's 'edit' button *
-
Thanks WM, that should be most helpful .
-
Search is A-1 SUPAR... :doubt:
http://www.hard-light.net/forums/index.php/topic,14157.0.html
Pretty much what WMC said.