|
coastline 0.0.4
|
The music player of FastTracker 2 modules, the sound channels, and the mixing thread. More...
#include "common/ambientsound.h"#include "common/audiomix.h"#include "common/soundchannel.h"#include "common/soundeffect.h"#include "common/soundpan.h"#include "common/soundsource.h"#include "common/types.h"

Go to the source code of this file.
Classes | |
| struct | XmSample |
| The header of an XM sample as the player keeps it, followed by its decoded data. More... | |
| struct | MusicChannel |
| The state of a channel of the music. More... | |
| struct | MusicPlayer |
| The position of the music player in its module. More... | |
| struct | SoundEffectSample |
| A sample a sound effect channel plays, and the loop at its end. More... | |
| struct | SdlMusicState |
| XM playback storage and game volumes for one SDL audio context. More... | |
Macros | |
| #define | AUDIO_FREQUENCY 21998 |
| The sample rate the audio interface is asked for. | |
| #define | MUSIC_OCTAVES 10 |
| #define | MUSIC_NOTES 12 |
| #define | MENU_MUSIC_MODULE_SIZE 0x70800 |
| The bytes from the menu music up to the heap at 0x80096400 on the console. | |
| #define | SILENCE_SAMPLE_BYTES 0x1000 |
| Silent bytes padded for a mixer block read before an SDL channel stops. | |
| #define | AUDIO_THREAD_STACK_WORDS 0x80 |
| The console thread that sequences music and fills the audio ring. | |
| #define | g_abMusicModuleWorkBuffer (GetSdlMusicState()->moduleWork) |
| Writable module decoding workspace, valid for this context. | |
| #define | g_nAudioChannelCount (GetSdlMusicState()->channelCount) |
| #define | g_bBgmVolume (GetSdlMusicState()->bgmVolume) |
| #define | g_bSfxMasterVolume (GetSdlMusicState()->sfxMasterVolume) |
| #define | g_bSfxVolume (GetSdlMusicState()->sfxVolume) |
| #define | g_afNoteFrequencies (GetSdlMusicState()->noteFrequencies) |
| #define | g_dwMusicPatternRow (GetSdlMusicState()->patternRow) |
| #define | g_SilenceSampleData (GetSdlMusicState()->silence) |
| #define | g_AudioDmaBuffer (GetSdlMusicState()->ring) |
| #define | g_apInstrumentData (GetSdlMusicState()->instruments) |
| #define | g_apPatternData (GetSdlMusicState()->patterns) |
| #define | g_MusicChannelStates (GetSdlMusicState()->channels) |
| #define | g_aSoundEffectSamples (GetSdlMusicState()->samples) |
| #define | g_bMusicPlaybackEnabled (GetSdlMusicState()->playbackEnabled) |
| #define | g_MusicPlayer (GetSdlMusicState()->player) |
| #define | g_aFreqScaleTable (GetSdlMusicState()->frequencySteps) |
Functions | |
| void | LoadMusicModule (u8 *module, u8 *work) |
| The 32.32 step of each note of each octave. | |
| void | BuildFrequencyScaleTable (void) |
| Fill the steps of every note of every octave. | |
| void | CheckMusicLoopPoints (void) |
| Loop or stop the music 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. | |
| void | ResetMusicChannels (void) |
| Start the music from before its first order. | |
| void | UpdateMusicPlayback (void) |
| Run a tick of the music: read a row when one is due, and run the arpeggios, portamentos and volume slides. | |
| void | InitAudioSystem (void *module, void *work) |
| Start the audio interface, the music player and the mixing thread. | |
| void | ResetMusicPlaybackState (void) |
| Stop the music and clear the state of every channel. | |
| void | InitMusicPlayback (void *module, void *work) |
| Start playing an XM module. | |
| s16 | FindFreeSoundChannel (void) |
| The first sound effect channel that is silent. | |
| 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, each at most 32. | |
| void | CheckSoundEffectLoopPoints (void) |
| Loop or stop the sound effect channels that passed the end of their samples. | |
| void | AudioMixingThreadMain (void *arg) |
| The mixing thread: on each message of the timer, scale the volumes, mix what the audio interface has played, tick the music, and feed the Rumble Paks. | |
| 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 of the same name of the PC release. | |
| void | N64StartSoundChannelMuted (s16 channel, s8 *sample, u32 length, u32 loopLength) |
| StartSoundChannelMuted() of the mixer of the Nintendo 64 release. | |
| SdlMusicState * | GetSdlMusicState (void) |
Variables | |
| u8 | g_abMenuMusicModule [MENU_MUSIC_MODULE_SIZE] |
| Storage for the decompressed menu XM module. | |
| u8 | g_bMusicVolume |
| The music-volume factor, from 0 to 255. | |
| u64 | g_aAudioThreadStack [AUDIO_THREAD_STACK_WORDS] |
| Stack storage for the audio mixing thread, in 64-bit words. | |
The music player of FastTracker 2 modules, the sound channels, and the mixing thread.
The player plays the first sample of each instrument of an XM module, 8-bit and without ping-pong loops, on the channels of the music mixer. A tick comes every other message of a timer of 10 milliseconds, and the mixing thread mixes what the audio interface has played since the last message.
| #define AUDIO_FREQUENCY 21998 |
The sample rate the audio interface is asked for.
| #define MUSIC_OCTAVES 10 |
The octaves of the table of steps.
| #define MUSIC_NOTES 12 |
The notes of each octave of the table of steps.
| #define MENU_MUSIC_MODULE_SIZE 0x70800 |
The bytes from the menu music up to the heap at 0x80096400 on the console.
| #define SILENCE_SAMPLE_BYTES 0x1000 |
Silent bytes padded for a mixer block read before an SDL channel stops.
| #define AUDIO_THREAD_STACK_WORDS 0x80 |
The console thread that sequences music and fills the audio ring.
| #define g_abMusicModuleWorkBuffer (GetSdlMusicState()->moduleWork) |
Writable module decoding workspace, valid for this context.
| #define g_nAudioChannelCount (GetSdlMusicState()->channelCount) |
The number of active music mixer channels, at most MIXER_CHANNELS.
| #define g_bBgmVolume (GetSdlMusicState()->bgmVolume) |
The BGM volume applied to module playback, with zero disabling processing.
| #define g_bSfxMasterVolume (GetSdlMusicState()->sfxMasterVolume) |
The effects master volume, with zero disabling effects processing.
| #define g_bSfxVolume (GetSdlMusicState()->sfxVolume) |
The transient effects level applied beneath the master volume.
| #define g_afNoteFrequencies (GetSdlMusicState()->noteFrequencies) |
Base note frequencies used to build the pitch table.
| #define g_dwMusicPatternRow (GetSdlMusicState()->patternRow) |
The current row within the active music pattern.
| #define g_SilenceSampleData (GetSdlMusicState()->silence) |
Zero-valued sample storage for inactive channels.
| #define g_AudioDmaBuffer (GetSdlMusicState()->ring) |
The interleaved stereo PCM ring buffer.
| #define g_apInstrumentData (GetSdlMusicState()->instruments) |
Decoded instrument headers and samples in moduleWork.
| #define g_apPatternData (GetSdlMusicState()->patterns) |
Pattern headers and packed rows in moduleWork.
| #define g_MusicChannelStates (GetSdlMusicState()->channels) |
Per-channel XM note and effect playback state.
| #define g_aSoundEffectSamples (GetSdlMusicState()->samples) |
Loaded effect sample descriptors.
| #define g_bMusicPlaybackEnabled (GetSdlMusicState()->playbackEnabled) |
Whether the XM player advances music playback.
| #define g_MusicPlayer (GetSdlMusicState()->player) |
The current XM order, row timing, and pattern playback state.
| #define g_aFreqScaleTable (GetSdlMusicState()->frequencySteps) |
32.32 sample-position increments.
The 32.32 step of each note of each octave.
| module | The XM module. |
| work | The memory the player reads the module from. |
| void BuildFrequencyScaleTable | ( | void | ) |
Fill the steps of every note of every octave.
| void CheckMusicLoopPoints | ( | void | ) |
Loop or stop the music channels that passed the end of their samples.
Read a row of a pattern for every channel and start its notes and effects.
| row | The packed data of the row. |
| void ResetMusicChannels | ( | void | ) |
Start the music from before its first order.
| void UpdateMusicPlayback | ( | void | ) |
Run a tick of the music: read a row when one is due, and run the arpeggios, portamentos and volume slides.
| void InitAudioSystem | ( | void * | module, |
| void * | work ) |
Start the audio interface, the music player and the mixing thread.
| module | The XM module to play. |
| work | The memory the player reads the module from. |
| void ResetMusicPlaybackState | ( | void | ) |
Stop the music and clear the state of every channel.
| void InitMusicPlayback | ( | void * | module, |
| void * | work ) |
Start playing an XM module.
| module | The XM module to play. |
| work | The memory the player reads the module from. |
| s16 FindFreeSoundChannel | ( | void | ) |
The first sound effect channel that is silent.
Set the levels of a sound effect channel, the right in the upper half and the left in the lower, each at most 32.
| channel | The sound effect channel. |
| levels | The right level in the upper 16 bits and the left in the lower 16 bits. |
| void CheckSoundEffectLoopPoints | ( | void | ) |
Loop or stop the sound effect channels that passed the end of their samples.
| void AudioMixingThreadMain | ( | void * | arg | ) |
The mixing thread: on each message of the timer, scale the volumes, mix what the audio interface has played, tick the music, and feed the Rumble Paks.
| arg | The argument of the thread, which is not read. |
InitSoundChannel() of the mixer of the Nintendo 64 release, which the SDL game has beside the routine of the same name of the PC release.
| channel | The channel of the sound effects. |
| sample | The signed 8-bit samples. |
| length | The samples before the end. |
| loopLength | The samples the channel goes back at the end, or 0 to stop. |
StartSoundChannelMuted() of the mixer of the Nintendo 64 release.
| channel | The channel of the sound effects. |
| sample | The signed 8-bit samples. |
| length | The samples before the end. |
| loopLength | The samples the channel goes back at the end, or 0 to stop. |
| SdlMusicState * GetSdlMusicState | ( | void | ) |
|
extern |
Storage for the decompressed menu XM module.
|
extern |
The music-volume factor, from 0 to 255.
|
extern |
Stack storage for the audio mixing thread, in 64-bit words.