Alchemy
Loading...
Searching...
No Matches

SoundVoice Struct Reference

A voice a track plays its notes with: its kind and base key, the sample or wave it plays, and its attack, decay, sustain and release. More...

#include <sound/audio_engine_types.h>

Data Fields

u8 kind
 bits: 7 rhythm | 6 key split | 3 fixed rate for PCM, bias rounding for CGB | 2..0 CGB channel (0 PCM).
u8 baseKey
 Key a rhythm entry plays every note at.
u8 length
 CGB sound length (NRx1); 0 plays until released.
u8 panOrSweep
 CGB channel 1's sweep (NR10) when bit 7 is clear and bits 6..4 are not; else no sweep.
const void * target
 The PCM sample, the CGB wave pattern, duty or noise width, or for a rhythm or split voice its voice table.
u8 attack
 PCM: added to the envelope each frame until 255.
u8 decay
 PCM: envelope * decay / 256 a frame. CGB: frames a step.
u8 sustain
 Level decay stops at: 0 to 255 for PCM, 0 to 15 for CGB.
u8 release
 PCM: envelope * release / 256 a frame. CGB: frames a step.

Detailed Description

A voice a track plays its notes with: its kind and base key, the sample or wave it plays, and its attack, decay, sustain and release.

Definition at line 114 of file audio_engine_types.h.

Field Documentation

◆ kind

u8 SoundVoice::kind

bits: 7 rhythm | 6 key split | 3 fixed rate for PCM, bias rounding for CGB | 2..0 CGB channel (0 PCM).

A rhythm or split voice plays an entry of the voice table at target, chosen by the key (rhythm) or through the key map that attack's four bytes point to (split).

Definition at line 120 of file audio_engine_types.h.

Referenced by MusicPlayer_ResetActiveTracks(), and MusicTrack_SetVoiceKind().

◆ baseKey

u8 SoundVoice::baseKey

Key a rhythm entry plays every note at.

Definition at line 121 of file audio_engine_types.h.

◆ length

u8 SoundVoice::length

CGB sound length (NRx1); 0 plays until released.

Definition at line 122 of file audio_engine_types.h.

Referenced by MusicTrack_SetVoiceLength().

◆ panOrSweep

u8 SoundVoice::panOrSweep

CGB channel 1's sweep (NR10) when bit 7 is clear and bits 6..4 are not; else no sweep.

In a rhythm entry with bit 7 set, the note's pan is (value - 192) * 2.

Definition at line 126 of file audio_engine_types.h.

Referenced by MusicTrack_SetVoicePanOrSweep().

◆ target

const void* SoundVoice::target

The PCM sample, the CGB wave pattern, duty or noise width, or for a rhythm or split voice its voice table.

Definition at line 129 of file audio_engine_types.h.

Referenced by MusicTrack_ReadVoiceTarget().

◆ attack

u8 SoundVoice::attack

PCM: added to the envelope each frame until 255.

CGB: frames a step. In a split voice, these four bytes are a pointer to its key map.

Definition at line 132 of file audio_engine_types.h.

Referenced by MusicTrack_SetVoiceAttack().

◆ decay

u8 SoundVoice::decay

PCM: envelope * decay / 256 a frame. CGB: frames a step.

Definition at line 133 of file audio_engine_types.h.

Referenced by MusicTrack_SetVoiceDecay().

◆ sustain

u8 SoundVoice::sustain

Level decay stops at: 0 to 255 for PCM, 0 to 15 for CGB.

Definition at line 134 of file audio_engine_types.h.

Referenced by MusicTrack_SetVoiceSustain().

◆ release

u8 SoundVoice::release

PCM: envelope * release / 256 a frame. CGB: frames a step.

Definition at line 135 of file audio_engine_types.h.

Referenced by MusicTrack_SetVoiceRelease().