Jump to content

XML:SNDD: Difference between revisions

127 bytes added ,  31 December 2023
m
→‎Scripting music: tweaked the formatting and wording for clarity
(wording around TRAM sound lookup; added blurb on PreventRepeat; more links between sections)
m (→‎Scripting music: tweaked the formatting and wording for clarity)
 
Line 505: Line 505:
==Scripting music==
==Scripting music==
===BSL commands===
===BSL commands===
'''sound_music_start name:string [volume:float]''', e.g. <tt><code>sound_music_start mus_asian 0.75</code></tt>
'''sound_music_start name:string [volume:float]''', e.g. <code>sound_music_start mus_asian 0.75</code>


'''sound_music_stop name:string''', e.g. <tt><code>sound_music_stop mus_asian</code></tt><br>
'''sound_music_stop name:string''', e.g. <code>sound_music_stop mus_asian</code><br>
If .amb file has InterruptTracksOnStop flag, music will proceed immediately to <OutSound>, otherwise current segment will finish playing and then <OutSound> will play.
If .amb file has InterruptTracksOnStop flag, music will proceed immediately to <OutSound>, otherwise current segment will finish playing and then <OutSound> will play.


'''sound_music_volume name:string volume:float [time:float]''', e.g. <tt><code>sound_music_volume mus_asian 0.35 1.0</code></tt><br>
'''sound_music_volume name:string volume:float [time:float]''', e.g. <code>sound_music_volume mus_asian 0.35 1.0</code><br>
Volume change takes effect instantly unless you specify a time as the third parameter.
Volume change takes effect instantly unless you specify a time as the third parameter.


===Stopping the music===
===Stopping the music===
When Oni's BSL scripting wants to stop some music, it will either:
When Oni's BSL scripting wants to stop some music, it will either:
# Call <tt>sound_music_stop</tt>.
# Call <code>sound_music_stop ''mus_name''</code>.
# Fade out the music with <tt>sound_music_volume</tt> and then call <tt>sound_music_stop</tt> when the music has reached zero volume.
# Fade out the music with <code>sound_music_volume ''mus_name'' 0.0 4.0</code> and then call <code>sound_music_stop ''mus_name''</code> when the music has reached zero volume. (4.0 is a sample fade-out time. Oni uses values ranging from 0.25 to 6.0 in various situations.)


When setting up your .amb file, you have to think about the timing of how the music will be used. If a music track has an <OutSound> in its .amb, then the sequence of events will be:<br>
When setting up your .amb file, you have to think about the timing of how the music will be used. If a music track has an <OutSound> in its .amb, then the sequence of events will be:<br>
:<tt>sound_music_stop</tt> called → current body segment finishes playing → outro segment plays
:<tt>sound_music_stop</tt> called → current body segment finishes playing → outro segment plays


Thus it can be quite a while before the music really stops. If this lag time is a problem, you could:
Thus it can be quite a while before the music really stops. If this is a problem, you could:
# Leave out the <OutSound> so that <tt>sound_music_stop</tt> ends the music after the current segment finishes.
# Leave out the <OutSound> so that <tt>sound_music_stop</tt> ends the music after the current segment finishes.
# Fade out the music over the desired amount of time with <tt>sound_music_volume</tt>. Don't forget to call <tt>sound_music_stop</tt> after the fade-out finishes so that the sound system can stop playing the music.
# Fade out the music over the desired amount of time with <tt>sound_music_volume</tt>. Use <tt>sound_music_stop</tt> on the track after its fade-out finishes so that the sound system can stop playing the music.
# Use the InterruptTracksOnStop flag so that <tt>sound_music_stop</tt> skips to playing <OutSound> immediately.
# Use the InterruptTracksOnStop flag so that <tt>sound_music_stop</tt> skips to playing <OutSound> immediately.


====InterruptTracksOnStop====
====InterruptTracksOnStop====
Oni contains many music OSBDs that come in two variants – with and without the InterruptTracksOnStop flag – such as OSBDmus_amasian.amb and OSBDmus_amasian_hd.amb; they play the same actual SNDDs, but the "_hd" variant has the InterruptTracksOnStop flag. When <tt>sound_music_stop</tt> is called on a "_hd" OSBD, you will hear it immediately jump to the outro, which is slightly jarring but can be useful in some cases. An easily observed example is OSBDmus_fiteb_hd, which plays in {{C2}} when combat starts after the opening cutscene in the lobby. When the last blow is delivered to the last standing Striker, the music will immediately jump to its outro. Any discontinuity in the rhythm is masked by the final attack sound effect, and in fact the hard transition serves to punctuate the end of the action. By contrast, if a track was interrupted in this way during a quiet moment in the game it would probably sound awkwardly abrupt.
Oni contains many music OSBDs that come in two variants – with and without the InterruptTracksOnStop flag – such as OSBDmus_amasian.amb and OSBDmus_amasian_hd.amb; they play the same actual SNDDs, but the "_hd" variant has the InterruptTracksOnStop flag. When <tt>sound_music_stop</tt> is called on a "_hd" OSBD, you will hear it immediately jump to the outro, which is slightly jarring but can be useful in some cases. An easily observed example is OSBDmus_fiteb_hd, which plays in {{C2}} when combat starts after the opening cutscene in the lobby. When the final blow is delivered to the last standing Striker, the music will immediately jump to its outro. Any discontinuity in the rhythm is masked by the sound of the attack that triggers it, and in fact the hard transition serves to punctuate the end of the action. By contrast, if a track was interrupted in this way during a quiet moment in the game it would probably sound awkwardly abrupt.


==Registering sounds for characters==
==Registering sounds for characters==