Alchemy
Loading...
Searching...
No Matches

SoundWork Struct Reference

The sound driver's work: its lock, the mixer's rate and buffers, the PCM and CGB notes, and the routines the driver calls. More...

#include <sound/audio_engine_types.h>

Data Fields

u32 lock
 SOUND_LOCK when free; raised while the driver changes it.
volatile u8 transferCountdown
 Frames until the VBlank DMA restart, which reloads it from transferPeriod; also picks the frame of the buffers being mixed.
u8 reverb
 0 to 127 (mode bits 6..0); 0 skips the reverb pass.
u8 pcmNoteCount
 PCM notes in use, 8 at start (mode bits 11..8).
u8 volume
 PCM volume 0 to 15, 15 at start (mode bits 15..12).
u8 rate
 1 to 12, indexes gSound_FrameLengths (mode bits 19..16).
u8 unk09
 Not named by TBS code.
u8 cgbTick
 Counts 14 down to 0 once a CGB update; at 0 the envelopes take an extra step.
u8 transferPeriod
 Frames the buffers hold: 0x630 / frameSamples.
u8 maxLines
 Nonzero: the mixer stops taking notes once the scanline passes this many lines after its start.
u8 unk0d [3]
 Not named by TBS code.
u32 frameSamples
 Samples mixed a frame, from gSound_FrameLengths.
u32 outputRate
 Samples a second: frameSamples * 59.7275, rounded.
u32 rateStep
 2^23 / outputRate, rounded; a note's frequency times it is its step a sample.
struct CgbNote * cgbNotes
 gSound_CgbNotes; NULL before CGB setup.
void(*) tick (struct SoundPlayer *player)
 First of the chain of player ticks run each mixer frame; NULL for none.
struct SoundPlayer * tickPlayer
 Passed to tick.
void(*) cgbUpdate (void)
 Run each mixer frame: Cgb_UpdateChannels.
void(*) cgbMute (u8 channel)
 CgbChannel_Mute, channel 1 to 4.
s32(*) cgbFrequency (u8 kind, u8 key, u8 fine)
 Cgb_KeyToFrequency.
SoundCommand * commands
 gSound_CommandTable.
void(*) noteOn (u32 command, struct SoundPlayer *player, struct SoundTrack *track)
 MusicTrack_HandleNote, run for song bytes from 0xCF up with the byte.
void(*) unk3c (void)
 Set to Audio_EmptyCallback by AudioEngine_Initialize; no TBS code reads it by name.
u8 unk40 [0x10]
 Not named by TBS code.
struct SoundNote pcmNotes [12]
 pcmNoteCount of them play.
s8 buffers [2][0x630]
 Right (0, DMA 1 to FIFO A) and left (1, DMA 2 to FIFO B) samples, transferPeriod frames of frameSamples each.

Detailed Description

The sound driver's work: its lock, the mixer's rate and buffers, the PCM and CGB notes, and the routines the driver calls.

Definition at line 390 of file audio_engine_types.h.

Field Documentation

◆ lock

◆ transferCountdown

volatile u8 SoundWork::transferCountdown

Frames until the VBlank DMA restart, which reloads it from transferPeriod; also picks the frame of the buffers being mixed.

Definition at line 397 of file audio_engine_types.h.

Referenced by AudioEngine_ResumeDirectSound().

◆ reverb

u8 SoundWork::reverb

0 to 127 (mode bits 6..0); 0 skips the reverb pass.

Definition at line 398 of file audio_engine_types.h.

Referenced by AudioEngine_SetMode().

◆ pcmNoteCount

u8 SoundWork::pcmNoteCount

PCM notes in use, 8 at start (mode bits 11..8).

Definition at line 399 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize(), and AudioEngine_SetMode().

◆ volume

u8 SoundWork::volume

PCM volume 0 to 15, 15 at start (mode bits 15..12).

Definition at line 400 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize(), and AudioEngine_SetMode().

◆ rate

u8 SoundWork::rate

1 to 12, indexes gSound_FrameLengths (mode bits 19..16).

Definition at line 401 of file audio_engine_types.h.

Referenced by AudioEngine_SetPcmRate().

◆ unk09

u8 SoundWork::unk09

Not named by TBS code.

Definition at line 402 of file audio_engine_types.h.

◆ cgbTick

u8 SoundWork::cgbTick

Counts 14 down to 0 once a CGB update; at 0 the envelopes take an extra step.

Definition at line 405 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ transferPeriod

u8 SoundWork::transferPeriod

Frames the buffers hold: 0x630 / frameSamples.

Definition at line 406 of file audio_engine_types.h.

Referenced by AudioEngine_SetPcmRate().

◆ maxLines

u8 SoundWork::maxLines

Nonzero: the mixer stops taking notes once the scanline passes this many lines after its start.

Sound_MaxLines, 0.

Definition at line 409 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize().

◆ unk0d

u8 SoundWork::unk0d[3]

Not named by TBS code.

Definition at line 410 of file audio_engine_types.h.

◆ frameSamples

u32 SoundWork::frameSamples

Samples mixed a frame, from gSound_FrameLengths.

Definition at line 411 of file audio_engine_types.h.

Referenced by AudioEngine_SetPcmRate().

◆ outputRate

u32 SoundWork::outputRate

Samples a second: frameSamples * 59.7275, rounded.

Definition at line 412 of file audio_engine_types.h.

Referenced by AudioEngine_SetPcmRate().

◆ rateStep

u32 SoundWork::rateStep

2^23 / outputRate, rounded; a note's frequency times it is its step a sample.

Definition at line 415 of file audio_engine_types.h.

Referenced by AudioEngine_SetPcmRate().

◆ cgbNotes

struct CgbNote* SoundWork::cgbNotes

gSound_CgbNotes; NULL before CGB setup.

Definition at line 416 of file audio_engine_types.h.

Referenced by AudioEngine_StopAllChannels(), Cgb_UpdateChannels(), and CgbAudio_Initialize().

◆ tick

void(*) SoundWork::tick(struct SoundPlayer *player)

First of the chain of player ticks run each mixer frame; NULL for none.

Definition at line 418 of file audio_engine_types.h.

Referenced by MusicPlayer_Initialize().

◆ tickPlayer

struct SoundPlayer* SoundWork::tickPlayer

Passed to tick.

Definition at line 419 of file audio_engine_types.h.

Referenced by MusicPlayer_Initialize().

◆ cgbUpdate

void(*) SoundWork::cgbUpdate(void)

Run each mixer frame: Cgb_UpdateChannels.

Definition at line 420 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize(), and CgbAudio_Initialize().

◆ cgbMute

void(*) SoundWork::cgbMute(u8 channel)

CgbChannel_Mute, channel 1 to 4.

Definition at line 421 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize(), AudioEngine_StopAllChannels(), and CgbAudio_Initialize().

◆ cgbFrequency

s32(*) SoundWork::cgbFrequency(u8 kind, u8 key, u8 fine)

Cgb_KeyToFrequency.

Definition at line 422 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize(), and CgbAudio_Initialize().

◆ commands

SoundCommand* SoundWork::commands

gSound_CommandTable.

Definition at line 423 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize().

◆ noteOn

void(*) SoundWork::noteOn(u32 command, struct SoundPlayer *player, struct SoundTrack *track)

MusicTrack_HandleNote, run for song bytes from 0xCF up with the byte.

  • 0xCF.

Definition at line 426 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize().

◆ unk3c

void(*) SoundWork::unk3c(void)

Set to Audio_EmptyCallback by AudioEngine_Initialize; no TBS code reads it by name.

Definition at line 430 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize().

◆ unk40

u8 SoundWork::unk40[0x10]

Not named by TBS code.

Definition at line 431 of file audio_engine_types.h.

◆ pcmNotes

struct SoundNote SoundWork::pcmNotes[12]

pcmNoteCount of them play.

Definition at line 432 of file audio_engine_types.h.

Referenced by AudioEngine_SetMode(), and AudioEngine_StopAllChannels().

◆ buffers

s8 SoundWork::buffers[2][0x630]

Right (0, DMA 1 to FIFO A) and left (1, DMA 2 to FIFO B) samples, transferPeriod frames of frameSamples each.

Definition at line 435 of file audio_engine_types.h.

Referenced by AudioEngine_Initialize(), and AudioEngine_SuspendDirectSound().