1#ifndef COASTLINE_AUDIO_H
2#define COASTLINE_AUDIO_H
14#if TGR_PLATFORM == TGR_PLATFORM_SDL
43#define AUDIO_FREQUENCY 21998
46#define MUSIC_OCTAVES 10
100#if TGR_PLATFORM == TGR_PLATFORM_SDL
102#define MENU_MUSIC_MODULE_SIZE 0x70800
121#define g_abMenuMusicModule ((u8 *)0x80025C00)
125extern u8 _menuMusicSegmentRomStart[];
127extern u8 _scrollSoundSegmentRomStart[];
129extern u8 _selectSoundSegmentRomStart[];
131#if TGR_PLATFORM != TGR_PLATFORM_SDL
175#if TGR_PLATFORM != TGR_PLATFORM_SDL
217#if TGR_PLATFORM == TGR_PLATFORM_SDL
219#define SILENCE_SAMPLE_BYTES 0x1000
222#define SILENCE_SAMPLE_BYTES 4
224#if TGR_PLATFORM != TGR_PLATFORM_SDL
236#if TGR_PLATFORM != TGR_PLATFORM_SDL
245extern s32 g_dwAudioTickToggle;
255extern s32 g_dwAiDmaPrevLength;
265extern u32 g_dwSoundEffectMixOffset;
268#if TGR_PLATFORM != TGR_PLATFORM_SDL
287extern OSMesg g_aAudioMsgBuf[2];
300#if TGR_PLATFORM != TGR_PLATFORM_SDL
379extern u8 g_MusicRestartOrder;
390#if TGR_PLATFORM != TGR_PLATFORM_SDL
395#define AUDIO_THREAD_STACK_WORDS 0x80
415#if TGR_PLATFORM != TGR_PLATFORM_SDL
419#if TGR_PLATFORM != TGR_PLATFORM_SDL
428extern s32 g_dwAudioMixBytes;
438extern s32 g_dwAiDmaCurrentLength;
448extern s32 g_dwAudioChannelLoopIdx;
597#if TGR_PLATFORM != TGR_PLATFORM_SDL
631#if TGR_PLATFORM == TGR_PLATFORM_SDL
660#define g_abMusicModuleWorkBuffer (GetSdlMusicState()->moduleWork)
662#define g_nAudioChannelCount (GetSdlMusicState()->channelCount)
664#define g_bBgmVolume (GetSdlMusicState()->bgmVolume)
666#define g_bSfxMasterVolume (GetSdlMusicState()->sfxMasterVolume)
668#define g_bSfxVolume (GetSdlMusicState()->sfxVolume)
670#define g_afNoteFrequencies (GetSdlMusicState()->noteFrequencies)
672#define g_dwMusicPatternRow (GetSdlMusicState()->patternRow)
674#define g_SilenceSampleData (GetSdlMusicState()->silence)
676#define g_AudioDmaBuffer (GetSdlMusicState()->ring)
678#define g_apInstrumentData (GetSdlMusicState()->instruments)
680#define g_apPatternData (GetSdlMusicState()->patterns)
682#define g_MusicChannelStates (GetSdlMusicState()->channels)
684#define g_aSoundEffectSamples (GetSdlMusicState()->samples)
686#define g_bMusicPlaybackEnabled (GetSdlMusicState()->playbackEnabled)
688#define g_MusicPlayer (GetSdlMusicState()->player)
690#define g_aFreqScaleTable (GetSdlMusicState()->frequencySteps)
s16 FindFreeSoundChannel(void)
The first sound effect channel that is silent.
#define g_aFreqScaleTable
Definition audio.h:690
void CheckMusicLoopPoints(void)
Loop or stop the music channels that passed the end of their samples.
u64 g_aAudioThreadStack[AUDIO_THREAD_STACK_WORDS]
Stack storage for the audio mixing thread, in 64-bit words.
#define g_dwMusicPatternRow
Definition audio.h:672
#define g_MusicPlayer
Definition audio.h:688
void LoadMusicModule(u8 *module, u8 *work)
The 32.32 step of each note of each octave.
#define g_AudioDmaBuffer
Definition audio.h:676
#define g_bMusicPlaybackEnabled
Definition audio.h:686
#define g_afNoteFrequencies
Definition audio.h:670
#define MENU_MUSIC_MODULE_SIZE
The bytes from the menu music up to the heap at 0x80096400 on the console.
Definition audio.h:102
void ResetMusicChannels(void)
Start the music from before its first order.
void InitAudioSystem(void *module, void *work)
Start the audio interface, the music player and the mixing thread.
void N64InitSoundChannel(s16 channel, s8 *sample, u32 length, u32 loopLength)
InitSoundChannel() of the mixer of the Nintendo 64 release, which the SDL game has beside the routine...
#define g_bBgmVolume
Definition audio.h:664
#define g_nAudioChannelCount
Definition audio.h:662
void CheckSoundEffectLoopPoints(void)
Loop or stop the sound effect channels that passed the end of their samples.
u8 * ParseMusicPatternRow(u8 *row)
Read a row of a pattern for every channel and start its notes and effects.
#define g_MusicChannelStates
Definition audio.h:682
#define g_aSoundEffectSamples
Definition audio.h:684
#define g_SilenceSampleData
Definition audio.h:674
#define MUSIC_OCTAVES
Definition audio.h:46
void BuildFrequencyScaleTable(void)
Fill the steps of every note of every octave.
#define AUDIO_THREAD_STACK_WORDS
The console thread that sequences music and fills the audio ring.
Definition audio.h:395
void AudioMixingThreadMain(void *arg)
The mixing thread: on each message of the timer, scale the volumes, mix what the audio interface has ...
SdlMusicState * GetSdlMusicState(void)
#define g_apPatternData
Definition audio.h:680
#define g_bSfxVolume
Definition audio.h:668
#define g_apInstrumentData
Definition audio.h:678
void UpdateMusicPlayback(void)
Run a tick of the music: read a row when one is due, and run the arpeggios, portamentos and volume sl...
void ResetMusicPlaybackState(void)
Stop the music and clear the state of every channel.
#define MUSIC_NOTES
Definition audio.h:47
void SetSoundChannelVolume(s16 channel, u32 levels)
Set the levels of a sound effect channel, the right in the upper half and the left in the lower,...
u8 g_bMusicVolume
The music-volume factor, from 0 to 255.
#define g_bSfxMasterVolume
Definition audio.h:666
#define g_abMusicModuleWorkBuffer
Writable module decoding workspace, valid for this context.
Definition audio.h:660
u8 g_abMenuMusicModule[MENU_MUSIC_MODULE_SIZE]
Storage for the decompressed menu XM module.
void N64StartSoundChannelMuted(s16 channel, s8 *sample, u32 length, u32 loopLength)
StartSoundChannelMuted() of the mixer of the Nintendo 64 release.
void InitMusicPlayback(void *module, void *work)
Start playing an XM module.
#define SILENCE_SAMPLE_BYTES
Silent bytes padded for a mixer block read before an SDL channel stops.
Definition audio.h:219
The hand-written routines of audiomix.s: copies of 64-bit words and the sample mixers,...
#define SOUND_EFFECT_CHANNELS
The channels of the sound effect mixer.
Definition audiomix.h:42
#define AUDIO_RING_BYTES
The bytes of the stereo ring buffer the mixers write.
Definition audiomix.h:17
#define MIXER_CHANNELS
The channels of the music mixer.
Definition audiomix.h:39
The state the renderer shares between the parts of a frame.
Public interface of the libultra operating system, as the game links it.
struct OSTimer_s OSTimer
A timer that sends a message when it expires, once or periodically.
struct OSThread_s OSThread
A thread: its place in the queues, its state, and the registers saved when it last stopped.
struct OSMesgQueue_s OSMesgQueue
A message queue: a ring of messages and the threads blocked sending or receiving.
void * OSMesg
Definition os.h:73
The start of a sample on a sound effect channel.
The sound effects of a race.
A frame of reference: three axes and a position, the rows of a 4 by 4 matrix whose last column Finish...
Definition render.h:30
The state of a channel of the music.
Definition audio.h:64
u8 arpeggio[4]
Definition audio.h:74
u8 effect
Definition audio.h:71
u8 effectParameter
Definition audio.h:72
u8 rowInstrument
Definition audio.h:73
u8 arpeggioOn
Definition audio.h:75
s16 volumeSlide
Definition audio.h:67
u8 volume
Definition audio.h:70
u8 note
Definition audio.h:68
u8 instrument
Definition audio.h:69
u8 pad17
Definition audio.h:76
u64 portamentoTarget
Definition audio.h:65
s16 portamentoSpeed
Definition audio.h:66
The position of the music player in its module.
Definition audio.h:80
u16 pad6
Definition audio.h:84
u8 order
Definition audio.h:87
u16 speed
Definition audio.h:81
u16 rowsLeft
Definition audio.h:83
u16 tick
Definition audio.h:82
u8 restartOrder
Definition audio.h:89
u8 songLength
Definition audio.h:88
u8 pad13[0x18 - 0x13]
Definition audio.h:90
u8 * orders
Definition audio.h:85
u8 * row
Definition audio.h:86
XM playback storage and game volumes for one SDL audio context.
Definition audio.h:633
u8 bgmVolume
Definition audio.h:635
f32 noteFrequencies[MUSIC_NOTES]
Definition audio.h:638
SoundEffectSample samples[SOUND_EFFECT_CHANNELS]
Definition audio.h:645
u8 sfxVolume
Definition audio.h:636
XmSample * instruments[128]
Definition audio.h:642
s8 silence[SILENCE_SAMPLE_BYTES]
Definition audio.h:640
s32 channelCount
Definition audio.h:634
s32 playbackEnabled
Definition audio.h:646
u8 moduleWork[0x100000]
Writable module decoding workspace, valid for this context.
Definition audio.h:650
u8 * patterns[256]
Definition audio.h:643
MusicChannel channels[MIXER_CHANNELS]
Definition audio.h:644
MusicPlayer player
Definition audio.h:647
s32 patternRow
Definition audio.h:639
s16 ring[AUDIO_RING_BYTES/sizeof(s16)]
Definition audio.h:641
u64 frequencySteps[MUSIC_OCTAVES][MUSIC_NOTES]
Definition audio.h:648
u8 sfxMasterVolume
Definition audio.h:637
A sample a sound effect channel plays, and the loop at its end.
Definition audio.h:94
s8 * start
Definition audio.h:95
u32 length
Definition audio.h:96
u32 loopLength
Definition audio.h:97
The header of an XM sample as the player keeps it, followed by its decoded data.
Definition audio.h:50
u8 reserved
Definition audio.h:59
u32 length
Definition audio.h:51
s8 finetune
Definition audio.h:55
char name[22]
Definition audio.h:60
s8 relativeNote
Definition audio.h:58
u8 volume
Definition audio.h:54
u32 loopStart
Definition audio.h:52
u32 loopLength
Definition audio.h:53
u8 panning
Definition audio.h:57
u8 type
Definition audio.h:56
The integer and floating-point types of the console, for headers shared with Windows.
Integer and floating-point types of libultra.
unsigned int u32
Definition ultratypes.h:20
signed char s8
Definition ultratypes.h:23
short s16
Definition ultratypes.h:24
float f32
Definition ultratypes.h:38
unsigned short u16
Definition ultratypes.h:19
int s32
Definition ultratypes.h:25
unsigned long long u64
Definition ultratypes.h:21
unsigned char u8
Definition ultratypes.h:18
The vehicles of a race, the cars they are, and their place on the track.