Difference between revisions of "Music.tbl"

From FreeSpace Wiki
Jump to: navigation, search
m (Revision fix)
(Related Links)
 
(27 intermediate revisions by 4 users not shown)
Line 1: Line 1:
 
{{TableVersion|5307}}
 
{{TableVersion|5307}}
 +
{{Tables}}
 +
<code>'''music.tbl'''</code> is a [[Tables|table file]] used by the ''FreeSpace'' game engine to define the [[music]] played during the game.
  
 +
In FSO, this table can be further extended with any [[modular table]] with a filename ending with <code>-mus</code> (e.g. <code>AF-mus.tbm</code>, <code>bp-mus.tbm</code>, <code>v_music-mus.tbm</code>).
  
==General Format==
+
<code>music.tbl</code> consists of two sections defined as follows:
*Music.tbl consist of several sections. Some are used to define in-game soundtracks and others various other musics.
+
# The soundtracks, which are music files intended to be played ''during a mission''.
*Sountrack entries
+
# The menu music, which are music files intended to be played for other purposes.
**'''#SoundTrack Start'''
 
**Soundtracks names and definitions
 
**'''#SoundTrack End'''
 
*Other musics
 
**'''#Menu Music Start'''
 
**Music names and definitions
 
**'''#Menu Music End'''
 
  
 +
Comments (which are not parsed by the game engine) can be added at the start of a line, or after any line containing formatting, by beginning with a semicolon (<code>;</code>).
  
==Soundtrack Musics==
+
<code>-mus.tbm</code> modular tables use the exact same formatting as <code>music.tbl</code>.
  
 +
== Soundtrack ==
 +
'''Each''' individual soundtrack '''must''' start with <code>#SoundTrack Start</code>, end with <code>#SoundTrack End</code>, and have the following lines in between:
 +
# <code>$Soundtrack Name:</code>
 +
# One of the following:
 +
::* 12 lines, all starting with <code>$Name:</code>
 +
{{Table3610|
 +
::* 12-14 lines, all starting with <code>$Name:</code>
 +
::* 14 lines, all starting with <code>$String:</code>
 +
}}
 +
 +
=== $Soundtrack Name: ===
 +
<code>$Soundtrack Name:</code> is immediately followed by the name of the soundtrack. This primarily affects how the soundtrack is referred to in [[FRED]] as well as its variants. The name of the soundtrack can be prefixed with a number to keep listings organised, such as the underlined code below:
 +
  $Soundtrack Name: <u>1: Genesis</u>
 +
 +
==== Flags ====
 +
{{Table3610|
 +
The following flags can be added in extra lines after <code>$Soundtrack Name:</code> in [[modular table]]s.
 +
 +
===== +nocreate =====
 +
This flag should be added if the soundtrack is intended to completely overwrite an existing soundtrack with the exact same name.
 +
 +
===== +Cycle: FS1 =====
 +
This cycles the Normal and Battle tracks the FS1 way, instead of the FS2 way.
 +
 +
===== +Allied Arrival Overlay: NO =====
 +
This allows the Allied Arrival track to play on its own, as it did in FS1.
 +
}}
  
===$Soundtrack Name:===
+
=== $Name: ===
*Soundtrack Name is immediately followed by the soundtrack order number and the name of the soundtrack.
+
For this section, refer to the code for <code>FS2_Amb_A01.wav</code>, as follows:
*Syntax: '''Integer''': '''String'''
+
  $Name: FS2_Amb_A01.wav 25.0 105840 ; * Ambience
**Example: 1: Genesis
 
  
 +
The code above can be explained using the following table:
 +
{| border=1 cellpadding=4 style="border-collapse: collapse; border: solid 1px #995050;"
 +
|- align="center" colspan=3 style="background:#351515; border: solid 1px #995050;"
 +
! $Name: (''fixed'') !! Filename !! Number of Measures (''m'') !! Samples per Measure (''s'') !! Comments (optional)
 +
|- align="left"
 +
| <code>$Name:</code> || <code>FS2_Amb_A01.wav</code> || <code>25.0</code> || <code>105840</code> || <code>; * Ambience</code>
 +
|}
  
===+nocreate===
+
The subsections describe each of the above columns in more detail.
 +
 
 +
==== $Name: ====
 +
The individual music segments in a soundtrack is defined using '''at least 12 lines''', all beginning with <code>$Name:</code>. The ''FreeSpace'' engine parses and plays the audio file referenced in each line in the following order:
 +
 
 +
{| border=1 cellpadding=4 style="border-collapse: collapse; border: solid 1px #995050;"
 +
|- align="center" colspan=3 style="background:#351515; border: solid 1px #995050;"
 +
! Order !! Situation !! Details
 +
|- align="left"
 +
| 1 || Ambience || Normal track.<br/>Plays when nothing is happening or units are out of combat range.<br/>Loops on itself until another situation is called, but if Ambience 2 is defined in FSO builds, will usually segue to it.
 +
|-
 +
| 2 || Allied Arrival during Ambience || Plays when a friendly unit arrives while Ambience is playing.<br/>By default, plays on top of other audio tracks without seguing; in FSO builds, if <code>+Allied Arrival Overlay: NO</code> is added below <code>$Soundtrack Name:</code>, the currently playing track will segue into this instead.
 +
|-
 +
| 3 || Enemy Arrival during Ambience || Plays when a hostile unit arrives while Ambience is playing.
 +
|-
 +
| 4 || Battle 1 || Battle track 1.<br/>Plays when units are in combat range.<br/>Usually segues into Battle 2.
 +
|-
 +
| 5 || Battle 2 || Battle track 2.<br/>Plays when units are in combat range.<br/>Usually segues into Battle 3.
 +
|-
 +
| 6 || Battle 3 || Battle track 3.<br/>Plays when units are in combat range.<br/>Usually segues into Battle 1.
 +
|-
 +
| 7 || Allied Arrival during Battle || Plays when a friendly unit arrives while any Battle track is playing.<br/>By default, plays on top of other audio tracks without seguing; in FSO builds, if <code>+Allied Arrival Overlay: NO</code> is added below <code>$Soundtrack Name:</code>, the currently playing track will segue into this instead.
 +
|-
 +
| 8 || Enemy Arrival during Battle || Plays when a hostile unit arrives while any Battle track is playing.
 +
|-
 +
| 9 || Victory 1 || Plays when a goal is completed.<br/>Segues into Victory 2, Ambience, or a Battle track depending on the remaining goals and hostile units remaining, and whether Victory 2 has already been called.
 +
|-
 +
| 10 || Victory 2 || Victory 1 segues into this track when all goals are completed ''and'' there are absolutely no hostile units present.<br/>Is only called once; if additional goals are validated in-mission and/or new hostile units arrive after this track has already been played, Victory 1 will segue into Ambience or a Battle track.
 +
|-
 +
| 11 || Goal Failed || Plays when the goals of a mission are failed.<br/>Does not appear to be called in-game.
 +
|-
 +
| 12 || Player Dies || Plays when the player is killed and goes to the death screen.
 +
|}
 
{{Table3610|
 
{{Table3610|
*Used with [[Modular Tables|modular tables]] to set the parser to use the modular table only for modifying an existing entry instead of creating new (possibly incomplete) one.}}
+
* The following lines can be added.}}
 +
{| border=1 cellpadding=4 style="border-collapse: collapse; border: solid 1px #995050;"
 +
|- align="center" colspan=3 style="background:#351515; border: solid 1px #995050;"
 +
! Order !! Situation !! Details
 +
|- align="left"
 +
| 13 || Ambience 2 || Normal track.<br/>Plays when nothing is happening or units are out of combat range.<br/>If Ambience 3 is defined, usually segues into it, otherwise segues into Ambience.
 +
|-
 +
| 14 || Ambience 3 || Normal track.<br/>Plays when nothing is happening or units are out of combat range.<br/>Usually segues into Ambience.
 +
|}
  
 +
The order and situation of the lines '''cannot be changed''' and are '''required''' in order for the engine to parse the audio files in the correct situations. If there is no audio file available for any of the situations (such as Battle 3, for instance), a placeholder line denoting an empty track should still be included, such as the bolded code below:
 +
  ...
 +
  $Name: FS2_Btl_A02.wav 27.8 81415 ; * Battle 2
 +
  '''$Name: silence.wav 0.0 0 ; * Battle 3'''
 +
  $Name: FS2_AArv_A01.wav 1.8 105840 ; * Allied Arrival during Battle
 +
  ...
  
===Soundtrack Flags===
+
====Filename====
{{Table3610|
+
The filename of the audio file must also include its file extension. FS1 and FS2 only support the playback of Waveform Audio (<code>.wav</code>) files.
If the music should be played according to the FS1 style, the following flags should be added after $Soundtrack Name:
+
 
 +
{{Table36|
 +
FSO supports the playback of Waveform Audio and OGG Vorbis (<code>.ogg</code>) files.
 +
 
 +
If there are two versions of the same file&mdash;one in Waveform Audio and one in OGG Vorbis format&mdash;FSO will typically attempt to play the OGG Vorbis version, even if the referenced file in <code>music.tbl</code> has a <code>.wav</code> file extension. In addition, if <code>$Name:</code> references a file that has the <code>.ogg</code> file extension, but only a Waveform Audio version of the file is available, FSO will still play the latter as if it is referenced directly in <code>music.tbl</code>.
 +
}}
 +
 
 +
====Number of Measures and Samples per Measure====
 +
The ''FreeSpace'' engine's dynamic music capabilities are defined using the number of measures (''m'') and samples per measure (''s''). Using ''m'', the engine parses the audio track by dividing it into individual parts, called ''measures''; if an event happens that would change the music being played, the game will play the current audio track until the end of the current measure, whereupon it segues into the correct audio track via a built-in crossfade. The length of the measures is defined using ''s'', which is the number of ''samples'' in a measure.
 +
 
 +
''m'' is user-defined and can be set to a decimal point for greater fine-tuning.
 +
 
 +
''s'' is calculated using the following formula:
 +
  ''s'' = 2 × sample rate (hertz) × total audio length (seconds; up to 3 decimal places) ÷ ''m''
  
*'''+Cycle: FS1'''
+
Depending on the ''m'' and ''s'' values declared, the game may only play a portion of the actual audio file or, if the values result in it attempting to play the audio file beyond its actual length, playing nothing for a period of time after it finishes playing the actual audio file.
**This cycles the NRML and BTTL tracks the FS1 way, instead of the FS2 way.
 
  
*'''+Allied Arrival Overlay: NO'''
+
In the case of <code>FS2_Amb_A01.wav</code>, it is defined in <code>music.tbl</code> as an audio track that has 25 ''m'' and 105,840 ''s'', so even though the file has an ''actual'' audio length of 62.556 seconds, the engine only ever parses the first 60 seconds of the audio file as its ''total'' audio length (hence omitting the last 2.556 seconds), split into 25 measures. This is because a reversal of the above calculation for ''s'' results in:
**This allows the Allied Arrival track to play on its own, as it did in FS1.}}
+
  105,840 (''s'') × 25 (''m'') ÷ 22,050 (hertz) ÷ 2 = 60.000 seconds
  
 +
'''The length of the measures in the audio track ''cannot'' be individually adjusted by any means'''&mdash;''s'' applies to '''all''' the measures in the audio file with '''no exceptions'''.
  
===Music Tracks===
+
===== Alternate Calculation Method =====
*All music track lines beging with '''$Name:''' followed by the '''filename''' of music track, with file extension. After the tracks filename the '''number of measures''' (NM) in the track is defined followed by the '''number of samples per measure''' (SPM).
+
If defining ''m'' and ''s'' is too time-consuming, the following formulae can be used to still make use of the ''FreeSpace'' engine's dynamic music capabilities, and would result in a maximum of 2 seconds' silence (since each measure would be 2 seconds long):
*Syntax: '''String''' '''Float''' '''Integer'''
+
  ''m'' = audio file length (seconds; up to 3 decimal places) ÷ 2
**Example: $Name: FS2_Amb_A01.wav 25.0 105840
+
  ''s'' = 4 × sample rate (hertz)
*The SPM value is computed using the formula '''SPM = 2 * SF * L / NM''', where SF is the sampling frequency in hz and L is length of the music piece in seconds (exact seconds up to about 3 decimal places). The NM value is important. The game uses SPM to determine how long a measure is, and it will stop playing the track after the specified number of measures. Whenever the game situation changes and one track must be interrupted by another, the game will interrupt the current track at the end of the currently playing measure.
 
So if you enter wrong numbers here, say using a different calculation, the track might still be played to the end - but when it should be interrupted it might not be for quite a while because you specified the length of one measure wrong.
 
E.g.: If you set NM to 1 and SPM to 2*SF*L the track will be played without problems - BUT, the interrupt will never happen. You have informed the game that the entire track basically consists of one large measure, so it will keep playing the track until that measure is over before switching to any other track - and this can take a while.
 
So make sure you use correct values here. If the exact measure count is not known you best use the following method:
 
  
Set NM to half the length of the track in seconds, say 61.202s = 30.601, and SPM to 4 * SF, say 4 * 22050Hz = 88200.
+
As an example, if we use the above alternate formulae with the ''actual'' audio length of <code>FS2_Amb_A01.wav</code>, we get the following:
By doing this you state that one measure is 2 seconds long. This leads to a max delay of 2 seconds.
+
  ''m'' = 62.556 seconds ÷ 2 = 31.278
 +
  ''s'' = 4 × 22,050 (hertz) = 88,200
  
 +
''m'' would be rounded to the nearest decimal point. Hence, we would input the following as the alternate length for <code>FS2_Amb_A01.wav</code> in <code>music.tbl</code>:
 +
  $Name: FS2_Amb_A01.wav 31.3 88200 ; * Ambience
  
Another important result of this is that a track must not contain any quiet at the beginning or end of the file, since that distorts the location of the measures in the file. The game considers the entire file to be the track, it does not check where the actual music starts. So make sure you cut the track so it is a snug fit, begins with music and ends with music.
+
{{Table3610|
This is however less important if you do not know the number of measures anyway and use the 2 second work-around described above, since an exact fade after a measure cannot be done that way anyway.
+
=== $String: ===
 +
FSO includes an alternate way to parse individual tracks.
  
 +
Instead of using <code>$Name:</code>, <code>$String:</code> can be used, with the <code>''String''</code> syntax being the situation reference, such as:
 +
  $Normal 1: FS2_Amb_A01.ogg 25.0 105840 ; * Ambience
  
====Order of the music tracks:====
+
Note that this system follows a different situation order from parsing <code>$Name:</code>, and it also cannot be changed under any circumstances. The situation order for parsing <code>$String:</code>, as well as the corresponding <code>$String:</code> to use for each situation, is as follows:
{|-
+
}}
| style="width:350px"|'''Ambience'''
+
{| border=1 cellpadding=4 style="border-collapse: collapse; border: solid 1px #995050;"
| style="width:100px"|''"Normal 1"''
+
|- align="center" colspan=3 style="background:#351515; border: solid 1px #995050;"
 +
! Order !! Situation !! <code>$String:</code> to Use !! Details
 +
|- align="left"
 +
| 1 || Ambience || <code>$Normal 1:</code> || Normal track&mdash;plays when nothing is happening or units are out of combat range; usually segues into Ambience 2
 
|-
 
|-
|'''Allied Arrival during Normal'''
+
| 2 || Ambience 2 || <code>$Normal 2:</code> || Normal track&mdash;plays when nothing is happening or units are out of combat range; usually segues into Ambience 3
|''"Ally arrival 1"''
 
 
|-
 
|-
|'''Enemy Arrival during Normal'''
+
| 3 || Ambience 3 || <code>$Normal 3:</code> || Normal track&mdash;plays when nothing is happening or units are out of combat range; usually segues into Ambience
|''"Enemy arrival 1"''
 
 
|-
 
|-
|'''Battle 1'''
+
| 4 || Allied Arrival during Ambience || <code>$Ally arrival 1:</code> || Plays when a friendly unit arrives while any Ambience track is playing
|''"Battle 1"''
 
 
|-
 
|-
|'''Battle 2'''
+
| 5 || Allied Arrival during Battle || <code>$Ally arrival 2:</code> || Plays when a friendly unit arrives while any Battle track is playing
|''"Battle 2"''
 
 
|-
 
|-
|'''Battle 3'''
+
| 6 || Enemy Arrival during Ambience || <code>$Enemy arrival 1:</code> || Plays when a friendly unit arrives while any Ambience track is playing
|''"Battle 3"''
 
 
|-
 
|-
|'''Allied Arrival during Battle'''
+
| 7 || Enemy Arrival during Battle || <code>$Enemy arrival 2:</code> || Plays when a friendly unit arrives while any Battle track is playing
|''"Ally arrival 2"''
 
 
|-
 
|-
|'''Enemy Arrival during Battle'''
+
| 8 || Battle 1 || <code>$Battle 1:</code> || Battle track 1—plays when units are in combat range; usually segues into Battle 2
|''"Enemy arrival 2"''
 
 
|-
 
|-
|'''Victory 1 ( goal completed )'''
+
| 9 || Battle 2 || <code>$Battle 2:</code> || Battle track 2—plays when units are in combat range; usually segues into Battle 3
|''"Victory 1"''
 
 
|-
 
|-
|'''Victory 2  ( all enemies dead, goals completed )'''
+
| 10 || Battle 3 || <code>$Battle 3:</code> || Battle track 3—plays when units are in combat range; usually segues into Battle 1
|''"Victory 2"''
 
 
|-
 
|-
|'''Goal Failed'''
+
| 11 || Goal Failed || <code>$Failure 1:</code> || Plays when the primary goals of a mission are failed
|''"Failure 1"''
 
 
|-
 
|-
|'''Player dies'''
+
| 12 || Victory 1 || <code>$Victory 1:</code> || Plays when a goal is completed
|''"Dead 1"''
 
|-
 
|}
 
{{Table3610|
 
*Following entries have been added by SCP}}
 
{|-
 
| style="width:350px"|'''Ambience 2'''
 
| style="width:100px"|''"Normal 2"''
 
 
|-
 
|-
|'''Ambience 3'''
+
| 13 || Victory 2 || <code>$Victory 2:</code> || Plays when all goals are completed and there are absolutely no hostile units present; is only called once
|''"Normal 3"''
 
 
|-
 
|-
 +
| 14 || Player Dies || <code>$Dead 1:</code> || Plays when the player is killed and goes to the death screen
 
|}
 
|}
  
===Specific Music Tracks===
+
== Menu Music ==
{{Table3610|
+
All menu music tracks are defined in the lines within '''one''' instance of <code>#Menu Music Start</code> and <code>#Menu Music End</code>. Up to 50 menu music tracks can be defined across all <code>.tbl</code> and <code>-mus.tbm</code> files being referenced.
*If table doesn't have retail like '''$Name:''' at the beginning of the line then a new method for parsing tables can be used
 
*Instead $'''String''': can be used where the string is shortened name of the music track.
 
*After the initial entry on the line, rest of the music entry is added after it.
 
*Name of the music track, name of the associated music file with file extension, number of measure, number of samples per measure
 
*Syntax: $'''String''': '''String''' '''Float''' '''Integer'''
 
*Example: $Battle 1:    FS2_Btl_G01.ogg            25.8  176400}}
 
 
 
 
 
==Menu Musics==
 
*Menu musics are defined with '''filename''' after the name of the tracks '''name'''.
 
*Syntax for all of the '''Menu Music''' entries are similar
 
*Syntax: $Filename: ''Filename.xxx''
 
**Example: $Filename: FS2_Brief_01.wav
 
  
 +
Each menu music track '''must''' have the following 2 lines in order:
 +
# <code>$Name:</code>
 +
# <code>$Filename:</code>
  
===$Name:===
+
For the subsections, refer to the code used to call <code>FS2_Brief_01.wav</code> in-game, which is:
*Defines the name of the menu music
+
  $Name: Brief1
*Syntax: '''String'''
+
  $Filename: FS2_Brief_01.wav ; briefing music 1
**Allowed musics:
 
***''Brief1''
 
***''Brief2''
 
***''Brief3''
 
***''Brief4''
 
***''Brief5''
 
***''Brief6''
 
***''Brief7''
 
***''Success''
 
***''Average''
 
***''Failure''
 
***''Aquitaine''
 
***''Psampik''
 
***''Cinema''
 
  
 +
=== $Name: ===
 +
The first line always starts with <code>$Name:</code>, followed by the name of the audio track, which is mainly referred to in FRED and its variants.
 +
  $Name: Brief1
  
===+nocreate===
 
 
{{Table3610|
 
{{Table3610|
*Used with [[Modular Tables|modular tables]] to set the parser to use the modular table only for modifying an existing entry instead of creating new (possibly incomplete) one.}}
+
* The following flag can be added after <code>$Name:</code> in modular tables:
 +
=== +nocreate ===
 +
This flag should be added if the track is intended to completely overwrite an existing track with the exact same name.
 +
}}
  
 +
=== $Filename: ===
 +
The last line starts with <code>$Filename:</code>, followed by the file name of the audio track.
 +
  $Filename: FS2_Brief_01.wav ; briefing music 1
  
===$Filename:===
+
== Format Sample ==
*Defines the actual file
+
The following is a heavily truncated version of <code>music.tbl</code> located within <code>Root_FS2.vp</code>.
*Syntax: '''String''', filename with file extension
+
  ;
 
+
  ; music.tbl
 
+
  ;
==Sample==
+
  ; Specifies which .wav files to use for the different sections of event-driven sound-tracks
*Uses normal soundtrack and menu musics from FS2
+
  ;
 
+
  ; format:  $Name:  filename.wav  num_measures (samples_per_measure)
   #SoundTrack Start
+
  ;
 +
   #SoundTrack Start         ; SoundTrack 0
 
   $Soundtrack Name: 1: Genesis
 
   $Soundtrack Name: 1: Genesis
   $Name:   FS2_Amb_A01.wav     25.0     105840
+
   $Name: FS2_Amb_A01.wav 25.0 105840 ; * Ambience
   $Name:   FS2_AArv_A01.wav     1.8     105840
+
   $Name: FS2_AArv_A01.wav 1.8 105840 ; * Allied Arrival during Normal
   $Name:   FS2_Arv_B01.wav     3.8     81415
+
   $Name: FS2_Arv_B01.wav 3.8 81415 ; * Enemy Arrival during Normal
   $Name:   FS2_Btl_A01.wav     25.8     66150
+
   $Name: FS2_Btl_A01.wav 25.8 66150 ; * Battle 1
   $Name:   FS2_Btl_A02.wav     27.8     81415
+
   $Name: FS2_Btl_A02.wav 27.8 81415 ; * Battle 2
   $Name:   FS2_Btl_A03.wav     39.8     81415
+
   $Name: FS2_Btl_A03.wav 39.8 81415 ; * Battle 3
   $Name:   FS2_AArv_A01.wav     1.8     105840
+
   $Name: FS2_AArv_A01.wav 1.8 105840 ; * Allied Arrival during Battle
   $Name:   FS2_Arv_B02.wav     3.8     81415
+
   $Name: FS2_Arv_B02.wav 3.8 81415 ; * Enemy Arrival during Battle
   $Name:   FS2_Vict_A01.wav     2.8     52920
+
   $Name: FS2_Vict_A01.wav 2.8 52920 ; * Victory 1 ( goal completed )
   $Name:   FS2_Vict_A02.wav     30.8     52920
+
   $Name: FS2_Vict_A02.wav 30.8 52920 ; * Victory 2 ( all enemies dead, goals completed )
   $Name:   FS2_Dth_A01.wav     23.8     132300
+
   $Name: FS2_Dth_A01.wav 23.8 132300 ; * Goal Failed
   $Name:   FS2_Dth_A01.wav     23.8     132300
+
   $Name: FS2_Dth_A01.wav 23.8 132300 ; * Player dies
   #SoundTrack End
+
   #SoundTrack End ; End Soundtrack 0
 +
  ;
 +
  #SoundTrack Start     ; SoundTrack 1
 +
  $Soundtrack Name: 2: Exodus
 +
  $Name: FS2_Amb_B01.wav 17.0 132300 ; * Ambience
 +
  $Name: FS2_AArv_A01.wav 1.8 105840 ; * Allied Arrival during Normal
 +
  $Name: FS2_Arv_B01.wav 4.8 81415 ; * Enemy Arrival during Normal
 +
  $Name: FS2_Btl_B01.wav 39.8 132300 ; * Battle 1
 +
  $Name: FS2_Btl_B02.wav 23.8 75600 ; * Battle 2
 +
  $Name: FS2_Btl_B03.wav 31.8 75600 ; * Battle 3
 +
  $Name: FS2_AArv_A01.wav 1.8 105840 ; * Allied Arrival during Battle
 +
  $Name: FS2_Arv_B04.wav 4.8 75600 ; * Enemy Arrival during Battle
 +
  $Name: FS2_Vict_A01.wav 2.8 52920 ; * Victory 1 ( goal completed )
 +
  $Name: FS2_Vict_B02.wav 40.8 88200 ; * Victory 2 ( all enemies dead, goals completed )
 +
  $Name: FS2_Dth_A01.wav 23.8 132300 ; * Goal Failed
 +
  $Name: FS2_Dth_A01.wav 23.8 132300 ; * Player dies
 +
  #SoundTrack End ; End Soundtrack 1
 +
  ;
 
   #Menu Music Start
 
   #Menu Music Start
   $Name:     Brief1
+
   $Name: Brief1
   $Filename: FS2_Brief_01.wav
+
   $Filename: FS2_Brief_01.wav ; briefing music 1
   $Name:     Brief2
+
 
   $Filename: FS2_Brief_02.wav
+
   $Name: Brief2
   $Name:     Brief3
+
   $Filename: FS2_Brief_02.wav ; briefing music 2
   $Filename: FS2_Brief_03.wav
+
 
  $Name:      Brief4
+
   $Name: Brief3
  $Filename:  FS2_Brief_04.wav
+
   $Filename: FS2_Brief_03.wav ; briefing music 3
  $Name:      Brief5
 
  $Filename:  FS2_Brief_05.wav
 
  $Name:      Brief6
 
  $Filename:  FS2_Btl_A01.wav
 
  $Name:      Brief7
 
  $Filename:  FS2_Cinema2.wav
 
  $Name:      Success
 
  $Filename:  FS2_DB_01.wav
 
  $Name:      Average
 
  $Filename:  FS2_DB_02.wav
 
  $Name:      Failure
 
  $Filename:  FS2_DB_03.wav
 
  $Name:      Aquitaine
 
  $Filename:  Aquitaine.wav
 
  $Name:      Psampik
 
  $Filename:  Psampik.wav
 
  $Name:      Cinema
 
  $Filename:  FS2_Cinema2.wav
 
 
   #Menu Music End
 
   #Menu Music End
 +
 +
== Related Links ==
 +
* [https://www.hard-light.net/forums/index.php?topic=89836.msg1787087 Music tables 301 | Hard Light Productions Forums]
 +
* [https://web.archive.org/web/20010314181125/http://ml.warpcore.org/fdl/199911/msg00204.html Archived post about music.tbl from the FreeSpace Developer List]
  
 
[[Category:Tables]]
 
[[Category:Tables]]

Latest revision as of 05:06, 26 November 2022

Revision information.....

FSO Revision: 5307
Note: Please update the version when the page is updated. If your edit had nothing to do with new code entries then please do not edit the version


List of Tables and related code files
* Notes Modular Tables
** Notes tables which only use modular tables
Ai.tbl* /ai/aicode.cpp
Ai_profiles.tbl* /ai/ai_profiles.cpp
Animation.tbl** /model/modelanimation.cpp
Armor.tbl* /ship/ship.cpp
Asteroid.tbl* /asteroid/asteroid.cpp
Autopilot.tbl* /autopilot/autopilot.cpp
Cheats.tbl* /cheats_table/cheats_table.cpp
Colors.tbl* /globalincs/alphacolors.cpp
Curves.tbl* /math/curves.cpp
Controlconfigdefaults.tbl /controlconfig/controlsconfigcommon.cpp
Credits.tbl* /menuui/credits.cpp
Cutscenes.tbl* /cutscene/cutscenes.cpp
Decals.tbl** /decals/decals.cpp
Fireball.tbl* /fireball/fireballs.cpp
Fonts.tbl* /graphics/font.cpp
Game_settings.tbl* /mod_table/mod_table.cpp
Glowpoints.tbl* /model/modelread.cpp
Help.tbl* /gamehelp/contexthelp.cpp
Hud_gauges.tbl* /hud/hudparse.cpp
Icons.tbl* /mission/missionbriefcommon.cpp
Iff_defs.tbl* /iff_defs/iff_defs.cpp
Lighting_Profiles.tbl* /lighting/lighting_profiles.cpp
Lightning.tbl* /nebula/neblightning.cpp
Mainhall.tbl* /menuui/mainhallmenu.cpp
Medals.tbl* /stats/medals.cpp
Messages.tbl* /mission/missionmessage.cpp
Mflash.tbl* /weapon/muzzleflash.cpp
Music.tbl* /gamesnd/eventmusic.cpp
Nebula.tbl* /nebula/neb.cpp
Objecttypes.tbl* /ship/ship.cpp
Options.tbl* Not In Codebase
Particle effects(-part.tbm)** /particle/effects...
Post_processing.tbl /graphics/gropenglpostprocessing.cpp
Rank.tbl* /stats/scoring.cpp
Scpui.tbl* Not In Codebase
Scripting.tbl* /parse/scripting.cpp
Ships.tbl* /ship/ship.cpp
Sexps.tbl** /parse/sexp/sexp_lookup.cpp
Sounds.tbl* /gamesnd/gamesnd.cpp
Species_defs.tbl* /species_defs/species_defs.cpp
Species.tbl* /menuui/techmenu.cpp
Ssm.tbl* /hud/hudartillery.cpp
Stars.tbl* /starfield/starfield.cpp
Strings.tbl* /localization/localize.cpp
Tips.tbl* /menuui/playermenu.cpp
Traitor.tbl* /stats/scoring.cpp
Tstrings.tbl* /localization/localize.cpp
Virtual_pofs.tbl* /model/modelreplace.cpp
Weapon_expl.tbl* /weapon/weapons.cpp
Weapons.tbl* /weapon/weapons.cpp

music.tbl is a table file used by the FreeSpace game engine to define the music played during the game.

In FSO, this table can be further extended with any modular table with a filename ending with -mus (e.g. AF-mus.tbm, bp-mus.tbm, v_music-mus.tbm).

music.tbl consists of two sections defined as follows:

  1. The soundtracks, which are music files intended to be played during a mission.
  2. The menu music, which are music files intended to be played for other purposes.

Comments (which are not parsed by the game engine) can be added at the start of a line, or after any line containing formatting, by beginning with a semicolon (;).

-mus.tbm modular tables use the exact same formatting as music.tbl.

Soundtrack

Each individual soundtrack must start with #SoundTrack Start, end with #SoundTrack End, and have the following lines in between:

  1. $Soundtrack Name:
  2. One of the following:
  • 12 lines, all starting with $Name:
FS2 Open 3.6.10:
  • 12-14 lines, all starting with $Name:
  • 14 lines, all starting with $String:

$Soundtrack Name:

$Soundtrack Name: is immediately followed by the name of the soundtrack. This primarily affects how the soundtrack is referred to in FRED as well as its variants. The name of the soundtrack can be prefixed with a number to keep listings organised, such as the underlined code below:

  $Soundtrack Name: 1: Genesis

Flags

FS2 Open 3.6.10:

The following flags can be added in extra lines after $Soundtrack Name: in modular tables.

+nocreate

This flag should be added if the soundtrack is intended to completely overwrite an existing soundtrack with the exact same name.

+Cycle: FS1

This cycles the Normal and Battle tracks the FS1 way, instead of the FS2 way.

+Allied Arrival Overlay: NO

This allows the Allied Arrival track to play on its own, as it did in FS1.

$Name:

For this section, refer to the code for FS2_Amb_A01.wav, as follows:

  $Name:	FS2_Amb_A01.wav				25.0	105840	; * Ambience 

The code above can be explained using the following table:

$Name: (fixed) Filename Number of Measures (m) Samples per Measure (s) Comments (optional)
$Name: FS2_Amb_A01.wav 25.0 105840 ; * Ambience

The subsections describe each of the above columns in more detail.

$Name:

The individual music segments in a soundtrack is defined using at least 12 lines, all beginning with $Name:. The FreeSpace engine parses and plays the audio file referenced in each line in the following order:

Order Situation Details
1 Ambience Normal track.
Plays when nothing is happening or units are out of combat range.
Loops on itself until another situation is called, but if Ambience 2 is defined in FSO builds, will usually segue to it.
2 Allied Arrival during Ambience Plays when a friendly unit arrives while Ambience is playing.
By default, plays on top of other audio tracks without seguing; in FSO builds, if +Allied Arrival Overlay: NO is added below $Soundtrack Name:, the currently playing track will segue into this instead.
3 Enemy Arrival during Ambience Plays when a hostile unit arrives while Ambience is playing.
4 Battle 1 Battle track 1.
Plays when units are in combat range.
Usually segues into Battle 2.
5 Battle 2 Battle track 2.
Plays when units are in combat range.
Usually segues into Battle 3.
6 Battle 3 Battle track 3.
Plays when units are in combat range.
Usually segues into Battle 1.
7 Allied Arrival during Battle Plays when a friendly unit arrives while any Battle track is playing.
By default, plays on top of other audio tracks without seguing; in FSO builds, if +Allied Arrival Overlay: NO is added below $Soundtrack Name:, the currently playing track will segue into this instead.
8 Enemy Arrival during Battle Plays when a hostile unit arrives while any Battle track is playing.
9 Victory 1 Plays when a goal is completed.
Segues into Victory 2, Ambience, or a Battle track depending on the remaining goals and hostile units remaining, and whether Victory 2 has already been called.
10 Victory 2 Victory 1 segues into this track when all goals are completed and there are absolutely no hostile units present.
Is only called once; if additional goals are validated in-mission and/or new hostile units arrive after this track has already been played, Victory 1 will segue into Ambience or a Battle track.
11 Goal Failed Plays when the goals of a mission are failed.
Does not appear to be called in-game.
12 Player Dies Plays when the player is killed and goes to the death screen.
FS2 Open 3.6.10:
  • The following lines can be added.
Order Situation Details
13 Ambience 2 Normal track.
Plays when nothing is happening or units are out of combat range.
If Ambience 3 is defined, usually segues into it, otherwise segues into Ambience.
14 Ambience 3 Normal track.
Plays when nothing is happening or units are out of combat range.
Usually segues into Ambience.

The order and situation of the lines cannot be changed and are required in order for the engine to parse the audio files in the correct situations. If there is no audio file available for any of the situations (such as Battle 3, for instance), a placeholder line denoting an empty track should still be included, such as the bolded code below:

  ...
  $Name:	FS2_Btl_A02.wav				27.8	81415	; * Battle 2
  $Name:	silence.wav				0.0	0	; * Battle 3
  $Name:	FS2_AArv_A01.wav			1.8	105840	; * Allied Arrival during Battle
  ...

Filename

The filename of the audio file must also include its file extension. FS1 and FS2 only support the playback of Waveform Audio (.wav) files.


FS2 Open, 3.6.x:

FSO supports the playback of Waveform Audio and OGG Vorbis (.ogg) files.

If there are two versions of the same file—one in Waveform Audio and one in OGG Vorbis format—FSO will typically attempt to play the OGG Vorbis version, even if the referenced file in music.tbl has a .wav file extension. In addition, if $Name: references a file that has the .ogg file extension, but only a Waveform Audio version of the file is available, FSO will still play the latter as if it is referenced directly in music.tbl.

Number of Measures and Samples per Measure

The FreeSpace engine's dynamic music capabilities are defined using the number of measures (m) and samples per measure (s). Using m, the engine parses the audio track by dividing it into individual parts, called measures; if an event happens that would change the music being played, the game will play the current audio track until the end of the current measure, whereupon it segues into the correct audio track via a built-in crossfade. The length of the measures is defined using s, which is the number of samples in a measure.

m is user-defined and can be set to a decimal point for greater fine-tuning.

s is calculated using the following formula:

  s = 2 × sample rate (hertz) × total audio length (seconds; up to 3 decimal places) ÷ m

Depending on the m and s values declared, the game may only play a portion of the actual audio file or, if the values result in it attempting to play the audio file beyond its actual length, playing nothing for a period of time after it finishes playing the actual audio file.

In the case of FS2_Amb_A01.wav, it is defined in music.tbl as an audio track that has 25 m and 105,840 s, so even though the file has an actual audio length of 62.556 seconds, the engine only ever parses the first 60 seconds of the audio file as its total audio length (hence omitting the last 2.556 seconds), split into 25 measures. This is because a reversal of the above calculation for s results in:

  105,840 (s) × 25 (m) ÷ 22,050 (hertz) ÷ 2 = 60.000 seconds

The length of the measures in the audio track cannot be individually adjusted by any meanss applies to all the measures in the audio file with no exceptions.

Alternate Calculation Method

If defining m and s is too time-consuming, the following formulae can be used to still make use of the FreeSpace engine's dynamic music capabilities, and would result in a maximum of 2 seconds' silence (since each measure would be 2 seconds long):

  m = audio file length (seconds; up to 3 decimal places) ÷ 2
  s = 4 × sample rate (hertz)

As an example, if we use the above alternate formulae with the actual audio length of FS2_Amb_A01.wav, we get the following:

  m = 62.556 seconds ÷ 2 = 31.278
  s = 4 × 22,050 (hertz) = 88,200

m would be rounded to the nearest decimal point. Hence, we would input the following as the alternate length for FS2_Amb_A01.wav in music.tbl:

  $Name:	FS2_Amb_A01.wav				31.3	88200	; * Ambience 


FS2 Open 3.6.10:

$String:

FSO includes an alternate way to parse individual tracks.

Instead of using $Name:, $String: can be used, with the String syntax being the situation reference, such as:

  $Normal 1:	FS2_Amb_A01.ogg				25.0	105840	; * Ambience 

Note that this system follows a different situation order from parsing $Name:, and it also cannot be changed under any circumstances. The situation order for parsing $String:, as well as the corresponding $String: to use for each situation, is as follows:

Order Situation $String: to Use Details
1 Ambience $Normal 1: Normal track—plays when nothing is happening or units are out of combat range; usually segues into Ambience 2
2 Ambience 2 $Normal 2: Normal track—plays when nothing is happening or units are out of combat range; usually segues into Ambience 3
3 Ambience 3 $Normal 3: Normal track—plays when nothing is happening or units are out of combat range; usually segues into Ambience
4 Allied Arrival during Ambience $Ally arrival 1: Plays when a friendly unit arrives while any Ambience track is playing
5 Allied Arrival during Battle $Ally arrival 2: Plays when a friendly unit arrives while any Battle track is playing
6 Enemy Arrival during Ambience $Enemy arrival 1: Plays when a friendly unit arrives while any Ambience track is playing
7 Enemy Arrival during Battle $Enemy arrival 2: Plays when a friendly unit arrives while any Battle track is playing
8 Battle 1 $Battle 1: Battle track 1—plays when units are in combat range; usually segues into Battle 2
9 Battle 2 $Battle 2: Battle track 2—plays when units are in combat range; usually segues into Battle 3
10 Battle 3 $Battle 3: Battle track 3—plays when units are in combat range; usually segues into Battle 1
11 Goal Failed $Failure 1: Plays when the primary goals of a mission are failed
12 Victory 1 $Victory 1: Plays when a goal is completed
13 Victory 2 $Victory 2: Plays when all goals are completed and there are absolutely no hostile units present; is only called once
14 Player Dies $Dead 1: Plays when the player is killed and goes to the death screen

Menu Music

All menu music tracks are defined in the lines within one instance of #Menu Music Start and #Menu Music End. Up to 50 menu music tracks can be defined across all .tbl and -mus.tbm files being referenced.

Each menu music track must have the following 2 lines in order:

  1. $Name:
  2. $Filename:

For the subsections, refer to the code used to call FS2_Brief_01.wav in-game, which is:

  $Name:		Brief1		
  $Filename:	FS2_Brief_01.wav			; briefing music 1

$Name:

The first line always starts with $Name:, followed by the name of the audio track, which is mainly referred to in FRED and its variants.

  $Name:		Brief1


FS2 Open 3.6.10:
  • The following flag can be added after $Name: in modular tables:

+nocreate

This flag should be added if the track is intended to completely overwrite an existing track with the exact same name.

$Filename:

The last line starts with $Filename:, followed by the file name of the audio track.

  $Filename:	FS2_Brief_01.wav			; briefing music 1

Format Sample

The following is a heavily truncated version of music.tbl located within Root_FS2.vp.

  ;
  ; music.tbl
  ;
  ; Specifies which .wav files to use for the different sections of event-driven sound-tracks
  ;
  ; format:  $Name:  filename.wav  num_measures (samples_per_measure)
  ;
  #SoundTrack Start	         				; SoundTrack 0
  $Soundtrack Name: 1: Genesis
  $Name:	FS2_Amb_A01.wav				25.0	105840	; * Ambience 
  $Name:	FS2_AArv_A01.wav			1.8	105840	; * Allied Arrival during Normal
  $Name:	FS2_Arv_B01.wav				3.8	81415	; * Enemy Arrival during Normal
  $Name:	FS2_Btl_A01.wav				25.8	66150	; * Battle 1
  $Name:	FS2_Btl_A02.wav				27.8	81415	; * Battle 2
  $Name:	FS2_Btl_A03.wav				39.8	81415	; * Battle 3
  $Name:	FS2_AArv_A01.wav			1.8	105840	; * Allied Arrival during Battle
  $Name:	FS2_Arv_B02.wav				3.8	81415	; * Enemy Arrival during Battle
  $Name:	FS2_Vict_A01.wav			2.8	52920	; * Victory 1 ( goal completed )
  $Name:	FS2_Vict_A02.wav			30.8	52920	; * Victory 2	( all enemies dead, goals completed )
  $Name:	FS2_Dth_A01.wav				23.8	132300	; * Goal Failed
  $Name:	FS2_Dth_A01.wav				23.8	132300	; * Player dies
  #SoundTrack End							; End Soundtrack 0
  ;
  #SoundTrack Start	     					; SoundTrack 1
  $Soundtrack Name: 2: Exodus
  $Name:	FS2_Amb_B01.wav				17.0	132300	; * Ambience 
  $Name:	FS2_AArv_A01.wav			1.8	105840	; * Allied Arrival during Normal
  $Name:	FS2_Arv_B01.wav				4.8	81415	; * Enemy Arrival during Normal
  $Name:	FS2_Btl_B01.wav				39.8	132300	; * Battle 1
  $Name:	FS2_Btl_B02.wav				23.8	75600	; * Battle 2
  $Name:	FS2_Btl_B03.wav				31.8	75600	; * Battle 3
  $Name:	FS2_AArv_A01.wav			1.8	105840	; * Allied Arrival during Battle
  $Name:	FS2_Arv_B04.wav				4.8	75600	; * Enemy Arrival during Battle
  $Name:	FS2_Vict_A01.wav			2.8	52920	; * Victory 1 ( goal completed )
  $Name:	FS2_Vict_B02.wav			40.8	88200	; * Victory 2	( all enemies dead, goals completed )
  $Name:	FS2_Dth_A01.wav				23.8	132300	; * Goal Failed
  $Name:	FS2_Dth_A01.wav				23.8	132300	; * Player dies
  #SoundTrack End							; End Soundtrack 1
  ;
  #Menu Music Start
  $Name:		Brief1				
  $Filename:	FS2_Brief_01.wav			; briefing music 1
  
  $Name:		Brief2
  $Filename:	FS2_Brief_02.wav			; briefing music 2
  
  $Name:		Brief3
  $Filename:	FS2_Brief_03.wav			; briefing music 3
  #Menu Music End

Related Links