An ambient sound is a looping background sequence, such as wind or birdsong, that maps play with PlayAmbientSounds. Each one is an MSEQ file in audio/mseq/ plus an entry in audio/ambient_sounds.xml.
Edit an ambient sequence
To change how a game ambient sound plays, replace its MSEQ file. The game's audio/ambient_sounds.xml shows which file each sound uses. The Spooky sound uses spooky, which is the file audio/mseq/spooky.xml.
Copy the game's
audio/mseq/spooky.xmltoaudio/mseq/spooky.xmlin your layer.In your copy, change the
volumeof the firstPlaySoundcommand from6Dto40.Rebuild the ROM and load a map that plays
AMBIENT_SPOOKY. The first sound is quieter.
Your file replaces the game's file at the same path, so you don't change any table.
An MSEQ file has a header and a list of commands:
<Mseq code="501" firstVoice="13">
<TrackRamps/>
<Commands>
<SetInstrument track="1" wav="crow"/>
<SetVolume track="1" volume="7F"/>
<PlaySound track="1" pitch="176" volume="6D"/>
<Delay duration="10"/>
<StopSound track="1" pitch="176"/>
</Commands>
</Mseq>SetInstrumentpicks a sample by name for a track. The sample must be in an always-loaded bank.PlaySoundandStopSoundstart and stop a note.Delaywaits fordurationticks.StartLoopandEndLooprepeat the commands between them. AnEndLoopwithcount="0"repeats forever, and the loop must contain aDelay.SetVolume,SetPan, andSetReverbset values for a track.volumeis in hexadecimal.
The game's files in audio/mseq/ show every command. Copy the one closest to what you want.
Add a new ambient sound
Copy one of the game's MSEQ files to
audio/mseq/rain.xmland edit it. Set itscodeto a label of one to four characters, such asRN1.Create
audio/ambient_sounds.xmlif it doesn't exist, and add the entry. The file lists only your entries, and the build merges it with the game's.
<?xml version="1.0" encoding="UTF-8"?>
<AmbientSounds>
<AmbientSound name="Rain" mseq="rain"/>
</AmbientSounds>The mseq value is the file name in audio/mseq/, without the extension.
Rebuild the ROM. The build gives the entry the constant
AMBIENT_RAIN. New ambient sounds get IDs after the game's own, so you don't need to delete anything to make room.Play the sound from a map script:
Call(PlayAmbientSounds, AMBIENT_RAIN)To replace a game ambient sound, keep its name and point mseq at your file. The entry keeps the original ID, so maps that play it use your version.
Related pages
- Add an instrument or a sound bank shows how to add samples for your sequence.
- Fix audio build errors lists common ambient sound errors.