Alchemy
Loading...
Searching...
No Matches

tables.c

Go to the documentation of this file.
1#include "types.h"
2
3//--------------------------------------------------------------------------
4// Sound library tables.
5//--------------------------------------------------------------------------
6
7struct SoundPlayer;
8struct SoundTrack;
9
10typedef void (*SoundFunc)(void);
11typedef void (*SoundCommand)(struct SoundPlayer *player,
12 struct SoundTrack *track);
13
15void MusicTrack_Goto(void);
35void MusicTrack_Stop(void);
40
41void MusicTrack_ReadVoiceTarget(struct SoundPlayer *player,
42 struct SoundTrack *track);
43void MusicTrack_SetVoiceKind(struct SoundPlayer *player,
44 struct SoundTrack *track);
45void MusicTrack_SetVoiceAttack(struct SoundPlayer *player,
46 struct SoundTrack *track);
47void MusicTrack_SetVoiceDecay(struct SoundPlayer *player,
48 struct SoundTrack *track);
49void MusicTrack_SetVoiceSustain(struct SoundPlayer *player,
50 struct SoundTrack *track);
51void MusicTrack_SetVoiceRelease(struct SoundPlayer *player,
52 struct SoundTrack *track);
53void MusicTrack_SetTailLevel(struct SoundPlayer *player,
54 struct SoundTrack *track);
55void MusicTrack_SetTailLength(struct SoundPlayer *player,
56 struct SoundTrack *track);
57void MusicTrack_SetVoiceLength(struct SoundPlayer *player,
58 struct SoundTrack *track);
60 struct SoundTrack *track);
62
63/// Sequence commands copied for each player, and driver entry points.
64// clang-format off
102};
103
104/// PCM pitches: the high four bits hold the octave, the low four the note.
106 0xe0, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8, 0xe9, 0xea, 0xeb,
107 0xd0, 0xd1, 0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xdb,
108 0xc0, 0xc1, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xcb,
109 0xb0, 0xb1, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xbb,
110 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab,
111 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
112 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b,
113 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b,
114 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
115 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b,
116 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
117 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
118 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
119 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
120 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b
121};
122
123/// Frequencies by note at octave zero, in 32-bit fixed point.
125 0x80000000, 0x879c7c97, 0x8facd61e, 0x9837f052,
126 0xa14517cc, 0xaadc0848, 0xb504f334, 0xbfc886bb,
127 0xcb2ff52a, 0xd744fccb, 0xe411f03a, 0xf1a1bf39
128};
129
130/// Samples per frame for each playback frequency setting.
132 96, 132, 176, 224, 264, 304, 352, 448, 528, 608, 672, 704
133};
134
135/// CGB channel pitches.
137 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0a, 0x0b,
138 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x1b,
139 0x20, 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x2b,
140 0x30, 0x31, 0x32, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
141 0x40, 0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x4b,
142 0x50, 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x5b,
143 0x60, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x6b,
144 0x70, 0x71, 0x72, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x7b,
145 0x80, 0x81, 0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x8b,
146 0x90, 0x91, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99, 0x9a, 0x9b,
147 0xa0, 0xa1, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xab
148};
149
150/// Frequencies by note for CGB channels.
152 -2004, -1891, -1785, -1685, -1591, -1501, -1417, -1337, -1262, -1192, -1125, -1062
153};
154
155/// Noise channel pitches.
157 0xd7, 0xd6, 0xd5, 0xd4, 0xc7, 0xc6, 0xc5, 0xc4, 0xb7, 0xb6, 0xb5, 0xb4,
158 0xa7, 0xa6, 0xa5, 0xa4, 0x97, 0x96, 0x95, 0x94, 0x87, 0x86, 0x85, 0x84,
159 0x77, 0x76, 0x75, 0x74, 0x67, 0x66, 0x65, 0x64, 0x57, 0x56, 0x55, 0x54,
160 0x47, 0x46, 0x45, 0x44, 0x37, 0x36, 0x35, 0x34, 0x27, 0x26, 0x25, 0x24,
161 0x17, 0x16, 0x15, 0x14, 0x07, 0x06, 0x05, 0x04, 0x03, 0x02, 0x01, 0x00
162};
163
164/// CGB channel 3 waveform volumes.
166 0x00, 0x00, 0x60, 0x60, 0x60, 0x60, 0x40, 0x40, 0x40, 0x40, 0x80, 0x80, 0x80, 0x80, 0x20, 0x20
167};
168
169/// Note durations in clock ticks.
171 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
172 16, 17, 18, 19, 20, 21, 22, 23, 24, 28, 30, 32, 36, 40, 42, 44,
173 48, 52, 54, 56, 60, 64, 66, 68, 72, 76, 78, 80, 84, 88, 90, 92,
174 96
175};
176
177/// Extended commands; entries zero and three do nothing.
191};
192// clang-format on
void MusicTrack_SetLfoSpeedFromCommand(struct SoundPlayer *player, struct SoundTrack *track)
void MusicTrack_ReleaseKey(struct SoundPlayer *player, struct SoundTrack *track)
void AudioEngine_SetPcmRate(u32 mode)
Sets the PCM frame length (mode bits 16 to 19 pick a gSound_FrameLengths entry) and the rates derived...
Definition engine.c:105
void MusicTrack_CalcOutput(struct SoundPlayer *player, struct SoundTrack *track)
Recalculates dirty stereo volumes and pitch from track settings and modulation.
Definition engine.c:411
void MusicPlayer_StepFade(struct SoundPlayer *player)
Advances a due fade step, updating active track volumes, or at the end of a fade out stops (or pauses...
Definition engine.c:360
void MusicTrack_Stop(struct SoundPlayer *player, struct SoundTrack *track)
u32 gSound_PcmFrequencySteps[]
Frequencies by note at octave zero, in 32-bit fixed point.
Definition tables.c:124
void MusicTrack_SetModulationFromCommand(struct SoundPlayer *player, struct SoundTrack *track)
u8 gSound_PcmPitchCodes[]
PCM pitches: the high four bits hold the octave, the low four the note.
Definition tables.c:105
const u16 gSound_FrameLengths[]
Samples per frame for each playback frequency setting.
Definition tables.c:131
void MusicTrack_SetVoiceAttack(struct SoundPlayer *player, struct SoundTrack *track)
Reads the voice attack rate from the sequence.
Definition engine.c:1099
void MusicTrack_SetVoiceRelease(struct SoundPlayer *player, struct SoundTrack *track)
Reads the voice release rate from the sequence.
Definition engine.c:1120
void MusicTrack_SetVoiceDecay(struct SoundPlayer *player, struct SoundTrack *track)
Reads the voice decay rate from the sequence.
Definition engine.c:1106
const u8 gSound_CgbPitchCodes[]
CGB channel pitches.
Definition tables.c:136
void MusicTrack_SetVoiceLength(struct SoundPlayer *player, struct SoundTrack *track)
Reads the hardware note length from the sequence.
Definition engine.c:1141
const u8 gSound_Cgb3LevelCodes[]
CGB channel 3 waveform volumes.
Definition tables.c:165
void MusicTrack_SetTailLength(struct SoundPlayer *player, struct SoundTrack *track)
Reads the note tail duration from the sequence.
Definition engine.c:1134
void MusicTrack_SetVoiceSustain(struct SoundPlayer *player, struct SoundTrack *track)
Reads the voice sustain level from the sequence.
Definition engine.c:1113
void MusicTrack_SetVoiceKind(struct SoundPlayer *player, struct SoundTrack *track)
Reads the voice kind from the sequence.
Definition engine.c:1092
const s16 gSound_CgbFrequencySteps[]
Frequencies by note for CGB channels.
Definition tables.c:151
const u8 gSound_NoisePitchCodes[]
Noise channel pitches.
Definition tables.c:156
void MusicTrack_SetVoicePanOrSweep(struct SoundPlayer *player, struct SoundTrack *track)
Reads the voice pan or CGB sweep setting from the sequence.
Definition engine.c:1148
void MusicTrack_SetTailLevel(struct SoundPlayer *player, struct SoundTrack *track)
Reads the note tail volume from the sequence.
Definition engine.c:1127
void MusicTrack_ReadVoiceTarget(struct SoundPlayer *player, struct SoundTrack *track)
Reads an unaligned little-endian voice target address from the sequence.
Definition engine.c:1078
void Runtime_CallWorkEntryWithArgs(struct SoundPlayer *player, struct SoundTrack *track)
Finishes a track through the base command table entry.
Definition engine.c:1070
A player, which plays one song: its header and status, its tracks, its tempo and fade.
A track of a playing song: the song commands it runs, its voice and notes, and the pitch,...
void MusicTrack_SetBendRangeFromCommand(void)
void SoundNote_Detach(void)
void(*) SoundCommand(struct SoundPlayer *player, struct SoundTrack *track)
A command table entry: the driver calls it with the player and the track.
Definition tables.c:11
void MusicTrack_WriteSoundRegisterFromCommand(void)
void MusicTrack_SetVolumeFromCommand(void)
void SoundDriver_ClearBuffer(void)
void MusicTrack_Goto(void)
void MusicTrack_SetPanFromCommand(void)
void MusicPlayer_SetTempoFromCommand(void)
void MusicTrack_SetLfoDelayFromCommand(void)
const SoundFunc gSound_CommandTableTemplate[]
Sequence commands copied for each player, and driver entry points.
Definition tables.c:65
void MusicTrack_SetTuneFromCommand(void)
void MusicTrack_ReturnFromPattern(void)
void MusicTrack_SetPriorityFromCommand(void)
void MusicTrack_SetBendFromCommand(void)
void MusicTrack_SetModulationTargetFromCommand(void)
void MusicTrack_CallPattern(void)
void MusicTrack_SetVoiceFromCommand(void)
void(*) SoundFunc(void)
Definition tables.c:10
void MusicTrack_Repeat(void)
void MusicTrack_FinishSequence(void)
const SoundCommand gSound_ExtendedCommandTable[]
Extended commands; entries zero and three do nothing.
Definition tables.c:178
void MusicTrack_SetKeyOffsetFromCommand(void)
const u8 gSound_ClockLengths[]
Note durations in clock ticks.
Definition tables.c:170
The integer types, TRUE, UNUSED and the fixed-address macros.
unsigned int u32
Definition types.h:15
signed short s16
Definition types.h:12
unsigned short u16
Definition types.h:13
unsigned char u8
Definition types.h:11