mirror of
https://github.com/zeldaret/mm.git
synced 2026-07-07 13:03:29 -04:00
audio_thread.c OK and Documented (code_80192BE0.c) (#1117)
* copy docs from audio * PR Suggestions Round 1 * more PR suggestions * fix bss * PR Suggestions * oops, duplicate * apply OoT Feedback, fix bss * cleanup * spacing * bss Co-authored-by: angie <angheloalf95@gmail.com>
This commit is contained in:
@@ -0,0 +1,644 @@
|
||||
#ifndef AUDIOTHREAD_CMD_H
|
||||
#define AUDIOTHREAD_CMD_H
|
||||
|
||||
/**
|
||||
* Audio thread commands to safely transfer information/requests/data
|
||||
* from the external graph thread to the internal audio thread
|
||||
*/
|
||||
|
||||
typedef enum {
|
||||
// Channel Commands
|
||||
/* 0x00 */ AUDIOCMD_OP_NOOP,
|
||||
/* 0x01 */ AUDIOCMD_OP_CHANNEL_SET_VOL_SCALE,
|
||||
/* 0x02 */ AUDIOCMD_OP_CHANNEL_SET_VOL,
|
||||
/* 0x03 */ AUDIOCMD_OP_CHANNEL_SET_PAN,
|
||||
/* 0x04 */ AUDIOCMD_OP_CHANNEL_SET_FREQ_SCALE,
|
||||
/* 0x05 */ AUDIOCMD_OP_CHANNEL_SET_REVERB_VOLUME,
|
||||
/* 0x06 */ AUDIOCMD_OP_CHANNEL_SET_IO,
|
||||
/* 0x07 */ AUDIOCMD_OP_CHANNEL_SET_PAN_WEIGHT,
|
||||
/* 0x08 */ AUDIOCMD_OP_CHANNEL_SET_MUTE,
|
||||
/* 0x09 */ AUDIOCMD_OP_CHANNEL_SET_MUTE_FLAGS,
|
||||
/* 0x0A */ AUDIOCMD_OP_CHANNEL_SET_VIBRATO_DEPTH,
|
||||
/* 0x0B */ AUDIOCMD_OP_CHANNEL_SET_VIBRATO_RATE,
|
||||
/* 0x0C */ AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_SIZE,
|
||||
/* 0x0D */ AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_GAIN,
|
||||
/* 0x0E */ AUDIOCMD_OP_CHANNEL_SET_STEREO,
|
||||
/* 0x0F */ AUDIOCMD_OP_CHANNEL_SET_SET_START_POS,
|
||||
/* 0x10 */ AUDIOCMD_OP_CHANNEL_SET_SFX_STATE,
|
||||
/* 0x11 */ AUDIOCMD_OP_CHANNEL_SET_REVERB_INDEX,
|
||||
/* 0x12 */ AUDIOCMD_OP_CHANNEL_SET_SURROUND_EFFECT_INDEX,
|
||||
/* 0x13 */ AUDIOCMD_OP_CHANNEL_SET_FILTER,
|
||||
/* 0x14 */ AUDIOCMD_OP_CHANNEL_SET_GAIN,
|
||||
// SeqPlayer Commands
|
||||
/* 0x41 */ AUDIOCMD_OP_SEQPLAYER_FADE_VOLUME_SCALE = 0x41,
|
||||
/* 0x46 */ AUDIOCMD_OP_SEQPLAYER_SET_IO = 0x46,
|
||||
/* 0x47 */ AUDIOCMD_OP_SEQPLAYER_SET_TEMPO,
|
||||
/* 0x48 */ AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION,
|
||||
/* 0x49 */ AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO,
|
||||
/* 0x4A */ AUDIOCMD_OP_SEQPLAYER_FADE_TO_SET_VOLUME,
|
||||
/* 0x4B */ AUDIOCMD_OP_SEQPLAYER_FADE_TO_SCALED_VOLUME,
|
||||
/* 0x4C */ AUDIOCMD_OP_SEQPLAYER_RESET_VOLUME,
|
||||
/* 0x4D */ AUDIOCMD_OP_SEQPLAYER_SET_BEND,
|
||||
/* 0x4E */ AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO_TICKS,
|
||||
// Global Commands
|
||||
/* 0x81 */ AUDIOCMD_OP_GLOBAL_SYNC_LOAD_SEQ_PARTS = 0x81,
|
||||
/* 0x82 */ AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER,
|
||||
/* 0x83 */ AUDIOCMD_OP_GLOBAL_DISABLE_SEQPLAYER,
|
||||
/* 0x85 */ AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS = 0x85,
|
||||
/* 0x90 */ AUDIOCMD_OP_GLOBAL_SET_CHANNEL_MASK = 0x90,
|
||||
/* 0xE0 */ AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT = 0xE0,
|
||||
/* 0xE1 */ AUDIOCMD_OP_GLOBAL_SET_SFX_FONT,
|
||||
/* 0xE2 */ AUDIOCMD_OP_GLOBAL_SET_INSTRUMENT_FONT,
|
||||
/* 0xE3 */ AUDIOCMD_OP_GLOBAL_POP_PERSISTENT_CACHE,
|
||||
/* 0xE4 */ AUDIOCMD_OP_GLOBAL_SET_CUSTOM_FUNCTION, // TODO: check
|
||||
/* 0xE5 */ AUDIOCMD_OP_GLOBAL_E5, // TODO: check
|
||||
/* 0xE6 */ AUDIOCMD_OP_GLOBAL_SET_REVERB_DATA,
|
||||
/* 0xF0 */ AUDIOCMD_OP_GLOBAL_SET_SOUND_MODE = 0xF0,
|
||||
/* 0xF1 */ AUDIOCMD_OP_GLOBAL_MUTE,
|
||||
/* 0xF2 */ AUDIOCMD_OP_GLOBAL_UNMUTE,
|
||||
/* 0xF3 */ AUDIOCMD_OP_GLOBAL_SYNC_LOAD_INSTRUMENT,
|
||||
/* 0xF4 */ AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK,
|
||||
/* 0xF5 */ AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT,
|
||||
/* 0xF6 */ AUDIOCMD_OP_GLOBAL_DISCARD_SEQ_FONTS,
|
||||
/* 0xF8 */ AUDIOCMD_OP_GLOBAL_STOP_AUDIOCMDS = 0xF8,
|
||||
/* 0xF9 */ AUDIOCMD_OP_GLOBAL_RESET_AUDIO_HEAP,
|
||||
/* 0xFA */ AUDIOCMD_OP_GLOBAL_NOOP_1, // used but no code exists for it
|
||||
/* 0xFB */ AUDIOCMD_OP_GLOBAL_SET_CUSTOM_UPDATE_FUNCTION,
|
||||
/* 0xFC */ AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SEQ,
|
||||
/* 0xFD */ AUDIOCMD_OP_GLOBAL_NOOP_2, // used but no code exists for it
|
||||
/* 0xFE */ AUDIOCMD_OP_GLOBAL_DISABLE_ALL_SEQPLAYERS
|
||||
} AudioThreadCmdOp;
|
||||
|
||||
#define AUDIO_MK_CMD(b0, b1, b2, b3) (_SHIFTL(b0, 24, 8) | _SHIFTL(b1, 16, 8) | _SHIFTL(b2, 8, 8) | _SHIFTL(b3, 0, 8))
|
||||
|
||||
#define AUDIOCMD_ALL_SEQPLAYERS 0xFF
|
||||
// Pass to a AUDIOCMD_CHANNEL_ command in place of a channelIndex to try and apply to all channels.
|
||||
// Then uses `threadCmdChannelMask` to determine which channels to apply the command to.
|
||||
#define AUDIOCMD_ALL_CHANNELS 0xFF
|
||||
|
||||
// ==== Audio Thread Channel Commands ====
|
||||
|
||||
/**
|
||||
* Set the volumeScale on a given channel
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param volumeScale (f32) the volume scale for the sequence. No change in volume is 1.0f
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_VOL_SCALE(seqPlayerIndex, channelIndex, volumeScale) \
|
||||
AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_VOL_SCALE, seqPlayerIndex, channelIndex, 0), \
|
||||
volumeScale)
|
||||
|
||||
/**
|
||||
* Set the volume on a given channel
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param volume (f32) the target volume for the sequence. Default volume is 1.0f
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_VOL(seqPlayerIndex, channelIndex, volume) \
|
||||
AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_VOL, seqPlayerIndex, channelIndex, 0), volume)
|
||||
|
||||
/**
|
||||
* Set the pan
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param pan (s8) the pan applied to the channel
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_PAN(seqPlayerIndex, channelIndex, pan) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_PAN, seqPlayerIndex, channelIndex, 0), pan)
|
||||
|
||||
/**
|
||||
* Set frequency scale
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param freqScale (f32) the scaling factor to shift the pitch.
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_FREQ_SCALE(seqPlayerIndex, channelIndex, freqScale) \
|
||||
AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_FREQ_SCALE, seqPlayerIndex, channelIndex, 0), \
|
||||
freqScale)
|
||||
|
||||
/**
|
||||
* Set reverb volume
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param reverbVolume (s8) volume to set the reverb to (dry/wet mix)
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_REVERB_VOLUME(seqPlayerIndex, channelIndex, reverbVolume) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_REVERB_VOLUME, seqPlayerIndex, channelIndex, 0), \
|
||||
reverbVolume)
|
||||
|
||||
/**
|
||||
* Write a value that can be read as input directly by the sequence itself. This will be set to the channel
|
||||
* ioPort, which will only affect a single channel
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to write the input to
|
||||
* @param channelIndex the index of the channel to write the input to
|
||||
* @param ioPort the index of the array to store the input-output value
|
||||
* @param ioData (s8) the value that's written to the input-output array
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_IO(seqPlayerIndex, channelIndex, ioPort, ioData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_IO, seqPlayerIndex, channelIndex, ioPort), ioData)
|
||||
|
||||
/**
|
||||
* Set the proportion of pan that comes from the channel
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param panChannelWeight (u8) proportion of pan that comes from the channel.
|
||||
* Set to 0 for layer-only, and 128 for channel-only.
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_PAN_WEIGHT(seqPlayerIndex, channelIndex, panChannelWeight) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_PAN_WEIGHT, seqPlayerIndex, channelIndex, 0), \
|
||||
panChannelWeight)
|
||||
|
||||
/**
|
||||
* Mute a specified channel. How a muted channel behaves will depend on channel mute flags
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param muted (s8) set true to mute
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_MUTE(seqPlayerIndex, channelIndex, muted) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_MUTE, seqPlayerIndex, channelIndex, 0), muted)
|
||||
|
||||
/**
|
||||
* Set the muteFlags for a specified channel
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param muteFlags (s8) Affected how a muted channel behaves. See `MUTE_BEHAVIOR_` macros
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_MUTE_FLAGS(seqPlayerIndex, channelIndex, muteFlags) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_MUTE_FLAGS, seqPlayerIndex, channelIndex, 0), muteFlags)
|
||||
|
||||
/**
|
||||
* Set the vibrato depth (magnitude/amplitude/extent)
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param vibratoDepthTarget (s8) the vibrato depth scaled down by 1/8th
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_VIBRATO_DEPTH(seqPlayerIndex, channelIndex, vibratoDepthTarget) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_VIBRATO_DEPTH, seqPlayerIndex, channelIndex, 0), \
|
||||
vibratoDepthTarget)
|
||||
|
||||
/**
|
||||
* Set the vibrato rate (freq/pitch)
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param vibratoRateTarget (s8) the vibrato rate scaled down by 1/32nd
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_VIBRATO_RATE(seqPlayerIndex, channelIndex, vibratoRateTarget) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_VIBRATO_RATE, seqPlayerIndex, channelIndex, 0), \
|
||||
vibratoRateTarget)
|
||||
|
||||
/**
|
||||
* Set the comb filter size
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param combFilterSize (s8) delay number of sample bytes to offset and add back to itself
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_COMB_FILTER_SIZE(seqPlayerIndex, channelIndex, combFilterSize) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_SIZE, seqPlayerIndex, channelIndex, 0), \
|
||||
combFilterSize)
|
||||
|
||||
/**
|
||||
* Set the comb filter gain
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param combFilterGain (u16) strength of the signal added back to itself
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_COMB_FILTER_GAIN(seqPlayerIndex, channelIndex, combFilterGain) \
|
||||
AudioThread_QueueCmdU16(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_GAIN, seqPlayerIndex, channelIndex, 0), \
|
||||
combFilterGain)
|
||||
|
||||
/**
|
||||
* Set the stereo bits
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param stereoData (s8) bit-packed stereo information. See `StereoData`
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_STEREO(seqPlayerIndex, channelIndex, stereoData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_STEREO, seqPlayerIndex, channelIndex, 0), stereoData)
|
||||
|
||||
/**
|
||||
* Set the start position of a sample.
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the seqPlayer to modify
|
||||
* @param startSamplePos
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_SET_START_POS(seqPlayerIndex, channelIndex, startSamplePos) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_SET_START_POS, seqPlayerIndex, channelIndex, 0), \
|
||||
startSamplePos)
|
||||
|
||||
/**
|
||||
* Set the address of the sfxState to read from.
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the seqPlayer to modify
|
||||
* @param sfxState
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_SFX_STATE(seqPlayerIndex, channelIndex, sfxState) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_SFX_STATE, seqPlayerIndex, channelIndex, 0), sfxState)
|
||||
|
||||
/**
|
||||
* Set the reverb index.
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the seqPlayer to modify
|
||||
* @param reverbIndex
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_REVERB_INDEX(seqPlayerIndex, channelIndex, reverbIndex) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_REVERB_INDEX, seqPlayerIndex, channelIndex, 0), \
|
||||
reverbIndex)
|
||||
|
||||
/**
|
||||
* Set the surround effect index.
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the seqPlayer to modify
|
||||
* @param surroundEffectIndex
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_SURROUND_EFFECT_INDEX(seqPlayerIndex, channelIndex, surroundEffectIndex) \
|
||||
AudioThread_QueueCmdS8( \
|
||||
AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_SURROUND_EFFECT_INDEX, seqPlayerIndex, channelIndex, 0), \
|
||||
surroundEffectIndex)
|
||||
|
||||
/**
|
||||
* Set a filter.
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the seqPlayer to modify
|
||||
* @param filterCutoff
|
||||
* @param filter
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_FILTER(seqPlayerIndex, channelIndex, filterCutoff, filter) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_FILTER, seqPlayerIndex, channelIndex, filterCutoff), \
|
||||
filter)
|
||||
|
||||
/**
|
||||
* Set the gain.
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the seqPlayer to modify
|
||||
* @param gain
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_GAIN(seqPlayerIndex, channelIndex, gain) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_GAIN, seqPlayerIndex, channelIndex, 0), gain)
|
||||
|
||||
// ==== Audio Thread SeqPlayer Commands ====
|
||||
|
||||
/**
|
||||
* Set the fade volume scale
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param fadeVolumeScale (f32) multiplicative scaling factor to apply to volume
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_FADE_VOLUME_SCALE(seqPlayerIndex, fadeVolumeScale) \
|
||||
AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_FADE_VOLUME_SCALE, seqPlayerIndex, 0, 0), \
|
||||
fadeVolumeScale)
|
||||
|
||||
/**
|
||||
* Write a value that can be read as input directly by the sequence itself. This will be set to the global
|
||||
* ioPort, which can affect the entire sequence
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to write the input to
|
||||
* @param ioPort the index of the array to store the input-output value
|
||||
* @param ioData (s8) the value that's written to the input-output array
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_SET_IO(seqPlayerIndex, ioPort, ioData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_IO, seqPlayerIndex, 0, ioPort), ioData)
|
||||
|
||||
/**
|
||||
* Set the tempo (bpm) of a sequence on a given seqPlayer
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param tempo (s32) the tempo for the sequence, in bpm
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_SET_TEMPO(seqPlayerIndex, tempo) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_TEMPO, seqPlayerIndex, 0, 0), tempo)
|
||||
|
||||
/**
|
||||
* Set the transposition
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param transposition (s8) the number of semitones to increase or decrease by for all notes on the seqPlayer
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_SET_TRANSPOSITION(seqPlayerIndex, transposition) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION, seqPlayerIndex, 0, 0), transposition)
|
||||
|
||||
/**
|
||||
* Set tempoChange in bpm
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param tempoChange (s32) difference in tempo to change, in bpm
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_CHANGE_TEMPO(seqPlayerIndex, tempoChange) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO, seqPlayerIndex, 0, 0), tempoChange)
|
||||
|
||||
/**
|
||||
* Set tempoChange in ticks per minute
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param tempoChange (s32) difference in tempo to change, in ticks per minute
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_CHANGE_TEMPO_TICKS(seqPlayerIndex, tempoChange) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO_TICKS, seqPlayerIndex, 0, 0), tempoChange)
|
||||
|
||||
/**
|
||||
* Fade the volume to the target volume requested in the command
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param fadeVolume target volume to fade to
|
||||
* @param fadeTimer (s32) number of ticks to fade to `fadeVolume`
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_FADE_TO_SET_VOLUME(seqPlayerIndex, fadeVolume, fadeTimer) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_FADE_TO_SET_VOLUME, seqPlayerIndex, fadeVolume, 0), \
|
||||
fadeTimer)
|
||||
|
||||
/**
|
||||
* Fade the volume to the current volume scaled by a scale factor
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param fadeVolumeScale scaling factor to apply to volume to get the targetVolume
|
||||
* @param fadeTimer (s32) number of ticks to fade to `targetVolume`
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_FADE_TO_SCALED_VOLUME(seqPlayerIndex, fadeVolumeScale, fadeTimer) \
|
||||
AudioThread_QueueCmdS32( \
|
||||
AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_FADE_TO_SCALED_VOLUME, seqPlayerIndex, fadeVolumeScale, 0), fadeTimer)
|
||||
|
||||
/**
|
||||
* Reset to the default volume of the seqPlayer
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param fadeTimer (s32) number of ticks to fade the sequence back to its default volume
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_RESET_VOLUME(seqPlayerIndex, fadeTimer) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_RESET_VOLUME, seqPlayerIndex, 0, 0), fadeTimer)
|
||||
|
||||
/**
|
||||
* Set the bend
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param bend (f32) ratio relative to 1.0f to scale channel frequencies by
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_SET_BEND(seqPlayerIndex, bend) \
|
||||
AudioThread_QueueCmdF32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_SET_BEND, seqPlayerIndex, 0, 0), bend)
|
||||
|
||||
// ==== Audio Thread Global Commands ====
|
||||
|
||||
/**
|
||||
* Synchronously load a sequence in parts
|
||||
*
|
||||
* @param seqId the id of the sequence to load, see `SeqId`
|
||||
* @param flags set `& 1` to load the sequence, set `& 2` to load the soundfonts
|
||||
* @param data
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SYNC_LOAD_SEQ_PARTS(seqId, flags, data) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SYNC_LOAD_SEQ_PARTS, 0, seqId, flags), data)
|
||||
|
||||
/**
|
||||
* Synchronously initialize a sequence player
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param seqId the id of the sequence to play, see `SeqId`
|
||||
* @param fadeInTimer (s32) number of ticks to fade in the sequence to the requested volume
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_INIT_SEQPLAYER(seqPlayerIndex, seqId, fadeInTimer) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER, seqPlayerIndex, seqId, 0), fadeInTimer)
|
||||
|
||||
/**
|
||||
* Disable a sequence player
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param fadeOutTimer (s32) number of ticks to fade out the sequence
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(seqPlayerIndex, fadeOutTimer) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_DISABLE_SEQPLAYER, seqPlayerIndex, 0, 0), fadeOutTimer)
|
||||
|
||||
/**
|
||||
* Synchronously initialize a sequence player and skip ticks,
|
||||
* allowing the sequence to start somewhere other than the beginning of the sequences
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param seqId the id of the sequence to play, see `SeqId`
|
||||
* @param skipTicks (s32) number of ticks to skip before starting the sequence
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS(seqPlayerIndex, seqId, skipTicks) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS, seqPlayerIndex, seqId, 0), \
|
||||
skipTicks)
|
||||
|
||||
/**
|
||||
* When processing an audio thread channel command on all channels, set which channels to process
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param threadCmdChannelMask (u16) bitfield for 16 channels. Turn bit on to allow audio thread commands of type
|
||||
* "Channel" to process that channel with `AUDIOCMD_ALL_CHANNELS` set.
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(seqPlayerIndex, threadCmdChannelMask) \
|
||||
AudioThread_QueueCmdU16(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_CHANNEL_MASK, seqPlayerIndex, 0, 0), \
|
||||
threadCmdChannelMask)
|
||||
|
||||
/**
|
||||
* Set a drum ptr within a soundfont
|
||||
*
|
||||
* @param fontId the id of the soundfont to set the drum in
|
||||
* @param drumId the id of the drum to set
|
||||
* @param drumPtr (s32) the ptr to the `Drum` struct
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SET_DRUM_FONT(fontId, drumId, drumPtr) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT, 0, fontId, drumId), drumPtr)
|
||||
|
||||
/**
|
||||
* Set a soundeffect ptr within a soundfont
|
||||
*
|
||||
* @param fontId the id of the soundfont to set the sound effect in
|
||||
* @param soundEffectId the id of the sound effect to set
|
||||
* @param soundEffectPtr (s32) the ptr to the `SoundEffect` struct
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SET_SFX_FONT(fontId, soundEffectId, soundEffectPtr) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_SFX_FONT, 0, fontId, soundEffectId), soundEffectPtr)
|
||||
|
||||
/**
|
||||
* Set an instrument ptr within a soundfont
|
||||
*
|
||||
* @param fontId the id of the soundfont to set the instrument in
|
||||
* @param instId the id of the instrument to set
|
||||
* @param instPtr (s32) the ptr to the `Instrument` struct
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SET_INSTRUMENT_FONT(fontId, instId, instPtr) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_INSTRUMENT_FONT, 0, fontId, instId), instPtr)
|
||||
|
||||
/**
|
||||
* Pop the persistent cache of the specified table
|
||||
*
|
||||
* @param tableType (s32) see the `SampleBankTableType` enum
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(tableType) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_POP_PERSISTENT_CACHE, 0, 0, 0), tableType)
|
||||
|
||||
/**
|
||||
* Set a custom function.
|
||||
*
|
||||
* @param functionType
|
||||
* @param functionPtr
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(functionType, functionPtr) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_CUSTOM_FUNCTION, 0, 0, functionType), functionPtr)
|
||||
|
||||
/**
|
||||
* Do something related to the unloaded-type audio data in the heap.
|
||||
*
|
||||
* @param tableType
|
||||
* @param id
|
||||
* @param type
|
||||
* @param data
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_E5(tableType, id, type, data) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_E5, tableType, id, type), data)
|
||||
|
||||
/**
|
||||
* Set reverb data.
|
||||
*
|
||||
* @param reverbIndex
|
||||
* @param dataType
|
||||
* @param data
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SET_REVERB_DATA(reverbIndex, dataType, data) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_REVERB_DATA, dataType, reverbIndex, 0), data)
|
||||
|
||||
/**
|
||||
* Change the sound mode of audio
|
||||
*
|
||||
* @param soundMode (s32) see the `SoundMode` enum
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SET_SOUND_MODE(soundMode) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_SOUND_MODE, 0, 0, 0), soundMode)
|
||||
|
||||
/**
|
||||
* Mute a sequence player
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_MUTE(seqPlayerIndex) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_MUTE, seqPlayerIndex, 0, 0), 0)
|
||||
|
||||
/**
|
||||
* Unmute a sequence player
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param restart (s32) if set to 1, then notes with the `MUTE_FLAGS_STOP_SAMPLES` flag set are marked as finished
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_UNMUTE(seqPlayerIndex, restart) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_UNMUTE, seqPlayerIndex, 0, 0), restart)
|
||||
|
||||
/**
|
||||
* Synchronously load an instrument
|
||||
*
|
||||
* @param fontId the id of the soundfont to load
|
||||
* @param instId If below 0x7F, the id of the instrument to use. If equal to 0x7F, load the drum using the drumId
|
||||
* @param drumId the id of the drum to use
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SYNC_LOAD_INSTRUMENT(fontId, instId, drumId) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SYNC_LOAD_INSTRUMENT, fontId, instId, drumId), 0)
|
||||
|
||||
/**
|
||||
* Asynchronously load a sample bank
|
||||
*
|
||||
* @param sampleBankId the id of the samplebank to load
|
||||
* @param retData return data from `externalLoadQueue`
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_ASYNC_LOAD_SAMPLE_BANK(sampleBankId, retData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK, sampleBankId, 0, retData), 0)
|
||||
|
||||
/**
|
||||
* Asynchronously load a font
|
||||
*
|
||||
* @param fontId the id of the soundfont to load
|
||||
* @param retData return data from `externalLoadQueue`
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_ASYNC_LOAD_FONT(fontId, retData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT, fontId, 20, retData), 0)
|
||||
|
||||
/**
|
||||
* Discard sequence fonts
|
||||
*
|
||||
* @param seqId the id of the sequence to discard, see `SeqId`
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_DISCARD_SEQ_FONTS(seqId) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_DISCARD_SEQ_FONTS, 0, seqId, 0), 0)
|
||||
|
||||
/**
|
||||
* Stop processing all audio thread commands
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_STOP_AUDIOCMDS() \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_STOP_AUDIOCMDS, 0, 0, 0), 0)
|
||||
|
||||
/**
|
||||
* Reset Audio Heap
|
||||
*
|
||||
* @param specId (s32) index for the audio specifications to set high-level audio parameters
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_RESET_AUDIO_HEAP(specId) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_RESET_AUDIO_HEAP, 0, 0, 0), specId)
|
||||
|
||||
/**
|
||||
* No Operation. No code exists for this OP
|
||||
*
|
||||
* @param arg0 No info
|
||||
* @param arg1 No info
|
||||
* @param arg2 No info
|
||||
* @param data (s32) No info
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_NOOP_1(arg0, arg1, arg2, data) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_NOOP_1, arg0, arg1, arg2), data)
|
||||
|
||||
/**
|
||||
* Set a custom function that runs every audio thread update, see `AudioCustomUpdateFunction`
|
||||
*
|
||||
* @param functionPtr (s32) address of the function to run once every audio frame
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SET_CUSTOM_UPDATE_FUNCTION(functionPtr) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SET_CUSTOM_UPDATE_FUNCTION, 0, 0, 0), functionPtr)
|
||||
|
||||
/**
|
||||
* Asynchronously load a sequence
|
||||
*
|
||||
* @param seqId the id of the sequence to load, see `SeqId`
|
||||
* @param retData return data from `externalLoadQueue`
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_ASYNC_LOAD_SEQ(seqId, retData) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SEQ, seqId, 0, retData), 0)
|
||||
|
||||
/**
|
||||
* No Operation. No code exists for this OP
|
||||
*
|
||||
* @param arg0 No info
|
||||
* @param arg1 No info
|
||||
* @param arg2 No info
|
||||
* @param data (s32) No info
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_NOOP_2(arg0, arg1, arg2, data) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_NOOP_2, arg0, arg1, arg2), data)
|
||||
|
||||
/**
|
||||
* Disable all sequence players
|
||||
*
|
||||
* @param flags (s32) Set `AUDIO_NOTE_RELEASE` to discard all sequences.
|
||||
*
|
||||
* @note Also set `AUDIO_NOTE_SAMPLE_NOTES` will also only discard sampled notes, but the sequences are disabled anyway.
|
||||
* Not setting `AUDIO_NOTE_RELEASE` should make this command useless
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_DISABLE_ALL_SEQPLAYERS(flags) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_DISABLE_ALL_SEQPLAYERS, 0, 0, 0), flags)
|
||||
|
||||
#endif
|
||||
+10
-31
@@ -2820,39 +2820,18 @@ void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* isDone);
|
||||
void AudioLoad_ProcessScriptLoads(void);
|
||||
void AudioLoad_InitScriptLoads(void);
|
||||
|
||||
AudioTask* func_80192BE0(void);
|
||||
// void func_80192C00(void);
|
||||
// void func_8019319C(void);
|
||||
// void func_801936D8(void);
|
||||
// void func_8019372C(void);
|
||||
// void func_80193774(void);
|
||||
// void func_8019380C(void);
|
||||
// void func_80193858(void);
|
||||
AudioTask* AudioThread_Update(void);
|
||||
void AudioThread_QueueCmdF32(u32 opArgs, f32 data);
|
||||
void AudioThread_QueueCmdS32(u32 opArgs, s32 data);
|
||||
void AudioThread_QueueCmdS8(u32 opArgs, s8 data);
|
||||
// void func_801938D0(void);
|
||||
void AudioThread_QueueCmdU16(u32 opArgs, u16 data);
|
||||
s32 AudioThread_ScheduleProcessCmds(void);
|
||||
// void func_80193990(void);
|
||||
// void func_801939A8(void);
|
||||
// void func_80193AEC(void);
|
||||
// void func_80193BA0(void);
|
||||
// void func_80193C04(void);
|
||||
// void func_80193C5C(void);
|
||||
// void func_80193CB4(void);
|
||||
// void func_80193D08(void);
|
||||
// void func_80193DA4(void);
|
||||
// void func_80193E6C(void);
|
||||
// void func_80193EA8(void);
|
||||
// void func_80194080(void);
|
||||
// void func_80194304(void);
|
||||
// void func_80194328(void);
|
||||
// void func_8019435C(void);
|
||||
// void func_8019439C(void);
|
||||
// void func_801943D0(void);
|
||||
// void func_8019440C(UNK_TYPE1 param_1, UNK_TYPE1 param_2, UNK_TYPE1 param_3, UNK_TYPE1 param_4, UNK_TYPE4 param_5);
|
||||
// void func_80194528(void);
|
||||
// void func_80194548(void);
|
||||
// void func_80194568(void);
|
||||
u32 AudioThread_GetExternalLoadQueueMsg(u32* retMsg);
|
||||
u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts);
|
||||
s32 func_80193C5C(void);
|
||||
s32 AudioThread_ResetAudioHeap(s32 specId);
|
||||
void AudioThread_PreNMIInternal(void);
|
||||
s32 AudioThread_GetEnabledNotesCount(void);
|
||||
u32 AudioThread_NextRandom(void);
|
||||
void AudioThread_InitMesgQueues(void);
|
||||
|
||||
@@ -2894,7 +2873,7 @@ void* AudioSeq_AudioListPopBack(AudioListItem* list);
|
||||
void AudioSeq_ProcessSequences(s32 arg0);
|
||||
void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer);
|
||||
void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer);
|
||||
void AudioSeq_InitSequencePlayerChannels(s32 playerIndex);
|
||||
void AudioSeq_InitSequencePlayerChannels(s32 seqPlayerIndex);
|
||||
void AudioSeq_InitSequencePlayers(void);
|
||||
|
||||
void func_8019AE40(s32 param_1, s32 param_2, u32 param_3, s32 param_4);
|
||||
|
||||
+5
-11
@@ -909,14 +909,9 @@ extern UNK_PTR D_801D5FE0;
|
||||
// extern UNK_TYPE1 D_801D5FE4;
|
||||
extern s32 gAudioCtxInitalized;
|
||||
// extern UNK_TYPE4 D_801D5FEC;
|
||||
// extern UNK_TYPE4 D_801D5FF0;
|
||||
// extern UNK_TYPE4 D_801D5FF4;
|
||||
// extern UNK_TYPE1 D_801D5FF8;
|
||||
// extern UNK_TYPE4 D_801D5FFC;
|
||||
extern UNK_PTR D_801D6000;
|
||||
// extern UNK_TYPE4 D_801D6190;
|
||||
// extern UNK_TYPE4 D_801D6194;
|
||||
// extern UNK_TYPE1 D_801D6200;
|
||||
extern u8 D_801D6200[0x400];
|
||||
extern u8 gIsLargeSfxBank[7];
|
||||
extern u8 D_801D6608[7];
|
||||
extern u8 gChannelsPerBank[4][7];
|
||||
@@ -2293,7 +2288,6 @@ extern u8 gSoundFontTable[];
|
||||
extern u8 gSequenceFontTable[];
|
||||
extern u8 gSequenceTable[];
|
||||
extern u8 gSampleBankTable[];
|
||||
extern u64 aspMainDataStart[];
|
||||
|
||||
// bss
|
||||
// extern UNK_TYPE1 D_801ED890;
|
||||
@@ -2791,10 +2785,10 @@ extern ActiveSequence gActiveSeqs[];
|
||||
// extern UNK_TYPE1 D_80200BCE;
|
||||
// extern UNK_TYPE1 D_80200BD0;
|
||||
extern AudioContext gAudioCtx; // at 0x80200C70
|
||||
extern void (*gCustomAudioUpdateFunction)(void);
|
||||
extern u32 (*gCustomAudioSeqFunction)(s8 value, SequenceChannel* channel);
|
||||
extern s32 (*gCustomAudioReverbFunction)(Sample*, s32, s8, s32);
|
||||
extern Acmd* (*gCustomAudioSynthFunction)(Acmd*, s32, s32);
|
||||
extern AudioCustomUpdateFunction gAudioCustomUpdateFunction;
|
||||
extern AudioCustomSeqFunction gAudioCustomSeqFunction;
|
||||
extern AudioCustomReverbFunction gAudioCustomReverbFunction;
|
||||
extern AudioCustomSynthFunction gAudioCustomSynthFunction;
|
||||
|
||||
// post-code buffers
|
||||
extern u8 gGfxSPTaskYieldBuffer[OS_YIELD_DATA_SIZE];
|
||||
|
||||
+52
-34
@@ -1,7 +1,7 @@
|
||||
#ifndef Z64_AUDIO_H
|
||||
#define Z64_AUDIO_H
|
||||
|
||||
#define AUDIO_MK_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0))
|
||||
#include "audiothread_cmd.h"
|
||||
|
||||
#define NO_LAYER ((SequenceLayer*)(-1))
|
||||
|
||||
@@ -11,16 +11,25 @@
|
||||
#define SEQ_NUM_CHANNELS 16
|
||||
#define SEQ_IO_VAL_NONE -1
|
||||
|
||||
typedef enum {
|
||||
/* 0x00 */ AUDIO_CUSTOM_FUNCTION_SEQ_0,
|
||||
/* 0x01 */ AUDIO_CUSTOM_FUNCTION_SEQ_1,
|
||||
/* 0x02 */ AUDIO_CUSTOM_FUNCTION_SEQ_2,
|
||||
/* 0x03 */ AUDIO_CUSTOM_FUNCTION_SEQ_3,
|
||||
/* 0xFE */ AUDIO_CUSTOM_FUNCTION_SYNTH = 0xFE,
|
||||
/* 0xFF */ AUDIO_CUSTOM_FUNCTION_REVERB
|
||||
} AudioCustomFunctions;
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ SEQPLAYER_STATE_0,
|
||||
/* 1 */ SEQPLAYER_STATE_1, // Fading in
|
||||
/* 2 */ SEQPLAYER_STATE_2 // Fading out
|
||||
/* 1 */ SEQPLAYER_STATE_FADE_IN,
|
||||
/* 2 */ SEQPLAYER_STATE_FADE_OUT
|
||||
} SeqPlayerState;
|
||||
|
||||
#define MAX_CHANNELS_PER_BANK 3
|
||||
|
||||
#define MUTE_FLAGS_3 (1 << 3) // prevent further noteSubEus from playing
|
||||
#define MUTE_FLAGS_4 (1 << 4) // stop something in seqLayer scripts
|
||||
#define MUTE_FLAGS_STOP_SAMPLES (1 << 3) // prevent further noteSubEus from playing
|
||||
#define MUTE_FLAGS_STOP_LAYER (1 << 4) // stop something in seqLayer scripts
|
||||
#define MUTE_FLAGS_SOFTEN (1 << 5) // lower volume, by default to half
|
||||
#define MUTE_FLAGS_STOP_NOTES (1 << 6) // prevent further notes from playing
|
||||
#define MUTE_FLAGS_STOP_SCRIPT (1 << 7) // stop processing sequence/channel scripts
|
||||
@@ -58,6 +67,10 @@ typedef enum {
|
||||
|
||||
#define REVERB_INDEX_NONE -1
|
||||
|
||||
// To be used with AudioThread_CountAndReleaseNotes()
|
||||
#define AUDIO_NOTE_RELEASE (1 << 0)
|
||||
#define AUDIO_NOTE_SAMPLE_NOTES (1 << 1)
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ REVERB_DATA_TYPE_SETTINGS, // Reverb Settings (Init)
|
||||
/* 1 */ REVERB_DATA_TYPE_DELAY, // Reverb Delay (numSamples)
|
||||
@@ -353,11 +366,11 @@ typedef struct {
|
||||
/* 0x007 */ s8 playerIndex;
|
||||
/* 0x008 */ u16 tempo; // tatums per minute
|
||||
/* 0x00A */ u16 tempoAcc;
|
||||
/* 0x00C */ s16 unk_0C;
|
||||
/* 0x00C */ s16 tempoChange;
|
||||
/* 0x00E */ s16 transposition;
|
||||
/* 0x010 */ u16 delay;
|
||||
/* 0x012 */ u16 fadeTimer;
|
||||
/* 0x014 */ u16 fadeTimerUnkEu;
|
||||
/* 0x014 */ u16 storedFadeTimer;
|
||||
/* 0x016 */ u16 unk_16;
|
||||
/* 0x018 */ u8* seqData;
|
||||
/* 0x01C */ f32 fadeVolume;
|
||||
@@ -374,8 +387,8 @@ typedef struct {
|
||||
/* 0x09C */ NotePool notePool;
|
||||
/* 0x0DC */ s32 skipTicks;
|
||||
/* 0x0E0 */ u32 scriptCounter;
|
||||
/* 0x0E4 */ char unk_E4[0x74]; // unused struct members for sequence/sound font dma management, according to sm64 decomp
|
||||
/* 0x158 */ s8 soundScriptIO[8];
|
||||
/* 0x0E4 */ UNK_TYPE1 unk_E4[0x74]; // unused struct members for sequence/sound font dma management, according to sm64 decomp
|
||||
/* 0x158 */ s8 seqScriptIO[8];
|
||||
} SequencePlayer; // size = 0x160
|
||||
|
||||
typedef struct {
|
||||
@@ -387,7 +400,7 @@ typedef struct {
|
||||
typedef struct {
|
||||
union {
|
||||
struct {
|
||||
/* 0x00 */ u8 unk_0b80 : 1;
|
||||
/* 0x00 */ u8 unused : 1;
|
||||
/* 0x00 */ u8 hang : 1;
|
||||
/* 0x00 */ u8 decay : 1;
|
||||
/* 0x00 */ u8 release : 1;
|
||||
@@ -402,7 +415,7 @@ typedef struct {
|
||||
/* 0x0C */ f32 fadeOutVel;
|
||||
/* 0x10 */ f32 current;
|
||||
/* 0x14 */ f32 target;
|
||||
/* 0x18 */ char unk_18[4];
|
||||
/* 0x18 */ UNK_TYPE1 unk_18[4];
|
||||
/* 0x1C */ EnvelopePoint* envelope;
|
||||
} AdsrState; // size = 0x20
|
||||
|
||||
@@ -434,11 +447,11 @@ typedef struct {
|
||||
|
||||
typedef struct VibratoSubStruct {
|
||||
/* 0x0 */ u16 vibratoRateStart;
|
||||
/* 0x2 */ u16 vibratoExtentStart;
|
||||
/* 0x2 */ u16 vibratoDepthStart;
|
||||
/* 0x4 */ u16 vibratoRateTarget;
|
||||
/* 0x6 */ u16 vibratoExtentTarget;
|
||||
/* 0x6 */ u16 vibratoDepthTarget;
|
||||
/* 0x8 */ u16 vibratoRateChangeDelay;
|
||||
/* 0xA */ u16 vibratoExtentChangeDelay;
|
||||
/* 0xA */ u16 vibratoDepthChangeDelay;
|
||||
/* 0xC */ u16 vibratoDelay;
|
||||
} VibratoSubStruct; // size = 0xE
|
||||
|
||||
@@ -447,7 +460,7 @@ typedef struct SequenceChannel {
|
||||
/* 0x00 */ u8 enabled : 1;
|
||||
/* 0x00 */ u8 finished : 1;
|
||||
/* 0x00 */ u8 stopScript : 1;
|
||||
/* 0x00 */ u8 stopSomething2 : 1; // sets SequenceLayer.stopSomething
|
||||
/* 0x00 */ u8 muted : 1; // sets SequenceLayer.muted
|
||||
/* 0x00 */ u8 hasInstrument : 1;
|
||||
/* 0x00 */ u8 stereoHeadsetEffects : 1;
|
||||
/* 0x00 */ u8 largeNotes : 1; // notes specify duration and velocity
|
||||
@@ -475,7 +488,7 @@ typedef struct SequenceChannel {
|
||||
/* 0x0E */ u8 gateTimeRandomVariance;
|
||||
/* 0x0F */ u8 combFilterSize;
|
||||
/* 0x10 */ u8 surroundEffectIndex;
|
||||
/* 0x11 */ u8 unk_11;
|
||||
/* 0x11 */ u8 channelIndex;
|
||||
/* 0x12 */ VibratoSubStruct vibrato;
|
||||
/* 0x20 */ u16 delay;
|
||||
/* 0x22 */ u16 combFilterGain;
|
||||
@@ -497,7 +510,7 @@ typedef struct SequenceChannel {
|
||||
/* 0x64 */ SeqScriptState scriptState;
|
||||
/* 0x80 */ AdsrSettings adsr;
|
||||
/* 0x88 */ NotePool notePool;
|
||||
/* 0xC8 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib, "io ports"
|
||||
/* 0xC8 */ s8 seqScriptIO[8]; // bridge between sound script and audio lib, "io ports"
|
||||
/* 0xD0 */ u8* sfxState; // SfxChannelState
|
||||
/* 0xD4 */ s16* filter;
|
||||
/* 0xD8 */ StereoData stereoData;
|
||||
@@ -509,7 +522,7 @@ typedef struct SequenceChannel {
|
||||
typedef struct SequenceLayer {
|
||||
/* 0x00 */ u8 enabled : 1;
|
||||
/* 0x00 */ u8 finished : 1;
|
||||
/* 0x00 */ u8 stopSomething : 1;
|
||||
/* 0x00 */ u8 muted : 1;
|
||||
/* 0x00 */ u8 continuousNotes : 1; // keep the same note for consecutive notes with the same sound
|
||||
/* 0x00 */ u8 bit3 : 1; // "loaded"?
|
||||
/* 0x00 */ u8 ignoreDrumPan : 1;
|
||||
@@ -605,11 +618,11 @@ typedef struct {
|
||||
/* 0x00 */ struct VibratoSubStruct* vibSubStruct; // Something else?
|
||||
/* 0x04 */ u32 time;
|
||||
/* 0x08 */ s16* curve;
|
||||
/* 0x0C */ f32 extent;
|
||||
/* 0x0C */ f32 depth;
|
||||
/* 0x10 */ f32 rate;
|
||||
/* 0x14 */ u8 active;
|
||||
/* 0x16 */ u16 rateChangeTimer;
|
||||
/* 0x18 */ u16 extentChangeTimer;
|
||||
/* 0x18 */ u16 depthChangeTimer;
|
||||
/* 0x1A */ u16 delay;
|
||||
} VibratoState; // size = 0x1C
|
||||
|
||||
@@ -984,7 +997,7 @@ typedef struct {
|
||||
/* 0x28B0 */ s32 sampleDmaBufSize;
|
||||
/* 0x28B4 */ s32 maxAudioCmds;
|
||||
/* 0x28B8 */ s32 numNotes;
|
||||
/* 0x2898 */ s16 tempoInternalToExternal;
|
||||
/* 0x2898 */ s16 maxTempo;
|
||||
/* 0x28BE */ s8 soundMode;
|
||||
/* 0x28C0 */ s32 totalTaskCount; // The total number of times the top-level function on the audio thread is run since the last audio reset
|
||||
/* 0x28C4 */ s32 curAudioFrameDmaCount;
|
||||
@@ -997,13 +1010,13 @@ typedef struct {
|
||||
/* 0x2980 */ f32 unk_2960;
|
||||
/* 0x2984*/ s32 refreshRate;
|
||||
/* 0x2988 */ s16* aiBuffers[3]; // Pointers to the audio buffer allocated on the initPool contained in the audio heap. Stores fully processed digital audio before transferring to the audio interface (AI)
|
||||
/* 0x2994 */ s16 aiBufNumSamples[3]; // Number of samples to transfer to the audio interface buffer
|
||||
/* 0x2994 */ s16 numSamplesPerFrame[3]; // Number of samples to transfer to the audio interface buffer
|
||||
/* 0x299C */ u32 audioRandom;
|
||||
/* 0x29A0 */ s32 audioErrorFlags;
|
||||
/* 0x29A4 */ volatile u32 resetTimer;
|
||||
/* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel);
|
||||
/* 0x29A8 */ u32 (*customSeqFunctions[4])(s8 value, SequenceChannel* channel);
|
||||
/* 0x29B8 */ s8 unk_29B8;
|
||||
/* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt
|
||||
/* 0x29BC */ s32 numAbiCmdsMax; // sMaxAbiCmdCnt
|
||||
/* 0x29C0 */ AudioAllocPool sessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset
|
||||
/* 0x29D0 */ AudioAllocPool externalPool; // pool allocated on an external device. Never used in game
|
||||
/* 0x29E0 */ AudioAllocPool initPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset
|
||||
@@ -1027,7 +1040,7 @@ typedef struct {
|
||||
/* 0x4398 */ u8 fontLoadStatus[0x30];
|
||||
/* 0x43C8 */ u8 seqLoadStatus[0x80];
|
||||
/* 0x4448 */ volatile u8 resetStatus;
|
||||
/* 0x4449 */ u8 audioResetSpecIdToLoad;
|
||||
/* 0x4449 */ u8 specId;
|
||||
/* 0x444C */ s32 audioResetFadeOutFramesLeft;
|
||||
/* 0x4450 */ f32* adsrDecayTable; // A table on the audio heap that stores decay rates used for ADSR
|
||||
/* 0x4454 */ u8* audioHeap;
|
||||
@@ -1039,21 +1052,21 @@ typedef struct {
|
||||
/* 0x7924 */ s32 sampleStateOffset; // Start of the list of sample states for this update. Resets after each audio frame.
|
||||
/* 0x7928 */ AudioListItem layerFreeList;
|
||||
/* 0x7938 */ NotePool noteFreeLists;
|
||||
/* 0x7978 */ u8 cmdWritePos;
|
||||
/* 0x7979 */ u8 cmdReadPos;
|
||||
/* 0x797A */ u8 cmdQueueFinished;
|
||||
/* 0x797C */ u16 activeChannelsFlags[5]; // bit-packed for 16 channels. Only channels with bit turned on will be processed
|
||||
/* 0x7978 */ u8 threadCmdWritePos;
|
||||
/* 0x7979 */ u8 threadCmdReadPos;
|
||||
/* 0x797A */ u8 threadCmdQueueFinished;
|
||||
/* 0x797C */ u16 threadCmdChannelMask[5]; // bit-packed for 16 channels. When processing an audio thread channel command on all channels, only process channels with their bit set.
|
||||
/* 0x7988 */ OSMesgQueue* audioResetQueueP;
|
||||
/* 0x798C */ OSMesgQueue* taskStartQueueP;
|
||||
/* 0x7990 */ OSMesgQueue* cmdProcQueueP;
|
||||
/* 0x7990 */ OSMesgQueue* threadCmdProcQueueP;
|
||||
/* 0x7994 */ OSMesgQueue taskStartQueue;
|
||||
/* 0x79AC */ OSMesgQueue cmdProcQueue;
|
||||
/* 0x79AC */ OSMesgQueue threadCmdProcQueue;
|
||||
/* 0x79C4 */ OSMesgQueue audioResetQueue;
|
||||
/* 0x79DC */ OSMesg taskStartMsgs[1];
|
||||
/* 0x79E0 */ OSMesg audioResetMesgs[1];
|
||||
/* 0x79E4 */ OSMesg cmdProcMsgs[4];
|
||||
/* 0x79F4 */ AudioCmd cmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread
|
||||
/* 0x81F4 */ char unk_81F4[4];
|
||||
/* 0x79E4 */ OSMesg threadCmdProcMsgBuf[4];
|
||||
/* 0x79F4 */ AudioCmd threadCmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread
|
||||
/* 0x81F4 */ UNK_TYPE1 unk_81F4[4];
|
||||
} AudioContext; // size = 0x81F8
|
||||
|
||||
typedef struct {
|
||||
@@ -1255,4 +1268,9 @@ typedef struct {
|
||||
/* 0x2 */ u16 params;
|
||||
} SfxParams; // size = 0x4
|
||||
|
||||
typedef void (*AudioCustomUpdateFunction)(void);
|
||||
typedef u32 (*AudioCustomSeqFunction)(s8 value, SequenceChannel* channel);
|
||||
typedef s32 (*AudioCustomReverbFunction)(Sample*, s32, s8, s32);
|
||||
typedef Acmd* (*AudioCustomSynthFunction)(Acmd*, s32, s32);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -609,8 +609,7 @@ beginseg
|
||||
include "build/src/code/audio/audio_heap.o"
|
||||
include "build/data/code/audio_heap.bss.o"
|
||||
include "build/src/code/audio/audio_load.o"
|
||||
include "build/src/code/audio/code_80192BE0.o"
|
||||
include "build/data/code/code_80192BE0.data.o"
|
||||
include "build/src/code/audio/audio_thread.o"
|
||||
include "build/src/code/audio/audio_dcache.o"
|
||||
include "build/src/code/audio/aisetnextbuf.o"
|
||||
include "build/src/code/audio/audio_playback.o"
|
||||
|
||||
@@ -63,7 +63,7 @@ void AudioEffects_SequencePlayerProcessSound(SequencePlayer* seqPlayer) {
|
||||
}
|
||||
|
||||
seqPlayer->fadeTimer--;
|
||||
if ((seqPlayer->fadeTimer == 0) && (seqPlayer->state == SEQPLAYER_STATE_2)) {
|
||||
if ((seqPlayer->fadeTimer == 0) && (seqPlayer->state == SEQPLAYER_STATE_FADE_OUT)) {
|
||||
AudioSeq_SequencePlayerDisable(seqPlayer);
|
||||
return;
|
||||
}
|
||||
@@ -112,10 +112,10 @@ f32 AudioEffects_GetVibratoFreqScale(VibratoState* vib) {
|
||||
static f32 activeVibratoFreqScaleSum = 0.0f;
|
||||
static s32 activeVibratoCount = 0;
|
||||
f32 pitchChange;
|
||||
f32 extent;
|
||||
f32 invExtent;
|
||||
f32 depth;
|
||||
f32 invDepth;
|
||||
f32 result;
|
||||
f32 scaledExtent;
|
||||
f32 scaledDepth;
|
||||
VibratoSubStruct* subVib = vib->vibSubStruct;
|
||||
|
||||
if (vib->delay != 0) {
|
||||
@@ -124,17 +124,17 @@ f32 AudioEffects_GetVibratoFreqScale(VibratoState* vib) {
|
||||
}
|
||||
|
||||
if (subVib != NULL) {
|
||||
if (vib->extentChangeTimer) {
|
||||
if (vib->extentChangeTimer == 1) {
|
||||
vib->extent = (s32)subVib->vibratoExtentTarget;
|
||||
if (vib->depthChangeTimer) {
|
||||
if (vib->depthChangeTimer == 1) {
|
||||
vib->depth = (s32)subVib->vibratoDepthTarget;
|
||||
} else {
|
||||
vib->extent += ((s32)subVib->vibratoExtentTarget - vib->extent) / (s32)vib->extentChangeTimer;
|
||||
vib->depth += ((s32)subVib->vibratoDepthTarget - vib->depth) / (s32)vib->depthChangeTimer;
|
||||
}
|
||||
|
||||
vib->extentChangeTimer--;
|
||||
} else if (subVib->vibratoExtentTarget != (s32)vib->extent) {
|
||||
if ((vib->extentChangeTimer = subVib->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = (s32)subVib->vibratoExtentTarget;
|
||||
vib->depthChangeTimer--;
|
||||
} else if (subVib->vibratoDepthTarget != (s32)vib->depth) {
|
||||
if ((vib->depthChangeTimer = subVib->vibratoDepthChangeDelay) == 0) {
|
||||
vib->depth = (s32)subVib->vibratoDepthTarget;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -153,17 +153,17 @@ f32 AudioEffects_GetVibratoFreqScale(VibratoState* vib) {
|
||||
}
|
||||
}
|
||||
|
||||
if (vib->extent == 0.0f) {
|
||||
if (vib->depth == 0.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
pitchChange = AudioEffects_GetVibratoPitchChange(vib) + 32768.0f;
|
||||
scaledExtent = vib->extent / 4096.0f;
|
||||
extent = scaledExtent + 1.0f;
|
||||
invExtent = 1.0f / extent;
|
||||
scaledDepth = vib->depth / 4096.0f;
|
||||
depth = scaledDepth + 1.0f;
|
||||
invDepth = 1.0f / depth;
|
||||
|
||||
// inverse linear interpolation
|
||||
result = 1.0f / ((extent - invExtent) * pitchChange / 65536.0f + invExtent);
|
||||
result = 1.0f / ((depth - invDepth) * pitchChange / 65536.0f + invDepth);
|
||||
|
||||
activeVibratoFreqScaleSum += result;
|
||||
activeVibratoCount++;
|
||||
@@ -196,10 +196,10 @@ void AudioEffects_NoteVibratoInit(Note* note) {
|
||||
|
||||
subVib = vib->vibSubStruct;
|
||||
|
||||
if ((vib->extentChangeTimer = subVib->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = (s32)subVib->vibratoExtentTarget;
|
||||
if ((vib->depthChangeTimer = subVib->vibratoDepthChangeDelay) == 0) {
|
||||
vib->depth = (s32)subVib->vibratoDepthTarget;
|
||||
} else {
|
||||
vib->extent = (s32)subVib->vibratoExtentStart;
|
||||
vib->depth = (s32)subVib->vibratoDepthStart;
|
||||
}
|
||||
|
||||
if ((vib->rateChangeTimer = subVib->vibratoRateChangeDelay) == 0) {
|
||||
|
||||
@@ -836,7 +836,7 @@ void AudioHeap_ClearAiBuffers(void) {
|
||||
s32 curAiBufferIndex = gAudioCtx.curAiBufferIndex;
|
||||
s32 i;
|
||||
|
||||
gAudioCtx.aiBufNumSamples[curAiBufferIndex] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMin;
|
||||
gAudioCtx.numSamplesPerFrame[curAiBufferIndex] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMin;
|
||||
|
||||
for (i = 0; i < AIBUF_LEN; i++) {
|
||||
gAudioCtx.aiBuffers[curAiBufferIndex][i] = 0;
|
||||
@@ -905,8 +905,8 @@ s32 AudioHeap_ResetStep(void) {
|
||||
case 1:
|
||||
AudioHeap_Init();
|
||||
gAudioCtx.resetStatus = 0;
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioCtx.aiBufNumSamples); i++) {
|
||||
gAudioCtx.aiBufNumSamples[i] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMax;
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioCtx.numSamplesPerFrame); i++) {
|
||||
gAudioCtx.numSamplesPerFrame[i] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMax;
|
||||
for (j = 0; j < AIBUF_LEN; j++) {
|
||||
gAudioCtx.aiBuffers[i][j] = 0;
|
||||
}
|
||||
@@ -932,7 +932,7 @@ void AudioHeap_Init(void) {
|
||||
s32 reverbIndex;
|
||||
s32 i;
|
||||
s32 pad2;
|
||||
AudioSpec* spec = &gAudioSpecs[gAudioCtx.audioResetSpecIdToLoad]; // Audio Specifications
|
||||
AudioSpec* spec = &gAudioSpecs[gAudioCtx.specId]; // Audio Specifications
|
||||
|
||||
gAudioCtx.sampleDmaCount = 0;
|
||||
|
||||
@@ -970,15 +970,15 @@ void AudioHeap_Init(void) {
|
||||
gAudioCtx.audioBufferParameters.numSequencePlayers = 5;
|
||||
}
|
||||
|
||||
gAudioCtx.unk_29BC = 8;
|
||||
gAudioCtx.numAbiCmdsMax = 8;
|
||||
gAudioCtx.unk_2 = spec->unk_14;
|
||||
gAudioCtx.tempoInternalToExternal =
|
||||
gAudioCtx.maxTempo =
|
||||
(u32)(gAudioCtx.audioBufferParameters.updatesPerFrame * 2880000.0f / gTatumsPerBeat / gAudioCtx.unk_2960);
|
||||
|
||||
gAudioCtx.unk_2870 = gAudioCtx.refreshRate;
|
||||
gAudioCtx.unk_2870 *= gAudioCtx.audioBufferParameters.updatesPerFrame;
|
||||
gAudioCtx.unk_2870 /= gAudioCtx.audioBufferParameters.aiSamplingFreq;
|
||||
gAudioCtx.unk_2870 /= gAudioCtx.tempoInternalToExternal;
|
||||
gAudioCtx.unk_2870 /= gAudioCtx.maxTempo;
|
||||
|
||||
gAudioCtx.audioBufferParameters.specUnk4 = spec->unk_04;
|
||||
gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget *= gAudioCtx.audioBufferParameters.specUnk4;
|
||||
|
||||
@@ -1212,12 +1212,12 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||
s32 i;
|
||||
s32 j;
|
||||
|
||||
gCustomAudioUpdateFunction = NULL;
|
||||
gCustomAudioReverbFunction = NULL;
|
||||
gCustomAudioSynthFunction = NULL;
|
||||
gAudioCustomUpdateFunction = NULL;
|
||||
gAudioCustomReverbFunction = NULL;
|
||||
gAudioCustomSynthFunction = NULL;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioCtx.unk_29A8); i++) {
|
||||
gAudioCtx.unk_29A8[i] = NULL;
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioCtx.customSeqFunctions); i++) {
|
||||
gAudioCtx.customSeqFunctions[i] = NULL;
|
||||
}
|
||||
|
||||
gAudioCtx.resetTimer = 0;
|
||||
@@ -1248,8 +1248,8 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||
|
||||
AudioThread_InitMesgQueues();
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioCtx.aiBufNumSamples); i++) {
|
||||
gAudioCtx.aiBufNumSamples[i] = 0xA0;
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioCtx.numSamplesPerFrame); i++) {
|
||||
gAudioCtx.numSamplesPerFrame[i] = 0xA0;
|
||||
}
|
||||
|
||||
gAudioCtx.totalTaskCount = 0;
|
||||
@@ -1301,7 +1301,7 @@ void AudioLoad_Init(void* heap, size_t heapSize) {
|
||||
|
||||
gAudioCtx.numSequences = gAudioCtx.sequenceTable->numEntries;
|
||||
|
||||
gAudioCtx.audioResetSpecIdToLoad = 0;
|
||||
gAudioCtx.specId = 0;
|
||||
gAudioCtx.resetStatus = 1; // Set reset to immediately initialize the audio heap
|
||||
AudioHeap_ResetStep();
|
||||
|
||||
|
||||
@@ -309,7 +309,7 @@ void AudioPlayback_ProcessNotes(void) {
|
||||
subAttrs.combFilterGain = channel->combFilterGain;
|
||||
bookOffset = channel->bookOffset & 0x7;
|
||||
|
||||
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) {
|
||||
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_STOP_SAMPLES)) {
|
||||
subAttrs.frequency = 0.0f;
|
||||
subAttrs.velocity = 0.0f;
|
||||
}
|
||||
@@ -531,7 +531,7 @@ void AudioPlayback_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
||||
|
||||
attrs->combFilterGain = channel->combFilterGain;
|
||||
attrs->combFilterSize = channel->combFilterSize;
|
||||
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_3)) {
|
||||
if (channel->seqPlayer->muted && (channel->muteFlags & MUTE_FLAGS_STOP_SAMPLES)) {
|
||||
note->sampleState.bitField0.finished = true;
|
||||
}
|
||||
|
||||
|
||||
@@ -123,7 +123,7 @@ u8 sSeqInstructionArgsTable[] = {
|
||||
CMD_ARGS_1(u8), // 0xD5 ()
|
||||
CMD_ARGS_1(u8), // 0xD6 ()
|
||||
CMD_ARGS_1(u8), // 0xD7 (channel: set vibrato rate)
|
||||
CMD_ARGS_1(u8), // 0xD8 (channel: set vibrato extent)
|
||||
CMD_ARGS_1(u8), // 0xD8 (channel: set vibrato depth)
|
||||
CMD_ARGS_1(u8), // 0xD9 (channel: set decay index)
|
||||
CMD_ARGS_1(s16), // 0xDA (channel: set envelope)
|
||||
CMD_ARGS_1(u8), // 0xDB (channel: transpose)
|
||||
@@ -133,7 +133,7 @@ u8 sSeqInstructionArgsTable[] = {
|
||||
CMD_ARGS_1(u8), // 0xDF (channel: set volume)
|
||||
CMD_ARGS_1(u8), // 0xE0 (channel: set volume scale)
|
||||
CMD_ARGS_3(u8, u8, u8), // 0xE1 (channel: set vibratorate linear)
|
||||
CMD_ARGS_3(u8, u8, u8), // 0xE2 (channel: set vibrato extent linear)
|
||||
CMD_ARGS_3(u8, u8, u8), // 0xE2 (channel: set vibrato depth linear)
|
||||
CMD_ARGS_1(u8), // 0xE3 (channel: set vibrato delay)
|
||||
CMD_ARGS_0(), // 0xE4 (channel: dyncall)
|
||||
CMD_ARGS_1(u8), // 0xE5 (channel: set reverb index)
|
||||
@@ -276,7 +276,7 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) {
|
||||
channel->enabled = false;
|
||||
channel->finished = false;
|
||||
channel->stopScript = false;
|
||||
channel->stopSomething2 = false;
|
||||
channel->muted = false;
|
||||
channel->hasInstrument = false;
|
||||
channel->stereoHeadsetEffects = false;
|
||||
channel->transposition = 0;
|
||||
@@ -302,10 +302,10 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) {
|
||||
channel->adsr.sustain = 0;
|
||||
channel->vibrato.vibratoRateTarget = 0x800;
|
||||
channel->vibrato.vibratoRateStart = 0x800;
|
||||
channel->vibrato.vibratoExtentTarget = 0;
|
||||
channel->vibrato.vibratoExtentStart = 0;
|
||||
channel->vibrato.vibratoDepthTarget = 0;
|
||||
channel->vibrato.vibratoDepthStart = 0;
|
||||
channel->vibrato.vibratoRateChangeDelay = 0;
|
||||
channel->vibrato.vibratoExtentChangeDelay = 0;
|
||||
channel->vibrato.vibratoDepthChangeDelay = 0;
|
||||
channel->vibrato.vibratoDelay = 0;
|
||||
channel->filter = NULL;
|
||||
channel->combFilterGain = 0;
|
||||
@@ -314,8 +314,8 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) {
|
||||
channel->volumeScale = 1.0f;
|
||||
channel->freqScale = 1.0f;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(channel->soundScriptIO); i++) {
|
||||
channel->soundScriptIO[i] = SEQ_IO_VAL_NONE;
|
||||
for (i = 0; i < ARRAY_COUNT(channel->seqScriptIO); i++) {
|
||||
channel->seqScriptIO[i] = SEQ_IO_VAL_NONE;
|
||||
}
|
||||
|
||||
channel->unused = false;
|
||||
@@ -348,7 +348,7 @@ s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) {
|
||||
layer->targetReverbVol = channel->targetReverbVol;
|
||||
layer->enabled = true;
|
||||
layer->finished = false;
|
||||
layer->stopSomething = false;
|
||||
layer->muted = false;
|
||||
layer->continuousNotes = false;
|
||||
layer->bit3 = false;
|
||||
layer->ignoreDrumPan = false;
|
||||
@@ -370,10 +370,10 @@ s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) {
|
||||
layer->unk_0A.asByte = 0xFFFF;
|
||||
layer->vibrato.vibratoRateTarget = 0x800;
|
||||
layer->vibrato.vibratoRateStart = 0x800;
|
||||
layer->vibrato.vibratoExtentTarget = 0;
|
||||
layer->vibrato.vibratoExtentStart = 0;
|
||||
layer->vibrato.vibratoDepthTarget = 0;
|
||||
layer->vibrato.vibratoDepthStart = 0;
|
||||
layer->vibrato.vibratoRateChangeDelay = 0;
|
||||
layer->vibrato.vibratoExtentChangeDelay = 0;
|
||||
layer->vibrato.vibratoDepthChangeDelay = 0;
|
||||
layer->vibrato.vibratoDelay = 0;
|
||||
layer->freqScale = 1.0f;
|
||||
layer->bend = 1.0f;
|
||||
@@ -562,9 +562,9 @@ void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) {
|
||||
|
||||
if (layer->delay > 1) {
|
||||
layer->delay--;
|
||||
if (!layer->stopSomething && (layer->delay <= layer->gateDelay)) {
|
||||
if (!layer->muted && (layer->delay <= layer->gateDelay)) {
|
||||
AudioPlayback_SeqLayerNoteDecay(layer);
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -590,7 +590,7 @@ void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) {
|
||||
AudioSeq_SeqLayerProcessScriptStep5(layer, cmd);
|
||||
}
|
||||
|
||||
if (layer->stopSomething == true) {
|
||||
if (layer->muted == true) {
|
||||
if ((layer->note != NULL) || layer->continuousNotes) {
|
||||
AudioPlayback_SeqLayerNoteDecay(layer);
|
||||
}
|
||||
@@ -856,7 +856,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
|
||||
drum = AudioPlayback_GetDrum(channel->fontId, semitone);
|
||||
if (drum == NULL) {
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
layer->delay2 = layer->delay;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
@@ -879,7 +879,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
|
||||
soundEffect = AudioPlayback_GetSoundEffect(channel->fontId, sfxId);
|
||||
if (soundEffect == NULL) {
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
layer->delay2 = layer->delay + 1;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
@@ -895,7 +895,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
|
||||
layer->semitone = semitone;
|
||||
if (semitone >= 0x80) {
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
@@ -948,7 +948,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
portamento->extent = (freqScale2 / freqScale) - 1.0f;
|
||||
|
||||
if (PORTAMENTO_IS_SPECIAL(*portamento)) {
|
||||
speed = seqPlayer->tempo * 0x8000 / gAudioCtx.tempoInternalToExternal;
|
||||
speed = seqPlayer->tempo * 0x8000 / gAudioCtx.maxTempo;
|
||||
if (layer->delay != 0) {
|
||||
speed = speed * 0x100 / (layer->delay * layer->portamentoTime);
|
||||
}
|
||||
@@ -1011,7 +1011,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
// (It's a bit unclear if 'portamento' has actually always been
|
||||
// set when this is reached...)
|
||||
if (PORTAMENTO_IS_SPECIAL(*portamento)) {
|
||||
speed2 = seqPlayer->tempo * 0x8000 / gAudioCtx.tempoInternalToExternal;
|
||||
speed2 = seqPlayer->tempo * 0x8000 / gAudioCtx.maxTempo;
|
||||
speed2 = speed2 * 0x100 / (layer->delay * layer->portamentoTime);
|
||||
if (speed2 >= 0x7FFF) {
|
||||
speed2 = 0x7FFF;
|
||||
@@ -1036,12 +1036,12 @@ s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) {
|
||||
|
||||
if (cmd == 0xC0) { // layer: delay
|
||||
layer->delay = AudioSeq_ScriptReadCompressedU16(state);
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
layer->bit1 = false;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
layer->stopSomething = false;
|
||||
layer->muted = false;
|
||||
|
||||
if (channel->largeNotes == true) {
|
||||
switch (cmd & 0xC0) {
|
||||
@@ -1124,14 +1124,14 @@ s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) {
|
||||
}
|
||||
}
|
||||
|
||||
if ((seqPlayer->muted && (channel->muteFlags & (MUTE_FLAGS_STOP_NOTES | MUTE_FLAGS_4))) ||
|
||||
channel->stopSomething2) {
|
||||
layer->stopSomething = true;
|
||||
if ((seqPlayer->muted && (channel->muteFlags & (MUTE_FLAGS_STOP_NOTES | MUTE_FLAGS_STOP_LAYER))) ||
|
||||
channel->muted) {
|
||||
layer->muted = true;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
if (seqPlayer->skipTicks != 0) {
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
@@ -1380,11 +1380,11 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
channel->adsr.decayIndex = cmd;
|
||||
break;
|
||||
|
||||
case 0xD8: // channel: set vibrato extent
|
||||
case 0xD8: // channel: set vibrato depth
|
||||
cmd = (u8)cmdArgs[0];
|
||||
channel->vibrato.vibratoExtentTarget = cmd * 8;
|
||||
channel->vibrato.vibratoExtentStart = 0;
|
||||
channel->vibrato.vibratoExtentChangeDelay = 0;
|
||||
channel->vibrato.vibratoDepthTarget = cmd * 8;
|
||||
channel->vibrato.vibratoDepthStart = 0;
|
||||
channel->vibrato.vibratoDepthChangeDelay = 0;
|
||||
break;
|
||||
|
||||
case 0xD7: // channel: set vibrato rate
|
||||
@@ -1394,13 +1394,13 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
channel->vibrato.vibratoRateStart = cmd * 32;
|
||||
break;
|
||||
|
||||
case 0xE2: // channel: set vibrato extent linear
|
||||
case 0xE2: // channel: set vibrato depth linear
|
||||
cmd = (u8)cmdArgs[0];
|
||||
channel->vibrato.vibratoExtentStart = cmd * 8;
|
||||
channel->vibrato.vibratoDepthStart = cmd * 8;
|
||||
cmd = (u8)cmdArgs[1];
|
||||
channel->vibrato.vibratoExtentTarget = cmd * 8;
|
||||
channel->vibrato.vibratoDepthTarget = cmd * 8;
|
||||
cmd = (u8)cmdArgs[2];
|
||||
channel->vibrato.vibratoExtentChangeDelay = cmd * 16;
|
||||
channel->vibrato.vibratoDepthChangeDelay = cmd * 16;
|
||||
break;
|
||||
|
||||
case 0xE1: // channel: set vibratorate linear
|
||||
@@ -1559,9 +1559,9 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
break;
|
||||
|
||||
case 0xEC: // channel: reset vibrato
|
||||
channel->vibrato.vibratoExtentTarget = 0;
|
||||
channel->vibrato.vibratoExtentStart = 0;
|
||||
channel->vibrato.vibratoExtentChangeDelay = 0;
|
||||
channel->vibrato.vibratoDepthTarget = 0;
|
||||
channel->vibrato.vibratoDepthStart = 0;
|
||||
channel->vibrato.vibratoDepthChangeDelay = 0;
|
||||
channel->vibrato.vibratoRateTarget = 0;
|
||||
channel->vibrato.vibratoRateStart = 0;
|
||||
channel->vibrato.vibratoRateChangeDelay = 0;
|
||||
@@ -1667,9 +1667,9 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
case 0xBE: // channel:
|
||||
if (cmdArgs[0] < 5) {
|
||||
if (1) {}
|
||||
if (gAudioCtx.unk_29A8[cmdArgs[0]] != NULL) {
|
||||
gCustomAudioSeqFunction = gAudioCtx.unk_29A8[cmdArgs[0]];
|
||||
scriptState->value = gCustomAudioSeqFunction(scriptState->value, channel);
|
||||
if (gAudioCtx.customSeqFunctions[cmdArgs[0]] != NULL) {
|
||||
gAudioCustomSeqFunction = gAudioCtx.customSeqFunctions[cmdArgs[0]];
|
||||
scriptState->value = gAudioCustomSeqFunction(scriptState->value, channel);
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -1698,13 +1698,13 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
break;
|
||||
|
||||
case 0xA5: // channel:
|
||||
scriptState->value += channel->unk_11;
|
||||
scriptState->value += channel->channelIndex;
|
||||
break;
|
||||
|
||||
case 0xA6: // channel:
|
||||
cmd = (u8)cmdArgs[0];
|
||||
cmdArgU16 = (u16)cmdArgs[1];
|
||||
seqData = seqPlayer->seqData + (u32)(cmdArgU16 + channel->unk_11);
|
||||
seqData = seqPlayer->seqData + (u32)(cmdArgU16 + channel->channelIndex);
|
||||
seqData[0] = (u8)scriptState->value + cmd;
|
||||
break;
|
||||
|
||||
@@ -1766,7 +1766,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
break;
|
||||
|
||||
case 0x70: // channel: io write value
|
||||
channel->soundScriptIO[lowBits] = scriptState->value;
|
||||
channel->seqScriptIO[lowBits] = scriptState->value;
|
||||
break;
|
||||
|
||||
case 0x78: // channel: set layer relative
|
||||
@@ -1792,26 +1792,26 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
|
||||
case 0x10: // channel: load sample
|
||||
if (lowBits < 8) {
|
||||
channel->soundScriptIO[lowBits] = SEQ_IO_VAL_NONE;
|
||||
if (AudioLoad_SlowLoadSample(channel->fontId, scriptState->value,
|
||||
&channel->soundScriptIO[lowBits]) == -1) {}
|
||||
channel->seqScriptIO[lowBits] = SEQ_IO_VAL_NONE;
|
||||
if (AudioLoad_SlowLoadSample(channel->fontId, scriptState->value, &channel->seqScriptIO[lowBits]) ==
|
||||
-1) {}
|
||||
} else {
|
||||
lowBits -= 8;
|
||||
channel->soundScriptIO[lowBits] = SEQ_IO_VAL_NONE;
|
||||
channel->seqScriptIO[lowBits] = SEQ_IO_VAL_NONE;
|
||||
if (AudioLoad_SlowLoadSample(channel->fontId, channel->unk_22 + 0x100,
|
||||
&channel->soundScriptIO[lowBits]) == -1) {}
|
||||
&channel->seqScriptIO[lowBits]) == -1) {}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x60: // channel: io read value
|
||||
scriptState->value = channel->soundScriptIO[lowBits];
|
||||
scriptState->value = channel->seqScriptIO[lowBits];
|
||||
if (lowBits < 2) {
|
||||
channel->soundScriptIO[lowBits] = SEQ_IO_VAL_NONE;
|
||||
channel->seqScriptIO[lowBits] = SEQ_IO_VAL_NONE;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x50: // channel: io read value subtract
|
||||
scriptState->value -= channel->soundScriptIO[lowBits];
|
||||
scriptState->value -= channel->seqScriptIO[lowBits];
|
||||
break;
|
||||
|
||||
case 0x20: // channel: start channel
|
||||
@@ -1821,12 +1821,12 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
|
||||
case 0x30: // channel: io write value 2
|
||||
cmd = AudioSeq_ScriptReadU8(scriptState);
|
||||
seqPlayer->channels[lowBits]->soundScriptIO[cmd] = scriptState->value;
|
||||
seqPlayer->channels[lowBits]->seqScriptIO[cmd] = scriptState->value;
|
||||
break;
|
||||
|
||||
case 0x40: // channel: io read value 2
|
||||
cmd = AudioSeq_ScriptReadU8(scriptState);
|
||||
scriptState->value = seqPlayer->channels[lowBits]->soundScriptIO[cmd];
|
||||
scriptState->value = seqPlayer->channels[lowBits]->seqScriptIO[cmd];
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -1879,18 +1879,18 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
|
||||
seqPlayer->scriptCounter++;
|
||||
|
||||
tempoChange = seqPlayer->tempo + seqPlayer->unk_0C;
|
||||
if (tempoChange > gAudioCtx.tempoInternalToExternal) {
|
||||
tempoChange = gAudioCtx.tempoInternalToExternal;
|
||||
tempoChange = seqPlayer->tempo + seqPlayer->tempoChange;
|
||||
if (tempoChange > gAudioCtx.maxTempo) {
|
||||
tempoChange = gAudioCtx.maxTempo;
|
||||
}
|
||||
|
||||
seqPlayer->tempoAcc += tempoChange;
|
||||
|
||||
if (seqPlayer->tempoAcc < gAudioCtx.tempoInternalToExternal) {
|
||||
if (seqPlayer->tempoAcc < gAudioCtx.maxTempo) {
|
||||
return;
|
||||
}
|
||||
|
||||
seqPlayer->tempoAcc -= (u16)gAudioCtx.tempoInternalToExternal;
|
||||
seqPlayer->tempoAcc -= (u16)gAudioCtx.maxTempo;
|
||||
seqPlayer->unk_16++;
|
||||
|
||||
if (seqPlayer->stopScript == true) {
|
||||
@@ -1943,8 +1943,8 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
|
||||
case 0xDD: // seqPlayer: set tempo
|
||||
seqPlayer->tempo = AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT;
|
||||
if (seqPlayer->tempo > gAudioCtx.tempoInternalToExternal) {
|
||||
seqPlayer->tempo = gAudioCtx.tempoInternalToExternal;
|
||||
if (seqPlayer->tempo > gAudioCtx.maxTempo) {
|
||||
seqPlayer->tempo = gAudioCtx.maxTempo;
|
||||
}
|
||||
|
||||
if ((s16)seqPlayer->tempo <= 0) {
|
||||
@@ -1953,7 +1953,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
break;
|
||||
|
||||
case 0xDC: // seqPlayer: add tempo
|
||||
seqPlayer->unk_0C = (s8)AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT;
|
||||
seqPlayer->tempoChange = (s8)AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT;
|
||||
break;
|
||||
|
||||
case 0xDA: // seqPlayer: change volume
|
||||
@@ -1961,14 +1961,14 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
temp = AudioSeq_ScriptReadS16(seqScript);
|
||||
switch (cmd) {
|
||||
case SEQPLAYER_STATE_0:
|
||||
case SEQPLAYER_STATE_1:
|
||||
if (seqPlayer->state != SEQPLAYER_STATE_2) {
|
||||
seqPlayer->fadeTimerUnkEu = temp;
|
||||
case SEQPLAYER_STATE_FADE_IN:
|
||||
if (seqPlayer->state != SEQPLAYER_STATE_FADE_OUT) {
|
||||
seqPlayer->storedFadeTimer = temp;
|
||||
seqPlayer->state = cmd;
|
||||
}
|
||||
break;
|
||||
|
||||
case SEQPLAYER_STATE_2:
|
||||
case SEQPLAYER_STATE_FADE_OUT:
|
||||
seqPlayer->fadeTimer = temp;
|
||||
seqPlayer->state = cmd;
|
||||
seqPlayer->fadeVelocity = (0.0f - seqPlayer->fadeVolume) / (s32)seqPlayer->fadeTimer;
|
||||
@@ -1979,13 +1979,13 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
case 0xDB: // seqPlayer: set volume
|
||||
value = AudioSeq_ScriptReadU8(seqScript);
|
||||
switch (seqPlayer->state) {
|
||||
case SEQPLAYER_STATE_1:
|
||||
case SEQPLAYER_STATE_FADE_IN:
|
||||
seqPlayer->state = SEQPLAYER_STATE_0;
|
||||
seqPlayer->fadeVolume = 0.0f;
|
||||
// fallthrough
|
||||
case SEQPLAYER_STATE_0:
|
||||
seqPlayer->fadeTimer = seqPlayer->fadeTimerUnkEu;
|
||||
if (seqPlayer->fadeTimerUnkEu != 0) {
|
||||
seqPlayer->fadeTimer = seqPlayer->storedFadeTimer;
|
||||
if (seqPlayer->storedFadeTimer != 0) {
|
||||
seqPlayer->fadeVelocity =
|
||||
((value / 127.0f) - seqPlayer->fadeVolume) / (s32)seqPlayer->fadeTimer;
|
||||
} else {
|
||||
@@ -1993,7 +1993,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
}
|
||||
break;
|
||||
|
||||
case SEQPLAYER_STATE_2:
|
||||
case SEQPLAYER_STATE_FADE_OUT:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -2104,7 +2104,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
cmd = AudioSeq_ScriptReadU8(seqScript);
|
||||
if (cmd == 0xFF) {
|
||||
cmd = seqPlayer->playerIndex;
|
||||
if (seqPlayer->state == SEQPLAYER_STATE_2) {
|
||||
if (seqPlayer->state == SEQPLAYER_STATE_FADE_OUT) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2123,7 +2123,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
temp = *new_var;
|
||||
|
||||
for (i = 0; i < ARRAY_COUNT(seqPlayer->channels); i++) {
|
||||
seqPlayer->channels[i]->stopSomething2 = temp & 1;
|
||||
seqPlayer->channels[i]->muted = temp & 1;
|
||||
temp = temp >> 1;
|
||||
}
|
||||
}
|
||||
@@ -2141,17 +2141,17 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
break;
|
||||
|
||||
case 0x50: // seqPlayer: io read value subtract
|
||||
seqScript->value -= seqPlayer->soundScriptIO[cmdLowBits];
|
||||
seqScript->value -= seqPlayer->seqScriptIO[cmdLowBits];
|
||||
break;
|
||||
|
||||
case 0x70: // seqPlayer: io write value
|
||||
seqPlayer->soundScriptIO[cmdLowBits] = seqScript->value;
|
||||
seqPlayer->seqScriptIO[cmdLowBits] = seqScript->value;
|
||||
break;
|
||||
|
||||
case 0x80: // seqPlayer: io read value
|
||||
seqScript->value = seqPlayer->soundScriptIO[cmdLowBits];
|
||||
seqScript->value = seqPlayer->seqScriptIO[cmdLowBits];
|
||||
if (cmdLowBits < 2) {
|
||||
seqPlayer->soundScriptIO[cmdLowBits] = SEQ_IO_VAL_NONE;
|
||||
seqPlayer->seqScriptIO[cmdLowBits] = SEQ_IO_VAL_NONE;
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -2173,14 +2173,14 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
cmd = AudioSeq_ScriptReadU8(seqScript);
|
||||
temp = AudioSeq_ScriptReadS16(seqScript);
|
||||
data2 = &seqPlayer->seqData[temp];
|
||||
AudioLoad_SlowLoadSeq(cmd, data2, &seqPlayer->soundScriptIO[cmdLowBits]);
|
||||
AudioLoad_SlowLoadSeq(cmd, data2, &seqPlayer->seqScriptIO[cmdLowBits]);
|
||||
break;
|
||||
|
||||
case 0x60: // seqPlayer: async load
|
||||
cmd = AudioSeq_ScriptReadU8(seqScript);
|
||||
value = cmd;
|
||||
temp = AudioSeq_ScriptReadU8(seqScript);
|
||||
AudioLoad_ScriptLoad(value, temp, &seqPlayer->soundScriptIO[cmdLowBits]);
|
||||
AudioLoad_ScriptLoad(value, temp, &seqPlayer->seqScriptIO[cmdLowBits]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2220,17 +2220,17 @@ void AudioSeq_SkipForwardSequence(SequencePlayer* seqPlayer) {
|
||||
}
|
||||
|
||||
void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer) {
|
||||
s32 i;
|
||||
s32 channelIndex;
|
||||
|
||||
AudioSeq_SequencePlayerDisable(seqPlayer);
|
||||
seqPlayer->stopScript = false;
|
||||
seqPlayer->delay = 0;
|
||||
seqPlayer->state = SEQPLAYER_STATE_1;
|
||||
seqPlayer->state = SEQPLAYER_STATE_FADE_IN;
|
||||
seqPlayer->fadeTimer = 0;
|
||||
seqPlayer->fadeTimerUnkEu = 0;
|
||||
seqPlayer->storedFadeTimer = 0;
|
||||
seqPlayer->tempoAcc = 0;
|
||||
seqPlayer->tempo = 120 * TATUMS_PER_BEAT; // 120 BPM
|
||||
seqPlayer->unk_0C = 0;
|
||||
seqPlayer->tempoChange = 0;
|
||||
seqPlayer->transposition = 0;
|
||||
seqPlayer->noteAllocPolicy = 0;
|
||||
seqPlayer->shortNoteVelocityTable = gDefaultShortNoteVelocityTable;
|
||||
@@ -2242,32 +2242,32 @@ void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer) {
|
||||
seqPlayer->volume = 0.0f;
|
||||
seqPlayer->muteVolumeScale = 0.5f;
|
||||
|
||||
for (i = 0; i < SEQ_NUM_CHANNELS; i++) {
|
||||
AudioSeq_InitSequenceChannel(seqPlayer->channels[i]);
|
||||
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
|
||||
AudioSeq_InitSequenceChannel(seqPlayer->channels[channelIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
void AudioSeq_InitSequencePlayerChannels(s32 playerIndex) {
|
||||
void AudioSeq_InitSequencePlayerChannels(s32 seqPlayerIndex) {
|
||||
SequenceChannel* channel;
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[playerIndex];
|
||||
s32 i;
|
||||
s32 j;
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex];
|
||||
s32 channelIndex;
|
||||
s32 layerIndex;
|
||||
|
||||
for (i = 0; i < SEQ_NUM_CHANNELS; i++) {
|
||||
seqPlayer->channels[i] = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(SequenceChannel));
|
||||
if (seqPlayer->channels[i] == NULL) {
|
||||
seqPlayer->channels[i] = &gAudioCtx.sequenceChannelNone;
|
||||
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
|
||||
seqPlayer->channels[channelIndex] = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(SequenceChannel));
|
||||
if (seqPlayer->channels[channelIndex] == NULL) {
|
||||
seqPlayer->channels[channelIndex] = &gAudioCtx.sequenceChannelNone;
|
||||
} else {
|
||||
channel = seqPlayer->channels[i];
|
||||
channel = seqPlayer->channels[channelIndex];
|
||||
channel->seqPlayer = seqPlayer;
|
||||
channel->enabled = false;
|
||||
channel->unk_11 = i;
|
||||
for (j = 0; j < ARRAY_COUNT(channel->layers); j++) {
|
||||
channel->layers[j] = NULL;
|
||||
channel->channelIndex = channelIndex;
|
||||
for (layerIndex = 0; layerIndex < ARRAY_COUNT(channel->layers); layerIndex++) {
|
||||
channel->layers[layerIndex] = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
AudioSeq_InitSequenceChannel(seqPlayer->channels[i]);
|
||||
AudioSeq_InitSequenceChannel(seqPlayer->channels[channelIndex]);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2285,8 +2285,8 @@ void AudioSeq_InitSequencePlayer(SequencePlayer* seqPlayer) {
|
||||
seqPlayer->seqDmaInProgress = false;
|
||||
seqPlayer->applyBend = false;
|
||||
|
||||
for (j = 0; j < ARRAY_COUNT(seqPlayer->soundScriptIO); j++) {
|
||||
seqPlayer->soundScriptIO[j] = SEQ_IO_VAL_NONE;
|
||||
for (j = 0; j < ARRAY_COUNT(seqPlayer->seqScriptIO); j++) {
|
||||
seqPlayer->seqScriptIO[j] = SEQ_IO_VAL_NONE;
|
||||
}
|
||||
|
||||
seqPlayer->muteFlags = MUTE_FLAGS_SOFTEN | MUTE_FLAGS_STOP_NOTES;
|
||||
|
||||
@@ -866,8 +866,8 @@ Acmd* AudioSynth_ProcessSamples(s16* aiBuf, s32 numSamplesPerUpdate, Acmd* cmd,
|
||||
size = numSamplesPerUpdate * SAMPLE_SIZE;
|
||||
aInterleave(cmd++, DMEM_TEMP, DMEM_LEFT_CH, DMEM_RIGHT_CH, size);
|
||||
|
||||
if (gCustomAudioSynthFunction != NULL) {
|
||||
cmd = gCustomAudioSynthFunction(cmd, 2 * size, updateIndex);
|
||||
if (gAudioCustomSynthFunction != NULL) {
|
||||
cmd = gAudioCustomSynthFunction(cmd, 2 * size, updateIndex);
|
||||
}
|
||||
aSaveBuffer(cmd++, DMEM_TEMP, aiBuf, 2 * size);
|
||||
|
||||
@@ -1109,8 +1109,8 @@ Acmd* AudioSynth_ProcessSample(s32 noteIndex, NoteSampleState* sampleState, Note
|
||||
|
||||
case CODEC_REVERB:
|
||||
reverbAddrSrc = (void*)0xFFFFFFFF;
|
||||
if (gCustomAudioReverbFunction != NULL) {
|
||||
reverbAddrSrc = gCustomAudioReverbFunction(sample, numSamplesToLoadAdj, flags, noteIndex);
|
||||
if (gAudioCustomReverbFunction != NULL) {
|
||||
reverbAddrSrc = gAudioCustomReverbFunction(sample, numSamplesToLoadAdj, flags, noteIndex);
|
||||
}
|
||||
|
||||
if (reverbAddrSrc == (void*)0xFFFFFFFF) {
|
||||
|
||||
@@ -0,0 +1,977 @@
|
||||
/**
|
||||
* @file audio_thread.c
|
||||
*
|
||||
* Top-level file that coordinates all audio code on the audio thread.
|
||||
*/
|
||||
#include "global.h"
|
||||
|
||||
AudioTask* AudioThread_UpdateImpl(void);
|
||||
void AudioThread_SetFadeOutTimer(s32 seqPlayerIndex, s32 fadeTimer);
|
||||
void AudioThread_SetFadeInTimer(s32 seqPlayerIndex, s32 fadeTimer);
|
||||
void AudioThread_ProcessCmds(u32 msg);
|
||||
void AudioThread_ProcessSeqPlayerCmd(SequencePlayer* seqPlayer, AudioCmd* cmd);
|
||||
void AudioThread_ProcessChannelCmd(SequenceChannel* channel, AudioCmd* cmd);
|
||||
s32 AudioThread_GetSamplePos(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex, s32* loopEnd, s32* samplePosInt);
|
||||
s32 AudioThread_CountAndReleaseNotes(s32 flags);
|
||||
|
||||
AudioTask* AudioThread_Update(void) {
|
||||
return AudioThread_UpdateImpl();
|
||||
}
|
||||
|
||||
AudioTask* AudioThread_UpdateImpl(void) {
|
||||
static AudioTask* sWaitingAudioTask = NULL;
|
||||
u32 numSamplesRemainingInAi;
|
||||
s32 numAbiCmds;
|
||||
s32 pad;
|
||||
s32 j;
|
||||
s32 dmaCount;
|
||||
s16* curAiBuffer;
|
||||
OSTask_t* task;
|
||||
s32 index;
|
||||
u32 msg;
|
||||
s32 validCount;
|
||||
s32 i;
|
||||
|
||||
gAudioCtx.totalTaskCount++;
|
||||
if ((gAudioCtx.totalTaskCount % gAudioCtx.audioBufferParameters.specUnk4) != 0) {
|
||||
if (gAudioCustomUpdateFunction != NULL) {
|
||||
gAudioCustomUpdateFunction();
|
||||
}
|
||||
|
||||
if (((gAudioCtx.totalTaskCount % gAudioCtx.audioBufferParameters.specUnk4) + 1) ==
|
||||
gAudioCtx.audioBufferParameters.specUnk4) {
|
||||
return sWaitingAudioTask;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
osSendMesg(gAudioCtx.taskStartQueueP, gAudioCtx.totalTaskCount, OS_MESG_NOBLOCK);
|
||||
gAudioCtx.rspTaskIndex ^= 1;
|
||||
gAudioCtx.curAiBufferIndex++;
|
||||
gAudioCtx.curAiBufferIndex %= 3;
|
||||
index = (gAudioCtx.curAiBufferIndex + 1) % 3;
|
||||
|
||||
// Division converts size to numSamples: 2 channels (left/right) * 2 bytes per sample
|
||||
numSamplesRemainingInAi = osAiGetLength() / (2 * SAMPLE_SIZE);
|
||||
|
||||
if (gAudioCtx.resetTimer < 16) {
|
||||
if (gAudioCtx.numSamplesPerFrame[index] != 0) {
|
||||
osAiSetNextBuffer(gAudioCtx.aiBuffers[index], 2 * gAudioCtx.numSamplesPerFrame[index] * (s32)SAMPLE_SIZE);
|
||||
if (gAudioCtx.aiBuffers[index]) {}
|
||||
if (gAudioCtx.numSamplesPerFrame[index]) {}
|
||||
}
|
||||
}
|
||||
|
||||
if (gAudioCustomUpdateFunction != NULL) {
|
||||
gAudioCustomUpdateFunction();
|
||||
}
|
||||
|
||||
dmaCount = gAudioCtx.curAudioFrameDmaCount;
|
||||
for (i = 0; i < gAudioCtx.curAudioFrameDmaCount; i++) {
|
||||
if (osRecvMesg(&gAudioCtx.curAudioFrameDmaQueue, NULL, OS_MESG_NOBLOCK) == 0) {
|
||||
dmaCount--;
|
||||
}
|
||||
}
|
||||
|
||||
if (dmaCount != 0) {
|
||||
for (i = 0; i < dmaCount; i++) {
|
||||
osRecvMesg(&gAudioCtx.curAudioFrameDmaQueue, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
validCount = gAudioCtx.curAudioFrameDmaQueue.validCount;
|
||||
if (validCount != 0) {
|
||||
for (i = 0; i < validCount; i++) {
|
||||
osRecvMesg(&gAudioCtx.curAudioFrameDmaQueue, NULL, OS_MESG_NOBLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
gAudioCtx.curAudioFrameDmaCount = 0;
|
||||
AudioLoad_DecreaseSampleDmaTtls();
|
||||
AudioLoad_ProcessLoads(gAudioCtx.resetStatus);
|
||||
AudioLoad_ProcessScriptLoads();
|
||||
|
||||
if (gAudioCtx.resetStatus != 0) {
|
||||
if (AudioHeap_ResetStep() == 0) {
|
||||
if (gAudioCtx.resetStatus == 0) {
|
||||
osSendMesg(gAudioCtx.audioResetQueueP, gAudioCtx.specId, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
sWaitingAudioTask = NULL;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
if (gAudioCtx.resetTimer > 16) {
|
||||
return NULL;
|
||||
}
|
||||
if (gAudioCtx.resetTimer != 0) {
|
||||
gAudioCtx.resetTimer++;
|
||||
}
|
||||
|
||||
gAudioCtx.curTask = &gAudioCtx.rspTask[gAudioCtx.rspTaskIndex];
|
||||
gAudioCtx.curAbiCmdBuf = gAudioCtx.abiCmdBufs[gAudioCtx.rspTaskIndex];
|
||||
|
||||
index = gAudioCtx.curAiBufferIndex;
|
||||
curAiBuffer = gAudioCtx.aiBuffers[index];
|
||||
|
||||
gAudioCtx.numSamplesPerFrame[index] =
|
||||
(s16)((((gAudioCtx.audioBufferParameters.numSamplesPerFrameTarget - numSamplesRemainingInAi) +
|
||||
(8 * SAMPLES_PER_FRAME)) &
|
||||
~0xF) +
|
||||
(1 * SAMPLES_PER_FRAME));
|
||||
|
||||
// Clamp numSamplesPerFrame between numSamplesPerFrameMin and numSamplesPerFrameMax
|
||||
if (gAudioCtx.numSamplesPerFrame[index] < gAudioCtx.audioBufferParameters.numSamplesPerFrameMin) {
|
||||
gAudioCtx.numSamplesPerFrame[index] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMin;
|
||||
}
|
||||
if (gAudioCtx.numSamplesPerFrame[index] > gAudioCtx.audioBufferParameters.numSamplesPerFrameMax) {
|
||||
gAudioCtx.numSamplesPerFrame[index] = gAudioCtx.audioBufferParameters.numSamplesPerFrameMax;
|
||||
}
|
||||
|
||||
j = 0;
|
||||
if (gAudioCtx.resetStatus == 0) {
|
||||
// msg = 0000RREE R = read pos, E = End Pos
|
||||
while (osRecvMesg(gAudioCtx.threadCmdProcQueueP, (OSMesg*)&msg, OS_MESG_NOBLOCK) != -1) {
|
||||
//! FAKE:
|
||||
if (1) {}
|
||||
AudioThread_ProcessCmds(msg);
|
||||
j++;
|
||||
}
|
||||
if ((j == 0) && gAudioCtx.threadCmdQueueFinished) {
|
||||
AudioThread_ScheduleProcessCmds();
|
||||
}
|
||||
}
|
||||
|
||||
if (gAudioSPDataPtr == (u64*)gAudioCtx.curAbiCmdBuf) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
gAudioCtx.curAbiCmdBuf =
|
||||
AudioSynth_Update(gAudioCtx.curAbiCmdBuf, &numAbiCmds, curAiBuffer, gAudioCtx.numSamplesPerFrame[index]);
|
||||
|
||||
// Update audioRandom to the next random number
|
||||
gAudioCtx.audioRandom = (gAudioCtx.audioRandom + gAudioCtx.totalTaskCount) * osGetCount();
|
||||
gAudioCtx.audioRandom = gAudioCtx.audioRandom + gAudioCtx.aiBuffers[index][gAudioCtx.totalTaskCount & 0xFF];
|
||||
|
||||
// gWaveSamples[8] interprets compiled assembly code as s16 samples as a way to generate sound with noise.
|
||||
// Start with the address of AudioThread_Update(), and offset it by a random number between 0 - 0xFFF0
|
||||
// Use the resulting address as the starting address to interpret an array of samples i.e. `s16 samples[]`
|
||||
gWaveSamples[8] = (s16*)((u8*)AudioThread_Update + (gAudioCtx.audioRandom & 0xFFF0));
|
||||
|
||||
index = gAudioCtx.rspTaskIndex;
|
||||
gAudioCtx.curTask->taskQueue = NULL;
|
||||
gAudioCtx.curTask->unk_44 = NULL;
|
||||
|
||||
task = &gAudioCtx.curTask->task.t;
|
||||
task->type = M_AUDTASK;
|
||||
task->flags = 0;
|
||||
task->ucodeBoot = aspMainTextStart;
|
||||
task->ucodeBootSize = SP_UCODE_SIZE;
|
||||
task->ucodeDataSize = ((aspMainDataEnd - aspMainDataStart) * sizeof(u64)) - 1;
|
||||
task->ucode = aspMainTextStart;
|
||||
task->ucodeData = aspMainDataStart;
|
||||
task->ucodeSize = SP_UCODE_SIZE;
|
||||
task->dramStack = (u64*)D_801D6200;
|
||||
task->dramStackSize = 0;
|
||||
task->outputBuff = NULL;
|
||||
task->outputBuffSize = NULL;
|
||||
if (1) {}
|
||||
task->dataPtr = (u64*)gAudioCtx.abiCmdBufs[index];
|
||||
task->dataSize = numAbiCmds * sizeof(Acmd);
|
||||
task->yieldDataPtr = NULL;
|
||||
task->yieldDataSize = 0;
|
||||
|
||||
if (gAudioCtx.numAbiCmdsMax < numAbiCmds) {
|
||||
gAudioCtx.numAbiCmdsMax = numAbiCmds;
|
||||
}
|
||||
|
||||
if (gAudioCtx.audioBufferParameters.specUnk4 == 1) {
|
||||
return gAudioCtx.curTask;
|
||||
} else {
|
||||
sWaitingAudioTask = gAudioCtx.curTask;
|
||||
return NULL;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) {
|
||||
s32 i;
|
||||
s32 pad;
|
||||
|
||||
switch (cmd->op) {
|
||||
case AUDIOCMD_OP_GLOBAL_SYNC_LOAD_SEQ_PARTS:
|
||||
AudioLoad_SyncLoadSeqParts(cmd->arg1, cmd->arg2, cmd->asInt, &gAudioCtx.externalLoadQueue);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER:
|
||||
AudioLoad_SyncInitSeqPlayer(cmd->arg0, cmd->arg1, cmd->arg2);
|
||||
AudioThread_SetFadeInTimer(cmd->arg0, cmd->asInt);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS:
|
||||
AudioLoad_SyncInitSeqPlayerSkipTicks(cmd->arg0, cmd->arg1, cmd->asInt);
|
||||
AudioThread_SetFadeInTimer(cmd->arg0, 500);
|
||||
AudioSeq_SkipForwardSequence(&gAudioCtx.seqPlayers[cmd->arg0]);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_DISABLE_SEQPLAYER:
|
||||
if (gAudioCtx.seqPlayers[cmd->arg0].enabled) {
|
||||
if (cmd->asInt == 0) {
|
||||
AudioSeq_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[cmd->arg0]);
|
||||
} else {
|
||||
AudioThread_SetFadeOutTimer(cmd->arg0, cmd->asInt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_SET_SOUND_MODE:
|
||||
gAudioCtx.soundMode = cmd->asInt;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_MUTE:
|
||||
if (cmd->arg0 == AUDIOCMD_ALL_SEQPLAYERS) {
|
||||
for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) {
|
||||
gAudioCtx.seqPlayers[i].muted = true;
|
||||
gAudioCtx.seqPlayers[i].recalculateVolume = true;
|
||||
}
|
||||
} else {
|
||||
gAudioCtx.seqPlayers[cmd->arg0].muted = true;
|
||||
gAudioCtx.seqPlayers[cmd->arg0].recalculateVolume = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_UNMUTE:
|
||||
if (cmd->asInt == true) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
Note* note = &gAudioCtx.notes[i];
|
||||
NoteSampleState* noteSampleState = ¬e->sampleState;
|
||||
|
||||
if (noteSampleState->bitField0.enabled && (note->playbackState.status == PLAYBACK_STATUS_0) &&
|
||||
(note->playbackState.parentLayer->channel->muteFlags & MUTE_FLAGS_STOP_SAMPLES)) {
|
||||
noteSampleState->bitField0.finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (cmd->arg0 == AUDIOCMD_ALL_SEQPLAYERS) {
|
||||
for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) {
|
||||
gAudioCtx.seqPlayers[i].muted = false;
|
||||
gAudioCtx.seqPlayers[i].recalculateVolume = true;
|
||||
}
|
||||
} else {
|
||||
gAudioCtx.seqPlayers[cmd->arg0].muted = false;
|
||||
gAudioCtx.seqPlayers[cmd->arg0].recalculateVolume = true;
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_SYNC_LOAD_INSTRUMENT:
|
||||
AudioLoad_SyncLoadInstrument(cmd->arg0, cmd->arg1, cmd->arg2);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK:
|
||||
AudioLoad_AsyncLoadSampleBank(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioCtx.externalLoadQueue);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT:
|
||||
AudioLoad_AsyncLoadFont(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioCtx.externalLoadQueue);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SEQ:
|
||||
AudioLoad_AsyncLoadSeq(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioCtx.externalLoadQueue);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_DISCARD_SEQ_FONTS:
|
||||
AudioLoad_DiscardSeqFonts(cmd->arg1);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_SET_CHANNEL_MASK:
|
||||
gAudioCtx.threadCmdChannelMask[cmd->arg0] = cmd->asUShort;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_RESET_AUDIO_HEAP:
|
||||
gAudioCtx.resetStatus = 5;
|
||||
gAudioCtx.specId = cmd->asUInt;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_SET_CUSTOM_UPDATE_FUNCTION:
|
||||
gAudioCustomUpdateFunction = cmd->asUInt;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_SET_CUSTOM_FUNCTION:
|
||||
if (cmd->arg2 == AUDIO_CUSTOM_FUNCTION_REVERB) {
|
||||
gAudioCustomReverbFunction = cmd->asUInt;
|
||||
} else if (cmd->arg2 == AUDIO_CUSTOM_FUNCTION_SYNTH) {
|
||||
gAudioCustomSynthFunction = cmd->asUInt;
|
||||
} else {
|
||||
gAudioCtx.customSeqFunctions[cmd->arg2] = cmd->asUInt;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT:
|
||||
case AUDIOCMD_OP_GLOBAL_SET_SFX_FONT:
|
||||
case AUDIOCMD_OP_GLOBAL_SET_INSTRUMENT_FONT:
|
||||
if (AudioPlayback_SetFontInstrument(cmd->op - AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT, cmd->arg1, cmd->arg2,
|
||||
cmd->asInt)) {}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_DISABLE_ALL_SEQPLAYERS: {
|
||||
u32 flags = cmd->asUInt;
|
||||
|
||||
if (flags == AUDIO_NOTE_RELEASE) {
|
||||
for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) {
|
||||
if (gAudioCtx.seqPlayers[i].enabled) {
|
||||
AudioSeq_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
AudioThread_CountAndReleaseNotes(flags);
|
||||
break;
|
||||
}
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_POP_PERSISTENT_CACHE:
|
||||
AudioHeap_PopPersistentCache(cmd->asInt);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_E5:
|
||||
func_8018FA60(cmd->arg0, cmd->arg1, cmd->arg2, cmd->asInt);
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_GLOBAL_SET_REVERB_DATA:
|
||||
AudioHeap_SetReverbData(cmd->arg1, cmd->arg0, cmd->asInt, false);
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_SetFadeOutTimer(s32 seqPlayerIndex, s32 fadeTimer) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex];
|
||||
|
||||
if (fadeTimer == 0) {
|
||||
fadeTimer = 1;
|
||||
}
|
||||
|
||||
seqPlayer->fadeVelocity = -(seqPlayer->fadeVolume / fadeTimer);
|
||||
seqPlayer->state = SEQPLAYER_STATE_FADE_OUT;
|
||||
seqPlayer->fadeTimer = fadeTimer;
|
||||
}
|
||||
|
||||
void AudioThread_SetFadeInTimer(s32 seqPlayerIndex, s32 fadeTimer) {
|
||||
SequencePlayer* seqPlayer;
|
||||
|
||||
if (fadeTimer != 0) {
|
||||
seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex];
|
||||
seqPlayer->state = SEQPLAYER_STATE_FADE_IN;
|
||||
seqPlayer->storedFadeTimer = fadeTimer;
|
||||
seqPlayer->fadeTimer = fadeTimer;
|
||||
seqPlayer->fadeVolume = 0.0f;
|
||||
seqPlayer->fadeVelocity = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_InitMesgQueuesInternal(void) {
|
||||
gAudioCtx.threadCmdWritePos = 0;
|
||||
gAudioCtx.threadCmdReadPos = 0;
|
||||
gAudioCtx.threadCmdQueueFinished = false;
|
||||
|
||||
gAudioCtx.taskStartQueueP = &gAudioCtx.taskStartQueue;
|
||||
gAudioCtx.threadCmdProcQueueP = &gAudioCtx.threadCmdProcQueue;
|
||||
gAudioCtx.audioResetQueueP = &gAudioCtx.audioResetQueue;
|
||||
|
||||
osCreateMesgQueue(gAudioCtx.taskStartQueueP, gAudioCtx.taskStartMsgs, ARRAY_COUNT(gAudioCtx.taskStartMsgs));
|
||||
osCreateMesgQueue(gAudioCtx.threadCmdProcQueueP, gAudioCtx.threadCmdProcMsgBuf,
|
||||
ARRAY_COUNT(gAudioCtx.threadCmdProcMsgBuf));
|
||||
osCreateMesgQueue(gAudioCtx.audioResetQueueP, gAudioCtx.audioResetMesgs, ARRAY_COUNT(gAudioCtx.audioResetMesgs));
|
||||
}
|
||||
|
||||
void AudioThread_QueueCmd(u32 opArgs, void** data) {
|
||||
AudioCmd* cmd = &gAudioCtx.threadCmdBuf[gAudioCtx.threadCmdWritePos & 0xFF];
|
||||
|
||||
cmd->opArgs = opArgs;
|
||||
cmd->data = *data;
|
||||
|
||||
gAudioCtx.threadCmdWritePos++;
|
||||
|
||||
if (gAudioCtx.threadCmdWritePos == gAudioCtx.threadCmdReadPos) {
|
||||
gAudioCtx.threadCmdWritePos--;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_QueueCmdF32(u32 opArgs, f32 data) {
|
||||
AudioThread_QueueCmd(opArgs, (void**)&data);
|
||||
}
|
||||
|
||||
void AudioThread_QueueCmdS32(u32 opArgs, s32 data) {
|
||||
AudioThread_QueueCmd(opArgs, (void**)&data);
|
||||
}
|
||||
|
||||
void AudioThread_QueueCmdS8(u32 opArgs, s8 data) {
|
||||
u32 uData = data << 0x18;
|
||||
|
||||
AudioThread_QueueCmd(opArgs, (void**)&uData);
|
||||
}
|
||||
|
||||
void AudioThread_QueueCmdU16(u32 opArgs, u16 data) {
|
||||
u32 uData = data << 0x10;
|
||||
|
||||
AudioThread_QueueCmd(opArgs, (void**)&uData);
|
||||
}
|
||||
|
||||
s32 AudioThread_ScheduleProcessCmds(void) {
|
||||
static s32 sMaxWriteReadDiff = 0;
|
||||
s32 ret;
|
||||
|
||||
if (sMaxWriteReadDiff < (u8)((gAudioCtx.threadCmdWritePos - gAudioCtx.threadCmdReadPos) + 0x100)) {
|
||||
sMaxWriteReadDiff = (u8)((gAudioCtx.threadCmdWritePos - gAudioCtx.threadCmdReadPos) + 0x100);
|
||||
}
|
||||
|
||||
ret = osSendMesg(gAudioCtx.threadCmdProcQueueP,
|
||||
(void*)(((gAudioCtx.threadCmdReadPos & 0xFF) << 8) | (gAudioCtx.threadCmdWritePos & 0xFF)),
|
||||
OS_MESG_NOBLOCK);
|
||||
if (ret != -1) {
|
||||
gAudioCtx.threadCmdReadPos = gAudioCtx.threadCmdWritePos;
|
||||
ret = 0;
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void AudioThread_ResetCmdQueue(void) {
|
||||
gAudioCtx.threadCmdQueueFinished = false;
|
||||
gAudioCtx.threadCmdReadPos = gAudioCtx.threadCmdWritePos;
|
||||
}
|
||||
|
||||
void AudioThread_ProcessCmd(AudioCmd* cmd) {
|
||||
SequencePlayer* seqPlayer;
|
||||
u16 threadCmdChannelMask;
|
||||
s32 channelIndex;
|
||||
|
||||
if ((cmd->op & 0xF0) >= 0xE0) {
|
||||
AudioThread_ProcessGlobalCmd(cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd->arg0 < gAudioCtx.audioBufferParameters.numSequencePlayers) {
|
||||
seqPlayer = &gAudioCtx.seqPlayers[cmd->arg0];
|
||||
if (cmd->op & 0x80) {
|
||||
AudioThread_ProcessGlobalCmd(cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd->op & 0x40) {
|
||||
AudioThread_ProcessSeqPlayerCmd(seqPlayer, cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd->arg1 < SEQ_NUM_CHANNELS) {
|
||||
AudioThread_ProcessChannelCmd(seqPlayer->channels[cmd->arg1], cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd->arg1 == AUDIOCMD_ALL_CHANNELS) {
|
||||
threadCmdChannelMask = gAudioCtx.threadCmdChannelMask[cmd->arg0];
|
||||
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
|
||||
if (threadCmdChannelMask & 1) {
|
||||
AudioThread_ProcessChannelCmd(seqPlayer->channels[channelIndex], cmd);
|
||||
}
|
||||
threadCmdChannelMask = threadCmdChannelMask >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_ProcessCmds(u32 msg) {
|
||||
static u8 sCurCmdRdPos = 0;
|
||||
AudioCmd* cmd;
|
||||
u8 endPos;
|
||||
|
||||
if (!gAudioCtx.threadCmdQueueFinished) {
|
||||
sCurCmdRdPos = msg >> 8;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
endPos = msg & 0xFF;
|
||||
if (sCurCmdRdPos == endPos) {
|
||||
gAudioCtx.threadCmdQueueFinished = false;
|
||||
break;
|
||||
}
|
||||
|
||||
cmd = &gAudioCtx.threadCmdBuf[sCurCmdRdPos++ & 0xFF];
|
||||
if (cmd->op == AUDIOCMD_OP_GLOBAL_STOP_AUDIOCMDS) {
|
||||
gAudioCtx.threadCmdQueueFinished = true;
|
||||
break;
|
||||
}
|
||||
|
||||
AudioThread_ProcessCmd(cmd);
|
||||
cmd->op = AUDIOCMD_OP_NOOP;
|
||||
}
|
||||
}
|
||||
|
||||
u32 AudioThread_GetExternalLoadQueueMsg(u32* retMsg) {
|
||||
u32 msg;
|
||||
|
||||
if (osRecvMesg(&gAudioCtx.externalLoadQueue, (OSMesg*)&msg, OS_MESG_NOBLOCK) == -1) {
|
||||
*retMsg = 0;
|
||||
return 0;
|
||||
}
|
||||
|
||||
*retMsg = msg & 0xFFFFFF;
|
||||
return msg >> 0x18;
|
||||
}
|
||||
|
||||
u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
|
||||
return AudioLoad_GetFontsForSequence(seqId, outNumFonts);
|
||||
}
|
||||
|
||||
void AudioThread_GetSampleBankIdsOfFont(s32 fontId, u32* sampleBankId1, u32* sampleBankId2) {
|
||||
*sampleBankId1 = gAudioCtx.soundFontList[fontId].sampleBankId1;
|
||||
*sampleBankId2 = gAudioCtx.soundFontList[fontId].sampleBankId2;
|
||||
}
|
||||
|
||||
s32 func_80193C5C(void) {
|
||||
s32 pad;
|
||||
s32 specId;
|
||||
|
||||
if (osRecvMesg(gAudioCtx.audioResetQueueP, (OSMesg*)&specId, OS_MESG_NOBLOCK) == -1) {
|
||||
return 0;
|
||||
} else if (gAudioCtx.specId != specId) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_WaitForAudioResetQueueP(void) {
|
||||
// macro?
|
||||
// clang-format off
|
||||
s32 chk = -1; s32 msg; do {} while (osRecvMesg(gAudioCtx.audioResetQueueP, (OSMesg*)&msg, OS_MESG_NOBLOCK) != chk);
|
||||
// clang-format on
|
||||
}
|
||||
|
||||
s32 AudioThread_ResetAudioHeap(s32 specId) {
|
||||
s32 resetStatus;
|
||||
OSMesg msg;
|
||||
s32 pad;
|
||||
|
||||
AudioThread_WaitForAudioResetQueueP();
|
||||
resetStatus = gAudioCtx.resetStatus;
|
||||
if (resetStatus != 0) {
|
||||
AudioThread_ResetCmdQueue();
|
||||
if (gAudioCtx.specId == specId) {
|
||||
return -2;
|
||||
} else if (resetStatus > 2) {
|
||||
gAudioCtx.specId = specId;
|
||||
return -3;
|
||||
} else {
|
||||
osRecvMesg(gAudioCtx.audioResetQueueP, &msg, OS_MESG_BLOCK);
|
||||
}
|
||||
}
|
||||
|
||||
AudioThread_WaitForAudioResetQueueP();
|
||||
AUDIOCMD_GLOBAL_RESET_AUDIO_HEAP(specId);
|
||||
|
||||
return AudioThread_ScheduleProcessCmds();
|
||||
}
|
||||
|
||||
void AudioThread_PreNMIInternal(void) {
|
||||
gAudioCtx.resetTimer = 1;
|
||||
if (gAudioCtxInitalized) {
|
||||
AudioThread_ResetAudioHeap(0);
|
||||
gAudioCtx.resetStatus = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// Unused
|
||||
s8 AudioThread_GetChannelIO(s32 seqPlayerIndex, s32 channelIndex, s32 ioPort) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex];
|
||||
SequenceChannel* channel;
|
||||
|
||||
if (seqPlayer->enabled) {
|
||||
channel = seqPlayer->channels[channelIndex];
|
||||
return channel->seqScriptIO[ioPort];
|
||||
} else {
|
||||
return SEQ_IO_VAL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
// Unused
|
||||
s8 AudioThread_GetSeqPlayerIO(s32 seqPlayerIndex, s32 ioPort) {
|
||||
return gAudioCtx.seqPlayers[seqPlayerIndex].seqScriptIO[ioPort];
|
||||
}
|
||||
|
||||
// Unused
|
||||
void AudioThread_InitExternalPool(void* addr, size_t size) {
|
||||
AudioHeap_InitPool(&gAudioCtx.externalPool, addr, size);
|
||||
}
|
||||
|
||||
// Unused
|
||||
void AudioThread_ResetExternalPool(void) {
|
||||
gAudioCtx.externalPool.startAddr = NULL;
|
||||
}
|
||||
|
||||
void AudioThread_ProcessSeqPlayerCmd(SequencePlayer* seqPlayer, AudioCmd* cmd) {
|
||||
f32 fadeVolume;
|
||||
|
||||
switch (cmd->op) {
|
||||
case AUDIOCMD_OP_SEQPLAYER_FADE_VOLUME_SCALE:
|
||||
if (seqPlayer->fadeVolumeScale != cmd->asFloat) {
|
||||
seqPlayer->fadeVolumeScale = cmd->asFloat;
|
||||
seqPlayer->recalculateVolume = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_TEMPO:
|
||||
seqPlayer->tempo = cmd->asInt * TATUMS_PER_BEAT;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO:
|
||||
seqPlayer->tempoChange = cmd->asInt * TATUMS_PER_BEAT;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO_TICKS:
|
||||
seqPlayer->tempoChange = cmd->asInt;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION:
|
||||
seqPlayer->transposition = cmd->asSbyte;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_IO:
|
||||
seqPlayer->seqScriptIO[cmd->arg2] = cmd->asSbyte;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_SEQPLAYER_FADE_TO_SET_VOLUME:
|
||||
fadeVolume = (s32)cmd->arg1 / 127.0f;
|
||||
goto apply_fade;
|
||||
|
||||
case AUDIOCMD_OP_SEQPLAYER_FADE_TO_SCALED_VOLUME:
|
||||
fadeVolume = ((s32)cmd->arg1 / 100.0f) * seqPlayer->fadeVolume;
|
||||
apply_fade:
|
||||
if (seqPlayer->state != SEQPLAYER_STATE_FADE_OUT) {
|
||||
seqPlayer->volume = seqPlayer->fadeVolume;
|
||||
if (cmd->asInt == 0) {
|
||||
seqPlayer->fadeVolume = fadeVolume;
|
||||
} else {
|
||||
s32 fadeTimer = cmd->asInt;
|
||||
|
||||
seqPlayer->state = SEQPLAYER_STATE_0;
|
||||
seqPlayer->fadeTimer = fadeTimer;
|
||||
seqPlayer->fadeVelocity = (fadeVolume - seqPlayer->fadeVolume) / fadeTimer;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_SEQPLAYER_RESET_VOLUME:
|
||||
if (seqPlayer->state != SEQPLAYER_STATE_FADE_OUT) {
|
||||
if (cmd->asInt == 0) {
|
||||
seqPlayer->fadeVolume = seqPlayer->volume;
|
||||
} else {
|
||||
s32 fadeTimer = cmd->asInt;
|
||||
|
||||
seqPlayer->state = SEQPLAYER_STATE_0;
|
||||
seqPlayer->fadeTimer = fadeTimer;
|
||||
seqPlayer->fadeVelocity = (seqPlayer->volume - seqPlayer->fadeVolume) / fadeTimer;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_BEND:
|
||||
seqPlayer->bend = cmd->asFloat;
|
||||
if (seqPlayer->bend == 1.0f) {
|
||||
seqPlayer->applyBend = false;
|
||||
} else {
|
||||
seqPlayer->applyBend = true;
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void AudioThread_ProcessChannelCmd(SequenceChannel* channel, AudioCmd* cmd) {
|
||||
u8 filterCutoff;
|
||||
|
||||
switch (cmd->op) {
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VOL_SCALE:
|
||||
if (channel->volumeScale != cmd->asFloat) {
|
||||
channel->volumeScale = cmd->asFloat;
|
||||
channel->changes.s.volume = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VOL:
|
||||
if (channel->volume != cmd->asFloat) {
|
||||
channel->volume = cmd->asFloat;
|
||||
channel->changes.s.volume = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_PAN:
|
||||
if (channel->newPan != cmd->asSbyte) {
|
||||
channel->newPan = cmd->asSbyte;
|
||||
channel->changes.s.pan = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_PAN_WEIGHT:
|
||||
if (channel->newPan != cmd->asSbyte) {
|
||||
channel->panChannelWeight = cmd->asSbyte;
|
||||
channel->changes.s.pan = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_FREQ_SCALE:
|
||||
if (channel->freqScale != cmd->asFloat) {
|
||||
channel->freqScale = cmd->asFloat;
|
||||
channel->changes.s.freqScale = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_REVERB_VOLUME:
|
||||
if (channel->targetReverbVol != cmd->asSbyte) {
|
||||
channel->targetReverbVol = cmd->asSbyte;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_REVERB_INDEX:
|
||||
if (channel->reverbIndex != cmd->asSbyte) {
|
||||
channel->reverbIndex = cmd->asSbyte;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_SURROUND_EFFECT_INDEX:
|
||||
channel->surroundEffectIndex = cmd->asSbyte;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_IO:
|
||||
if (cmd->arg2 < ARRAY_COUNT(channel->seqScriptIO)) {
|
||||
channel->seqScriptIO[cmd->arg2] = cmd->asSbyte;
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_MUTE:
|
||||
channel->muted = cmd->asSbyte;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_MUTE_FLAGS:
|
||||
channel->muteFlags = cmd->asSbyte;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VIBRATO_DEPTH:
|
||||
channel->vibrato.vibratoDepthTarget = cmd->asUbyte * 8;
|
||||
channel->vibrato.vibratoDepthChangeDelay = 1;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VIBRATO_RATE:
|
||||
channel->vibrato.vibratoRateTarget = cmd->asUbyte * 32;
|
||||
channel->vibrato.vibratoRateChangeDelay = 1;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_SIZE:
|
||||
channel->combFilterSize = cmd->asUbyte;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_GAIN:
|
||||
channel->combFilterGain = cmd->asUShort;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_STEREO:
|
||||
channel->stereoData.asByte = cmd->asUbyte;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_SET_START_POS:
|
||||
channel->startSamplePos = cmd->asInt;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_SFX_STATE:
|
||||
channel->sfxState = cmd->asUInt;
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_FILTER:
|
||||
filterCutoff = cmd->arg2;
|
||||
if (cmd->asUInt != 0) {
|
||||
channel->filter = cmd->asUInt;
|
||||
}
|
||||
if (channel->filter != NULL) {
|
||||
AudioHeap_LoadFilter(channel->filter, filterCutoff >> 4, filterCutoff & 0xF);
|
||||
}
|
||||
break;
|
||||
|
||||
case AUDIOCMD_OP_CHANNEL_SET_GAIN:
|
||||
channel->gain = cmd->asUbyte;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Call an audio-thread command that has no code to process it. Unused.
|
||||
*/
|
||||
void AudioThread_Noop1Cmd(s32 arg0, s32 arg1, s32 arg2) {
|
||||
AUDIOCMD_GLOBAL_NOOP_1(arg0, arg1, arg2, 1);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call an audio-thread command that has no code to process it. Unused.
|
||||
*/
|
||||
void AudioThread_Noop1CmdZeroed(void) {
|
||||
AUDIOCMD_GLOBAL_NOOP_1(0, 0, 0, 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Call an audio-thread command that has no code to process it. Unused.
|
||||
*/
|
||||
void AudioThread_Noop2Cmd(u32 arg0, s32 arg1) {
|
||||
AUDIOCMD_GLOBAL_NOOP_2(0, 0, arg1, arg0);
|
||||
}
|
||||
|
||||
// Unused
|
||||
void AudioThread_WaitForAudioTask(void) {
|
||||
osRecvMesg(gAudioCtx.taskStartQueueP, NULL, OS_MESG_NOBLOCK);
|
||||
osRecvMesg(gAudioCtx.taskStartQueueP, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of s16-samples from the start of the sample to the current sample position.
|
||||
* Unused
|
||||
*/
|
||||
s32 AudioThread_GetSamplePosFromStart(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex) {
|
||||
s32 pad;
|
||||
s32 loopEnd;
|
||||
s32 samplePosInt;
|
||||
|
||||
if (!AudioThread_GetSamplePos(seqPlayerIndex, channelIndex, layerIndex, &loopEnd, &samplePosInt)) {
|
||||
return 0;
|
||||
}
|
||||
return samplePosInt;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the number of s16-samples from the current sample position to the end of the sample.
|
||||
* Unused
|
||||
*/
|
||||
s32 AudioThread_GetSamplePosUntilEnd(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex) {
|
||||
s32 pad;
|
||||
s32 loopEnd;
|
||||
s32 samplePosInt;
|
||||
|
||||
if (!AudioThread_GetSamplePos(seqPlayerIndex, channelIndex, layerIndex, &loopEnd, &samplePosInt)) {
|
||||
return 0;
|
||||
}
|
||||
return loopEnd - samplePosInt;
|
||||
}
|
||||
|
||||
// Only used in unused functions
|
||||
s32 AudioThread_GetSamplePos(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex, s32* loopEnd, s32* samplePosInt) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex];
|
||||
SequenceLayer* layer;
|
||||
Note* note;
|
||||
TunedSample* tunedSample;
|
||||
|
||||
if (seqPlayer->enabled && seqPlayer->channels[channelIndex]->enabled) {
|
||||
layer = seqPlayer->channels[channelIndex]->layers[layerIndex];
|
||||
if (layer == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (layer->enabled) {
|
||||
if (layer->note == NULL) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!layer->bit3) {
|
||||
return false;
|
||||
}
|
||||
|
||||
note = layer->note;
|
||||
if (layer == note->playbackState.parentLayer) {
|
||||
|
||||
if (note->sampleState.bitField1.isSyntheticWave == true) {
|
||||
return false;
|
||||
}
|
||||
|
||||
tunedSample = note->sampleState.tunedSample;
|
||||
if (tunedSample == NULL) {
|
||||
return false;
|
||||
}
|
||||
*loopEnd = tunedSample->sample->loop->loopEnd;
|
||||
*samplePosInt = note->synthesisState.samplePosInt;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
s32 AudioThread_GetEnabledNotesCount(void) {
|
||||
return AudioThread_CountAndReleaseNotes(0);
|
||||
}
|
||||
|
||||
s32 AudioThread_GetEnabledSampledNotesCount(void) {
|
||||
return AudioThread_CountAndReleaseNotes(AUDIO_NOTE_SAMPLE_NOTES);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param flags 0: count notes. 1: release all notes. 2: count sample notes 3: release sample notes
|
||||
* @return s32 number of notes
|
||||
*/
|
||||
s32 AudioThread_CountAndReleaseNotes(s32 flags) {
|
||||
s32 noteCount;
|
||||
NotePlaybackState* playbackState;
|
||||
NoteSampleState* noteSampleState;
|
||||
s32 i;
|
||||
Note* note;
|
||||
TunedSample* tunedSample;
|
||||
|
||||
noteCount = 0;
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
note = &gAudioCtx.notes[i];
|
||||
playbackState = ¬e->playbackState;
|
||||
if (note->sampleState.bitField0.enabled) {
|
||||
noteSampleState = ¬e->sampleState;
|
||||
if (playbackState->adsr.action.s.state != ADSR_STATE_DISABLED) {
|
||||
if (flags >= AUDIO_NOTE_SAMPLE_NOTES) {
|
||||
tunedSample = noteSampleState->tunedSample;
|
||||
if ((tunedSample == NULL) || noteSampleState->bitField1.isSyntheticWave) {
|
||||
continue;
|
||||
}
|
||||
if (tunedSample->sample->medium == MEDIUM_RAM) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
noteCount++;
|
||||
if ((flags & AUDIO_NOTE_RELEASE) == AUDIO_NOTE_RELEASE) {
|
||||
playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv;
|
||||
playbackState->adsr.action.s.release = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return noteCount;
|
||||
}
|
||||
|
||||
u32 AudioThread_NextRandom(void) {
|
||||
static u32 sAudioRandom = 0x12345678;
|
||||
static u32 sAudioOsCount = 0x11111111;
|
||||
u32 count = osGetCount();
|
||||
|
||||
sAudioRandom = (gAudioCtx.totalTaskCount + sAudioRandom + count) * (gAudioCtx.audioRandom + 0x1234567);
|
||||
sAudioRandom = (sAudioRandom & 1) + (sAudioRandom * 2) + sAudioOsCount;
|
||||
sAudioOsCount = count;
|
||||
|
||||
return sAudioRandom;
|
||||
}
|
||||
|
||||
void AudioThread_InitMesgQueues(void) {
|
||||
AudioThread_InitMesgQueuesInternal();
|
||||
}
|
||||
@@ -1,81 +0,0 @@
|
||||
#include "global.h"
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80192BE0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80192C00.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019319C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801936D8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019372C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193774.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019380C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193858.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS32.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801938D0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_ScheduleProcessCmds.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193990.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801939A8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193AEC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193BA0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193C04.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193C24.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193C5C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193CB4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193D08.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193DA4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193DF0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193E44.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193E6C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193E9C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80193EA8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194080.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801942BC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194304.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194328.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019435C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019439C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_801943D0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_8019440C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194528.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194548.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/func_80194568.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_NextRandom.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_80192BE0/AudioThread_InitMesgQueues.s")
|
||||
@@ -2640,7 +2640,7 @@ void AudioOcarina_PlayControllerInput(u8 isOcarinaSfxSuppressedWhenCancelled) {
|
||||
// Add vibrato of the ocarina note based on the x control stick
|
||||
sCurOcarinaVibrato = ABS_ALT(sOcarinaInputStickRel.x) >> 2;
|
||||
// Sets vibrato to io port 6
|
||||
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 6, sCurOcarinaVibrato);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 6, sCurOcarinaVibrato);
|
||||
} else {
|
||||
// no bending or vibrato for recording state OCARINA_RECORD_SCARECROW_SPAWN
|
||||
sCurOcarinaBendIndex = 0;
|
||||
@@ -2652,10 +2652,9 @@ void AudioOcarina_PlayControllerInput(u8 isOcarinaSfxSuppressedWhenCancelled) {
|
||||
if ((sCurOcarinaPitch != OCARINA_PITCH_NONE) && (sPrevOcarinaPitch != sCurOcarinaPitch)) {
|
||||
// Sets ocarina instrument Id to io port 7, which is used
|
||||
// as an index in seq 0 to get the true instrument Id
|
||||
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 7,
|
||||
sOcarinaInstrumentId - 1);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 7, sOcarinaInstrumentId - 1);
|
||||
// Sets pitch to io port 5
|
||||
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 5, sCurOcarinaPitch);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 5, sCurOcarinaPitch);
|
||||
AudioSfx_PlaySfx(NA_SE_OC_OCARINA, &gSfxDefaultPos, 4, &sCurOcarinaBendFreq, &sDefaultOcarinaVolume,
|
||||
&gSfxDefaultReverb);
|
||||
} else if ((sPrevOcarinaPitch != OCARINA_PITCH_NONE) && (sCurOcarinaPitch == OCARINA_PITCH_NONE) &&
|
||||
@@ -2862,7 +2861,7 @@ void AudioOcarina_PlaybackSong(void) {
|
||||
// Update vibrato
|
||||
sNotePlaybackVibrato = sPlaybackSong[sPlaybackNotePos].vibrato;
|
||||
// Sets vibrato to io port 6
|
||||
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 6, sNotePlaybackVibrato);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 6, sNotePlaybackVibrato);
|
||||
|
||||
// Update bend
|
||||
if (sNotePlaybackBend != sPlaybackSong[sPlaybackNotePos].bend) {
|
||||
@@ -2892,10 +2891,9 @@ void AudioOcarina_PlaybackSong(void) {
|
||||
sPlaybackStaffPos++;
|
||||
// Sets ocarina instrument Id to io port 7, which is used
|
||||
// as an index in seq 0 to get the true instrument Id
|
||||
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 7,
|
||||
sOcarinaInstrumentId - 1);
|
||||
AudioThread_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 5,
|
||||
sPlaybackPitch & OCARINA_BUTTON_MASK_PITCH);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 7, sOcarinaInstrumentId - 1);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 5,
|
||||
sPlaybackPitch & OCARINA_BUTTON_MASK_PITCH);
|
||||
AudioSfx_PlaySfx(NA_SE_OC_OCARINA, &gSfxDefaultPos, 4, &sRelativeNotePlaybackBend,
|
||||
&sRelativeNotePlaybackVolume, &gSfxDefaultReverb);
|
||||
} else {
|
||||
@@ -3400,7 +3398,7 @@ u8 sRequestCustomSequence = false;
|
||||
void AudioOcarina_SetCustomSequence(void) {
|
||||
// Never passes true as sRequestCustomSequence is never set true
|
||||
if (sRequestCustomSequence && gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].enabled &&
|
||||
((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].soundScriptIO[0] == (u8)SEQ_IO_VAL_NONE)) {
|
||||
((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].seqScriptIO[0] == (u8)SEQ_IO_VAL_NONE)) {
|
||||
gAudioCtx.seqPlayers[SEQ_PLAYER_FANFARE].seqData = sCustomSequenceScript;
|
||||
sRequestCustomSequence = false;
|
||||
}
|
||||
@@ -3754,8 +3752,8 @@ s8 AudioSfx_ComputeReverb(u8 bankId, u8 entryIndex, u8 channelIndex) {
|
||||
}
|
||||
|
||||
if (IS_SEQUENCE_CHANNEL_VALID(gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex])) {
|
||||
scriptAdd = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1];
|
||||
if (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->soundScriptIO[1] <= SEQ_IO_VAL_NONE) {
|
||||
scriptAdd = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->seqScriptIO[1];
|
||||
if (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIndex]->seqScriptIO[1] <= SEQ_IO_VAL_NONE) {
|
||||
scriptAdd = 0;
|
||||
}
|
||||
}
|
||||
@@ -4051,8 +4049,8 @@ void AudioSfx_SetProperties(u8 bankId, u8 entryIndex, u8 channelIndex) {
|
||||
//! FAKE:
|
||||
if (1) {}
|
||||
|
||||
// CHAN_UPD_SCRIPT_IO (slot 2, sets volume)
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | (channelIndex << 8) | 2, volumeS8);
|
||||
// ioPort 2, sets volume
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, channelIndex, 2, volumeS8);
|
||||
|
||||
if (sSfxChannelState[channelIndex].reverb != reverb) {
|
||||
sSfxChannelState[channelIndex].reverb = reverb;
|
||||
@@ -4307,16 +4305,16 @@ f32 sBigBellsVolume[8] = {
|
||||
*/
|
||||
void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) {
|
||||
u8 channelIndex;
|
||||
s8 pan = 0;
|
||||
s8 panChannelWeight = 0;
|
||||
|
||||
// Ganondorfs's Lair
|
||||
if (ganonsTowerLevel == 0) {
|
||||
pan = 0x7F;
|
||||
// Pan comes entirely from the SequenceChannel
|
||||
panChannelWeight = 0x7F;
|
||||
}
|
||||
|
||||
for (channelIndex = 0; channelIndex < 16; channelIndex++) {
|
||||
// CHAN_UPD_PAN_UNSIGNED
|
||||
AudioThread_QueueCmdS8(((u8)(u32)channelIndex << 8) | 0x7000000, pan);
|
||||
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
|
||||
AUDIOCMD_CHANNEL_SET_PAN_WEIGHT(SEQ_PLAYER_BGM_MAIN, channelIndex, panChannelWeight);
|
||||
}
|
||||
|
||||
// Lowest room in Ganon's Tower (Entrance Room)
|
||||
@@ -4359,11 +4357,12 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) {
|
||||
for (channelIndex = 0; channelIndex < ARRAY_COUNT(gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels);
|
||||
channelIndex++) {
|
||||
if (&gAudioCtx.sequenceChannelNone != gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]) {
|
||||
// soundScriptIO[5] was set to 0x40 in channels 0, 1, and 4 (BGM no longer in OoT)
|
||||
if ((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] !=
|
||||
// seqScriptIO[5] was originally set to 0x40 in channels 0, 1, and 4 by OoT's Ganon's Tower BGM,
|
||||
// which was removed in MM
|
||||
if ((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->seqScriptIO[5] !=
|
||||
(u8)SEQ_IO_VAL_NONE) {
|
||||
// Higher volume leads to lower reverb
|
||||
reverb = (((u16)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->soundScriptIO[5] -
|
||||
reverb = (((u16)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->seqScriptIO[5] -
|
||||
targetVolume) +
|
||||
0x7F);
|
||||
|
||||
@@ -4371,10 +4370,7 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVolume) {
|
||||
reverb = 0x7F;
|
||||
}
|
||||
|
||||
// CHAN_UPD_REVERB
|
||||
AudioThread_QueueCmdS8(_SHIFTL(5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) |
|
||||
_SHIFTL(channelIndex, 8, 8),
|
||||
(u8)reverb);
|
||||
AUDIOCMD_CHANNEL_SET_REVERB_VOLUME(SEQ_PLAYER_BGM_MAIN, channelIndex, (u8)reverb);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4445,9 +4441,7 @@ void AudioSfx_SetChannelIO(Vec3f* pos, u16 sfxId, u8 ioData) {
|
||||
|
||||
if (entryIndex != 0xFF) {
|
||||
if ((sfxId == gSfxBanks[bankId][entryIndex].sfxId) && (&pos->x == gSfxBanks[bankId][entryIndex].posX)) {
|
||||
AudioThread_QueueCmdS8(_SHIFTL(6, 24, 8) | _SHIFTL(SEQ_PLAYER_SFX, 16, 8) |
|
||||
_SHIFTL(channelIndex, 8, 8) | _SHIFTL(6, 0, 8),
|
||||
ioData);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, channelIndex, 6, ioData);
|
||||
}
|
||||
}
|
||||
channelIndex++;
|
||||
@@ -4498,7 +4492,7 @@ void func_801A09D4(Vec3f* pos, f32 xzDistToPlayer) {
|
||||
if (channelIndex != 9) {
|
||||
Audio_QueueSeqCmd(((u32)(6) << 28) | ((u32)(SEQ_PLAYER_BGM_MAIN) << 24) | ((u32)(2) << 16) |
|
||||
((u32)(channelIndex) << 8) | ((u8)(127.0f * volumeRel)));
|
||||
AudioThread_QueueCmdS8(0x03000000 | ((u8)((u32)channelIndex) << 8), pan);
|
||||
AUDIOCMD_CHANNEL_SET_PAN(SEQ_PLAYER_BGM_MAIN, channelIndex, pan);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4721,7 +4715,7 @@ void Audio_UpdateSceneSequenceResumePoint(void) {
|
||||
if ((seqId != NA_BGM_DISABLED) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) {
|
||||
if (sSeqResumePoint != SEQ_RESUME_POINT_NONE) {
|
||||
// Get the current point to resume from
|
||||
sSeqResumePoint = gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3];
|
||||
sSeqResumePoint = gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[3];
|
||||
} else {
|
||||
// Initialize the point to resume from to the start of the sequence
|
||||
sSeqResumePoint = 0;
|
||||
@@ -5089,7 +5083,7 @@ void Audio_StartAmbience(u16 initChannelMask, u16 initMuteChannelMask) {
|
||||
if ((Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_DISABLED) &&
|
||||
(Audio_GetActiveSequence(SEQ_PLAYER_AMBIENCE) != NA_BGM_AMBIENCE)) {
|
||||
Audio_StopSequence(SEQ_PLAYER_AMBIENCE, 0);
|
||||
AudioThread_QueueCmdS32(0xF8 << 24, 0);
|
||||
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
|
||||
}
|
||||
|
||||
if (Audio_GetActiveSequence(SEQ_PLAYER_BGM_SUB) == (NA_BGM_ENEMY | 0x800)) {
|
||||
@@ -5164,12 +5158,11 @@ void AudioSfx_Init(u16 fadeTimer) {
|
||||
Audio_StartSequence(SEQ_PLAYER_SFX, NA_BGM_GENERAL_SFX, 0x70, fadeTimer);
|
||||
|
||||
for (channelIndex = 0; channelIndex < ARRAY_COUNT(sSfxChannelState); channelIndex++) {
|
||||
AudioThread_QueueCmdS32(0x10 << 24 | SEQ_PLAYER_SFX << 16 | ((u8)(u32)channelIndex << 8),
|
||||
&sSfxChannelState[channelIndex]);
|
||||
AUDIOCMD_CHANNEL_SET_SFX_STATE(SEQ_PLAYER_SFX, channelIndex, &sSfxChannelState[channelIndex]);
|
||||
}
|
||||
|
||||
AudioThread_QueueCmdS32(0xE4000000, AudioSfx_SetFreqAndStereoBits);
|
||||
AudioThread_QueueCmdS32(0xE4000001, Audio_SetAmbienceRandomBend);
|
||||
AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(AUDIO_CUSTOM_FUNCTION_SEQ_0, AudioSfx_SetFreqAndStereoBits);
|
||||
AUDIOCMD_GLOBAL_SET_CUSTOM_FUNCTION(AUDIO_CUSTOM_FUNCTION_SEQ_1, Audio_SetAmbienceRandomBend);
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_8019AF00/func_801A4D00.s")
|
||||
|
||||
@@ -410,9 +410,8 @@ void AudioSfx_ChooseActiveSfx(u8 bankId) {
|
||||
// If a "one-frame" sfx is still in "SFX_STATE_PLAYING_ONE_FRAME", then remove the sfx
|
||||
} else if (!(gSfxBanks[bankId][entryIndex].sfxId & SFX_FLAG_MASK) &&
|
||||
(gSfxBanks[bankId][entryIndex].state == SFX_STATE_PLAYING_ONE_FRAME)) {
|
||||
// CHAN_UPD_SCRIPT_IO (ioPort 0, force stop sfx in seq 0)
|
||||
AudioThread_QueueCmdS8(
|
||||
(0x6 << 24) | (SEQ_PLAYER_SFX << 16) | (gSfxBanks[bankId][entryIndex].channelIndex << 8), 0);
|
||||
// ioPort 0, force stop sfx in seq 0
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, gSfxBanks[bankId][entryIndex].channelIndex, 0, 0);
|
||||
AudioSfx_RemoveBankEntry(bankId, entryIndex);
|
||||
}
|
||||
|
||||
@@ -459,8 +458,8 @@ void AudioSfx_ChooseActiveSfx(u8 bankId) {
|
||||
|
||||
// If too far away and also playing, stop playing
|
||||
if (entry->state == SFX_STATE_PLAYING) {
|
||||
// CHAN_UPD_SCRIPT_IO (ioPort 0, force stop sfx in seq 0)
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | (entry->channelIndex << 8), 0);
|
||||
// ioPort 0, force stop sfx in seq 0
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
if (entry->sfxId & SFX_FLAG_MASK) {
|
||||
AudioSfx_RemoveBankEntry(bankId, entryIndex);
|
||||
entryIndex = k;
|
||||
@@ -632,15 +631,11 @@ void AudioSfx_PlayActiveSfx(u8 bankId) {
|
||||
// Calculate all the properties of sfx
|
||||
AudioSfx_SetProperties(bankId, entryIndex, sCurSfxPlayerChannelIndex);
|
||||
|
||||
// CHAN_UPD_SCRIPT_IO (ioPort 0, enable the sfx to play in seq 0)
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((sCurSfxPlayerChannelIndex & 0xFF) << 8),
|
||||
1);
|
||||
// ioPort 0, enable the sfx to play in `NA_BGM_GENERAL_SFX`
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 0, 1);
|
||||
|
||||
// CHAN_UPD_SCRIPT_IO (ioPort 4, write the lower bits sfx index to seq 0 so it can find the right code
|
||||
// to execute)
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) |
|
||||
((sCurSfxPlayerChannelIndex & 0xFF) << 8) | 4,
|
||||
entry->sfxId & 0xFF);
|
||||
// ioPort 4, write the lower bits sfx index for `NA_BGM_GENERAL_SFX` to find the right code to execute
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 4, entry->sfxId & 0xFF);
|
||||
|
||||
// If the sfx bank has more than 255 entries (greater than a u8 can store),
|
||||
// then store the Id in upper and lower bits
|
||||
@@ -656,11 +651,9 @@ void AudioSfx_PlayActiveSfx(u8 bankId) {
|
||||
}
|
||||
|
||||
if (D_801D6608[bankId]) {
|
||||
// CHAN_UPD_SCRIPT_IO (ioPort 5, write the upper bits sfx index and a flag to seq 0, for banks with
|
||||
// > 0xFF entries)
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) |
|
||||
((sCurSfxPlayerChannelIndex & 0xFF) << 8) | 5,
|
||||
ioPort5Data);
|
||||
// ioPort 5, write the upper bits sfx index and a flag for `NA_BGM_GENERAL_SFX`,
|
||||
// for banks with > 0xFF entries
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 5, ioPort5Data);
|
||||
}
|
||||
|
||||
// Update playing state
|
||||
@@ -671,7 +664,7 @@ void AudioSfx_PlayActiveSfx(u8 bankId) {
|
||||
// "one-frame" sfx
|
||||
entry->state = SFX_STATE_PLAYING_ONE_FRAME;
|
||||
}
|
||||
} else if ((u8)channel->soundScriptIO[1] == (u8)SEQ_IO_VAL_NONE) {
|
||||
} else if ((u8)channel->seqScriptIO[1] == (u8)SEQ_IO_VAL_NONE) {
|
||||
// Signal from seq 0 that the sfx is finished playing. Remove entry
|
||||
AudioSfx_RemoveBankEntry(bankId, entryIndex);
|
||||
} else if (entry->state == SFX_STATE_PLAYING_REFRESH) {
|
||||
@@ -702,7 +695,7 @@ void AudioSfx_StopByBank(u8 bankId) {
|
||||
while (entryIndex != 0xFF) {
|
||||
entry = &gSfxBanks[bankId][entryIndex];
|
||||
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
@@ -724,7 +717,7 @@ void AudioSfx_StopByPosAndBankImpl(u8 bankId, Vec3f* pos) {
|
||||
entry = &gSfxBanks[bankId][entryIndex];
|
||||
if (entry->posX == &pos->x) {
|
||||
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
@@ -769,7 +762,7 @@ void AudioSfx_StopByPosAndId(Vec3f* pos, u16 sfxId) {
|
||||
entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex];
|
||||
if ((entry->posX == &pos->x) && (entry->sfxId == sfxId)) {
|
||||
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
@@ -800,7 +793,7 @@ void AudioSfx_StopByTokenAndId(u8 token, u16 sfxId) {
|
||||
entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex];
|
||||
if ((entry->token == token) && (entry->sfxId == sfxId)) {
|
||||
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
@@ -830,7 +823,7 @@ void AudioSfx_StopById(u32 sfxId) {
|
||||
entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex];
|
||||
if (entry->sfxId == sfxId) {
|
||||
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
|
||||
AudioThread_QueueCmdS8((0x6 << 24) | (SEQ_PLAYER_SFX << 16) | ((entry->channelIndex & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
AudioSfx_RemoveBankEntry(SFX_BANK(sfxId), entryIndex);
|
||||
|
||||
+1
-1
@@ -39,7 +39,7 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
||||
if (SREG(20) >= 2) {
|
||||
rspTask = NULL;
|
||||
} else {
|
||||
rspTask = func_80192BE0();
|
||||
rspTask = AudioThread_Update();
|
||||
}
|
||||
|
||||
if (audioMgr->rspTask != NULL) {
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
* Description: Fishing Pond Elements (Owner, Fish, Props, Effects...)
|
||||
*/
|
||||
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "z_en_fishing.h"
|
||||
#include "z64rumble.h"
|
||||
#include "z64shrink_window.h"
|
||||
|
||||
@@ -484,7 +484,7 @@
|
||||
0x801877D0 : "audio_synthesis",
|
||||
0x8018B0F0 : "audio_heap",
|
||||
0x8018EB60 : "audio_load",
|
||||
0x80192BE0 : "code_80192BE0",
|
||||
0x80192BE0 : "audio_thread",
|
||||
0x80194710 : "audio_dcache",
|
||||
0x80194790 : "aisetnextbuf",
|
||||
0x80194930 : "audio_playback",
|
||||
@@ -588,7 +588,7 @@
|
||||
0x801D2E80 : "audio_data",
|
||||
0x801D5FB0 : "audio_synthesis",
|
||||
0x801D5FE0 : "audio_load",
|
||||
0x801D5FF0 : "code_80192BE0",
|
||||
0x801D5FF0 : "audio_thread",
|
||||
0x801D6010 : "aisetnextbuf",
|
||||
0x801D6190 : "audio_effects",
|
||||
0x801D61A0 : "audio_seqplayer",
|
||||
@@ -672,7 +672,7 @@
|
||||
0x801E0280 : "audio_synthesis",
|
||||
0x801E02B0 : "audio_heap",
|
||||
0x801E0300 : "audio_load",
|
||||
0x801E0390 : "code_80192BE0",
|
||||
0x801E0390 : "audio_thread",
|
||||
0x801E04E0 : "audio_playback",
|
||||
0x801E0510 : "audio_effects",
|
||||
0x801E0540 : "audio_seqplayer",
|
||||
|
||||
+34
-34
@@ -3680,44 +3680,44 @@
|
||||
0x80192AE8:("AudioLoad_ScriptLoad",),
|
||||
0x80192B54:("AudioLoad_ProcessScriptLoads",),
|
||||
0x80192BAC:("AudioLoad_InitScriptLoads",),
|
||||
0x80192BE0:("func_80192BE0",),
|
||||
0x80192C00:("func_80192C00",),
|
||||
0x8019319C:("func_8019319C",),
|
||||
0x801936D8:("func_801936D8",),
|
||||
0x8019372C:("func_8019372C",),
|
||||
0x80193774:("func_80193774",),
|
||||
0x8019380C:("func_8019380C",),
|
||||
0x80193858:("func_80193858",),
|
||||
0x80192BE0:("AudioThread_Update",),
|
||||
0x80192C00:("AudioThread_UpdateImpl",),
|
||||
0x8019319C:("AudioThread_ProcessGlobalCmd",),
|
||||
0x801936D8:("AudioThread_SetFadeOutTimer",),
|
||||
0x8019372C:("AudioThread_SetFadeInTimer",),
|
||||
0x80193774:("AudioThread_InitMesgQueuesInternal",),
|
||||
0x8019380C:("AudioThread_QueueCmd",),
|
||||
0x80193858:("AudioThread_QueueCmdF32",),
|
||||
0x8019387C:("AudioThread_QueueCmdS32",),
|
||||
0x801938A0:("AudioThread_QueueCmdS8",),
|
||||
0x801938D0:("func_801938D0",),
|
||||
0x801938D0:("AudioThread_QueueCmdU16",),
|
||||
0x80193900:("AudioThread_ScheduleProcessCmds",),
|
||||
0x80193990:("func_80193990",),
|
||||
0x801939A8:("func_801939A8",),
|
||||
0x80193AEC:("func_80193AEC",),
|
||||
0x80193BA0:("func_80193BA0",),
|
||||
0x80193C04:("func_80193C04",),
|
||||
0x80193C24:("func_80193C24",),
|
||||
0x80193990:("AudioThread_ResetCmdQueue",),
|
||||
0x801939A8:("AudioThread_ProcessCmd",),
|
||||
0x80193AEC:("AudioThread_ProcessCmds",),
|
||||
0x80193BA0:("AudioThread_GetExternalLoadQueueMsg",),
|
||||
0x80193C04:("AudioThread_GetFontsForSequence",),
|
||||
0x80193C24:("AudioThread_GetSampleBankIdsOfFont",),
|
||||
0x80193C5C:("func_80193C5C",),
|
||||
0x80193CB4:("func_80193CB4",),
|
||||
0x80193D08:("func_80193D08",),
|
||||
0x80193DA4:("func_80193DA4",),
|
||||
0x80193DF0:("func_80193DF0",),
|
||||
0x80193E44:("func_80193E44",),
|
||||
0x80193E6C:("func_80193E6C",),
|
||||
0x80193E9C:("func_80193E9C",),
|
||||
0x80193EA8:("func_80193EA8",),
|
||||
0x80194080:("func_80194080",),
|
||||
0x801942BC:("func_801942BC",),
|
||||
0x80194304:("func_80194304",),
|
||||
0x80194328:("func_80194328",),
|
||||
0x8019435C:("func_8019435C",),
|
||||
0x8019439C:("func_8019439C",),
|
||||
0x801943D0:("func_801943D0",),
|
||||
0x8019440C:("func_8019440C",),
|
||||
0x80194528:("func_80194528",),
|
||||
0x80194548:("func_80194548",),
|
||||
0x80194568:("func_80194568",),
|
||||
0x80193CB4:("AudioThread_WaitForAudioResetQueueP",),
|
||||
0x80193D08:("AudioThread_ResetAudioHeap",),
|
||||
0x80193DA4:("AudioThread_PreNMIInternal",),
|
||||
0x80193DF0:("AudioThread_GetChannelIO",),
|
||||
0x80193E44:("AudioThread_GetSeqPlayerIO",),
|
||||
0x80193E6C:("AudioThread_InitExternalPool",),
|
||||
0x80193E9C:("AudioThread_ResetExternalPool",),
|
||||
0x80193EA8:("AudioThread_ProcessSeqPlayerCmd",),
|
||||
0x80194080:("AudioThread_ProcessChannelCmd",),
|
||||
0x801942BC:("AudioThread_Noop1Cmd",),
|
||||
0x80194304:("AudioThread_Noop1CmdZeroed",),
|
||||
0x80194328:("AudioThread_Noop2Cmd",),
|
||||
0x8019435C:("AudioThread_WaitForAudioTask",),
|
||||
0x8019439C:("AudioThread_GetSamplePosFromStart",),
|
||||
0x801943D0:("AudioThread_GetSamplePosUntilEnd",),
|
||||
0x8019440C:("AudioThread_GetSamplePos",),
|
||||
0x80194528:("AudioThread_GetEnabledNotesCount",),
|
||||
0x80194548:("AudioThread_GetEnabledSampledNotesCount",),
|
||||
0x80194568:("AudioThread_CountAndReleaseNotes",),
|
||||
0x80194668:("AudioThread_NextRandom",),
|
||||
0x801946E4:("AudioThread_InitMesgQueues",),
|
||||
0x80194710:("Audio_InvalDCache",),
|
||||
|
||||
@@ -2249,11 +2249,11 @@
|
||||
0x801D5FE4:("D_801D5FE4","UNK_TYPE1","",0x1),
|
||||
0x801D5FE8:("gAudioCtxInitalized","UNK_TYPE4","",0x4),
|
||||
0x801D5FEC:("D_801D5FEC","UNK_TYPE4","",0x4),
|
||||
0x801D5FF0:("D_801D5FF0","UNK_TYPE4","",0x4),
|
||||
0x801D5FF4:("D_801D5FF4","UNK_TYPE4","",0x4),
|
||||
0x801D5FF8:("D_801D5FF8","UNK_TYPE1","",0x1),
|
||||
0x801D5FFC:("D_801D5FFC","UNK_TYPE4","",0x4),
|
||||
0x801D6000:("D_801D6000","UNK_PTR","",0x4),
|
||||
0x801D5FF0:("sWaitingAudioTask","UNK_TYPE4","",0x4),
|
||||
0x801D5FF4:("sMaxWriteReadDiff","UNK_TYPE4","",0x4),
|
||||
0x801D5FF8:("sCurCmdRdPos","UNK_TYPE1","",0x1),
|
||||
0x801D5FFC:("sAudioRandom","UNK_TYPE4","",0x4),
|
||||
0x801D6000:("sAudioOsCount","UNK_PTR","",0x4),
|
||||
0x801D6010:("D_801D6010","UNK_TYPE1","",0x1),
|
||||
0x801D6014:("D_801D6014","UNK_TYPE1","",0x1),
|
||||
0x801D6028:("D_801D6028","UNK_TYPE1","",0x1),
|
||||
@@ -4352,10 +4352,10 @@
|
||||
0x80200BCE:("D_80200BCE","UNK_TYPE1","",0x1),
|
||||
0x80200BD0:("D_80200BD0","UNK_TYPE1","",0x1),
|
||||
0x80200C70:("gAudioCtx","AudioContext","",0x81F8),
|
||||
0x80208E68:("gCustomAudioUpdateFunction","UNK_TYPE4","",0x4),
|
||||
0x80208E6C:("gCustomAudioSeqFunction","UNK_TYPE4","",0x4),
|
||||
0x80208E70:("gCustomAudioReverbFunction","UNK_TYPE4","",0x4),
|
||||
0x80208E74:("gCustomAudioSynthFunction","UNK_TYPE4","",0x4),
|
||||
0x80208E68:("gAudioCustomUpdateFunction","UNK_TYPE4","",0x4),
|
||||
0x80208E6C:("gAudioCustomSeqFunction","UNK_TYPE4","",0x4),
|
||||
0x80208E70:("gAudioCustomReverbFunction","UNK_TYPE4","",0x4),
|
||||
0x80208E74:("gAudioCustomSynthFunction","UNK_TYPE4","",0x4),
|
||||
0x80208E90:("sJpegBitStreamPtr","UNK_TYPE1","",0x1),
|
||||
0x80208E94:("sJpegBitStreamByteIdx","UNK_TYPE1","",0x1),
|
||||
0x80208E98:("sJpegBitStreamBitIdx","UNK_TYPE1","",0x1),
|
||||
|
||||
@@ -3196,46 +3196,46 @@ asm/non_matchings/code/audio_load/AudioLoad_Unused5.s,AudioLoad_Unused5,0x80192A
|
||||
asm/non_matchings/code/audio_load/AudioLoad_ScriptLoad.s,AudioLoad_ScriptLoad,0x80192AE8,0x1B
|
||||
asm/non_matchings/code/audio_load/AudioLoad_ProcessScriptLoads.s,AudioLoad_ProcessScriptLoads,0x80192B54,0x16
|
||||
asm/non_matchings/code/audio_load/AudioLoad_InitScriptLoads.s,AudioLoad_InitScriptLoads,0x80192BAC,0xD
|
||||
asm/non_matchings/code/code_80192BE0/func_80192BE0.s,func_80192BE0,0x80192BE0,0x8
|
||||
asm/non_matchings/code/code_80192BE0/func_80192C00.s,func_80192C00,0x80192C00,0x167
|
||||
asm/non_matchings/code/code_80192BE0/func_8019319C.s,func_8019319C,0x8019319C,0x14F
|
||||
asm/non_matchings/code/code_80192BE0/func_801936D8.s,func_801936D8,0x801936D8,0x15
|
||||
asm/non_matchings/code/code_80192BE0/func_8019372C.s,func_8019372C,0x8019372C,0x12
|
||||
asm/non_matchings/code/code_80192BE0/func_80193774.s,func_80193774,0x80193774,0x26
|
||||
asm/non_matchings/code/code_80192BE0/func_8019380C.s,func_8019380C,0x8019380C,0x13
|
||||
asm/non_matchings/code/code_80192BE0/func_80193858.s,func_80193858,0x80193858,0x9
|
||||
asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS32.s,AudioThread_QueueCmdS32,0x8019387C,0x9
|
||||
asm/non_matchings/code/code_80192BE0/AudioThread_QueueCmdS8.s,AudioThread_QueueCmdS8,0x801938A0,0xC
|
||||
asm/non_matchings/code/code_80192BE0/func_801938D0.s,func_801938D0,0x801938D0,0xC
|
||||
asm/non_matchings/code/code_80192BE0/AudioThread_ScheduleProcessCmds.s,AudioThread_ScheduleProcessCmds,0x80193900,0x24
|
||||
asm/non_matchings/code/code_80192BE0/func_80193990.s,func_80193990,0x80193990,0x6
|
||||
asm/non_matchings/code/code_80192BE0/func_801939A8.s,func_801939A8,0x801939A8,0x51
|
||||
asm/non_matchings/code/code_80192BE0/func_80193AEC.s,func_80193AEC,0x80193AEC,0x2D
|
||||
asm/non_matchings/code/code_80192BE0/func_80193BA0.s,func_80193BA0,0x80193BA0,0x19
|
||||
asm/non_matchings/code/code_80192BE0/func_80193C04.s,func_80193C04,0x80193C04,0x8
|
||||
asm/non_matchings/code/code_80192BE0/func_80193C24.s,func_80193C24,0x80193C24,0xE
|
||||
asm/non_matchings/code/code_80192BE0/func_80193C5C.s,func_80193C5C,0x80193C5C,0x16
|
||||
asm/non_matchings/code/code_80192BE0/func_80193CB4.s,func_80193CB4,0x80193CB4,0x15
|
||||
asm/non_matchings/code/code_80192BE0/func_80193D08.s,func_80193D08,0x80193D08,0x27
|
||||
asm/non_matchings/code/code_80192BE0/func_80193DA4.s,func_80193DA4,0x80193DA4,0x13
|
||||
asm/non_matchings/code/code_80192BE0/func_80193DF0.s,func_80193DF0,0x80193DF0,0x15
|
||||
asm/non_matchings/code/code_80192BE0/func_80193E44.s,func_80193E44,0x80193E44,0xA
|
||||
asm/non_matchings/code/code_80192BE0/func_80193E6C.s,func_80193E6C,0x80193E6C,0xC
|
||||
asm/non_matchings/code/code_80192BE0/func_80193E9C.s,func_80193E9C,0x80193E9C,0x3
|
||||
asm/non_matchings/code/code_80192BE0/func_80193EA8.s,func_80193EA8,0x80193EA8,0x76
|
||||
asm/non_matchings/code/code_80192BE0/func_80194080.s,func_80194080,0x80194080,0x8F
|
||||
asm/non_matchings/code/code_80192BE0/func_801942BC.s,func_801942BC,0x801942BC,0x12
|
||||
asm/non_matchings/code/code_80192BE0/func_80194304.s,func_80194304,0x80194304,0x9
|
||||
asm/non_matchings/code/code_80192BE0/func_80194328.s,func_80194328,0x80194328,0xD
|
||||
asm/non_matchings/code/code_80192BE0/func_8019435C.s,func_8019435C,0x8019435C,0x10
|
||||
asm/non_matchings/code/code_80192BE0/func_8019439C.s,func_8019439C,0x8019439C,0xD
|
||||
asm/non_matchings/code/code_80192BE0/func_801943D0.s,func_801943D0,0x801943D0,0xF
|
||||
asm/non_matchings/code/code_80192BE0/func_8019440C.s,func_8019440C,0x8019440C,0x47
|
||||
asm/non_matchings/code/code_80192BE0/func_80194528.s,func_80194528,0x80194528,0x8
|
||||
asm/non_matchings/code/code_80192BE0/func_80194548.s,func_80194548,0x80194548,0x8
|
||||
asm/non_matchings/code/code_80192BE0/func_80194568.s,func_80194568,0x80194568,0x40
|
||||
asm/non_matchings/code/code_80192BE0/AudioThread_NextRandom.s,AudioThread_NextRandom,0x80194668,0x1F
|
||||
asm/non_matchings/code/code_80192BE0/AudioThread_InitMesgQueues.s,AudioThread_InitMesgQueues,0x801946E4,0xB
|
||||
asm/non_matchings/code/audio_thread/AudioThread_Update.s,AudioThread_Update,0x80192BE0,0x8
|
||||
asm/non_matchings/code/audio_thread/AudioThread_UpdateImpl.s,AudioThread_UpdateImpl,0x80192C00,0x167
|
||||
asm/non_matchings/code/audio_thread/AudioThread_ProcessGlobalCmd.s,AudioThread_ProcessGlobalCmd,0x8019319C,0x14F
|
||||
asm/non_matchings/code/audio_thread/AudioThread_SetFadeOutTimer.s,AudioThread_SetFadeOutTimer,0x801936D8,0x15
|
||||
asm/non_matchings/code/audio_thread/AudioThread_SetFadeInTimer.s,AudioThread_SetFadeInTimer,0x8019372C,0x12
|
||||
asm/non_matchings/code/audio_thread/AudioThread_InitMesgQueuesInternal.s,AudioThread_InitMesgQueuesInternal,0x80193774,0x26
|
||||
asm/non_matchings/code/audio_thread/AudioThread_QueueCmd.s,AudioThread_QueueCmd,0x8019380C,0x13
|
||||
asm/non_matchings/code/audio_thread/AudioThread_QueueCmdF32.s,AudioThread_QueueCmdF32,0x80193858,0x9
|
||||
asm/non_matchings/code/audio_thread/AudioThread_QueueCmdS32.s,AudioThread_QueueCmdS32,0x8019387C,0x9
|
||||
asm/non_matchings/code/audio_thread/AudioThread_QueueCmdS8.s,AudioThread_QueueCmdS8,0x801938A0,0xC
|
||||
asm/non_matchings/code/audio_thread/AudioThread_QueueCmdU16.s,AudioThread_QueueCmdU16,0x801938D0,0xC
|
||||
asm/non_matchings/code/audio_thread/AudioThread_ScheduleProcessCmds.s,AudioThread_ScheduleProcessCmds,0x80193900,0x24
|
||||
asm/non_matchings/code/audio_thread/AudioThread_ResetCmdQueue.s,AudioThread_ResetCmdQueue,0x80193990,0x6
|
||||
asm/non_matchings/code/audio_thread/AudioThread_ProcessCmd.s,AudioThread_ProcessCmd,0x801939A8,0x51
|
||||
asm/non_matchings/code/audio_thread/AudioThread_ProcessCmds.s,AudioThread_ProcessCmds,0x80193AEC,0x2D
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetExternalLoadQueueMsg.s,AudioThread_GetExternalLoadQueueMsg,0x80193BA0,0x19
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetFontsForSequence.s,AudioThread_GetFontsForSequence,0x80193C04,0x8
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetSampleBankIdsOfFont.s,AudioThread_GetSampleBankIdsOfFont,0x80193C24,0xE
|
||||
asm/non_matchings/code/audio_thread/func_80193C5C.s,func_80193C5C,0x80193C5C,0x16
|
||||
asm/non_matchings/code/audio_thread/AudioThread_WaitForAudioResetQueueP.s,AudioThread_WaitForAudioResetQueueP,0x80193CB4,0x15
|
||||
asm/non_matchings/code/audio_thread/AudioThread_ResetAudioHeap.s,AudioThread_ResetAudioHeap,0x80193D08,0x27
|
||||
asm/non_matchings/code/audio_thread/AudioThread_PreNMIInternal.s,AudioThread_PreNMIInternal,0x80193DA4,0x13
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetChannelIO.s,AudioThread_GetChannelIO,0x80193DF0,0x15
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetSeqPlayerIO.s,AudioThread_GetSeqPlayerIO,0x80193E44,0xA
|
||||
asm/non_matchings/code/audio_thread/AudioThread_InitExternalPool.s,AudioThread_InitExternalPool,0x80193E6C,0xC
|
||||
asm/non_matchings/code/audio_thread/AudioThread_ResetExternalPool.s,AudioThread_ResetExternalPool,0x80193E9C,0x3
|
||||
asm/non_matchings/code/audio_thread/AudioThread_ProcessSeqPlayerCmd.s,AudioThread_ProcessSeqPlayerCmd,0x80193EA8,0x76
|
||||
asm/non_matchings/code/audio_thread/AudioThread_ProcessChannelCmd.s,AudioThread_ProcessChannelCmd,0x80194080,0x8F
|
||||
asm/non_matchings/code/audio_thread/AudioThread_Noop1Cmd.s,AudioThread_Noop1Cmd,0x801942BC,0x12
|
||||
asm/non_matchings/code/audio_thread/AudioThread_Noop1CmdZeroed.s,AudioThread_Noop1CmdZeroed,0x80194304,0x9
|
||||
asm/non_matchings/code/audio_thread/AudioThread_Noop2Cmd.s,AudioThread_Noop2Cmd,0x80194328,0xD
|
||||
asm/non_matchings/code/audio_thread/AudioThread_WaitForAudioTask.s,AudioThread_WaitForAudioTask,0x8019435C,0x10
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetSamplePosFromStart.s,AudioThread_GetSamplePosFromStart,0x8019439C,0xD
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetSamplePosUntilEnd.s,AudioThread_GetSamplePosUntilEnd,0x801943D0,0xF
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetSamplePos.s,AudioThread_GetSamplePos,0x8019440C,0x47
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetEnabledNotesCount.s,AudioThread_GetEnabledNotesCount,0x80194528,0x8
|
||||
asm/non_matchings/code/audio_thread/AudioThread_GetEnabledSampledNotesCount.s,AudioThread_GetEnabledSampledNotesCount,0x80194548,0x8
|
||||
asm/non_matchings/code/audio_thread/AudioThread_CountAndReleaseNotes.s,AudioThread_CountAndReleaseNotes,0x80194568,0x40
|
||||
asm/non_matchings/code/audio_thread/AudioThread_NextRandom.s,AudioThread_NextRandom,0x80194668,0x1F
|
||||
asm/non_matchings/code/audio_thread/AudioThread_InitMesgQueues.s,AudioThread_InitMesgQueues,0x801946E4,0xB
|
||||
asm/non_matchings/code/code_80194710/Audio_InvalDCache.s,Audio_InvalDCache,0x80194710,0x10
|
||||
asm/non_matchings/code/code_80194710/Audio_WritebackDCache.s,Audio_WritebackDCache,0x80194750,0x10
|
||||
asm/non_matchings/code/code_80194710/osAiSetNextBuffer.s,osAiSetNextBuffer,0x80194790,0x1D
|
||||
|
||||
|
@@ -131,6 +131,8 @@ D_80025D00 = 0x80025D00;
|
||||
|
||||
rspbootTextSize = 0x160;
|
||||
rspbootTextEnd = rspbootTextStart + rspbootTextSize;
|
||||
aspMainTextEnd = aspMainTextStart + 0x1000;
|
||||
aspMainDataEnd = aspMainDataStart + 0x2E0;
|
||||
|
||||
// Segmented Addresses
|
||||
|
||||
|
||||
Reference in New Issue
Block a user