Classes | |
struct | Channel_t |
struct | Command_t |
A buffer describing a single note. More... | |
struct | EnvelopeMarker_t |
A single entry for sound envelope marking. More... | |
struct | InstrData_t |
struct | PatternData_t |
A buffer describing a group of notes. More... | |
class | SampleDescription |
A buffer describing digital sample for an instrument. More... | |
struct | SongDescription_t |
class | SongPackage |
Public Types | |
enum | eImporterErrors { IMPORT_OKAY , IMPORT_UNKNOWN , IMPORT_BADFILE , IMPORT_TRUNCATION , IMPORT_OUTOFMEMORY } |
enum | eLoopType { LOOP_NORMAL = 0 , LOOP_PINGPONG = 1 } |
enum | eNote { NOTE_MIN =0 , NOTE_MID =40 , NOTE_LAST =95 , NOTE_MAX =96 , NOTE_OFF =254 , NOTE_UNUSED =255 } |
typedef uint_t(*) | ImportProc(SongPackage *pOutput, const uint8_t *pInput, uintptr_t uInputLength) |
Public Member Functions | |
Sequencer (SoundManager *pSoundManager) | |
Constructor for the music sequencer. | |
~Sequencer () | |
Destructor for the music sequencer. | |
uint_t | Init (void) |
Initialize the music sequencer. | |
void | Shutdown (void) |
Dispose of everything in the sequencer. | |
uint_t | AddImporter (ImportProc pImportProc) |
Add a song file importer. | |
uint_t | ImportSong (SongPackage **ppOutput, const uint8_t *pInput, uintptr_t uInputLength) |
Import a song. | |
uint_t | GetVolume (void) const |
void | SetVolume (uint_t uVolume) |
Set the volume of the song. | |
void | ClearChannels (void) |
Clear all of the channels. | |
uint_t | CalculateVolume (const Channel_t *pChannel, uint_t uSpeaker) const |
Calculate the final volume for a voice. | |
uint_t | SetSong (SongPackage *pSongPackage) |
Set the song to play. | |
uint_t | Play (SongPackage *pSongPackage) |
Play a song. | |
uint_t | Play (const void *pInput, uintptr_t uInputLength) |
Play a song. | |
uint_t | Play (const char *pFilename) |
Play a song. | |
uint_t | PlayRez (RezFile *pRezFile, uint_t uRezNum) |
uint_t | StartSequencing (void) |
Start music sequencer. | |
uint_t | StopSequencing (void) |
Stop music sequencer. | |
void | DisposeSong (void) |
Stop music sequencer and release the song. | |
void | Reset (void) |
Reset music sequencer. | |
void | Pause (void) |
Pause music sequencer. | |
void | Resume (void) |
Resume music sequencer. | |
uint_t | GetMaxVoices (void) const |
void | SetMaxVoices (uint_t uMaxVoices) |
Set the maximum number of voices. | |
SoundManager::eDataType | GetOutputDataType (void) const |
void | SetOutputDataType (SoundManager::eDataType uOutputDataType) |
Set the bit size for the final sound output. | |
uint_t | GetSampleRate (void) const |
void | SetSampleRate (uint_t uSampleRate) |
Set the sample rate for the final sound output. | |
uint_t | GetMicroDelayDuration (void) const |
void | SetMicroDelayDuration (uint_t uMicroDelayDuration) |
Set the delay duration. | |
uint_t | GetReverbSize (void) const |
uint_t | GetReverbStrength (void) const |
void | SetReverb (uint_t uReverbSizeMS, uint_t uReverbStrength) |
Set the reverb settings. | |
uint_t | IsPlaying (void) const |
uint_t | IsLooping (void) const |
void | EnableLooping (void) |
void | DisableLooping (void) |
void | SetSoundManager (SoundManager *pSoundManager) |
SoundManager * | GetSoundManager (void) const |
Static Public Member Functions | |
static eNote | AddNoteSaturate (eNote uNote, int32_t iOffset) |
Add a offset to a note and clamp the result. | |
static uint_t | GetNotePeriod (eNote uNote, uint_t uC2Speed) |
Calculate the sample rate period from a note. | |
Static Public Attributes | |
static const uint_t | cAmigaFrequency = 8363 |
Default MOD file sample frequency (7159090/856) | |
static const uint_t | cInstrumentMaxCount = 255 |
Maximum number of instruments. | |
static const uint_t | cSampleMaxCount = 64 |
Maximum number of samples. | |
static const uint_t | cPointerMaxCount = 999 |
Maximum number of track pointers. | |
static const uint_t | cTrackMaxCount = 256 |
Maximum number of tracks. | |
static const uint_t | cPatternMaxCount = 200 |
Maximum number of patterns. | |
static const uint_t | cArpeggioMaxCount = 3 |
Maximum number of arpeggio commands. | |
static const uint_t | cMaxPlugIns = 16 |
Maximum number of song format importers. | |
static const uint_t | cDefaultVolumeFade = 300 |
Default volume fade speed. | |
static const uint_t | cAmigaClock = 14317456 |
Scream Tracker Amiga base clock. | |
static const uint_t | cFixedPointShift = 8 |
Number of bits for fixed point math 24.8. | |
static const uint_t | cMaxVolume = 64 |
Maximum internal volume for commands. | |
static const uint_t | cMaxPan = 64 |
Maximum internal pan for commands. | |
static const uint_t | cMinimumPitch = 113 |
Minimum pitch (Samples per second) | |
static const uint_t | cMaximumPitch = 27392 |
Maximum pitch (Samples per second) | |
static const int32_t | g_VibratoTable [64] |
Vibrato table. | |
Protected Member Functions | |
uint_t | CreateReverbTables (void) |
Create the reverb table. | |
void | DisposeReverbTables (void) |
Get rid of the reverb tables. | |
uint_t | CreateDriverBuffer (void) |
Create the main sound buffer. | |
void | DisposeDriverBuffer (void) |
Get rid of the main sound buffer. | |
uint_t | CreateVolumeBuffer (void) |
Create the main accumulation buffer. | |
void | DisposeVolumeBuffer (void) |
Get rid of the accumulator buffers. | |
void | ProcessTick (Channel_t *pChannel, int32_t *pLeft, int32_t *pRight) |
Process the fading of a buffer. | |
void | DetermineSpeed (void) |
Determine the starting speed of a song. | |
void | PrepareSequencer (void) |
Prepare the sequencer to start music. | |
void | ClearSequencer (void) |
Clear the sequencer from music playback. | |
void | SetChannelCount (void) |
Set up the output channel count. | |
void | Sample8To32AddDelay (Channel_t *pChannel, int32_t *pAccumBuffer) |
Add in a channel's 8 bit sample into a 32 bit stereo buffer. | |
void | Sample16To32AddDelay (Channel_t *pChannel, int32_t *pAccumBuffer) |
Add in a channel's 16 bit sample into a 32 bit stereo buffer. | |
void | Sample8To16AddDelay (Channel_t *pChannel, int16_t *pAccumBuffer) |
Add in a channel's 8 bit sample into a 16 bit stereo buffer. | |
void | Sample16To16AddDelay (Channel_t *pChannel, int16_t *pAccumBuffer) |
Add in a channel's 16 bit sample into a 16 bit stereo buffer. | |
void | Sample8To32AddDelayStereo (Channel_t *pChannel, int32_t *pAccumBuffer) |
Add in a channel's 8 bit stereo sample into a 32 bit stereo buffer. | |
void | Sample16To32AddDelayStereo (Channel_t *pChannel, int32_t *pAccumBuffer) |
Add in a channel's 16 bit stereo sample into a 32 bit stereo buffer. | |
void | Sample8To16AddDelayStereo (Channel_t *pChannel, int16_t *pAccumBuffer) |
Add in a channel's 8 bit stereo sample into a 16 bit stereo buffer. | |
void | Sample16To16AddDelayStereo (Channel_t *pChannel, int16_t *pAccumBuffer) |
Add in a channel's 16 bit stereo sample into a 16 bit stereo buffer. | |
void | MixTo32 (void) |
Mix all channels into the 32 bit buffer. | |
void | MixTo16 (void) |
Mix all channels into the 16 bit buffer. | |
void | GenerateSound (void) |
Mix all the channels into the output buffer. | |
void | ApplySurround (void) |
Apply surround sound to the output buffer. | |
void | PurgeChannels (void) |
Purge all of the channels from playback. | |
void | SetUpEffect (Channel_t *pChannel) |
Process the current active effect. | |
void | DoEffect (Channel_t *pChannel, uint_t uStep) |
Process the current active effect. | |
void | ProcessFadeOut (Channel_t *pChannel) const |
Handle the volume fading. | |
void | ProcessEnvelope (Channel_t *pChannel) const |
Handle the volume envelope. | |
void | ProcessPanning (Channel_t *pChannel) const |
Handle the pan envelope. | |
void | ProcessNote (Channel_t *pChannel, const Command_t *pCommand) |
Process a note on/off command. | |
void | PerformSequencing (void) |
Perform the sequencing and fill the output buffer. | |
uint_t | PlatformInit (void) |
Allocate the platform specific resources. | |
void | PlatformShutdown (void) |
Release the platform specific resources. | |
Static Protected Member Functions | |
static unsigned long __stdcall | ThreadCallback (void *pThis) |
Protected Attributes | |
SoundManager * | m_pSoundManager |
Pointer to the sound manager to send audio data to. | |
IDirectSoundBuffer8 * | m_pDirectSoundBuffer8 |
DirectSoundBuffer (Windows Only) | |
IDirectSoundNotify * | m_pDirectSoundNotify |
DirectSoundNotify for alert when sound is complete (Windows Only) | |
void * | m_hCallback |
HANDLE of the callback thread (Windows only) | |
unsigned long | m_uCallbackID |
ID of the callback thread (Windows only) | |
void * | m_hEvents [cMaxEventCount] |
Events for DirectSound completion functions (Windows Only) | |
SongPackage * | m_pSongPackage |
Current song being played. | |
int32_t * | m_pAccumBuffer32 |
32 bit accumulator buffer (Used for 16 bit samples) | |
int16_t * | m_pAccumBuffer16 |
16 bit accumulator buffer (Used for 8 bit samples) | |
void * | m_pReverbBuffer |
Pointer to the reverb buffer. | |
uintptr_t | m_uReverbDelayBufferSize |
Length in samples of the reverb buffer. | |
void * | m_pBuffer |
Data buffer. | |
uintptr_t | m_uBufferSize |
Size of the data buffer in bytes. | |
uintptr_t | m_uBytesGenerated |
Number of bytes generated and uploaded to sound driver. | |
uintptr_t | m_uBytesToGenerate |
Number of bytes to generate. | |
uintptr_t | m_uChunkSize |
Number of bytes per time quantum (50Hz) | |
uintptr_t | m_uAccumBufferSize |
Size in bytes of the accumulator buffer. | |
uintptr_t | m_uMicroDelayBufferSize |
Size in bytes of the delay buffer. | |
uint_t | m_uImporterCount |
Number of pointers in m_pImporters. | |
uint_t | m_uMaxVoices |
Active number of track for the currently playing song. | |
uint_t | m_uMicroDelayDuration |
Micro delay duration (min 0 ms, max 1000 ms) | |
SoundManager::eDataType | m_eOutputDataType |
Mix to 8 or 16 bit size. | |
uint_t | m_uFinalSampleRate |
Mix to this many samples per second. | |
uint_t | m_uReverbSizeMS |
Reverb delay duration (min 25 ms, max 1000 ms) | |
uint_t | m_uReverbStrength |
Reverb strength in % (0 <-> 70, default 20%) | |
uint_t | m_uVolume |
Burgerlib volume for the song (0-255) | |
uint_t | m_uMasterSpeed |
Current music speed, 80 = normal. | |
uint_t | m_uMasterPitch |
Current music pitch, 80 = normal. | |
uint_t | m_uCurrentSpeed |
Current speed. | |
uint_t | m_uFineSpeed |
Current fine speed. | |
uint_t | m_uPatternPosition |
Current position in pattern. | |
uint_t | m_uCurrentIDPattern |
Current ID Pattern. | |
uint_t | m_uPartitionPosition |
Current position in partition. | |
uint_t | m_uSpeedCounter |
Current mark for song speed. | |
uint8_t | m_bSurroundEnabled |
Surround effect active if TRUE. | |
uint8_t | m_bReverbEnabled |
Reverb effect active if TRUE. | |
uint8_t | m_bTickRemoverEnabled |
Remove volume/sample/loop ticks. | |
uint8_t | m_bRepeatEnabled |
If music finished, repeat if TRUE. | |
uint8_t | m_bSongIsPlaying |
TRUE if song is in progress | |
uint8_t | m_bSequencingInProgress |
TRUE if song is being sequenced | |
uint8_t | m_bPaused |
TRUE if song is paused | |
ImportProc | m_pImporters [cMaxPlugIns] |
Pointers to the active song importers. | |
Channel_t | m_Channels [cTrackMaxCount] |
Current note channels. | |
Static Protected Attributes | |
static const uint_t | cMaxEventCount = 2 |
uint_t( *) Burger::Sequencer::ImportProc(SongPackage *pOutput, const uint8_t *pInput, uintptr_t uInputLength) |
Burger::Sequencer::Sequencer | ( | SoundManager * | pSoundManager | ) |
Constructor for the music sequencer.
Burger::Sequencer::~Sequencer | ( | ) |
Destructor for the music sequencer.
uint_t BURGER_API Burger::Sequencer::AddImporter | ( | ImportProc | pImportProc | ) |
Add a song file importer.
Add a function pointer to the list of file format importers so when a song is attempted to be played, there is a method for extracting the notes into Burgerlib format
pImportProc | Pointer to a function that will parse a song file |
|
static |
Add a offset to a note and clamp the result.
Add a note shift to a note enumeration and return it clamped to be between NOTE_MIN and NOTE_LAST inclusive.
uNote | Parse slide argument to process |
iOffset | Signed value to add to the note |
|
protected |
Apply surround sound to the output buffer.
Assuming the output buffer is stereo, and phase reverse the left channel
uint_t BURGER_API Burger::Sequencer::CalculateVolume | ( | const Channel_t * | pChannel, |
uint_t | uSpeaker ) const |
Calculate the final volume for a voice.
Given a voice and a requested speaker channel, return the volume for the current state of the channel
pChannel | |
uSpeaker | Which speaker to get the volume for (0=left, 1 = right) |
void BURGER_API Burger::Sequencer::ClearChannels | ( | void | ) |
Clear all of the channels.
|
protected |
Clear the sequencer from music playback.
|
protected |
Create the main sound buffer.
|
protected |
Create the reverb table.
|
protected |
Create the main accumulation buffer.
|
protected |
Determine the starting speed of a song.
Parse the patterns from the end and locate the speed and fine speed commands and set the initial speeds to those values to allow the looped speed commands to be effective
|
inline |
|
protected |
Get rid of the main sound buffer.
|
protected |
Get rid of the reverb tables.
void BURGER_API Burger::Sequencer::DisposeSong | ( | void | ) |
Stop music sequencer and release the song.
|
protected |
Get rid of the accumulator buffers.
|
protected |
Process the current active effect.
|
inline |
|
protected |
Mix all the channels into the output buffer.
|
inline |
|
inline |
|
static |
Calculate the sample rate period from a note.
Given a note enumeration and a samples per second fine tuning value assuming 8363 is no adjustment, calculate the samples per second to play a sample
uNote | Note to play |
uC2Speed | Samples per second to play C2 (C one octave higher than middle C) |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
|
inline |
uint_t BURGER_API Burger::Sequencer::ImportSong | ( | SongPackage ** | ppOutput, |
const uint8_t * | pInput, | ||
uintptr_t | uInputLength ) |
Import a song.
Given a song file in memory, try all the song importers until one accepts the file format and converts the song into a SongPackage
ppOutput | Pointer to a pointer that will have a new SongPackage if parsing is successful |
pInput | Pointer to a valid song file |
uInputLength | Length of the valid song file in bytes |
uint_t BURGER_API Burger::Sequencer::Init | ( | void | ) |
Initialize the music sequencer.
|
inline |
|
inline |
|
protected |
Mix all channels into the 16 bit buffer.
|
protected |
Mix all channels into the 32 bit buffer.
void BURGER_API Burger::Sequencer::Pause | ( | void | ) |
Pause music sequencer.
|
protected |
Perform the sequencing and fill the output buffer.
|
protected |
Allocate the platform specific resources.
|
protected |
Release the platform specific resources.
uint_t BURGER_API Burger::Sequencer::Play | ( | const char * | pFilename | ) |
Play a song.
Load a song file and then run the data through an importer and then play the song if there were no importation errors
uint_t BURGER_API Burger::Sequencer::Play | ( | const void * | pInput, |
uintptr_t | uInputLength ) |
Play a song.
Run the data through an importer and then play the song if there were no importation errors
uint_t BURGER_API Burger::Sequencer::Play | ( | SongPackage * | pSongPackage | ) |
Play a song.
uint_t BURGER_API Burger::Sequencer::PlayRez | ( | RezFile * | pRezFile, |
uint_t | uRezNum ) |
|
protected |
Prepare the sequencer to start music.
|
protected |
Handle the volume envelope.
|
protected |
Handle the volume fading.
|
protected |
Process a note on/off command.
|
protected |
Handle the pan envelope.
|
protected |
Process the fading of a buffer.
pChannel | Pointer to a channel to process |
pLeft | Pointer to the left audio buffer |
pRight | Pointer to the right audio buffer |
|
protected |
Purge all of the channels from playback.
void BURGER_API Burger::Sequencer::Reset | ( | void | ) |
Reset music sequencer.
void BURGER_API Burger::Sequencer::Resume | ( | void | ) |
Resume music sequencer.
|
protected |
Add in a channel's 16 bit sample into a 16 bit stereo buffer.
pChannel | Pointer to channel being added |
pAccumBuffer | Pointer to stereo buffer to add in the sample |
|
protected |
Add in a channel's 16 bit stereo sample into a 16 bit stereo buffer.
pChannel | Pointer to channel being added |
pAccumBuffer | Pointer to stereo buffer to add in the sample |
|
protected |
Add in a channel's 16 bit sample into a 32 bit stereo buffer.
pChannel | Pointer to channel being added |
pAccumBuffer | Pointer to stereo buffer to add in the sample |
|
protected |
Add in a channel's 16 bit stereo sample into a 32 bit stereo buffer.
pChannel | Pointer to channel being added |
pAccumBuffer | Pointer to stereo buffer to add in the sample |
|
protected |
Add in a channel's 8 bit sample into a 16 bit stereo buffer.
pChannel | Pointer to channel being added |
pAccumBuffer | Pointer to stereo buffer to add in the sample |
|
protected |
Add in a channel's 8 bit stereo sample into a 16 bit stereo buffer.
pChannel | Pointer to channel being added |
pAccumBuffer | Pointer to stereo buffer to add in the sample |
|
protected |
Add in a channel's 8 bit sample into a 32 bit stereo buffer.
pChannel | Pointer to channel being added |
pAccumBuffer | Pointer to stereo buffer to add in the sample |
|
protected |
Add in a channel's 8 bit stereo sample into a 32 bit stereo buffer.
pChannel | Pointer to channel being added |
pAccumBuffer | Pointer to stereo buffer to add in the sample |
|
protected |
Set up the output channel count.
void BURGER_API Burger::Sequencer::SetMaxVoices | ( | uint_t | uMaxVoices | ) |
Set the maximum number of voices.
uMaxVoices | Maximum number of voices to use |
void BURGER_API Burger::Sequencer::SetMicroDelayDuration | ( | uint_t | uMicroDelayDuration | ) |
Set the delay duration.
uMicroDelayDuration | 0 turns it off and 1000 is one second (In milliseconds) |
void BURGER_API Burger::Sequencer::SetOutputDataType | ( | SoundManager::eDataType | uOutputDataType | ) |
Set the bit size for the final sound output.
uOutputDataType | 8 or 16 to set the bit size. |
void BURGER_API Burger::Sequencer::SetReverb | ( | uint_t | uReverbSizeMS, |
uint_t | uReverbStrength ) |
Set the reverb settings.
uReverbSizeMS | 24 or less turns it off and 1000 is one second (In milliseconds) |
uReverbStrength | 0 turns it off to 70 in percentage (0-70) |
void BURGER_API Burger::Sequencer::SetSampleRate | ( | uint_t | uSampleRate | ) |
Set the sample rate for the final sound output.
uSampleRate | 5000 to 48000 |
uint_t BURGER_API Burger::Sequencer::SetSong | ( | SongPackage * | pSongPackage | ) |
Set the song to play.
|
inline |
|
protected |
Process the current active effect.
void BURGER_API Burger::Sequencer::SetVolume | ( | uint_t | uVolume | ) |
Set the volume of the song.
Set the volume for song playback, 0 = silence, 255 = maximum volume
uVolume | New volume for the song |
void BURGER_API Burger::Sequencer::Shutdown | ( | void | ) |
Dispose of everything in the sequencer.
uint_t BURGER_API Burger::Sequencer::StartSequencing | ( | void | ) |
Start music sequencer.
uint_t BURGER_API Burger::Sequencer::StopSequencing | ( | void | ) |
Stop music sequencer.
|
staticprotected |
|
static |
Scream Tracker Amiga base clock.
|
static |
Default MOD file sample frequency (7159090/856)
C one octave above Middle C is 523.25 Hz. To play this on the Amiga with 16 samples would require a sample rate of 8372 Hz. However, the Amiga has a clock rate of 7,159,090 Hz on NTSC and 7,093,790 Hz for PAL. So, by dividing by 855 and 847 respectively, the effective sample rate is actually 8363 Hz. To reduce the chance of harmonic distortion by sample rate adjusted tuning, samples are optimized at 8363 samples per second.
Hence, this weird magic number used for tuning.
|
static |
Maximum number of arpeggio commands.
|
static |
Default volume fade speed.
|
static |
Number of bits for fixed point math 24.8.
|
static |
Maximum number of instruments.
|
staticprotected |
|
static |
Maximum pitch (Samples per second)
|
static |
Maximum internal pan for commands.
|
static |
Maximum number of song format importers.
|
static |
Maximum internal volume for commands.
|
static |
Minimum pitch (Samples per second)
|
static |
Maximum number of patterns.
|
static |
Maximum number of track pointers.
|
static |
Maximum number of samples.
|
static |
Maximum number of tracks.
|
static |
Vibrato table.
Table with values to use for vibrato.
|
protected |
TRUE if song is paused
|
protected |
If music finished, repeat if TRUE.
|
protected |
Reverb effect active if TRUE.
|
protected |
TRUE if song is being sequenced
|
protected |
TRUE if song is in progress
|
protected |
Surround effect active if TRUE.
|
protected |
Remove volume/sample/loop ticks.
|
protected |
Current note channels.
|
protected |
Mix to 8 or 16 bit size.
|
protected |
HANDLE of the callback thread (Windows only)
|
protected |
Events for DirectSound completion functions (Windows Only)
|
protected |
16 bit accumulator buffer (Used for 8 bit samples)
|
protected |
32 bit accumulator buffer (Used for 16 bit samples)
|
protected |
Data buffer.
|
protected |
DirectSoundBuffer (Windows Only)
|
protected |
DirectSoundNotify for alert when sound is complete (Windows Only)
|
protected |
Pointers to the active song importers.
|
protected |
Pointer to the reverb buffer.
|
protected |
Current song being played.
|
protected |
Pointer to the sound manager to send audio data to.
|
protected |
Size in bytes of the accumulator buffer.
|
protected |
Size of the data buffer in bytes.
|
protected |
Number of bytes generated and uploaded to sound driver.
|
protected |
Number of bytes to generate.
|
protected |
ID of the callback thread (Windows only)
|
protected |
Number of bytes per time quantum (50Hz)
|
protected |
Current ID Pattern.
|
protected |
Current speed.
|
protected |
Mix to this many samples per second.
|
protected |
Current fine speed.
|
protected |
Number of pointers in m_pImporters.
|
protected |
Current music pitch, 80 = normal.
|
protected |
Current music speed, 80 = normal.
|
protected |
Active number of track for the currently playing song.
|
protected |
Size in bytes of the delay buffer.
|
protected |
Micro delay duration (min 0 ms, max 1000 ms)
|
protected |
Current position in partition.
|
protected |
Current position in pattern.
|
protected |
Length in samples of the reverb buffer.
|
protected |
Reverb delay duration (min 25 ms, max 1000 ms)
|
protected |
Reverb strength in % (0 <-> 70, default 20%)
|
protected |
Current mark for song speed.
|
protected |
Burgerlib volume for the song (0-255)