Alchemy
Loading...
Searching...
No Matches

CgbNote Struct Reference

A note on one of the four CGB channels of the hardware: its state and envelope, its levels and pan, its frequency and its wave. More...

#include <sound/audio_engine_types.h>

Data Fields

u8 state
 CgbNoteState and CgbNotePhase; 0 when the channel is free.
u8 kind
 Channel number 1 to 4 at setup, then the voice's kind; bit 3 rounds the frequency to the sound bias's resolution on channels 1 to 3.
u8 outRight
 Velocity and track volume to the right, 0 to 255.
u8 outLeft
 Velocity and track volume to the left, 0 to 255.
u8 attack
 Frames per attack step.
u8 decay
 Frames per decay step.
u8 sustain
 Sustain level 0 to 15, scaled by peak.
u8 release
 Frames per release step.
u8 key
 The key played, before the track's pitch.
u8 level
 Envelope level 0 to 15 written to the channel.
u8 peak
 Top of the envelope: (outRight + outLeft) / 16, at most 15 when one side plays.
u8 counter
 Frames left in the current envelope step.
u8 echoLevel
 After release, the level held is peak * echoLevel / 256.
u8 echoLength
 Frames the echo lasts.
u8 unk0e [0x0b]
 0x10 gate in ticks, 0x11 the song's key, 0x12 velocity, 0x13 priority (a new note of higher priority takes the channel), 0x14 rhythm pan.
u8 sustainLevel
 (peak * sustain + 15) / 16.
u8 trigger
 Value for NRx4: 7 restart, 6 length on, 2..0 frequency.
u8 panBits
 NR51 bits this note sets: one side or both.
u8 channelBits
 This channel's NR51 bits: 0x11, 0x22, 0x44, 0x88.
u8 modified
 CgbNoteModified: what to write to the channel.
u8 length
 The voice's length.
u8 sweep
 Channel 1's NR10 sweep; 8 when none.
u32 frequency
 Tone frequency from Cgb_KeyToFrequency (2048 added), or channel 4's NR43 value.
u32 * wave
 Channel 3: the 16-byte wave pattern.
u32 * loadedWave
 Channel 3: the pattern last copied into wave RAM.
u8 unk2c [0x14]
 0x2c track, 0x30 prev and 0x34 next, as in SoundNote.

Detailed Description

A note on one of the four CGB channels of the hardware: its state and envelope, its levels and pan, its frequency and its wave.

Definition at line 184 of file audio_engine_types.h.

Field Documentation

◆ state

u8 CgbNote::state

CgbNoteState and CgbNotePhase; 0 when the channel is free.

Definition at line 185 of file audio_engine_types.h.

Referenced by AudioEngine_StopAllChannels(), and Cgb_UpdateChannels().

◆ kind

u8 CgbNote::kind

Channel number 1 to 4 at setup, then the voice's kind; bit 3 rounds the frequency to the sound bias's resolution on channels 1 to 3.

Definition at line 188 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), and CgbAudio_Initialize().

◆ outRight

u8 CgbNote::outRight

Velocity and track volume to the right, 0 to 255.

Definition at line 189 of file audio_engine_types.h.

Referenced by CgbNote_UpdatePanEnvelope().

◆ outLeft

u8 CgbNote::outLeft

Velocity and track volume to the left, 0 to 255.

Definition at line 190 of file audio_engine_types.h.

Referenced by CgbNote_UpdatePanEnvelope().

◆ attack

u8 CgbNote::attack

Frames per attack step.

Definition at line 191 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ decay

u8 CgbNote::decay

Frames per decay step.

Definition at line 192 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ sustain

u8 CgbNote::sustain

Sustain level 0 to 15, scaled by peak.

Definition at line 193 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), and CgbNote_UpdatePanEnvelope().

◆ release

u8 CgbNote::release

Frames per release step.

Definition at line 194 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ key

u8 CgbNote::key

The key played, before the track's pitch.

Definition at line 195 of file audio_engine_types.h.

◆ level

u8 CgbNote::level

Envelope level 0 to 15 written to the channel.

Definition at line 196 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ peak

u8 CgbNote::peak

Top of the envelope: (outRight + outLeft) / 16, at most 15 when one side plays.

Definition at line 199 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), and CgbNote_UpdatePanEnvelope().

◆ counter

u8 CgbNote::counter

Frames left in the current envelope step.

Definition at line 200 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ echoLevel

u8 CgbNote::echoLevel

After release, the level held is peak * echoLevel / 256.

Definition at line 201 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ echoLength

u8 CgbNote::echoLength

Frames the echo lasts.

Definition at line 202 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ unk0e

u8 CgbNote::unk0e[0x0b]

0x10 gate in ticks, 0x11 the song's key, 0x12 velocity, 0x13 priority (a new note of higher priority takes the channel), 0x14 rhythm pan.

Definition at line 205 of file audio_engine_types.h.

◆ sustainLevel

u8 CgbNote::sustainLevel

(peak * sustain + 15) / 16.

Definition at line 206 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), and CgbNote_UpdatePanEnvelope().

◆ trigger

u8 CgbNote::trigger

Value for NRx4: 7 restart, 6 length on, 2..0 frequency.

Definition at line 207 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ panBits

u8 CgbNote::panBits

NR51 bits this note sets: one side or both.

Definition at line 208 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels(), and CgbNote_UpdatePanEnvelope().

◆ channelBits

u8 CgbNote::channelBits

This channel's NR51 bits: 0x11, 0x22, 0x44, 0x88.

Definition at line 209 of file audio_engine_types.h.

Referenced by CgbAudio_Initialize(), and CgbNote_UpdatePanEnvelope().

◆ modified

u8 CgbNote::modified

CgbNoteModified: what to write to the channel.

Definition at line 210 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ length

u8 CgbNote::length

The voice's length.

Definition at line 211 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ sweep

u8 CgbNote::sweep

Channel 1's NR10 sweep; 8 when none.

Definition at line 212 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ frequency

u32 CgbNote::frequency

Tone frequency from Cgb_KeyToFrequency (2048 added), or channel 4's NR43 value.

Definition at line 215 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ wave

u32* CgbNote::wave

Channel 3: the 16-byte wave pattern.

Channels 1 and 2: the duty, into NRx1's bits 7..6. Channel 4: the width, into NR43's bit 3.

Definition at line 218 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ loadedWave

u32* CgbNote::loadedWave

Channel 3: the pattern last copied into wave RAM.

Definition at line 219 of file audio_engine_types.h.

Referenced by Cgb_UpdateChannels().

◆ unk2c

u8 CgbNote::unk2c[0x14]

0x2c track, 0x30 prev and 0x34 next, as in SoundNote.

Definition at line 221 of file audio_engine_types.h.