Hard Light Productions Forums
Modding, Mission Design, and Coding => The Modding Workshop => Topic started by: PotzUK on September 03, 2006, 10:04:48 am
-
OK, I've just spent the better part of a day trying to get this to work :)
I've been able to get my score to play in the game, but it does not change when an enemy warps in etc. I suspect I don't have the right numbers in the tbm file.
Could someone tell me what values I need to use for a 2 minute file that's got a beat every 4 seconds and encoded at 44,100Khz / 128KBps?
-
Going by http://www.hard-light.net/forums/index.php/topic,14157.0.html, can someone tell me if this is correct:
num_measures = number of 'beats' in the music file (30)
samples_per_measure =
bitrate * length in seconds (120) = Kb in the music (15360)
* 1024 = bytes in music (15728640)
/ num_measures = bytes per measure (524288)
/ 2 = samples per measure (262144)
So my music file would need to be:
$Name Music.ogg 30 262144
Problem is that formula does not give the same result as what is in the table file!
-
I'd like to know more about this too....
-
Looking in the eventmusic.cpp file, the relevant section would appear to be :
// convert from samples per measure to bytes per measure
Pattern_bytes_per_measure[Num_soundtracks][num_patterns] *= 2;
strcpy(Soundtracks[Num_soundtracks].pattern_fnames[num_patterns], fname);
num_patterns++;
So the number in the music table / 2
The question is, how do you get to the number in the music file :doubt:
-
I think I've cracked it.
The assumptions so far in all the posts I've seen are that the numbers represent the length of the *entire* track. I've just been toying with the numbers from a "Point at which this track can be interupted" angle, and it seems to be working. Keeping the measure count high on the ambients and low on the battle scenes (so that they clear quickly once the enemy are gone) with corresponding values would appear to work. It is not exact, but it's pretty darn close
I'm still fiddling, but :
(Length of track in seconds x Time in seconds between beats) x ((Encoded Bitrate x 1024) x (Length in Seconds / Time in seconds between Beats)) / 2
-
*heads spinning*
-
Samples per measure x Number of measures = Total samples in the file.
You can find out the number of samples in a file by loading up the file bar in foobar2000, right-clicking on the song and clicking "Properties..."
-
EDIT: Nvm, just try samples per measure, and number of measures for the values. The code should work with that, regardless of the file format.
-
I've only been able to use sound editing software (ie Cool Edit) to find out the number of samples in a measure. Not sure what freeware software lets you do that. You can calculate the number, as you've done, but since music files generally don't contain exact numbers, it's not going to be 100% accurate.
-
So it's basically sample rate * seconds?
-
sample rate * seconds gives the total number of samples in the song. You then have to count the number of measures in the song and divide it by that number.
Though if you just want the entire song to play, include the whole song as one measure and put in the number of total samples.
-
Ah ok.... I think i understand now..