Alchemy
Loading...
Searching...
No Matches

SoundTrack Struct Reference

A track of a playing song: the song commands it runs, its voice and notes, and the pitch, volume, pan and modulation it gives them. More...

#include <sound/audio_engine_types.h>

Data Fields

u8 flags
 SoundTrackFlag.
u8 unk01 [7]
 0x01 ticks until the next command, 0x02 pattern depth (0 to 3), 0x03 repeat count, 0x04 gate of the last note in ticks, 0x05 its key, 0x06 its velocity, 0x07 the last command byte from 0xBD up, which a byte below 0x80 repeats.
u8 pitchHi
 Whole semitones of the track's pitch, read as signed and added to each note's key (a sum below 0 plays key 0).
u8 pitchLo
 The pitch's fraction, 0 to 255 in 1/256 semitone, passed as the fine pitch to the key-to-frequency step.
s8 keyOffsetA
 Semitones, from the song's key-shift command.
s8 keyOffsetB
 Semitones, from MusicPlayer_SetPitch.
s8 tune
 The tune command's byte - 64: 1/64 semitone.
u8 fine
 1/256 semitone, from MusicPlayer_SetPitch.
s8 bend
 The bend command's byte - 64: full bend is bendRange.
u8 bendRange
 Semitones a full bend reaches; 2 at reset.
u8 outVolumeA
 Right volume: (pan + 128) * scaled volume / 256.
u8 outVolumeB
 Left volume: (127 - pan) * scaled volume / 256.
u8 volume
 The song's volume command, scaled by volumeScale / 32.
u8 volumeScale
 0 to 64 (full, the reset value): a player volume or fade level of 0 to 0x100 divided by 4.
s8 pan
 The pan command's byte - 64, -64 to 63; doubled for output.
s8 panOffset
 Added to the doubled pan, from MusicPlayer_SetPan.
s8 modAmount
 The LFO's output, modDepth * wave / 64: added to the pitch in 1/16 semitone, to the pan, or scaling the volume by (amount + 128) / 128.
u8 modDepth
 0 to 255, from the modulation command or MusicPlayer_SetModulationDepth; 0 stops the LFO and clears modAmount.
u8 modTarget
 SoundModulationTarget.
u8 lfoSpeed
 LFO phase step a tick, 22 at reset; 0 stops the LFO and clears modAmount.
u8 lfoPhase
 0 to 255, wrapping; the wave is phase over 0 to 63, 128 - phase over 64 to 191 and phase - 256 over 192 to 255, so -64 to 64.
u8 unk1b [3]
 0x1b LFO delay in ticks (song command), 0x1c its countdown, reloaded by each note, 0x1d track priority added to the player's for its notes.
u8 tailLevel
 Each new note's echo level.
u8 tailLength
 Each new note's echo length in frames.
struct SoundNote * notes
 The notes this track started, newest first, linked through SoundNote.next; PCM notes from SoundWork.pcmNotes and CGB notes.
struct SoundVoice voice
 Copied from the player's voice table by the voice command, or set a field at a time by extended commands.
u8 unk30 [0x10]
 Not named by TBS code; zeroed with the first 64 bytes at reset.
const u8 * cursor
 The next command byte in the song's data, from the header's track pointer; a track's commands end at a finish command (0xB1).
u8 unk44 [0x0c]
 Cursors to return to after each of up to three nested patterns.

Detailed Description

A track of a playing song: the song commands it runs, its voice and notes, and the pitch, volume, pan and modulation it gives them.

Definition at line 275 of file audio_engine_types.h.

Field Documentation

◆ flags

◆ unk01

u8 SoundTrack::unk01[7]

0x01 ticks until the next command, 0x02 pattern depth (0 to 3), 0x03 repeat count, 0x04 gate of the last note in ticks, 0x05 its key, 0x06 its velocity, 0x07 the last command byte from 0xBD up, which a byte below 0x80 repeats.

Definition at line 283 of file audio_engine_types.h.

◆ pitchHi

u8 SoundTrack::pitchHi

Whole semitones of the track's pitch, read as signed and added to each note's key (a sum below 0 plays key 0).

Definition at line 286 of file audio_engine_types.h.

Referenced by MusicTrack_CalcOutput().

◆ pitchLo

u8 SoundTrack::pitchLo

The pitch's fraction, 0 to 255 in 1/256 semitone, passed as the fine pitch to the key-to-frequency step.

Definition at line 289 of file audio_engine_types.h.

Referenced by MusicTrack_CalcOutput().

◆ keyOffsetA

s8 SoundTrack::keyOffsetA

Semitones, from the song's key-shift command.

Definition at line 290 of file audio_engine_types.h.

Referenced by MusicTrack_CalcOutput().

◆ keyOffsetB

s8 SoundTrack::keyOffsetB

Semitones, from MusicPlayer_SetPitch.

Definition at line 291 of file audio_engine_types.h.

Referenced by MusicPlayer_SetPitch(), and MusicTrack_CalcOutput().

◆ tune

s8 SoundTrack::tune

The tune command's byte - 64: 1/64 semitone.

Definition at line 292 of file audio_engine_types.h.

Referenced by MusicTrack_CalcOutput().

◆ fine

u8 SoundTrack::fine

1/256 semitone, from MusicPlayer_SetPitch.

Definition at line 293 of file audio_engine_types.h.

Referenced by Cgb_KeyToFrequency(), MusicPlayer_SetPitch(), and MusicTrack_CalcOutput().

◆ bend

s8 SoundTrack::bend

The bend command's byte - 64: full bend is bendRange.

Definition at line 294 of file audio_engine_types.h.

Referenced by MusicTrack_CalcOutput().

◆ bendRange

u8 SoundTrack::bendRange

Semitones a full bend reaches; 2 at reset.

Definition at line 295 of file audio_engine_types.h.

Referenced by MusicPlayer_ResetActiveTracks(), and MusicTrack_CalcOutput().

◆ outVolumeA

u8 SoundTrack::outVolumeA

Right volume: (pan + 128) * scaled volume / 256.

Definition at line 296 of file audio_engine_types.h.

Referenced by MusicTrack_CalcOutput().

◆ outVolumeB

u8 SoundTrack::outVolumeB

Left volume: (127 - pan) * scaled volume / 256.

Definition at line 297 of file audio_engine_types.h.

Referenced by MusicTrack_CalcOutput().

◆ volume

u8 SoundTrack::volume

The song's volume command, scaled by volumeScale / 32.

Definition at line 298 of file audio_engine_types.h.

Referenced by MusicPlayer_SetVolume(), and MusicTrack_CalcOutput().

◆ volumeScale

u8 SoundTrack::volumeScale

0 to 64 (full, the reset value): a player volume or fade level of 0 to 0x100 divided by 4.

Definition at line 301 of file audio_engine_types.h.

Referenced by MusicPlayer_ResetActiveTracks(), MusicPlayer_SetVolume(), MusicPlayer_StepFade(), and MusicTrack_CalcOutput().

◆ pan

s8 SoundTrack::pan

The pan command's byte - 64, -64 to 63; doubled for output.

Definition at line 302 of file audio_engine_types.h.

Referenced by MusicPlayer_SetPan(), and MusicTrack_CalcOutput().

◆ panOffset

s8 SoundTrack::panOffset

Added to the doubled pan, from MusicPlayer_SetPan.

Definition at line 303 of file audio_engine_types.h.

Referenced by MusicPlayer_SetPan(), and MusicTrack_CalcOutput().

◆ modAmount

s8 SoundTrack::modAmount

The LFO's output, modDepth * wave / 64: added to the pitch in 1/16 semitone, to the pan, or scaling the volume by (amount + 128) / 128.

Definition at line 306 of file audio_engine_types.h.

Referenced by MusicTrack_CalcOutput(), and MusicTrack_ClearModulation().

◆ modDepth

u8 SoundTrack::modDepth

0 to 255, from the modulation command or MusicPlayer_SetModulationDepth; 0 stops the LFO and clears modAmount.

Definition at line 309 of file audio_engine_types.h.

Referenced by MusicPlayer_SetModulationDepth().

◆ modTarget

u8 SoundTrack::modTarget

◆ lfoSpeed

u8 SoundTrack::lfoSpeed

LFO phase step a tick, 22 at reset; 0 stops the LFO and clears modAmount.

Definition at line 312 of file audio_engine_types.h.

Referenced by MusicPlayer_ResetActiveTracks(), and MusicPlayer_SetLfoSpeed().

◆ lfoPhase

u8 SoundTrack::lfoPhase

0 to 255, wrapping; the wave is phase over 0 to 63, 128 - phase over 64 to 191 and phase - 256 over 192 to 255, so -64 to 64.

Definition at line 315 of file audio_engine_types.h.

Referenced by MusicTrack_ClearModulation().

◆ unk1b

u8 SoundTrack::unk1b[3]

0x1b LFO delay in ticks (song command), 0x1c its countdown, reloaded by each note, 0x1d track priority added to the player's for its notes.

Definition at line 318 of file audio_engine_types.h.

◆ tailLevel

u8 SoundTrack::tailLevel

Each new note's echo level.

Definition at line 319 of file audio_engine_types.h.

Referenced by MusicTrack_SetTailLevel().

◆ tailLength

u8 SoundTrack::tailLength

Each new note's echo length in frames.

Definition at line 320 of file audio_engine_types.h.

Referenced by MusicTrack_SetTailLength().

◆ notes

struct SoundNote* SoundTrack::notes

The notes this track started, newest first, linked through SoundNote.next; PCM notes from SoundWork.pcmNotes and CGB notes.

NULL ends the list or leaves it empty.

Definition at line 324 of file audio_engine_types.h.

Referenced by MusicPlayer_StartSong().

◆ voice

struct SoundVoice SoundTrack::voice

◆ unk30

u8 SoundTrack::unk30[0x10]

Not named by TBS code; zeroed with the first 64 bytes at reset.

Definition at line 329 of file audio_engine_types.h.

◆ cursor

◆ unk44

u8 SoundTrack::unk44[0x0c]

Cursors to return to after each of up to three nested patterns.

Definition at line 334 of file audio_engine_types.h.