Author Topic: Music Scores  (Read 1588 times)

0 Members and 1 Guest are viewing this topic.

Offline PotzUK

  • 28
    • PyroPort
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?

 

Offline PotzUK

  • 28
    • PyroPort
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!
« Last Edit: September 04, 2006, 04:26:10 am by PotzUK »

 
I'd like to know more about this too....
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline PotzUK

  • 28
    • PyroPort
Looking in the eventmusic.cpp file, the relevant section would appear to be :

Code: [Select]
// 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:

 

Offline PotzUK

  • 28
    • PyroPort
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
« Last Edit: September 04, 2006, 08:04:42 am by PotzUK »

 
*heads spinning*
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
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..."
-C

 

Offline WMCoolmon

  • Purveyor of space crack
  • 213
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.
« Last Edit: September 04, 2006, 10:25:15 pm by WMCoolmon »
-C

 

Offline Darius

  • 211
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?
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"

 

Offline Darius

  • 211
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..
That's cool and ....disturbing at the same time o_o  - Vasudan Admiral

"Don't play games with me. You just killed someone I like, that is not a safe place to stand. I'm the Doctor. And you're in the biggest library in the universe. Look me up."

"Quick everyone out of the universe now!"