mirror of
https://github.com/zeldaret/oot.git
synced 2025-05-11 03:23:46 +00:00
Document Audio Thread Commands (#1399)
* begin docs * cleanup * copy over progress * cleanup * small cleanup * more docs, fill out cmds * small touchup * pan weight ganon comment * fix specId * seqcmd cleanup * format * small cleanup * one more thing * small feedback from MM * partial PR * some PR Suggestions * small adjustments * ticks, seqticks, frames, updates: term cleanup * small fix * PR Review * PR Review * PR Review * rm param * adjust comment * update renamed functions * format --------- Co-authored-by: Dragorn421 <Dragorn421@users.noreply.github.com>
This commit is contained in:
parent
d65fb6ed28
commit
a0d31dba68
25 changed files with 1393 additions and 842 deletions
537
include/audiothread_cmd.h
Normal file
537
include/audiothread_cmd.h
Normal file
|
@ -0,0 +1,537 @@
|
|||
#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_BEHAVIOR,
|
||||
/* 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,
|
||||
// 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_SEQTICKS,
|
||||
// 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,
|
||||
/* 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;
|
||||
|
||||
// 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 (s8) proportion of pan that comes from the channel.
|
||||
* Set to 0 for layer-only, and 128 for channel-only.
|
||||
* As the type used is `s8` and internally cast to u8 later,
|
||||
* pass `-128` to produce 128, or just use 127 instead
|
||||
*/
|
||||
#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 muteBehavior for a specified channel
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelIndex the index of the channel to modify
|
||||
* @param muteBehavior (s8) Affected how a muted channel behaves. See `MUTE_BEHAVIOR_` macros
|
||||
*/
|
||||
#define AUDIOCMD_CHANNEL_SET_MUTE_BEHAVIOR(seqPlayerIndex, channelIndex, muteBehavior) \
|
||||
AudioThread_QueueCmdS8(AUDIO_MK_CMD(AUDIOCMD_OP_CHANNEL_SET_MUTE_BEHAVIOR, seqPlayerIndex, channelIndex, 0), \
|
||||
muteBehavior)
|
||||
|
||||
/**
|
||||
* Set the vibrato depth (also called 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)
|
||||
|
||||
// ==== 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 seqTicks per minute
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param tempoChange (s32) difference in tempo to change, in seqTicks per minute
|
||||
*/
|
||||
#define AUDIOCMD_SEQPLAYER_CHANGE_TEMPO_SEQTICKS(seqPlayerIndex, tempoChange) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO_SEQTICKS, 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
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_SYNC_LOAD_SEQ_PARTS(seqId, flags) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_SYNC_LOAD_SEQ_PARTS, 0, seqId, flags), 0)
|
||||
|
||||
/**
|
||||
* 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, fontId, drumId, 0), 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, fontId, soundEffectId, 0), 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, fontId, instId, 0), 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)
|
||||
|
||||
/**
|
||||
* 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 all sequence players
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_MUTE() \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_MUTE, 0, 0, 0), 0)
|
||||
|
||||
/**
|
||||
* Unmute all sequence players
|
||||
*
|
||||
* @param restartNotes (s32) if set to 1, then notes with the `MUTE_BEHAVIOR_STOP_SAMPLES` flag set
|
||||
* are marked as finished for all seqPlayers
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_UNMUTE(restartNotes) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_UNMUTE, 0, 0, 0), restartNotes)
|
||||
|
||||
/**
|
||||
* 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, 0, 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 `& 1` to discard all sequences.
|
||||
*
|
||||
* @note Setting `& 3` will also only discard sampled notes, but the sequences are disabled anyway.
|
||||
* Not setting `& 1` should make this command useless TODO: Test
|
||||
*/
|
||||
#define AUDIOCMD_GLOBAL_DISABLE_ALL_SEQPLAYERS(flags) \
|
||||
AudioThread_QueueCmdS32(AUDIO_MK_CMD(AUDIOCMD_OP_GLOBAL_DISABLE_ALL_SEQPLAYERS, 0, 0, 0), flags)
|
||||
|
||||
#endif
|
|
@ -1536,20 +1536,22 @@ void AudioLoad_LoadPermanentSamples(void);
|
|||
void AudioLoad_ScriptLoad(s32 tableType, s32 id, s8* status);
|
||||
void AudioLoad_ProcessScriptLoads(void);
|
||||
void AudioLoad_InitScriptLoads(void);
|
||||
AudioTask* func_800E4FE0(void);
|
||||
void Audio_QueueCmdF32(u32 opArgs, f32 data);
|
||||
void Audio_QueueCmdS32(u32 opArgs, s32 data);
|
||||
void Audio_QueueCmdS8(u32 opArgs, s8 data);
|
||||
void Audio_QueueCmdU16(u32 opArgs, u16 data);
|
||||
s32 Audio_ScheduleProcessCmds(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 AudioThread_QueueCmdU16(u32 opArgs, u16 data);
|
||||
s32 AudioThread_ScheduleProcessCmds(void);
|
||||
u32 func_800E5E20(u32* out);
|
||||
u8* func_800E5E84(s32 arg0, u32* arg1);
|
||||
u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts);
|
||||
s32 func_800E5EDC(void);
|
||||
s32 func_800E5F88(s32 resetPreloadID);
|
||||
void Audio_PreNMIInternal(void);
|
||||
s32 AudioThread_ResetAudioHeap(s32 specId);
|
||||
void AudioThread_PreNMIInternal(void);
|
||||
s32 func_800E6680(void);
|
||||
u32 Audio_NextRandom(void);
|
||||
void Audio_InitMesgQueues(void);
|
||||
u32 AudioThread_NextRandom(void);
|
||||
void AudioThread_InitMesgQueues(void);
|
||||
|
||||
void Audio_InvalDCache(void* buf, s32 size);
|
||||
void Audio_WritebackDCache(void* buf, s32 size);
|
||||
s32 osAiSetNextBuffer(void*, u32);
|
||||
|
@ -1616,8 +1618,8 @@ s32 AudioOcarina_MemoryGameNextNote(void);
|
|||
void AudioOcarina_PlayLongScarecrowSong(void);
|
||||
void AudioDebug_Draw(GfxPrint* printer);
|
||||
void AudioDebug_ScrPrt(const char* str, u16 num);
|
||||
void func_800F3054(void);
|
||||
void Audio_SetSfxProperties(u8 bankId, u8 entryIdx, u8 channelIdx);
|
||||
void Audio_Update(void);
|
||||
void Audio_SetSfxProperties(u8 bankId, u8 entryIdx, u8 channelIndex);
|
||||
void Audio_PlayCutsceneEffectsSequence(u8 csEffectType);
|
||||
void func_800F4010(Vec3f* pos, u16 sfxId, f32);
|
||||
void Audio_PlaySfxRandom(Vec3f* pos, u16 baseSfxId, u8 randLim);
|
||||
|
@ -1680,8 +1682,8 @@ void Audio_InitSound(void);
|
|||
void func_800F7170(void);
|
||||
void func_800F71BC(s32 arg0);
|
||||
void Audio_SetSfxBanksMute(u16 muteMask);
|
||||
void Audio_QueueSeqCmdMute(u8 channelIdx);
|
||||
void Audio_ClearBGMMute(u8 channelIdx);
|
||||
void Audio_QueueSeqCmdMute(u8 channelIndex);
|
||||
void Audio_ClearBGMMute(u8 channelIndex);
|
||||
void Audio_PlaySfxGeneral(u16 sfxId, Vec3f* pos, u8 token, f32* freqScale, f32* vol, s8* reverbAdd);
|
||||
void Audio_ProcessSfxRequest(void);
|
||||
void Audio_ChooseActiveSfx(u8 bankId);
|
||||
|
|
|
@ -10,10 +10,10 @@ typedef enum {
|
|||
/* 0x1 */ SEQCMD_OP_STOP_SEQUENCE,
|
||||
/* 0x2 */ SEQCMD_OP_QUEUE_SEQUENCE,
|
||||
/* 0x3 */ SEQCMD_OP_UNQUEUE_SEQUENCE,
|
||||
/* 0x4 */ SEQCMD_OP_SET_PLAYER_VOLUME,
|
||||
/* 0x5 */ SEQCMD_OP_SET_PLAYER_FREQ,
|
||||
/* 0x4 */ SEQCMD_OP_SET_SEQPLAYER_VOLUME,
|
||||
/* 0x5 */ SEQCMD_OP_SET_SEQPLAYER_FREQ,
|
||||
/* 0x6 */ SEQCMD_OP_SET_CHANNEL_VOLUME,
|
||||
/* 0x7 */ SEQCMD_OP_SET_PLAYER_IO,
|
||||
/* 0x7 */ SEQCMD_OP_SET_SEQPLAYER_IO,
|
||||
/* 0x8 */ SEQCMD_OP_SET_CHANNEL_IO,
|
||||
/* 0x9 */ SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK,
|
||||
/* 0xA */ SEQCMD_OP_SET_CHANNEL_DISABLE_MASK,
|
||||
|
@ -37,17 +37,17 @@ typedef enum {
|
|||
|
||||
// Subset of `SEQCMD_OP_SETUP_CMD`
|
||||
typedef enum {
|
||||
/* 0x0 */ SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME,
|
||||
/* 0x0 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME,
|
||||
/* 0x1 */ SEQCMD_SUB_OP_SETUP_SEQ_UNQUEUE,
|
||||
/* 0x2 */ SEQCMD_SUB_OP_SETUP_RESTART_SEQ,
|
||||
/* 0x3 */ SEQCMD_SUB_OP_SETUP_TEMPO_SCALE,
|
||||
/* 0x4 */ SEQCMD_SUB_OP_SETUP_TEMPO_RESET,
|
||||
/* 0x5 */ SEQCMD_SUB_OP_SETUP_PLAY_SEQ,
|
||||
/* 0x6 */ SEQCMD_SUB_OP_SETUP_SET_FADE_TIMER,
|
||||
/* 0x7 */ SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME_IF_QUEUED,
|
||||
/* 0x8 */ SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME_WITH_SCALE_INDEX,
|
||||
/* 0x7 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED,
|
||||
/* 0x8 */ SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX,
|
||||
/* 0x9 */ SEQCMD_SUB_OP_SETUP_SET_CHANNEL_DISABLE_MASK,
|
||||
/* 0xA */ SEQCMD_SUB_OP_SETUP_SET_PLAYER_FREQ,
|
||||
/* 0xA */ SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ,
|
||||
/* 0xE */ SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE = 0xE,
|
||||
/* 0xF */ SEQCMD_SUB_OP_SETUP_RESET_SETUP_CMDS
|
||||
} SeqCmdSetupCmdOp;
|
||||
|
@ -64,13 +64,15 @@ typedef enum {
|
|||
* Play a sequence on a given seqPlayer
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to play the sequence
|
||||
* @param fadeInDuration duration the sequence will fade in over
|
||||
* @param seqArg no effect: < 0x7F, skip ticks: = 0x7F, will not play: >= 0x80 (see note)
|
||||
* @param fadeInDuration effect will depend on seqArg. See below
|
||||
* @param seqArg no effect: < 0x7F, skip ahead: = 0x7F, will not play: >= 0x80 (see note)
|
||||
* @param seqId the id of the sequence to play, see `SeqId`
|
||||
*
|
||||
* @note seqArg will also be stored in gActiveSeqs.seqId, any check against that seqId must also include seqArg.
|
||||
* seqArg = 0x7F will interpret the duration as the number of ticks to skip.
|
||||
* seqArg >= 0x80 was intented to load a soundFont asynchronously but the code is unfinished (based on MM).
|
||||
* seqArg < 0x7F: fade in the sequence over `fadeInDuration` in units of (1/30th) seconds
|
||||
* seqArg = 0x7F: start the sequence immediately, but begins `fadeInDuration` number of second into the sequence.
|
||||
* seqArg >= 0x80: no sequence will play. Intended to load a soundFont asynchronously but was only half implemented
|
||||
* (inferred from MM).
|
||||
*/
|
||||
#define SEQCMD_PLAY_SEQUENCE(seqPlayerIndex, fadeInDuration, seqArg, seqId) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_PLAY_SEQUENCE << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(fadeInDuration) << 16) | \
|
||||
|
@ -79,7 +81,7 @@ typedef enum {
|
|||
/**
|
||||
* Stop a sequence on a given seqPlayer
|
||||
*
|
||||
* @param seqPlayerIndex the index of the seqPlayer to play the sequence
|
||||
* @param seqPlayerIndex the index of the seqPlayer to stop the sequence
|
||||
* @param fadeOutDuration duration the sequence will fade out over
|
||||
*
|
||||
* @note the 0xFF in the command is not read from at all, but is common in all Stop SeqPlayer Commands
|
||||
|
@ -125,8 +127,8 @@ typedef enum {
|
|||
* @param duration duration to transition to the volume
|
||||
* @param volume the target volume for the sequence. Ranged from 0-0xFF, with 0x7F mapping to 1.0f
|
||||
*/
|
||||
#define SEQCMD_SET_PLAYER_VOLUME(seqPlayerIndex, duration, volume) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SET_PLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \
|
||||
#define SEQCMD_SET_SEQPLAYER_VOLUME(seqPlayerIndex, duration, volume) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \
|
||||
(volume))
|
||||
|
||||
/**
|
||||
|
@ -139,8 +141,8 @@ typedef enum {
|
|||
* @note 2000 will double the frequency (raise an octave), 500 will halve the frequency (lower an octave).
|
||||
* Cannot be used with `SEQCMD_SET_CHANNEL_FREQ` as they will overwrite one another.
|
||||
*/
|
||||
#define SEQCMD_SET_PLAYER_FREQ(seqPlayerIndex, duration, freqScale) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SET_PLAYER_FREQ << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \
|
||||
#define SEQCMD_SET_SEQPLAYER_FREQ(seqPlayerIndex, duration, freqScale) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_FREQ << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \
|
||||
(freqScale))
|
||||
|
||||
/**
|
||||
|
@ -152,7 +154,7 @@ typedef enum {
|
|||
* @param freqScale the scaling factor to shift the pitch. Ranged from 0-0xFFF, with 1000 mapping to 1.0f
|
||||
*
|
||||
* @note a frequency of 2000 will double the frequency (raise an octave), 500 will halve the frequency (lower an octave).
|
||||
* Cannot be used with `SEQCMD_SET_PLAYER_FREQ` as they will overwrite one another.
|
||||
* Cannot be used with `SEQCMD_SET_SEQPLAYER_FREQ` as they will overwrite one another.
|
||||
*/
|
||||
#define SEQCMD_SET_CHANNEL_FREQ(seqPlayerIndex, channelIndex, duration, freqScale) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_FREQ << 28) | ((u8)(seqPlayerIndex) << 24) | ((duration) << 16) | \
|
||||
|
@ -175,15 +177,15 @@ typedef enum {
|
|||
* 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 ioPort the index of the array to store the input-output value
|
||||
* @param ioData the value s8 that's written to the input-output array
|
||||
*
|
||||
* @note Each seqPlayer has 8 global ioPorts indexed 0-7.
|
||||
* ioPort 0 and 1 are read-only-once, and will reset after being read by the sequence.
|
||||
* ioPort 2-7 can be read multiple times.
|
||||
*/
|
||||
#define SEQCMD_SET_PLAYER_IO(seqPlayerIndex, ioPort, ioData) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SET_PLAYER_IO << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(ioPort) << 16) | \
|
||||
#define SEQCMD_SET_SEQPLAYER_IO(seqPlayerIndex, ioPort, ioData) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SET_SEQPLAYER_IO << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(ioPort) << 16) | \
|
||||
(u8)(ioData))
|
||||
|
||||
/**
|
||||
|
@ -209,7 +211,7 @@ typedef enum {
|
|||
* @param seqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param channelMask a 16 bit mask where each bit maps to a channel. Bitflag on to disable
|
||||
*
|
||||
* @note using Audio_QueueCmdS8 0x06 will bypass this channelMask
|
||||
* @note using AUDIOCMD_CHANNEL_SET_IO will bypass this channelMask
|
||||
*/
|
||||
#define SEQCMD_SET_CHANNEL_IO_DISABLE_MASK(seqPlayerIndex, channelMask) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK << 28) | ((u8)(seqPlayerIndex) << 24) | (u16)(channelMask))
|
||||
|
@ -304,8 +306,8 @@ typedef enum {
|
|||
* @param targetSeqPlayerIndex the index of the seqPlayer to modify
|
||||
* @param duration duration to transition to the volume
|
||||
*/
|
||||
#define SEQCMD_SETUP_RESTORE_PLAYER_VOLUME(setupSeqPlayerIndex, targetSeqPlayerIndex, duration) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME << 20) | \
|
||||
#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME(setupSeqPlayerIndex, targetSeqPlayerIndex, duration) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME << 20) | \
|
||||
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | (u8)(duration))
|
||||
|
||||
/**
|
||||
|
@ -394,9 +396,9 @@ typedef enum {
|
|||
* @param duration duration to transition to the volume
|
||||
* @param numSeqRequests the number of sequence requests queued that must match the actual number of sequence requests
|
||||
*/
|
||||
#define SEQCMD_SETUP_RESTORE_PLAYER_VOLUME_IF_QUEUED(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, \
|
||||
numSeqRequests) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME_IF_QUEUED << 20) | \
|
||||
#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, \
|
||||
numSeqRequests) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED << 20) | \
|
||||
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | ((u8)(duration) << 8) | \
|
||||
(u8)(numSeqRequests))
|
||||
|
||||
|
@ -409,9 +411,11 @@ typedef enum {
|
|||
* @param scaleIndex the scale index of a seqPlayer
|
||||
* @param duration duration to transition to the volume
|
||||
*/
|
||||
#define SEQCMD_SETUP_RESTORE_PLAYER_VOLUME_WITH_SCALE_INDEX(setupSeqPlayerIndex, targetSeqPlayerIndex, scaleIndex, duration) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME_WITH_SCALE_INDEX << 20) | \
|
||||
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \
|
||||
#define SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(setupSeqPlayerIndex, targetSeqPlayerIndex, scaleIndex, \
|
||||
duration) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | \
|
||||
(SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX << 20) | \
|
||||
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | \
|
||||
((u8)(scaleIndex) << 8) | (u8)(duration))
|
||||
|
||||
/**
|
||||
|
@ -438,8 +442,8 @@ typedef enum {
|
|||
* @note The base value for frequency, 100, is 10 times smaller than other frequency commands.
|
||||
* 200 will double the frequency (raise an octave), 50 will halve the frequency (lower an octave).
|
||||
*/
|
||||
#define SEQCMD_SETUP_SET_PLAYER_FREQ(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, freqScale) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_PLAYER_FREQ << 20) | \
|
||||
#define SEQCMD_SETUP_SET_SEQPLAYER_FREQ(setupSeqPlayerIndex, targetSeqPlayerIndex, duration, freqScale) \
|
||||
Audio_QueueSeqCmd((SEQCMD_OP_SETUP_CMD << 28) | (SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ << 20) | \
|
||||
((u8)(setupSeqPlayerIndex) << 24) | ((u8)(targetSeqPlayerIndex) << 16) | ((u8)(duration) << 8) | \
|
||||
(u8)(freqScale))
|
||||
|
||||
|
|
|
@ -21,24 +21,24 @@ typedef enum {
|
|||
} SfxState;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ f32* posX;
|
||||
/* 0x04 */ f32* posY;
|
||||
/* 0x08 */ f32* posZ;
|
||||
/* 0x0C */ u8 token;
|
||||
/* 0x10 */ f32* freqScale;
|
||||
/* 0x14 */ f32* vol;
|
||||
/* 0x18 */ s8* reverbAdd;
|
||||
/* 0x1C */ f32 dist;
|
||||
/* 0x20 */ u32 priority; // lower is more prioritized
|
||||
/* 0x24 */ u8 sfxImportance;
|
||||
/* 0x26 */ u16 sfxParams;
|
||||
/* 0x28 */ u16 sfxId;
|
||||
/* 0x2A */ u8 state; // uses SfxState enum
|
||||
/* 0x2B */ u8 freshness;
|
||||
/* 0x2C */ u8 prev;
|
||||
/* 0x2D */ u8 next;
|
||||
/* 0x2E */ u8 channelIdx;
|
||||
/* 0x2F */ u8 unk_2F;
|
||||
/* 0x00 */ f32* posX;
|
||||
/* 0x04 */ f32* posY;
|
||||
/* 0x08 */ f32* posZ;
|
||||
/* 0x0C */ u8 token;
|
||||
/* 0x10 */ f32* freqScale;
|
||||
/* 0x14 */ f32* vol;
|
||||
/* 0x18 */ s8* reverbAdd;
|
||||
/* 0x1C */ f32 dist;
|
||||
/* 0x20 */ u32 priority; // lower is more prioritized
|
||||
/* 0x24 */ u8 sfxImportance;
|
||||
/* 0x26 */ u16 sfxParams;
|
||||
/* 0x28 */ u16 sfxId;
|
||||
/* 0x2A */ u8 state; // uses SfxState enum
|
||||
/* 0x2B */ u8 freshness;
|
||||
/* 0x2C */ u8 prev;
|
||||
/* 0x2D */ u8 next;
|
||||
/* 0x2E */ u8 channelIndex;
|
||||
/* 0x2F */ u8 unk_2F;
|
||||
} SfxBankEntry; // size = 0x30
|
||||
|
||||
/*
|
||||
|
|
|
@ -157,8 +157,7 @@ extern s32 gSystemArenaLogSeverity;
|
|||
extern u8 __osPfsInodeCacheBank;
|
||||
extern s32 __osPfsLastChannel;
|
||||
|
||||
extern const s16 D_8014A6C0[];
|
||||
#define gTatumsPerBeat (D_8014A6C0[1])
|
||||
extern const TempoData gTempoData;
|
||||
extern const AudioHeapInitSizes gAudioHeapInitSizes;
|
||||
extern s16 gOcarinaSongItemMap[];
|
||||
extern u8 gSoundFontTable[];
|
||||
|
@ -215,7 +214,7 @@ extern u16 gAudioSfxSwapTarget[10];
|
|||
extern u8 gAudioSfxSwapMode[10];
|
||||
extern ActiveSequence gActiveSeqs[4];
|
||||
extern AudioContext gAudioCtx;
|
||||
extern void(*D_801755D0)(void);
|
||||
extern AudioCustomUpdateFunction gAudioCustomUpdateFunction;
|
||||
|
||||
extern u32 __osMalloc_FreeBlockTest_Enable;
|
||||
extern Arena gSystemArena;
|
||||
|
|
|
@ -38,6 +38,7 @@
|
|||
#include "z64view.h"
|
||||
#include "z64vis.h"
|
||||
#include "alignment.h"
|
||||
#include "audiothread_cmd.h"
|
||||
#include "seqcmd.h"
|
||||
#include "sequence.h"
|
||||
#include "sfx.h"
|
||||
|
|
|
@ -1,11 +1,25 @@
|
|||
#ifndef Z64_AUDIO_H
|
||||
#define Z64_AUDIO_H
|
||||
|
||||
#define MK_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0))
|
||||
typedef void (*AudioCustomUpdateFunction)(void);
|
||||
|
||||
|
||||
#define REFRESH_RATE_PAL 50
|
||||
#define REFRESH_RATE_MPAL 60
|
||||
#define REFRESH_RATE_NTSC 60
|
||||
|
||||
// Small deviation parameters used in estimating the max tempo
|
||||
// It is unclear why these vary by region, and aren't all just 1
|
||||
#define REFRESH_RATE_DEVIATION_PAL 1.001521f
|
||||
#define REFRESH_RATE_DEVIATION_MPAL 0.99276f
|
||||
#define REFRESH_RATE_DEVIATION_NTSC 1.00278f
|
||||
|
||||
#define AUDIO_MK_CMD(b0,b1,b2,b3) ((((b0) & 0xFF) << 0x18) | (((b1) & 0xFF) << 0x10) | (((b2) & 0xFF) << 0x8) | (((b3) & 0xFF) << 0))
|
||||
|
||||
#define NO_LAYER ((SequenceLayer*)(-1))
|
||||
|
||||
#define TATUMS_PER_BEAT 48
|
||||
// Also known as "Pulses Per Quarter Note" or "Tatums Per Beat"
|
||||
#define SEQTICKS_PER_BEAT 48
|
||||
|
||||
#define IS_SEQUENCE_CHANNEL_VALID(ptr) ((u32)(ptr) != (u32)&gAudioCtx.sequenceChannelNone)
|
||||
#define SEQ_NUM_CHANNELS 16
|
||||
|
@ -297,12 +311,12 @@ typedef struct {
|
|||
/* 0x005 */ u8 defaultFont;
|
||||
/* 0x006 */ u8 unk_06[1];
|
||||
/* 0x007 */ s8 playerIdx;
|
||||
/* 0x008 */ u16 tempo; // tatums per minute
|
||||
/* 0x00A */ u16 tempoAcc;
|
||||
/* 0x00C */ u16 unk_0C;
|
||||
/* 0x008 */ u16 tempo; // seqTicks per minute
|
||||
/* 0x00A */ u16 tempoAcc; // tempo accumulation, used in a discretized algorithm to apply tempo.
|
||||
/* 0x00C */ u16 tempoChange; // Used to adjust the tempo without altering the base tempo.
|
||||
/* 0x00E */ s16 transposition;
|
||||
/* 0x010 */ u16 delay;
|
||||
/* 0x012 */ u16 fadeTimer;
|
||||
/* 0x012 */ u16 fadeTimer; // in ticks
|
||||
/* 0x014 */ u16 fadeTimerUnkEu;
|
||||
/* 0x018 */ u8* seqData;
|
||||
/* 0x01C */ f32 fadeVolume;
|
||||
|
@ -320,7 +334,7 @@ typedef struct {
|
|||
/* 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];
|
||||
/* 0x158 */ s8 seqScriptIO[8];
|
||||
} SequencePlayer; // size = 0x160
|
||||
|
||||
typedef struct {
|
||||
|
@ -332,7 +346,7 @@ typedef struct {
|
|||
typedef struct {
|
||||
/* 0x00 */ union {
|
||||
struct A {
|
||||
/* 0x00 */ u8 unk_0b80 : 1;
|
||||
/* 0x00 */ u8 unused : 1;
|
||||
/* 0x00 */ u8 hang : 1;
|
||||
/* 0x00 */ u8 decay : 1;
|
||||
/* 0x00 */ u8 release : 1;
|
||||
|
@ -370,8 +384,8 @@ typedef struct {
|
|||
/* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number
|
||||
/* 0x02 */ u8 pan;
|
||||
/* 0x03 */ Stereo stereo;
|
||||
/* 0x04 */ u8 unk_4;
|
||||
/* 0x06 */ u16 unk_6;
|
||||
/* 0x04 */ u8 combFilterSize;
|
||||
/* 0x06 */ u16 combFilterGain;
|
||||
/* 0x08 */ f32 freqScale;
|
||||
/* 0x0C */ f32 velocity;
|
||||
/* 0x10 */ s16* filter;
|
||||
|
@ -383,7 +397,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
|
||||
|
@ -398,7 +412,7 @@ typedef struct SequenceChannel {
|
|||
} changes;
|
||||
/* 0x02 */ u8 noteAllocPolicy;
|
||||
/* 0x03 */ u8 muteBehavior;
|
||||
/* 0x04 */ u8 reverb; // or dry/wet mix
|
||||
/* 0x04 */ u8 targetReverbVol;
|
||||
/* 0x05 */ u8 notePriority; // 0-3
|
||||
/* 0x06 */ u8 someOtherPriority;
|
||||
/* 0x07 */ u8 fontId;
|
||||
|
@ -409,16 +423,16 @@ typedef struct SequenceChannel {
|
|||
/* 0x0C */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number
|
||||
/* 0x0D */ u8 velocityRandomVariance;
|
||||
/* 0x0E */ u8 gateTimeRandomVariance;
|
||||
/* 0x0F */ u8 unk_0F;
|
||||
/* 0x0F */ u8 combFilterSize;
|
||||
/* 0x10 */ u16 vibratoRateStart;
|
||||
/* 0x12 */ u16 vibratoExtentStart;
|
||||
/* 0x12 */ u16 vibratoDepthStart;
|
||||
/* 0x14 */ u16 vibratoRateTarget;
|
||||
/* 0x16 */ u16 vibratoExtentTarget;
|
||||
/* 0x16 */ u16 vibratoDepthTarget;
|
||||
/* 0x18 */ u16 vibratoRateChangeDelay;
|
||||
/* 0x1A */ u16 vibratoExtentChangeDelay;
|
||||
/* 0x1A */ u16 vibratoDepthChangeDelay;
|
||||
/* 0x1C */ u16 vibratoDelay;
|
||||
/* 0x1E */ u16 delay;
|
||||
/* 0x20 */ u16 unk_20;
|
||||
/* 0x20 */ u16 combFilterGain;
|
||||
/* 0x22 */ u16 unk_22;
|
||||
/* 0x24 */ s16 instOrWave; // either 0 (none), instrument index + 1, or
|
||||
// 0x80..0x83 for sawtooth/triangle/sine/square waves.
|
||||
|
@ -437,7 +451,7 @@ typedef struct SequenceChannel {
|
|||
/* 0x60 */ SeqScriptState scriptState;
|
||||
/* 0x7C */ AdsrSettings adsr;
|
||||
/* 0x84 */ NotePool notePool;
|
||||
/* 0xC4 */ s8 soundScriptIO[8]; // bridge between sound script and audio lib, "io ports"
|
||||
/* 0xC4 */ s8 seqScriptIO[8]; // bridge between .seq script and audio lib, "io ports"
|
||||
/* 0xCC */ s16* filter;
|
||||
/* 0xD0 */ Stereo stereo;
|
||||
} SequenceChannel; // size = 0xD4
|
||||
|
@ -446,7 +460,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;
|
||||
|
@ -490,7 +504,7 @@ typedef struct {
|
|||
/* 0x040 */ s16 mixEnvelopeState[32];
|
||||
/* 0x080 */ s16 unusedState[16];
|
||||
/* 0x0A0 */ s16 haasEffectDelayState[32];
|
||||
/* 0x0E0 */ s16 unkState[128];
|
||||
/* 0x0E0 */ s16 combFilterState[128];
|
||||
} NoteSynthesisBuffers; // size = 0x1E0
|
||||
|
||||
typedef struct {
|
||||
|
@ -505,23 +519,20 @@ typedef struct {
|
|||
/* 0x0C */ NoteSynthesisBuffers* synthesisBuffers;
|
||||
/* 0x10 */ s16 curVolLeft;
|
||||
/* 0x12 */ s16 curVolRight;
|
||||
/* 0x14 */ u16 unk_14;
|
||||
/* 0x16 */ u16 unk_16;
|
||||
/* 0x18 */ u16 unk_18;
|
||||
/* 0x1A */ u8 unk_1A;
|
||||
/* 0x1C */ u16 unk_1C;
|
||||
/* 0x1E */ u16 unk_1E;
|
||||
/* 0x14 */ char unk_14[0x6];
|
||||
/* 0x1A */ u8 combFilterNeedsInit;
|
||||
/* 0x1C */ char unk_1C[0x4];
|
||||
} NoteSynthesisState; // size = 0x20
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ struct SequenceChannel* channel;
|
||||
/* 0x04 */ u32 time;
|
||||
/* 0x08 */ s16* curve;
|
||||
/* 0x0C */ f32 extent;
|
||||
/* 0x08 */ s16* curve; // sineWave
|
||||
/* 0x0C */ f32 depth;
|
||||
/* 0x10 */ f32 rate;
|
||||
/* 0x14 */ u8 active;
|
||||
/* 0x16 */ u16 rateChangeTimer;
|
||||
/* 0x18 */ u16 extentChangeTimer;
|
||||
/* 0x18 */ u16 depthChangeTimer;
|
||||
/* 0x1A */ u16 delay;
|
||||
} VibratoState; // size = 0x1C
|
||||
|
||||
|
@ -567,11 +578,11 @@ typedef struct {
|
|||
/* 0x04 */ u8 haasEffectRightDelaySize;
|
||||
/* 0x05 */ u8 reverbVol;
|
||||
/* 0x06 */ u8 harmonicIndexCurAndPrev; // bits 3..2 store curHarmonicIndex, bits 1..0 store prevHarmonicIndex
|
||||
/* 0x07 */ u8 unk_07;
|
||||
/* 0x07 */ u8 combFilterSize;
|
||||
/* 0x08 */ u16 targetVolLeft;
|
||||
/* 0x0A */ u16 targetVolRight;
|
||||
/* 0x0C */ u16 resamplingRateFixedPoint;
|
||||
/* 0x0E */ u16 unk_0E;
|
||||
/* 0x0E */ u16 combFilterGain;
|
||||
/* 0x10 */ union {
|
||||
TunedSample* tunedSample;
|
||||
s16* waveSampleAddr; // used for synthetic waves
|
||||
|
@ -642,15 +653,15 @@ typedef struct {
|
|||
/* 0x06 */ s16 samplesPerFrameTarget;
|
||||
/* 0x08 */ s16 maxAiBufferLength;
|
||||
/* 0x0A */ s16 minAiBufferLength;
|
||||
/* 0x0C */ s16 updatesPerFrame; // for each frame of the audio thread (default 60 fps), number of updates to process audio
|
||||
/* 0x0E */ s16 samplesPerUpdate;
|
||||
/* 0x10 */ s16 samplesPerUpdateMax;
|
||||
/* 0x12 */ s16 samplesPerUpdateMin;
|
||||
/* 0x0C */ s16 ticksPerUpdate; // for each audio thread update, number of ticks to process audio
|
||||
/* 0x0E */ s16 samplesPerTick;
|
||||
/* 0x10 */ s16 samplesPerTickMax;
|
||||
/* 0x12 */ s16 samplesPerTickMin;
|
||||
/* 0x14 */ s16 numSequencePlayers;
|
||||
/* 0x18 */ f32 resampleRate;
|
||||
/* 0x1C */ f32 updatesPerFrameInv; // inverse (reciprocal) of updatesPerFrame
|
||||
/* 0x20 */ f32 updatesPerFrameInvScaled; // updatesPerFrameInv scaled down by a factor of 256
|
||||
/* 0x24 */ f32 updatesPerFrameScaled; // updatesPerFrame scaled down by a factor of 4
|
||||
/* 0x1C */ f32 ticksPerUpdateInv; // inverse (reciprocal) of ticksPerUpdate
|
||||
/* 0x20 */ f32 ticksPerUpdateInvScaled; // ticksPerUpdateInv scaled down by a factor of 256
|
||||
/* 0x24 */ f32 ticksPerUpdateScaled; // ticksPerUpdate scaled down by a factor of 4
|
||||
} AudioBufferParameters; // size = 0x28
|
||||
|
||||
/**
|
||||
|
@ -887,7 +898,7 @@ typedef struct {
|
|||
/* 0x288C */ s32 sampleDmaBufSize;
|
||||
/* 0x2890 */ s32 maxAudioCmds;
|
||||
/* 0x2894 */ s32 numNotes;
|
||||
/* 0x2898 */ s16 tempoInternalToExternal;
|
||||
/* 0x2898 */ s16 maxTempo; // Maximum possible tempo (seqTicks per minute), using every tick as a seqTick to process a .seq file
|
||||
/* 0x289A */ s8 soundMode;
|
||||
/* 0x289C */ s32 totalTaskCount; // The total number of times the top-level function on the audio thread has run since audio was initialized
|
||||
/* 0x28A0 */ s32 curAudioFrameDmaCount;
|
||||
|
@ -898,7 +909,7 @@ typedef struct {
|
|||
/* 0x28B8 */ AudioTask* curTask;
|
||||
/* 0x28BC */ char unk_28BC[0x4];
|
||||
/* 0x28C0 */ AudioTask rspTask[2];
|
||||
/* 0x2960 */ f32 unk_2960;
|
||||
/* 0x2960 */ f32 maxTempoTvTypeFactors; // tvType factors that impact maxTempo, in units of milliseconds/frame
|
||||
/* 0x2964 */ s32 refreshRate;
|
||||
/* 0x2968 */ s16* aiBuffers[3];
|
||||
/* 0x2974 */ s16 aiBufLengths[3];
|
||||
|
@ -929,7 +940,7 @@ typedef struct {
|
|||
/* 0x3468 */ u8 fontLoadStatus[0x30];
|
||||
/* 0x3498 */ u8 seqLoadStatus[0x80];
|
||||
/* 0x3518 */ volatile u8 resetStatus;
|
||||
/* 0x3519 */ u8 audioResetSpecIdToLoad;
|
||||
/* 0x3519 */ u8 specId;
|
||||
/* 0x351C */ s32 audioResetFadeOutFramesLeft;
|
||||
/* 0x3520 */ f32* adsrDecayTable; // A table on the audio heap that stores decay rates used for adsr
|
||||
/* 0x3524 */ u8* audioHeap;
|
||||
|
@ -941,20 +952,20 @@ typedef struct {
|
|||
/* 0x5B84 */ s32 noteSubEuOffset;
|
||||
/* 0x5B88 */ AudioListItem layerFreeList;
|
||||
/* 0x5B98 */ NotePool noteFreeLists;
|
||||
/* 0x5BD8 */ u8 cmdWrPos;
|
||||
/* 0x5BD9 */ u8 cmdRdPos;
|
||||
/* 0x5BDA */ u8 cmdQueueFinished;
|
||||
/* 0x5BDC */ u16 unk_5BDC[4];
|
||||
/* 0x5BD8 */ u8 threadCmdWritePos;
|
||||
/* 0x5BD9 */ u8 threadCmdReadPos;
|
||||
/* 0x5BDA */ u8 threadCmdQueueFinished;
|
||||
/* 0x5BDC */ u16 threadCmdChannelMask[4]; // bitfield for 16 channels. When processing an audio thread channel command on all channels, only process channels with their bit set.
|
||||
/* 0x5BE4 */ OSMesgQueue* audioResetQueueP;
|
||||
/* 0x5BE8 */ OSMesgQueue* taskStartQueueP;
|
||||
/* 0x5BEC */ OSMesgQueue* cmdProcQueueP;
|
||||
/* 0x5BEC */ OSMesgQueue* threadCmdProcQueueP;
|
||||
/* 0x5BF0 */ OSMesgQueue taskStartQueue;
|
||||
/* 0x5C08 */ OSMesgQueue cmdProcQueue;
|
||||
/* 0x5C08 */ OSMesgQueue threadCmdProcQueue;
|
||||
/* 0x5C20 */ OSMesgQueue audioResetQueue;
|
||||
/* 0x5C38 */ OSMesg taskStartMsgBuf[1];
|
||||
/* 0x5C3C */ OSMesg audioResetMsgBuf[1];
|
||||
/* 0x5C40 */ OSMesg cmdProcMsgBuf[4];
|
||||
/* 0x5C50 */ AudioCmd cmdBuf[0x100]; // Audio commands used to transfer audio requests from the graph thread to the audio thread
|
||||
/* 0x5C40 */ OSMesg threadCmdProcMsgBuf[4];
|
||||
/* 0x5C50 */ AudioCmd threadCmdBuf[0x100]; // Audio thread commands used to transfer audio requests from the graph thread to the audio thread
|
||||
} AudioContext; // size = 0x6450
|
||||
|
||||
typedef struct {
|
||||
|
@ -966,10 +977,15 @@ typedef struct {
|
|||
/* 0x08 */ f32 velocity;
|
||||
/* 0x0C */ char unk_0C[0x4];
|
||||
/* 0x10 */ s16* filter;
|
||||
/* 0x14 */ u8 unk_14;
|
||||
/* 0x16 */ u16 unk_16;
|
||||
/* 0x14 */ u8 combFilterSize;
|
||||
/* 0x16 */ u16 combFilterGain;
|
||||
} NoteSubAttributes; // size = 0x18
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ s16 unk_00; // set to 0x1C00, unused
|
||||
/* 0x2 */ s16 seqTicksPerBeat;
|
||||
} TempoData; // size = 0x4
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u32 heapSize; // total number of bytes allocated to the audio heap. Must be <= the size of `gAudioHeap` (ideally about the same size)
|
||||
/* 0x04 */ u32 initPoolSize; // The entire audio heap is split into two pools.
|
||||
|
|
|
@ -240,7 +240,7 @@ void AudioDebug_Draw(GfxPrint* printer) {
|
|||
for (k2 = 0; k2 < gChannelsPerBank[gSfxChannelLayout][k]; k2++) {
|
||||
#define entryIndex (gActiveSfx[k][k2].entryIndex)
|
||||
#define entry (&gSfxBanks[k][entryIndex])
|
||||
#define chan (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[entry->channelIdx])
|
||||
#define chan (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[entry->channelIndex])
|
||||
GfxPrint_SetPos(printer, 2 + sAudioIntInfoX, 5 + ind + sAudioIntInfoY);
|
||||
if (sAudioIntInfoBankPage[k] == 1) {
|
||||
if ((entryIndex != 0xFF) &&
|
||||
|
@ -265,7 +265,7 @@ void AudioDebug_Draw(GfxPrint* printer) {
|
|||
((entry->state == SFX_STATE_PLAYING_1) || (entry->state == SFX_STATE_PLAYING_2))) {
|
||||
GfxPrint_Printf(printer, "%2X %5d %5d %5d %3d %3d %04X", entryIndex, (s32)*entry->posX,
|
||||
(s32)*entry->posY, (s32)*entry->posZ, (s32)(chan->freqScale * 100.0f),
|
||||
chan->reverb, entry->sfxId);
|
||||
chan->targetReverbVol, entry->sfxId);
|
||||
} else {
|
||||
GfxPrint_Printf(printer, "FF ----- ----- ----- --- --- ----");
|
||||
}
|
||||
|
@ -410,7 +410,7 @@ void AudioDebug_Draw(GfxPrint* printer) {
|
|||
}
|
||||
|
||||
GfxPrint_SetPos(printer, 15 + i, 8);
|
||||
if (gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[i]->stopSomething2) {
|
||||
if (gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[i]->muted) {
|
||||
GfxPrint_Printf(printer, "O");
|
||||
} else {
|
||||
GfxPrint_Printf(printer, "X");
|
||||
|
@ -476,7 +476,7 @@ void AudioDebug_Draw(GfxPrint* printer) {
|
|||
GfxPrint_Printf(printer, "%02X ",
|
||||
(u8)gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
|
||||
.channels[sAudioSubTrackInfoChannelSel]
|
||||
->soundScriptIO[i]);
|
||||
->seqScriptIO[i]);
|
||||
}
|
||||
|
||||
if (gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[sAudioSubTrackInfoChannelSel]->enabled) {
|
||||
|
@ -526,9 +526,10 @@ void AudioDebug_Draw(GfxPrint* printer) {
|
|||
->panChannelWeight);
|
||||
|
||||
GfxPrint_SetPos(printer, 15, 17);
|
||||
GfxPrint_Printf(
|
||||
printer, "%d",
|
||||
gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel].channels[sAudioSubTrackInfoChannelSel]->reverb);
|
||||
GfxPrint_Printf(printer, "%d",
|
||||
gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
|
||||
.channels[sAudioSubTrackInfoChannelSel]
|
||||
->targetReverbVol);
|
||||
|
||||
GfxPrint_SetPos(printer, 15, 18);
|
||||
GfxPrint_Printf(printer, "%d",
|
||||
|
@ -547,7 +548,7 @@ void AudioDebug_Draw(GfxPrint* printer) {
|
|||
GfxPrint_Printf(printer, "%d",
|
||||
(u8)(gAudioCtx.seqPlayers[sAudioSubTrackInfoPlayerSel]
|
||||
.channels[sAudioSubTrackInfoChannelSel]
|
||||
->vibratoExtentTarget /
|
||||
->vibratoDepthTarget /
|
||||
8));
|
||||
|
||||
GfxPrint_SetPos(printer, 15, 21);
|
||||
|
@ -623,35 +624,33 @@ void AudioDebug_Draw(GfxPrint* printer) {
|
|||
|
||||
SETCOL(255, 255, 255);
|
||||
GfxPrint_SetPos(printer, 3, 7);
|
||||
GfxPrint_Printf(printer, "NEXT SCENE %02X %s",
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[2],
|
||||
sAudioSceneNames[(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[2]]);
|
||||
GfxPrint_Printf(printer, "NEXT SCENE %02X %s", (u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[2],
|
||||
sAudioSceneNames[(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[2]]);
|
||||
|
||||
GfxPrint_SetPos(printer, 3, 8);
|
||||
GfxPrint_Printf(printer, "NOW SCENE %02X %s",
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[4],
|
||||
sAudioSceneNames[(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[4]]);
|
||||
GfxPrint_Printf(printer, "NOW SCENE %02X %s", (u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[4],
|
||||
sAudioSceneNames[(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[4]]);
|
||||
|
||||
GfxPrint_SetPos(printer, 3, 9);
|
||||
GfxPrint_Printf(printer, "NOW BLOCK %02X",
|
||||
(gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[5] + 1) & 0xFF);
|
||||
(gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[5] + 1) & 0xFF);
|
||||
|
||||
GfxPrint_SetPos(printer, 3, 11);
|
||||
GfxPrint_Printf(printer, "PORT");
|
||||
|
||||
GfxPrint_SetPos(printer, 3, 12);
|
||||
GfxPrint_Printf(printer, "%02X %02X %02X %02X",
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[0],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[1],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[2],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[3]);
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[0],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[1],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[2],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[3]);
|
||||
|
||||
GfxPrint_SetPos(printer, 3, 13);
|
||||
GfxPrint_Printf(printer, "%02X %02X %02X %02X",
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[4],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[5],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[6],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].soundScriptIO[7]);
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[4],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[5],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[6],
|
||||
(u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].seqScriptIO[7]);
|
||||
break;
|
||||
|
||||
case PAGE_OCARINA_TEST:
|
||||
|
@ -1174,7 +1173,7 @@ void AudioDebug_ProcessInput_BlkChgBgm(void) {
|
|||
}
|
||||
|
||||
if (CHECK_BTN_ANY(sDebugPadPress, BTN_A)) {
|
||||
Audio_QueueCmdS8(MK_CMD(0x46, SEQ_PLAYER_BGM_MAIN, 0x00, 0x00), sAudioBlkChgBgmWork[1]);
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_BGM_MAIN, 0, sAudioBlkChgBgmWork[1]);
|
||||
SEQCMD_PLAY_SEQUENCE(SEQ_PLAYER_BGM_MAIN, 1, 0, sAudioBlkChgBgmWork[0]);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,18 +1,16 @@
|
|||
#include "ultra64.h"
|
||||
#include "global.h"
|
||||
|
||||
#define Audio_DisableSeq(seqPlayerIndex, fadeOut) Audio_QueueCmdS32(0x83000000 | ((u8)seqPlayerIndex << 16), fadeOut)
|
||||
|
||||
#define ABS_ALT(x) ((x) < 0 ? -(x) : (x))
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ f32 vol;
|
||||
/* 0x4 */ f32 freqScale;
|
||||
/* 0x8 */ s8 reverb;
|
||||
/* 0x9 */ s8 panSigned;
|
||||
/* 0x9 */ s8 pan;
|
||||
/* 0xA */ s8 stereoBits;
|
||||
/* 0xB */ u8 filter;
|
||||
/* 0xC */ u8 unk_0C;
|
||||
/* 0xC */ u8 combFilterGain;
|
||||
} SfxPlayerState;
|
||||
|
||||
typedef enum {
|
||||
|
@ -1728,7 +1726,7 @@ void AudioOcarina_PlayControllerInput(u8 unused) {
|
|||
// Add vibrato of the ocarina note based on the x control stick
|
||||
sCurOcarinaVibrato = ABS_ALT(sOcarinaInputStickAdj.x) >> 2;
|
||||
// Sets vibrato to io port 6
|
||||
Audio_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;
|
||||
|
@ -1737,11 +1735,11 @@ void AudioOcarina_PlayControllerInput(u8 unused) {
|
|||
|
||||
// Processes new and valid notes
|
||||
if ((sCurOcarinaPitch != OCARINA_PITCH_NONE) && (sPrevOcarinaPitch != sCurOcarinaPitch)) {
|
||||
// Sets ocarina instrument Id to channelIdx io port 7, which is used
|
||||
// Sets ocarina instrument Id to channelIndex io port 7, which is used
|
||||
// as an index in seq 0 to get the true instrument Id
|
||||
Audio_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
|
||||
Audio_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);
|
||||
Audio_PlaySfxGeneral(NA_SE_OC_OCARINA, &gSfxDefaultPos, 4, &sCurOcarinaBendFreq, &sRelativeOcarinaVolume,
|
||||
&gSfxDefaultReverb);
|
||||
} else if ((sPrevOcarinaPitch != OCARINA_PITCH_NONE) && (sCurOcarinaPitch == OCARINA_PITCH_NONE)) {
|
||||
|
@ -1879,7 +1877,7 @@ void AudioOcarina_PlaybackSong(void) {
|
|||
if (sNotePlaybackVibrato != sPlaybackSong[sPlaybackNotePos].vibrato) {
|
||||
sNotePlaybackVibrato = sPlaybackSong[sPlaybackNotePos].vibrato;
|
||||
// Sets vibrato to io port 6
|
||||
Audio_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
|
||||
|
@ -1908,13 +1906,11 @@ void AudioOcarina_PlaybackSong(void) {
|
|||
|
||||
if (sPlaybackPitch != OCARINA_PITCH_NONE) {
|
||||
sPlaybackStaffPos++;
|
||||
// Sets ocarina instrument Id to channelIdx io port 7, which is used
|
||||
// Sets ocarina instrument Id to channelIndex io port 7, which is used
|
||||
// as an index in seq 0 to get the true instrument Id
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 7,
|
||||
sOcarinaInstrumentId - 1);
|
||||
// Sets sPlaybackPitch to channelIdx io port 5
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | SFX_CHANNEL_OCARINA << 8 | 5,
|
||||
sPlaybackPitch & 0x3F);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 7, sOcarinaInstrumentId - 1);
|
||||
// Sets sPlaybackPitch to channelIndex io port 5
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, SFX_CHANNEL_OCARINA, 5, sPlaybackPitch & 0x3F);
|
||||
Audio_PlaySfxGeneral(NA_SE_OC_OCARINA, &gSfxDefaultPos, 4, &sRelativeNotePlaybackBend,
|
||||
&sRelativeNotePlaybackVolume, &gSfxDefaultReverb);
|
||||
} else {
|
||||
|
@ -2198,7 +2194,7 @@ s32 AudioOcarina_MemoryGameNextNote(void) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
randomButtonIndex = Audio_NextRandom();
|
||||
randomButtonIndex = AudioThread_NextRandom();
|
||||
randomPitch = sButtonToPitchMap[randomButtonIndex % 5];
|
||||
|
||||
if (sOcarinaSongNotes[OCARINA_SONG_MEMORY_GAME][sOcaMemoryGameAppendPos - 1].pitch == randomPitch) {
|
||||
|
@ -2322,7 +2318,7 @@ void Audio_UpdateFanfare(void);
|
|||
/**
|
||||
* This is Audio_Update for the graph thread
|
||||
*/
|
||||
void func_800F3054(void) {
|
||||
void Audio_Update(void) {
|
||||
if (func_800FAD34() == 0) {
|
||||
#if OOT_DEBUG
|
||||
sAudioUpdateTaskStart = gAudioCtx.totalTaskCount;
|
||||
|
@ -2348,7 +2344,7 @@ void func_800F3054(void) {
|
|||
AudioDebug_ProcessInput();
|
||||
#endif
|
||||
|
||||
Audio_ScheduleProcessCmds();
|
||||
AudioThread_ScheduleProcessCmds();
|
||||
|
||||
#if OOT_DEBUG
|
||||
sAudioUpdateTaskEnd = gAudioCtx.totalTaskCount;
|
||||
|
@ -2363,8 +2359,8 @@ void func_800F3138(UNK_TYPE arg0) {
|
|||
void func_800F3140(UNK_TYPE arg0, UNK_TYPE arg1) {
|
||||
}
|
||||
|
||||
void func_800F314C(s8 arg0) {
|
||||
Audio_QueueCmdS32(0x82 << 24 | SEQ_PLAYER_BGM_MAIN << 16 | (((u8)arg0 & 0xFF) << 8), 1);
|
||||
void func_800F314C(s8 seqId) {
|
||||
AUDIOCMD_GLOBAL_INIT_SEQPLAYER(SEQ_PLAYER_BGM_MAIN, (u8)seqId, 1);
|
||||
}
|
||||
|
||||
f32 Audio_ComputeSfxVolume(u8 bankId, u8 entryIdx) {
|
||||
|
@ -2427,8 +2423,8 @@ s8 Audio_ComputeSfxReverb(u8 bankId, u8 entryIdx, u8 channelIdx) {
|
|||
}
|
||||
|
||||
if (IS_SEQUENCE_CHANNEL_VALID(gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx])) {
|
||||
scriptAdd = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx]->soundScriptIO[1];
|
||||
if (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx]->soundScriptIO[1] <= SEQ_IO_VAL_NONE) {
|
||||
scriptAdd = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx]->seqScriptIO[1];
|
||||
if (gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[channelIdx]->seqScriptIO[1] <= SEQ_IO_VAL_NONE) {
|
||||
scriptAdd = 0;
|
||||
}
|
||||
}
|
||||
|
@ -2588,28 +2584,28 @@ u8 func_800F37B8(f32 behindScreenZ, SfxBankEntry* arg1, s8 arg2) {
|
|||
return (phi_v1 * 0x10) + (u8)((phi_f0 * phi_f12) / (10000.0f / 5.2f));
|
||||
}
|
||||
|
||||
s8 func_800F3990(f32 arg0, u16 sfxParams) {
|
||||
s8 ret = 0;
|
||||
s8 func_800F3990(f32 posY, u16 sfxParams) {
|
||||
s8 combFilterGain = 0;
|
||||
|
||||
if (arg0 >= 0.0f) {
|
||||
if (arg0 > 625.0f) {
|
||||
ret = 127;
|
||||
if (posY >= 0.0f) {
|
||||
if (posY > 625.0f) {
|
||||
combFilterGain = 127;
|
||||
} else {
|
||||
ret = (arg0 / 625.0f) * 126.0f;
|
||||
combFilterGain = (posY / 625.0f) * 126.0f;
|
||||
}
|
||||
}
|
||||
return ret | 1;
|
||||
return combFilterGain | 1;
|
||||
}
|
||||
|
||||
void Audio_SetSfxProperties(u8 bankId, u8 entryIdx, u8 channelIdx) {
|
||||
void Audio_SetSfxProperties(u8 bankId, u8 entryIdx, u8 channelIndex) {
|
||||
f32 vol = 1.0f;
|
||||
s8 volS8;
|
||||
s8 reverb = 0;
|
||||
f32 freqScale = 1.0f;
|
||||
s8 panSigned = 0x40;
|
||||
s8 pan = 0x40;
|
||||
u8 stereoBits = 0;
|
||||
u8 filter = 0;
|
||||
s8 sp38 = 0;
|
||||
s8 combFilterGain = 0;
|
||||
f32 behindScreenZ;
|
||||
u8 baseFilter = 0;
|
||||
SfxBankEntry* entry = &gSfxBanks[bankId][entryIdx];
|
||||
|
@ -2621,15 +2617,15 @@ void Audio_SetSfxProperties(u8 bankId, u8 entryIdx, u8 channelIdx) {
|
|||
case BANK_ENEMY:
|
||||
case BANK_VOICE:
|
||||
if (sSoundMode == SOUNDMODE_SURROUND) {
|
||||
sp38 = func_800F3990(*entry->posY, entry->sfxParams);
|
||||
combFilterGain = func_800F3990(*entry->posY, entry->sfxParams);
|
||||
}
|
||||
FALLTHROUGH;
|
||||
case BANK_OCARINA:
|
||||
entry->dist = sqrtf(entry->dist * SFX_DIST_SCALING);
|
||||
|
||||
vol = Audio_ComputeSfxVolume(bankId, entryIdx) * *entry->vol;
|
||||
reverb = Audio_ComputeSfxReverb(bankId, entryIdx, channelIdx);
|
||||
panSigned = Audio_ComputeSfxPanSigned(*entry->posX, *entry->posZ, entry->token);
|
||||
reverb = Audio_ComputeSfxReverb(bankId, entryIdx, channelIndex);
|
||||
pan = Audio_ComputeSfxPanSigned(*entry->posX, *entry->posZ, entry->token);
|
||||
freqScale = Audio_ComputeSfxFreqScale(bankId, entryIdx) * *entry->freqScale;
|
||||
|
||||
if (sSoundMode == SOUNDMODE_SURROUND) {
|
||||
|
@ -2639,14 +2635,14 @@ void Audio_SetSfxProperties(u8 bankId, u8 entryIdx, u8 channelIdx) {
|
|||
stereoBits = 0x10;
|
||||
}
|
||||
|
||||
if ((sSfxChannelState[channelIdx].stereoBits ^ stereoBits) & 0x10) {
|
||||
if (panSigned < 0x40) {
|
||||
stereoBits = sSfxChannelState[channelIdx].stereoBits ^ 0x14;
|
||||
if ((sSfxChannelState[channelIndex].stereoBits ^ stereoBits) & 0x10) {
|
||||
if (pan < 0x40) {
|
||||
stereoBits = sSfxChannelState[channelIndex].stereoBits ^ 0x14;
|
||||
} else {
|
||||
stereoBits = sSfxChannelState[channelIdx].stereoBits ^ 0x18;
|
||||
stereoBits = sSfxChannelState[channelIndex].stereoBits ^ 0x18;
|
||||
}
|
||||
} else {
|
||||
stereoBits = sSfxChannelState[channelIdx].stereoBits;
|
||||
stereoBits = sSfxChannelState[channelIndex].stereoBits;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2659,49 +2655,54 @@ void Audio_SetSfxProperties(u8 bankId, u8 entryIdx, u8 channelIdx) {
|
|||
if ((baseFilter | sAudioExtraFilter) != 0) {
|
||||
filter = (baseFilter | sAudioExtraFilter);
|
||||
} else if ((sSoundMode == SOUNDMODE_SURROUND) && !(entry->sfxParams & SFX_FLAG_13)) {
|
||||
filter = func_800F37B8(behindScreenZ, entry, panSigned);
|
||||
filter = func_800F37B8(behindScreenZ, entry, pan);
|
||||
}
|
||||
break;
|
||||
case BANK_SYSTEM:
|
||||
break;
|
||||
}
|
||||
|
||||
if (sSfxChannelState[channelIdx].vol != vol) {
|
||||
if (sSfxChannelState[channelIndex].vol != vol) {
|
||||
volS8 = (u8)(vol * 127.0f);
|
||||
sSfxChannelState[channelIdx].vol = vol;
|
||||
sSfxChannelState[channelIndex].vol = vol;
|
||||
} else {
|
||||
volS8 = -1;
|
||||
}
|
||||
|
||||
// CHAN_UPD_SCRIPT_IO (slot 2, sets volume)
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | (channelIdx << 8) | 2, volS8);
|
||||
if (reverb != sSfxChannelState[channelIdx].reverb) {
|
||||
Audio_QueueCmdS8(0x5 << 24 | SEQ_PLAYER_SFX << 16 | (channelIdx << 8), reverb);
|
||||
sSfxChannelState[channelIdx].reverb = reverb;
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, channelIndex, 2, volS8);
|
||||
|
||||
if (reverb != sSfxChannelState[channelIndex].reverb) {
|
||||
AUDIOCMD_CHANNEL_SET_REVERB_VOLUME(SEQ_PLAYER_SFX, channelIndex, reverb);
|
||||
sSfxChannelState[channelIndex].reverb = reverb;
|
||||
}
|
||||
if (freqScale != sSfxChannelState[channelIdx].freqScale) {
|
||||
Audio_QueueCmdF32(0x4 << 24 | SEQ_PLAYER_SFX << 16 | (channelIdx << 8), freqScale);
|
||||
sSfxChannelState[channelIdx].freqScale = freqScale;
|
||||
|
||||
if (freqScale != sSfxChannelState[channelIndex].freqScale) {
|
||||
AUDIOCMD_CHANNEL_SET_FREQ_SCALE(SEQ_PLAYER_SFX, channelIndex, freqScale);
|
||||
sSfxChannelState[channelIndex].freqScale = freqScale;
|
||||
}
|
||||
if (stereoBits != sSfxChannelState[channelIdx].stereoBits) {
|
||||
Audio_QueueCmdS8(0xE << 24 | SEQ_PLAYER_SFX << 16 | (channelIdx << 8), stereoBits | 0x10);
|
||||
sSfxChannelState[channelIdx].stereoBits = stereoBits;
|
||||
|
||||
//! @bug: comparing a `u8` to an `s8`. if the most significant bit is set,
|
||||
//! it'll always pass because the s8 value will be <0 and the u8 value is always >=0
|
||||
if (stereoBits != sSfxChannelState[channelIndex].stereoBits) {
|
||||
AUDIOCMD_CHANNEL_SET_STEREO(SEQ_PLAYER_SFX, channelIndex, stereoBits | 0x10);
|
||||
sSfxChannelState[channelIndex].stereoBits = stereoBits;
|
||||
}
|
||||
if (filter != sSfxChannelState[channelIdx].filter) {
|
||||
// CHAN_UPD_SCRIPT_IO (slot 3, sets filter)
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | (channelIdx << 8) | 3, filter);
|
||||
sSfxChannelState[channelIdx].filter = filter;
|
||||
|
||||
if (filter != sSfxChannelState[channelIndex].filter) {
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, channelIndex, 3, filter);
|
||||
sSfxChannelState[channelIndex].filter = filter;
|
||||
}
|
||||
if (sp38 != sSfxChannelState[channelIdx].unk_0C) {
|
||||
// CHAN_UPD_UNK_0F
|
||||
Audio_QueueCmdS8(0xC << 24 | SEQ_PLAYER_SFX << 16 | (channelIdx << 8), 0x10);
|
||||
// CHAN_UPD_UNK_20
|
||||
Audio_QueueCmdU16(0xD << 24 | SEQ_PLAYER_SFX << 16 | (channelIdx << 8), ((u16)(sp38) << 8) + 0xFF);
|
||||
sSfxChannelState[channelIdx].unk_0C = sp38;
|
||||
|
||||
if (combFilterGain != sSfxChannelState[channelIndex].combFilterGain) {
|
||||
AUDIOCMD_CHANNEL_SET_COMB_FILTER_SIZE(SEQ_PLAYER_SFX, channelIndex, 0x10);
|
||||
AUDIOCMD_CHANNEL_SET_COMB_FILTER_GAIN(SEQ_PLAYER_SFX, channelIndex, ((u16)(combFilterGain) << 8) + 0xFF);
|
||||
sSfxChannelState[channelIndex].combFilterGain = combFilterGain;
|
||||
}
|
||||
if (panSigned != sSfxChannelState[channelIdx].panSigned) {
|
||||
Audio_QueueCmdS8(0x3 << 24 | SEQ_PLAYER_SFX << 16 | (channelIdx << 8), panSigned);
|
||||
sSfxChannelState[channelIdx].panSigned = panSigned;
|
||||
|
||||
if (pan != sSfxChannelState[channelIndex].pan) {
|
||||
AUDIOCMD_CHANNEL_SET_PAN(SEQ_PLAYER_SFX, channelIndex, pan);
|
||||
sSfxChannelState[channelIndex].pan = pan;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2714,13 +2715,13 @@ void Audio_ResetSfxChannelState(void) {
|
|||
state->vol = 1.0f;
|
||||
state->freqScale = 1.0f;
|
||||
state->reverb = 0;
|
||||
state->panSigned = 0x40;
|
||||
state->pan = 0x40;
|
||||
state->stereoBits = 0;
|
||||
state->filter = 0xFF;
|
||||
state->unk_0C = 0xFF;
|
||||
state->combFilterGain = 0xFF;
|
||||
}
|
||||
|
||||
sSfxChannelState[SFX_CHANNEL_OCARINA].unk_0C = 0;
|
||||
sSfxChannelState[SFX_CHANNEL_OCARINA].combFilterGain = 0;
|
||||
sPrevSeqMode = 0;
|
||||
sAudioCodeReverb = 0;
|
||||
}
|
||||
|
@ -2788,7 +2789,7 @@ void func_800F4190(Vec3f* pos, u16 sfxId) {
|
|||
Audio_PlaySfxGeneral(sfxId, pos, 4, &D_801305B0, &gSfxDefaultFreqAndVolScale, &D_801305B4);
|
||||
}
|
||||
void Audio_PlaySfxRandom(Vec3f* pos, u16 baseSfxId, u8 randLim) {
|
||||
u8 offset = Audio_NextRandom() % randLim;
|
||||
u8 offset = AudioThread_NextRandom() % randLim;
|
||||
|
||||
Audio_PlaySfxGeneral(baseSfxId + offset, pos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale,
|
||||
&gSfxDefaultReverb);
|
||||
|
@ -2916,19 +2917,17 @@ void Audio_SetMainBgmVolume(u8 targetVol, u8 volFadeTimer) {
|
|||
* Incrementally increase volume of NA_BGM_GANON_TOWER for each new room during the climb of Ganon's Tower
|
||||
*/
|
||||
void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) {
|
||||
u8 channelIdx;
|
||||
s8 pan = 0;
|
||||
u8 channelIndex;
|
||||
s8 panChannelWeight = 0; // Pan comes entirely from the SequenceLayer
|
||||
|
||||
// Ganondorf's Lair
|
||||
if (ganonsTowerLevel == 0) {
|
||||
pan = 0x7F;
|
||||
// Pan comes entirely from the SequenceChannel
|
||||
panChannelWeight = 0x7F;
|
||||
}
|
||||
|
||||
for (channelIdx = 0; channelIdx < 16; channelIdx++) {
|
||||
// CHAN_UPD_PAN_UNSIGNED
|
||||
Audio_QueueCmdS8(_SHIFTL(0x7, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) | _SHIFTL(channelIdx, 8, 8) |
|
||||
_SHIFTL(0, 0, 8),
|
||||
pan);
|
||||
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
|
||||
AUDIOCMD_CHANNEL_SET_PAN_WEIGHT(SEQ_PLAYER_BGM_MAIN, (u32)channelIndex, panChannelWeight);
|
||||
}
|
||||
|
||||
// Lowest room in Ganon's Tower (Entrance Room)
|
||||
|
@ -2947,7 +2946,7 @@ void Audio_SetGanonsTowerBgmVolumeLevel(u8 ganonsTowerLevel) {
|
|||
s32 Audio_SetGanonsTowerBgmVolume(u8 targetVol) {
|
||||
u8 lowPassFilterCutoff;
|
||||
u16 reverb;
|
||||
u8 channelIdx;
|
||||
u8 channelIndex;
|
||||
|
||||
if (sGanonsTowerVol != targetVol) {
|
||||
// Sets the volume
|
||||
|
@ -2966,22 +2965,19 @@ s32 Audio_SetGanonsTowerBgmVolume(u8 targetVol) {
|
|||
SEQCMD_SET_CHANNEL_IO(SEQ_PLAYER_BGM_MAIN, 15, 4, lowPassFilterCutoff);
|
||||
|
||||
// Sets the reverb
|
||||
for (channelIdx = 0; channelIdx < 16; channelIdx++) {
|
||||
if (gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIdx] != &gAudioCtx.sequenceChannelNone) {
|
||||
// soundScriptIO[5] is set to 0x40 in channels 0, 1, and 4
|
||||
if ((u8)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIdx]->soundScriptIO[5] !=
|
||||
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
|
||||
if (gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex] != &gAudioCtx.sequenceChannelNone) {
|
||||
// seqScriptIO[5] is set to 0x40 in channels 0, 1, and 4
|
||||
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[channelIdx]->soundScriptIO[5] -
|
||||
reverb = ((u16)gAudioCtx.seqPlayers[SEQ_PLAYER_BGM_MAIN].channels[channelIndex]->seqScriptIO[5] -
|
||||
targetVol) +
|
||||
0x7F;
|
||||
if (reverb > 0x7F) {
|
||||
reverb = 0x7F;
|
||||
}
|
||||
// CHAN_UPD_REVERB
|
||||
Audio_QueueCmdS8(_SHIFTL(0x5, 24, 8) | _SHIFTL(SEQ_PLAYER_BGM_MAIN, 16, 8) |
|
||||
_SHIFTL(channelIdx, 8, 8) | _SHIFTL(0, 0, 8),
|
||||
(u8)reverb);
|
||||
AUDIOCMD_CHANNEL_SET_REVERB_VOLUME(SEQ_PLAYER_BGM_MAIN, (u32)channelIndex, (u8)reverb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3043,31 +3039,30 @@ void Audio_PlaySfxTransposed(Vec3f* pos, u16 sfxId, s8 semitone) {
|
|||
&gSfxDefaultReverb);
|
||||
}
|
||||
|
||||
void func_800F4C58(Vec3f* pos, u16 sfxId, u8 arg2) {
|
||||
u8 phi_s1 = 0;
|
||||
void func_800F4C58(Vec3f* pos, u16 sfxId, u8 ioData) {
|
||||
u8 channelIndex = 0;
|
||||
u8 i;
|
||||
u8 bankId;
|
||||
|
||||
bankId = SFX_BANK_SHIFT(sfxId);
|
||||
for (i = 0; i < bankId; i++) {
|
||||
phi_s1 += gChannelsPerBank[gSfxChannelLayout][i];
|
||||
channelIndex += gChannelsPerBank[gSfxChannelLayout][i];
|
||||
}
|
||||
|
||||
for (i = 0; i < gChannelsPerBank[gSfxChannelLayout][bankId]; i++) {
|
||||
if ((gActiveSfx[bankId][i].entryIndex != 0xFF) &&
|
||||
(sfxId == gSfxBanks[bankId][gActiveSfx[bankId][i].entryIndex].sfxId)) {
|
||||
Audio_QueueCmdS8(
|
||||
_SHIFTL(0x6, 24, 8) | _SHIFTL(SEQ_PLAYER_SFX, 16, 8) | _SHIFTL(phi_s1, 8, 8) | _SHIFTL(6, 0, 8), arg2);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, channelIndex, 6, ioData);
|
||||
}
|
||||
phi_s1++;
|
||||
channelIndex++;
|
||||
}
|
||||
Audio_PlaySfxGeneral(sfxId, pos, 4, &gSfxDefaultFreqAndVolScale, &gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
||||
}
|
||||
|
||||
void func_800F4E30(Vec3f* pos, f32 arg1) {
|
||||
f32 phi_f22;
|
||||
s8 phi_s4;
|
||||
u8 i;
|
||||
s8 pan;
|
||||
u8 channelIndex;
|
||||
|
||||
if (sSariaBgmPtr == NULL) {
|
||||
sSariaBgmPtr = pos;
|
||||
|
@ -3082,11 +3077,11 @@ void func_800F4E30(Vec3f* pos, f32 arg1) {
|
|||
}
|
||||
|
||||
if (sSariaBgmPtr->x > 100.0f) {
|
||||
phi_s4 = 0x7F;
|
||||
pan = 0x7F;
|
||||
} else if (sSariaBgmPtr->x < -100.0f) {
|
||||
phi_s4 = 0;
|
||||
pan = 0;
|
||||
} else {
|
||||
phi_s4 = ((sSariaBgmPtr->x / 100.0f) * 64.0f) + 64.0f;
|
||||
pan = ((sSariaBgmPtr->x / 100.0f) * 64.0f) + 64.0f;
|
||||
}
|
||||
|
||||
if (D_80130650 > 400.0f) {
|
||||
|
@ -3097,10 +3092,10 @@ void func_800F4E30(Vec3f* pos, f32 arg1) {
|
|||
phi_f22 = ((1.0f - ((D_80130650 - 120.0f) / 280.0f)) * 0.9f) + 0.1f;
|
||||
}
|
||||
|
||||
for (i = 0; i < 0x10; i++) {
|
||||
if (i != 9) {
|
||||
SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, i, 2, (127.0f * phi_f22));
|
||||
Audio_QueueCmdS8(0x3 << 24 | SEQ_PLAYER_BGM_MAIN << 16 | ((u8)((u32)i) << 8), phi_s4);
|
||||
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
|
||||
if (channelIndex != 9) {
|
||||
SEQCMD_SET_CHANNEL_VOLUME(SEQ_PLAYER_BGM_MAIN, channelIndex, 2, (127.0f * phi_f22));
|
||||
AUDIOCMD_CHANNEL_SET_PAN(SEQ_PLAYER_BGM_MAIN, (u32)channelIndex, pan);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3227,8 +3222,7 @@ void Audio_PlaySceneSequence(u16 seqId) {
|
|||
if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN) != NA_BGM_WINDMILL) {
|
||||
if (Audio_GetActiveSeqId(SEQ_PLAYER_BGM_SUB) == NA_BGM_LONLON) {
|
||||
Audio_StopSequence(SEQ_PLAYER_BGM_SUB, 0);
|
||||
// Terminate all internal audio cmds
|
||||
Audio_QueueCmdS32(0xF8000000, 0);
|
||||
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
|
||||
}
|
||||
|
||||
if ((sSeqFlags[sPrevSceneSeqId] & SEQ_FLAG_RESUME_PREV) && (sSeqFlags[seqId & 0xFF & 0xFF] & SEQ_FLAG_RESUME)) {
|
||||
|
@ -3263,7 +3257,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;
|
||||
|
@ -3285,7 +3279,7 @@ void Audio_SetMainBgmTempoFreqAfterFanfare(f32 scaleTempoAndFreq, u8 duration) {
|
|||
SEQCMD_SETUP_SCALE_TEMPO(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, duration, scaleTempoAndFreq * 100.0f);
|
||||
}
|
||||
|
||||
SEQCMD_SETUP_SET_PLAYER_FREQ(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, duration, scaleTempoAndFreq * 100.0f);
|
||||
SEQCMD_SETUP_SET_SEQPLAYER_FREQ(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, duration, scaleTempoAndFreq * 100.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3406,8 +3400,8 @@ void Audio_PlayFanfare(u16 seqId) {
|
|||
|
||||
curSeqId = Audio_GetActiveSeqId(SEQ_PLAYER_FANFARE);
|
||||
|
||||
curFontId = func_800E5E84(curSeqId & 0xFF, &outNumFonts);
|
||||
requestedFontId = func_800E5E84(seqId & 0xFF, &outNumFonts);
|
||||
curFontId = AudioThread_GetFontsForSequence(curSeqId & 0xFF, &outNumFonts);
|
||||
requestedFontId = AudioThread_GetFontsForSequence(seqId & 0xFF, &outNumFonts);
|
||||
|
||||
if ((curSeqId == NA_BGM_DISABLED) || (*curFontId == *requestedFontId)) {
|
||||
sFanfareStartTimer = 1;
|
||||
|
@ -3428,8 +3422,8 @@ void Audio_UpdateFanfare(void) {
|
|||
if (sFanfareStartTimer != 0) {
|
||||
sFanfareStartTimer--;
|
||||
if (sFanfareStartTimer == 0) {
|
||||
Audio_QueueCmdS32(0xE3000000, SEQUENCE_TABLE);
|
||||
Audio_QueueCmdS32(0xE3000000, FONT_TABLE);
|
||||
AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(SEQUENCE_TABLE);
|
||||
AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(FONT_TABLE);
|
||||
|
||||
seqIdBgmMain = Audio_GetActiveSeqId(SEQ_PLAYER_BGM_MAIN);
|
||||
seqIdFanfare = Audio_GetActiveSeqId(SEQ_PLAYER_FANFARE);
|
||||
|
@ -3439,10 +3433,10 @@ void Audio_UpdateFanfare(void) {
|
|||
if (seqIdFanfare == NA_BGM_DISABLED) {
|
||||
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_FANFARE, 0, 5);
|
||||
Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_FANFARE, 0, 5);
|
||||
SEQCMD_SETUP_RESTORE_PLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN,
|
||||
VOL_SCALE_INDEX_FANFARE, 10);
|
||||
SEQCMD_SETUP_RESTORE_PLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_SUB,
|
||||
VOL_SCALE_INDEX_FANFARE, 10);
|
||||
SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN,
|
||||
VOL_SCALE_INDEX_FANFARE, 10);
|
||||
SEQCMD_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_SUB,
|
||||
VOL_SCALE_INDEX_FANFARE, 10);
|
||||
SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_MAIN, 0);
|
||||
if (seqIdBgmSub != NA_BGM_LONLON) {
|
||||
SEQCMD_SETUP_SET_CHANNEL_DISABLE_MASK(SEQ_PLAYER_FANFARE, SEQ_PLAYER_BGM_SUB, 0);
|
||||
|
@ -3458,7 +3452,7 @@ void Audio_UpdateFanfare(void) {
|
|||
}
|
||||
|
||||
void Audio_PlaySequenceWithSeqPlayerIO(u8 seqPlayerIndex, u16 seqId, u8 fadeInDuration, s8 ioPort, s8 ioData) {
|
||||
SEQCMD_SET_PLAYER_IO(seqPlayerIndex, ioPort, ioData);
|
||||
SEQCMD_SET_SEQPLAYER_IO(seqPlayerIndex, ioPort, ioData);
|
||||
SEQCMD_PLAY_SEQUENCE(seqPlayerIndex, fadeInDuration, 0, seqId);
|
||||
}
|
||||
|
||||
|
@ -3537,7 +3531,7 @@ void Audio_SetSequenceMode(u8 seqMode) {
|
|||
}
|
||||
|
||||
sPrevSeqMode = seqMode;
|
||||
SEQCMD_SET_PLAYER_IO(SEQ_PLAYER_BGM_MAIN, 2, seqMode);
|
||||
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 2, seqMode);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3641,11 +3635,11 @@ void func_800F64E0(u8 arg0) {
|
|||
if (arg0 != 0) {
|
||||
Audio_PlaySfxGeneral(NA_SE_SY_WIN_OPEN, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
||||
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
||||
Audio_QueueCmdS32(0xF1000000, 0);
|
||||
AUDIOCMD_GLOBAL_MUTE();
|
||||
} else {
|
||||
Audio_PlaySfxGeneral(NA_SE_SY_WIN_CLOSE, &gSfxDefaultPos, 4, &gSfxDefaultFreqAndVolScale,
|
||||
&gSfxDefaultFreqAndVolScale, &gSfxDefaultReverb);
|
||||
Audio_QueueCmdS32(0xF2000000, 0);
|
||||
AUDIOCMD_GLOBAL_UNMUTE(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3754,16 +3748,13 @@ void Audio_SetBaseFilter(u8 filter) {
|
|||
}
|
||||
|
||||
void Audio_SetExtraFilter(u8 filter) {
|
||||
u32 t;
|
||||
u8 i;
|
||||
u8 channelIndex;
|
||||
|
||||
sAudioExtraFilter2 = filter;
|
||||
sAudioExtraFilter = filter;
|
||||
if (gActiveSeqs[SEQ_PLAYER_BGM_MAIN].seqId == NA_BGM_NATURE_AMBIENCE) {
|
||||
for (i = 0; i < 16; i++) {
|
||||
t = i;
|
||||
// CHAN_UPD_SCRIPT_IO (seq player 0, all channels, slot 6)
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_BGM_MAIN << 16 | ((t & 0xFF) << 8) | 6, filter);
|
||||
for (channelIndex = 0; channelIndex < SEQ_NUM_CHANNELS; channelIndex++) {
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_BGM_MAIN, (u32)channelIndex, 6, filter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3824,11 +3815,11 @@ void func_800F6B3C(void) {
|
|||
}
|
||||
|
||||
void Audio_DisableAllSeq(void) {
|
||||
Audio_DisableSeq(SEQ_PLAYER_BGM_MAIN, 0);
|
||||
Audio_DisableSeq(SEQ_PLAYER_FANFARE, 0);
|
||||
Audio_DisableSeq(SEQ_PLAYER_SFX, 0);
|
||||
Audio_DisableSeq(SEQ_PLAYER_BGM_SUB, 0);
|
||||
Audio_ScheduleProcessCmds();
|
||||
AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(SEQ_PLAYER_BGM_MAIN, 0);
|
||||
AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(SEQ_PLAYER_FANFARE, 0);
|
||||
AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(SEQ_PLAYER_SFX, 0);
|
||||
AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(SEQ_PLAYER_BGM_SUB, 0);
|
||||
AudioThread_ScheduleProcessCmds();
|
||||
}
|
||||
|
||||
s8 func_800F6BB8(void) {
|
||||
|
@ -3837,7 +3828,7 @@ s8 func_800F6BB8(void) {
|
|||
|
||||
void func_800F6BDC(void) {
|
||||
Audio_DisableAllSeq();
|
||||
Audio_ScheduleProcessCmds();
|
||||
AudioThread_ScheduleProcessCmds();
|
||||
while (true) {
|
||||
if (!func_800F6BB8()) {
|
||||
return;
|
||||
|
@ -3846,7 +3837,7 @@ void func_800F6BDC(void) {
|
|||
}
|
||||
|
||||
void Audio_PreNMI(void) {
|
||||
Audio_PreNMIInternal();
|
||||
AudioThread_PreNMIInternal();
|
||||
}
|
||||
|
||||
void func_800F6C34(void) {
|
||||
|
@ -3872,7 +3863,7 @@ void func_800F6C34(void) {
|
|||
sSpecReverb = sSpecReverbs[gAudioSpecId];
|
||||
D_80130608 = 0;
|
||||
sPrevMainBgmSeqId = NA_BGM_DISABLED;
|
||||
Audio_QueueCmdS8(0x46 << 24 | SEQ_PLAYER_BGM_MAIN << 16, -1);
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_BGM_MAIN, 0, SEQ_IO_VAL_NONE);
|
||||
sSariaBgmPtr = NULL;
|
||||
sFanfareStartTimer = 0;
|
||||
D_8016B9F3 = 1;
|
||||
|
@ -3921,9 +3912,9 @@ void Audio_StartNatureAmbienceSequence(u16 playerIO, u16 channelMask) {
|
|||
return;
|
||||
}
|
||||
|
||||
SEQCMD_SET_PLAYER_IO(SEQ_PLAYER_BGM_MAIN, 0, 1);
|
||||
SEQCMD_SET_PLAYER_IO(SEQ_PLAYER_BGM_MAIN, 4, playerIO >> 8);
|
||||
SEQCMD_SET_PLAYER_IO(SEQ_PLAYER_BGM_MAIN, 5, playerIO & 0xFF);
|
||||
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 0, 1);
|
||||
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 4, playerIO >> 8);
|
||||
SEQCMD_SET_SEQPLAYER_IO(SEQ_PLAYER_BGM_MAIN, 5, playerIO & 0xFF);
|
||||
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_BGM_MAIN, 0x7F, 1);
|
||||
|
||||
channelIdx = false;
|
||||
|
@ -3986,9 +3977,9 @@ void Audio_InitSound(void) {
|
|||
|
||||
void func_800F7170(void) {
|
||||
Audio_StartSequence(SEQ_PLAYER_SFX, 0, 0x70, 1);
|
||||
Audio_QueueCmdS32(0xF2000000, 1);
|
||||
Audio_ScheduleProcessCmds();
|
||||
Audio_QueueCmdS32(0xF8000000, 0);
|
||||
AUDIOCMD_GLOBAL_UNMUTE(1);
|
||||
AudioThread_ScheduleProcessCmds();
|
||||
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
|
||||
}
|
||||
|
||||
void func_800F71BC(s32 arg0) {
|
||||
|
@ -4002,7 +3993,7 @@ void func_800F71BC(s32 arg0) {
|
|||
|
||||
void func_800F7208(void) {
|
||||
Audio_ResetActiveSequences();
|
||||
Audio_QueueCmdS32(0xF2000000, 1);
|
||||
AUDIOCMD_GLOBAL_UNMUTE(1);
|
||||
func_800F6C34();
|
||||
Audio_ResetSfxChannelState();
|
||||
Audio_StartSequence(SEQ_PLAYER_SFX, 0, 0x70, 1);
|
||||
|
|
|
@ -113,8 +113,8 @@ f32 Audio_GetVibratoFreqScale(VibratoState* vib) {
|
|||
static f32 D_80130510 = 0.0f;
|
||||
static s32 D_80130514 = 0;
|
||||
f32 pitchChange;
|
||||
f32 extent;
|
||||
f32 invExtent;
|
||||
f32 depth;
|
||||
f32 invDepth;
|
||||
f32 result;
|
||||
f32 temp;
|
||||
SequenceChannel* channel = vib->channel;
|
||||
|
@ -127,17 +127,17 @@ f32 Audio_GetVibratoFreqScale(VibratoState* vib) {
|
|||
//! @bug this probably meant to compare with gAudioCtx.sequenceChannelNone.
|
||||
//! -1 isn't used as a channel pointer anywhere else.
|
||||
if (channel != ((SequenceChannel*)(-1))) {
|
||||
if (vib->extentChangeTimer) {
|
||||
if (vib->extentChangeTimer == 1) {
|
||||
vib->extent = (s32)channel->vibratoExtentTarget;
|
||||
if (vib->depthChangeTimer) {
|
||||
if (vib->depthChangeTimer == 1) {
|
||||
vib->depth = (s32)channel->vibratoDepthTarget;
|
||||
} else {
|
||||
vib->extent += ((s32)channel->vibratoExtentTarget - vib->extent) / (s32)vib->extentChangeTimer;
|
||||
vib->depth += ((s32)channel->vibratoDepthTarget - vib->depth) / (s32)vib->depthChangeTimer;
|
||||
}
|
||||
|
||||
vib->extentChangeTimer--;
|
||||
} else if (channel->vibratoExtentTarget != (s32)vib->extent) {
|
||||
if ((vib->extentChangeTimer = channel->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = (s32)channel->vibratoExtentTarget;
|
||||
vib->depthChangeTimer--;
|
||||
} else if (channel->vibratoDepthTarget != (s32)vib->depth) {
|
||||
if ((vib->depthChangeTimer = channel->vibratoDepthChangeDelay) == 0) {
|
||||
vib->depth = (s32)channel->vibratoDepthTarget;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,16 +156,16 @@ f32 Audio_GetVibratoFreqScale(VibratoState* vib) {
|
|||
}
|
||||
}
|
||||
|
||||
if (vib->extent == 0.0f) {
|
||||
if (vib->depth == 0.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
pitchChange = Audio_GetVibratoPitchChange(vib) + 32768.0f;
|
||||
temp = vib->extent / 4096.0f;
|
||||
extent = temp + 1.0f;
|
||||
invExtent = 1.0f / extent;
|
||||
temp = vib->depth / 4096.0f;
|
||||
depth = temp + 1.0f;
|
||||
invDepth = 1.0f / depth;
|
||||
|
||||
result = 1.0f / ((extent - invExtent) * pitchChange / 65536.0f + invExtent);
|
||||
result = 1.0f / ((depth - invDepth) * pitchChange / 65536.0f + invDepth);
|
||||
|
||||
D_80130510 += result;
|
||||
D_80130514++;
|
||||
|
@ -190,16 +190,16 @@ void Audio_NoteVibratoInit(Note* note) {
|
|||
|
||||
vib = ¬e->playbackState.vibratoState;
|
||||
|
||||
vib->active = 1;
|
||||
vib->active = true;
|
||||
vib->time = 0;
|
||||
vib->curve = gWaveSamples[2]; // gSineWaveSample[0..63]
|
||||
|
||||
vib->curve = gWaveSamples[2];
|
||||
vib->channel = note->playbackState.parentLayer->channel;
|
||||
channel = vib->channel;
|
||||
if ((vib->extentChangeTimer = channel->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = (s32)channel->vibratoExtentTarget;
|
||||
if ((vib->depthChangeTimer = channel->vibratoDepthChangeDelay) == 0) {
|
||||
vib->depth = (s32)channel->vibratoDepthTarget;
|
||||
} else {
|
||||
vib->extent = (s32)channel->vibratoExtentStart;
|
||||
vib->depth = (s32)channel->vibratoDepthStart;
|
||||
}
|
||||
|
||||
if ((vib->rateChangeTimer = channel->vibratoRateChangeDelay) == 0) {
|
||||
|
@ -264,7 +264,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) {
|
|||
break;
|
||||
|
||||
default:
|
||||
adsr->delay *= gAudioCtx.audioBufferParameters.updatesPerFrameScaled;
|
||||
adsr->delay *= gAudioCtx.audioBufferParameters.ticksPerUpdateScaled;
|
||||
if (adsr->delay == 0) {
|
||||
adsr->delay = 1;
|
||||
}
|
||||
|
|
|
@ -11,12 +11,10 @@ void AudioHeap_DiscardSampleBank(s32 sampleBankId);
|
|||
void AudioHeap_DiscardSampleBanks(void);
|
||||
|
||||
/**
|
||||
* Effectively scales `updatesPerFrameInv` by the reciprocal of `scaleInv`
|
||||
* `updatesPerFrameInvScaled` is just `updatesPerFrameInv` scaled down by a factor of 256.0f
|
||||
* i.e. (256.0f * `updatesPerFrameInvScaled`) is just `updatesPerFrameInv`
|
||||
* Effectively scales `ticksPerUpdateInv` by the reciprocal of `scaleInv`
|
||||
*/
|
||||
f32 AudioHeap_CalculateAdsrDecay(f32 scaleInv) {
|
||||
return (256.0f * gAudioCtx.audioBufferParameters.updatesPerFrameInvScaled) / scaleInv;
|
||||
return (256.0f * gAudioCtx.audioBufferParameters.ticksPerUpdateInvScaled) / scaleInv;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -96,7 +94,7 @@ void AudioHeap_ReleaseNotesForFont(s32 fontId) {
|
|||
if (playbackState->fontId == fontId) {
|
||||
if ((playbackState->priority != 0) && (playbackState->adsr.action.s.state == ADSR_STATE_DECAY)) {
|
||||
playbackState->priority = 1;
|
||||
playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv;
|
||||
playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.ticksPerUpdateInv;
|
||||
playbackState->adsr.action.s.release = true;
|
||||
}
|
||||
}
|
||||
|
@ -793,7 +791,7 @@ s32 AudioHeap_ResetStep(void) {
|
|||
if (gAudioCtx.notes[i].noteSubEu.bitField0.enabled &&
|
||||
gAudioCtx.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) {
|
||||
gAudioCtx.notes[i].playbackState.adsr.fadeOutVel =
|
||||
gAudioCtx.audioBufferParameters.updatesPerFrameInv;
|
||||
gAudioCtx.audioBufferParameters.ticksPerUpdateInv;
|
||||
gAudioCtx.notes[i].playbackState.adsr.action.s.release = true;
|
||||
}
|
||||
}
|
||||
|
@ -853,7 +851,7 @@ void AudioHeap_Init(void) {
|
|||
s32 i;
|
||||
s32 j;
|
||||
s32 pad2;
|
||||
AudioSpec* spec = &gAudioSpecs[gAudioCtx.audioResetSpecIdToLoad]; // Audio Specifications
|
||||
AudioSpec* spec = &gAudioSpecs[gAudioCtx.specId]; // Audio Specifications
|
||||
|
||||
gAudioCtx.sampleDmaCount = 0;
|
||||
|
||||
|
@ -865,17 +863,17 @@ void AudioHeap_Init(void) {
|
|||
ALIGN16(gAudioCtx.audioBufferParameters.samplingFrequency / gAudioCtx.refreshRate);
|
||||
gAudioCtx.audioBufferParameters.minAiBufferLength = gAudioCtx.audioBufferParameters.samplesPerFrameTarget - 0x10;
|
||||
gAudioCtx.audioBufferParameters.maxAiBufferLength = gAudioCtx.audioBufferParameters.samplesPerFrameTarget + 0x10;
|
||||
gAudioCtx.audioBufferParameters.updatesPerFrame =
|
||||
gAudioCtx.audioBufferParameters.ticksPerUpdate =
|
||||
((gAudioCtx.audioBufferParameters.samplesPerFrameTarget + 0x10) / 0xD0) + 1;
|
||||
gAudioCtx.audioBufferParameters.samplesPerUpdate =
|
||||
(gAudioCtx.audioBufferParameters.samplesPerFrameTarget / gAudioCtx.audioBufferParameters.updatesPerFrame) & ~7;
|
||||
gAudioCtx.audioBufferParameters.samplesPerUpdateMax = gAudioCtx.audioBufferParameters.samplesPerUpdate + 8;
|
||||
gAudioCtx.audioBufferParameters.samplesPerUpdateMin = gAudioCtx.audioBufferParameters.samplesPerUpdate - 8;
|
||||
gAudioCtx.audioBufferParameters.samplesPerTick =
|
||||
(gAudioCtx.audioBufferParameters.samplesPerFrameTarget / gAudioCtx.audioBufferParameters.ticksPerUpdate) & ~7;
|
||||
gAudioCtx.audioBufferParameters.samplesPerTickMax = gAudioCtx.audioBufferParameters.samplesPerTick + 8;
|
||||
gAudioCtx.audioBufferParameters.samplesPerTickMin = gAudioCtx.audioBufferParameters.samplesPerTick - 8;
|
||||
gAudioCtx.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioCtx.audioBufferParameters.samplingFrequency;
|
||||
gAudioCtx.audioBufferParameters.updatesPerFrameInvScaled =
|
||||
(1.0f / 256.0f) / gAudioCtx.audioBufferParameters.updatesPerFrame;
|
||||
gAudioCtx.audioBufferParameters.updatesPerFrameScaled = gAudioCtx.audioBufferParameters.updatesPerFrame / 4.0f;
|
||||
gAudioCtx.audioBufferParameters.updatesPerFrameInv = 1.0f / gAudioCtx.audioBufferParameters.updatesPerFrame;
|
||||
gAudioCtx.audioBufferParameters.ticksPerUpdateInvScaled =
|
||||
(1.0f / 256.0f) / gAudioCtx.audioBufferParameters.ticksPerUpdate;
|
||||
gAudioCtx.audioBufferParameters.ticksPerUpdateScaled = gAudioCtx.audioBufferParameters.ticksPerUpdate / 4.0f;
|
||||
gAudioCtx.audioBufferParameters.ticksPerUpdateInv = 1.0f / gAudioCtx.audioBufferParameters.ticksPerUpdate;
|
||||
|
||||
// SampleDma buffer size
|
||||
gAudioCtx.sampleDmaBufSize1 = spec->sampleDmaBufSize1;
|
||||
|
@ -887,19 +885,22 @@ void AudioHeap_Init(void) {
|
|||
gAudioCtx.audioBufferParameters.numSequencePlayers = 4;
|
||||
}
|
||||
gAudioCtx.unk_2 = spec->unk_14;
|
||||
gAudioCtx.tempoInternalToExternal =
|
||||
(u32)(gAudioCtx.audioBufferParameters.updatesPerFrame * 2880000.0f / gTatumsPerBeat / gAudioCtx.unk_2960);
|
||||
|
||||
// (ticks / min)
|
||||
// 60 * 1000 is a conversion from milliseconds to minutes
|
||||
gAudioCtx.maxTempo = (u32)(gAudioCtx.audioBufferParameters.ticksPerUpdate * (f32)(60 * 1000 * SEQTICKS_PER_BEAT) /
|
||||
gTempoData.seqTicksPerBeat / gAudioCtx.maxTempoTvTypeFactors);
|
||||
|
||||
gAudioCtx.unk_2870 = gAudioCtx.refreshRate;
|
||||
gAudioCtx.unk_2870 *= gAudioCtx.audioBufferParameters.updatesPerFrame;
|
||||
gAudioCtx.unk_2870 *= gAudioCtx.audioBufferParameters.ticksPerUpdate;
|
||||
gAudioCtx.unk_2870 /= gAudioCtx.audioBufferParameters.aiSamplingFrequency;
|
||||
gAudioCtx.unk_2870 /= gAudioCtx.tempoInternalToExternal;
|
||||
gAudioCtx.unk_2870 /= gAudioCtx.maxTempo;
|
||||
|
||||
gAudioCtx.audioBufferParameters.specUnk4 = spec->unk_04;
|
||||
gAudioCtx.audioBufferParameters.samplesPerFrameTarget *= gAudioCtx.audioBufferParameters.specUnk4;
|
||||
gAudioCtx.audioBufferParameters.maxAiBufferLength *= gAudioCtx.audioBufferParameters.specUnk4;
|
||||
gAudioCtx.audioBufferParameters.minAiBufferLength *= gAudioCtx.audioBufferParameters.specUnk4;
|
||||
gAudioCtx.audioBufferParameters.updatesPerFrame *= gAudioCtx.audioBufferParameters.specUnk4;
|
||||
gAudioCtx.audioBufferParameters.ticksPerUpdate *= gAudioCtx.audioBufferParameters.specUnk4;
|
||||
|
||||
if (gAudioCtx.audioBufferParameters.specUnk4 >= 2) {
|
||||
gAudioCtx.audioBufferParameters.maxAiBufferLength -= 0x10;
|
||||
|
@ -907,7 +908,7 @@ void AudioHeap_Init(void) {
|
|||
|
||||
// Determine the length of the buffer for storing the audio command list passed to the rsp audio microcode
|
||||
gAudioCtx.maxAudioCmds =
|
||||
gAudioCtx.numNotes * 0x10 * gAudioCtx.audioBufferParameters.updatesPerFrame + spec->numReverbs * 0x18 + 0x140;
|
||||
gAudioCtx.numNotes * 0x10 * gAudioCtx.audioBufferParameters.ticksPerUpdate + spec->numReverbs * 0x18 + 0x140;
|
||||
|
||||
// Calculate sizes for various caches on the audio heap
|
||||
persistentSize =
|
||||
|
@ -949,7 +950,7 @@ void AudioHeap_Init(void) {
|
|||
gAudioCtx.notes = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, gAudioCtx.numNotes * sizeof(Note));
|
||||
Audio_NoteInitAll();
|
||||
Audio_InitNoteFreeList();
|
||||
gAudioCtx.noteSubsEu = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, gAudioCtx.audioBufferParameters.updatesPerFrame *
|
||||
gAudioCtx.noteSubsEu = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, gAudioCtx.audioBufferParameters.ticksPerUpdate *
|
||||
gAudioCtx.numNotes * sizeof(NoteSubEu));
|
||||
// Initialize audio binary interface command list buffers
|
||||
for (i = 0; i != 2; i++) {
|
||||
|
@ -1011,7 +1012,7 @@ void AudioHeap_Init(void) {
|
|||
reverb->unk_34 = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(RESAMPLE_STATE));
|
||||
reverb->unk_38 = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(RESAMPLE_STATE));
|
||||
reverb->unk_3C = AudioHeap_AllocZeroed(&gAudioCtx.miscPool, sizeof(RESAMPLE_STATE));
|
||||
for (j = 0; j < gAudioCtx.audioBufferParameters.updatesPerFrame; j++) {
|
||||
for (j = 0; j < gAudioCtx.audioBufferParameters.ticksPerUpdate; j++) {
|
||||
ramAddr = AudioHeap_AllocZeroedAttemptExternal(&gAudioCtx.miscPool, DMEM_2CH_SIZE);
|
||||
reverb->items[0][j].toDownsampleLeft = ramAddr;
|
||||
reverb->items[0][j].toDownsampleRight = ramAddr + DMEM_1CH_SIZE / SAMPLE_SIZE;
|
||||
|
|
|
@ -1126,7 +1126,7 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
|
|||
void* ramAddr;
|
||||
s32 i;
|
||||
|
||||
D_801755D0 = NULL;
|
||||
gAudioCustomUpdateFunction = NULL;
|
||||
gAudioCtx.resetTimer = 0;
|
||||
|
||||
{
|
||||
|
@ -1138,25 +1138,26 @@ void AudioLoad_Init(void* heap, u32 heapSize) {
|
|||
}
|
||||
}
|
||||
|
||||
// 1000 is a conversion from seconds to milliseconds
|
||||
switch (osTvType) {
|
||||
case OS_TV_PAL:
|
||||
gAudioCtx.unk_2960 = 20.03042f;
|
||||
gAudioCtx.refreshRate = 50;
|
||||
gAudioCtx.maxTempoTvTypeFactors = 1000 * REFRESH_RATE_DEVIATION_PAL / REFRESH_RATE_PAL;
|
||||
gAudioCtx.refreshRate = REFRESH_RATE_PAL;
|
||||
break;
|
||||
|
||||
case OS_TV_MPAL:
|
||||
gAudioCtx.unk_2960 = 16.546f;
|
||||
gAudioCtx.refreshRate = 60;
|
||||
gAudioCtx.maxTempoTvTypeFactors = 1000 * REFRESH_RATE_DEVIATION_MPAL / REFRESH_RATE_MPAL;
|
||||
gAudioCtx.refreshRate = REFRESH_RATE_MPAL;
|
||||
break;
|
||||
|
||||
case OS_TV_NTSC:
|
||||
default:
|
||||
gAudioCtx.unk_2960 = 16.713f;
|
||||
gAudioCtx.refreshRate = 60;
|
||||
gAudioCtx.maxTempoTvTypeFactors = 1000 * REFRESH_RATE_DEVIATION_NTSC / REFRESH_RATE_NTSC;
|
||||
gAudioCtx.refreshRate = REFRESH_RATE_NTSC;
|
||||
break;
|
||||
}
|
||||
|
||||
Audio_InitMesgQueues();
|
||||
AudioThread_InitMesgQueues();
|
||||
|
||||
for (i = 0; i < 3; i++) {
|
||||
gAudioCtx.aiBufLengths[i] = 0xA0;
|
||||
|
@ -1209,7 +1210,7 @@ void AudioLoad_Init(void* heap, u32 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();
|
||||
|
|
|
@ -100,8 +100,8 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
|
|||
|
||||
sub->gain = attrs->gain;
|
||||
sub->filter = attrs->filter;
|
||||
sub->unk_07 = attrs->unk_14;
|
||||
sub->unk_0E = attrs->unk_16;
|
||||
sub->combFilterSize = attrs->combFilterSize;
|
||||
sub->combFilterGain = attrs->combFilterGain;
|
||||
sub->reverbVol = reverbVol;
|
||||
}
|
||||
|
||||
|
@ -174,7 +174,7 @@ void Audio_ProcessNotes(void) {
|
|||
|
||||
if (note != playbackState->parentLayer->note && playbackState->unk_04 == 0) {
|
||||
playbackState->adsr.action.s.release = true;
|
||||
playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv;
|
||||
playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.ticksPerUpdateInv;
|
||||
playbackState->priority = 1;
|
||||
playbackState->unk_04 = 2;
|
||||
goto out;
|
||||
|
@ -256,8 +256,8 @@ void Audio_ProcessNotes(void) {
|
|||
subAttrs.stereo = attrs->stereo;
|
||||
subAttrs.gain = attrs->gain;
|
||||
subAttrs.filter = attrs->filter;
|
||||
subAttrs.unk_14 = attrs->unk_4;
|
||||
subAttrs.unk_16 = attrs->unk_6;
|
||||
subAttrs.combFilterSize = attrs->combFilterSize;
|
||||
subAttrs.combFilterGain = attrs->combFilterGain;
|
||||
bookOffset = noteSubEu->bitField1.bookOffset;
|
||||
} else {
|
||||
SequenceLayer* layer = playbackState->parentLayer;
|
||||
|
@ -271,11 +271,11 @@ void Audio_ProcessNotes(void) {
|
|||
} else {
|
||||
subAttrs.stereo = layer->stereo;
|
||||
}
|
||||
subAttrs.reverbVol = channel->reverb;
|
||||
subAttrs.reverbVol = channel->targetReverbVol;
|
||||
subAttrs.gain = channel->gain;
|
||||
subAttrs.filter = channel->filter;
|
||||
subAttrs.unk_14 = channel->unk_0F;
|
||||
subAttrs.unk_16 = channel->unk_20;
|
||||
subAttrs.combFilterSize = channel->combFilterSize;
|
||||
subAttrs.combFilterGain = channel->combFilterGain;
|
||||
bookOffset = channel->bookOffset & 0x7;
|
||||
|
||||
if (channel->seqPlayer->muted && (channel->muteBehavior & MUTE_BEHAVIOR_3)) {
|
||||
|
@ -433,7 +433,7 @@ s32 Audio_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* val
|
|||
void Audio_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
||||
Note* note;
|
||||
NoteAttributes* attrs;
|
||||
SequenceChannel* chan;
|
||||
SequenceChannel* channel;
|
||||
s32 i;
|
||||
|
||||
if (layer == NO_LAYER) {
|
||||
|
@ -456,7 +456,7 @@ void Audio_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
|||
if (note->playbackState.parentLayer != layer) {
|
||||
if (note->playbackState.parentLayer == NO_LAYER && note->playbackState.wantedParentLayer == NO_LAYER &&
|
||||
note->playbackState.prevParentLayer == layer && target != ADSR_STATE_DECAY) {
|
||||
note->playbackState.adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv;
|
||||
note->playbackState.adsr.fadeOutVel = gAudioCtx.audioBufferParameters.ticksPerUpdateInv;
|
||||
note->playbackState.adsr.action.s.release = true;
|
||||
}
|
||||
return;
|
||||
|
@ -468,10 +468,10 @@ void Audio_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
|||
attrs->pan = layer->notePan;
|
||||
|
||||
if (layer->channel != NULL) {
|
||||
chan = layer->channel;
|
||||
attrs->reverb = chan->reverb;
|
||||
attrs->gain = chan->gain;
|
||||
attrs->filter = chan->filter;
|
||||
channel = layer->channel;
|
||||
attrs->reverb = channel->targetReverbVol;
|
||||
attrs->gain = channel->gain;
|
||||
attrs->filter = channel->filter;
|
||||
|
||||
if (attrs->filter != NULL) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
|
@ -480,18 +480,18 @@ void Audio_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
|||
attrs->filter = attrs->filterBuf;
|
||||
}
|
||||
|
||||
attrs->unk_6 = chan->unk_20;
|
||||
attrs->unk_4 = chan->unk_0F;
|
||||
if (chan->seqPlayer->muted && (chan->muteBehavior & MUTE_BEHAVIOR_3)) {
|
||||
attrs->combFilterGain = channel->combFilterGain;
|
||||
attrs->combFilterSize = channel->combFilterSize;
|
||||
if (channel->seqPlayer->muted && (channel->muteBehavior & MUTE_BEHAVIOR_3)) {
|
||||
note->noteSubEu.bitField0.finished = true;
|
||||
}
|
||||
|
||||
if (layer->stereo.asByte == 0) {
|
||||
attrs->stereo = chan->stereo;
|
||||
attrs->stereo = channel->stereo;
|
||||
} else {
|
||||
attrs->stereo = layer->stereo;
|
||||
}
|
||||
note->playbackState.priority = chan->someOtherPriority;
|
||||
note->playbackState.priority = channel->someOtherPriority;
|
||||
} else {
|
||||
attrs->stereo = layer->stereo;
|
||||
note->playbackState.priority = 1;
|
||||
|
@ -500,7 +500,7 @@ void Audio_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
|||
note->playbackState.prevParentLayer = note->playbackState.parentLayer;
|
||||
note->playbackState.parentLayer = NO_LAYER;
|
||||
if (target == ADSR_STATE_RELEASE) {
|
||||
note->playbackState.adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv;
|
||||
note->playbackState.adsr.fadeOutVel = gAudioCtx.audioBufferParameters.ticksPerUpdateInv;
|
||||
note->playbackState.adsr.action.s.release = true;
|
||||
note->playbackState.unk_04 = 2;
|
||||
} else {
|
||||
|
@ -805,7 +805,7 @@ void Audio_NoteReleaseAndTakeOwnership(Note* note, SequenceLayer* layer) {
|
|||
note->playbackState.wantedParentLayer = layer;
|
||||
note->playbackState.priority = layer->channel->notePriority;
|
||||
|
||||
note->playbackState.adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv;
|
||||
note->playbackState.adsr.fadeOutVel = gAudioCtx.audioBufferParameters.ticksPerUpdateInv;
|
||||
note->playbackState.adsr.action.s.release = true;
|
||||
}
|
||||
|
||||
|
|
|
@ -259,7 +259,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;
|
||||
|
@ -274,7 +274,7 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) {
|
|||
channel->gateTimeRandomVariance = 0;
|
||||
channel->noteUnused = NULL;
|
||||
channel->reverbIndex = 0;
|
||||
channel->reverb = 0;
|
||||
channel->targetReverbVol = 0;
|
||||
channel->gain = 0;
|
||||
channel->notePriority = 3;
|
||||
channel->someOtherPriority = 1;
|
||||
|
@ -284,20 +284,20 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) {
|
|||
channel->adsr.sustain = 0;
|
||||
channel->vibratoRateTarget = 0x800;
|
||||
channel->vibratoRateStart = 0x800;
|
||||
channel->vibratoExtentTarget = 0;
|
||||
channel->vibratoExtentStart = 0;
|
||||
channel->vibratoDepthTarget = 0;
|
||||
channel->vibratoDepthStart = 0;
|
||||
channel->vibratoRateChangeDelay = 0;
|
||||
channel->vibratoExtentChangeDelay = 0;
|
||||
channel->vibratoDepthChangeDelay = 0;
|
||||
channel->vibratoDelay = 0;
|
||||
channel->filter = NULL;
|
||||
channel->unk_20 = 0;
|
||||
channel->unk_0F = 0;
|
||||
channel->combFilterGain = 0;
|
||||
channel->combFilterSize = 0;
|
||||
channel->volume = 1.0f;
|
||||
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;
|
||||
|
@ -326,7 +326,7 @@ s32 AudioSeq_SeqChannelSetLayer(SequenceChannel* channel, s32 layerIndex) {
|
|||
layer->adsr.decayIndex = 0;
|
||||
layer->enabled = true;
|
||||
layer->finished = false;
|
||||
layer->stopSomething = false;
|
||||
layer->muted = false;
|
||||
layer->continuousNotes = false;
|
||||
layer->bit3 = false;
|
||||
layer->ignoreDrumPan = false;
|
||||
|
@ -530,9 +530,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)) {
|
||||
Audio_SeqLayerNoteDecay(layer);
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
@ -555,7 +555,7 @@ void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) {
|
|||
AudioSeq_SeqLayerProcessScriptStep5(layer, cmd);
|
||||
}
|
||||
|
||||
if (layer->stopSomething == true) {
|
||||
if (layer->muted == true) {
|
||||
if ((layer->note != NULL) || layer->continuousNotes) {
|
||||
Audio_SeqLayerNoteDecay(layer);
|
||||
}
|
||||
|
@ -579,9 +579,9 @@ void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer) {
|
|||
s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSample) {
|
||||
Note* note;
|
||||
|
||||
if (!layer->stopSomething && layer->tunedSample != NULL &&
|
||||
layer->tunedSample->sample->codec == CODEC_S16_INMEMORY && layer->tunedSample->sample->medium != MEDIUM_RAM) {
|
||||
layer->stopSomething = true;
|
||||
if (!layer->muted && (layer->tunedSample != NULL) && (layer->tunedSample->sample->codec == CODEC_S16_INMEMORY) &&
|
||||
(layer->tunedSample->sample->medium != MEDIUM_RAM)) {
|
||||
layer->muted = true;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
|
@ -812,7 +812,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
|||
|
||||
drum = Audio_GetDrum(channel->fontId, semitone);
|
||||
if (drum == NULL) {
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
layer->delay2 = layer->delay;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
@ -834,7 +834,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
|||
|
||||
soundEffect = Audio_GetSoundEffect(channel->fontId, sfxId);
|
||||
if (soundEffect == NULL) {
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
layer->delay2 = layer->delay + 1;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
@ -850,7 +850,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
|||
|
||||
layer->semitone = semitone;
|
||||
if (semitone >= 0x80) {
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
|
@ -903,12 +903,12 @@ 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);
|
||||
}
|
||||
} else {
|
||||
speed = 0x20000 / (layer->portamentoTime * gAudioCtx.audioBufferParameters.updatesPerFrame);
|
||||
speed = 0x20000 / (layer->portamentoTime * gAudioCtx.audioBufferParameters.ticksPerUpdate);
|
||||
}
|
||||
|
||||
if (speed >= 0x7FFF) {
|
||||
|
@ -964,7 +964,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;
|
||||
|
@ -989,12 +989,12 @@ s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) {
|
|||
|
||||
if (cmd == 0xC0) {
|
||||
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) {
|
||||
|
@ -1078,13 +1078,13 @@ s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) {
|
|||
}
|
||||
|
||||
if ((seqPlayer->muted && (channel->muteBehavior & (MUTE_BEHAVIOR_STOP_NOTES | MUTE_BEHAVIOR_4))) ||
|
||||
channel->stopSomething2) {
|
||||
layer->stopSomething = true;
|
||||
channel->muted) {
|
||||
layer->muted = true;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
if (seqPlayer->skipTicks != 0) {
|
||||
layer->stopSomething = true;
|
||||
layer->muted = true;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
|
@ -1329,9 +1329,9 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
|
||||
case 0xD8:
|
||||
cmd = (u8)cmdArgs[0];
|
||||
channel->vibratoExtentTarget = cmd * 8;
|
||||
channel->vibratoExtentStart = 0;
|
||||
channel->vibratoExtentChangeDelay = 0;
|
||||
channel->vibratoDepthTarget = cmd * 8;
|
||||
channel->vibratoDepthStart = 0;
|
||||
channel->vibratoDepthChangeDelay = 0;
|
||||
break;
|
||||
|
||||
case 0xD7:
|
||||
|
@ -1343,11 +1343,11 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
|
||||
case 0xE2:
|
||||
cmd = (u8)cmdArgs[0];
|
||||
channel->vibratoExtentStart = cmd * 8;
|
||||
channel->vibratoDepthStart = cmd * 8;
|
||||
cmd = (u8)cmdArgs[1];
|
||||
channel->vibratoExtentTarget = cmd * 8;
|
||||
channel->vibratoDepthTarget = cmd * 8;
|
||||
cmd = (u8)cmdArgs[2];
|
||||
channel->vibratoExtentChangeDelay = cmd * 16;
|
||||
channel->vibratoDepthChangeDelay = cmd * 16;
|
||||
break;
|
||||
|
||||
case 0xE1:
|
||||
|
@ -1366,7 +1366,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
|
||||
case 0xD4:
|
||||
cmd = (u8)cmdArgs[0];
|
||||
channel->reverb = cmd;
|
||||
channel->targetReverbVol = cmd;
|
||||
break;
|
||||
|
||||
case 0xC6:
|
||||
|
@ -1483,7 +1483,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
data += 4;
|
||||
channel->newPan = data[-3];
|
||||
channel->panChannelWeight = data[-2];
|
||||
channel->reverb = data[-1];
|
||||
channel->targetReverbVol = data[-1];
|
||||
channel->reverbIndex = data[0];
|
||||
//! @bug: Not marking reverb state as changed
|
||||
channel->changes.s.pan = true;
|
||||
|
@ -1497,16 +1497,16 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
channel->transposition = (s8)AudioSeq_ScriptReadU8(scriptState);
|
||||
channel->newPan = AudioSeq_ScriptReadU8(scriptState);
|
||||
channel->panChannelWeight = AudioSeq_ScriptReadU8(scriptState);
|
||||
channel->reverb = AudioSeq_ScriptReadU8(scriptState);
|
||||
channel->targetReverbVol = AudioSeq_ScriptReadU8(scriptState);
|
||||
channel->reverbIndex = AudioSeq_ScriptReadU8(scriptState);
|
||||
//! @bug: Not marking reverb state as changed
|
||||
channel->changes.s.pan = true;
|
||||
break;
|
||||
|
||||
case 0xEC:
|
||||
channel->vibratoExtentTarget = 0;
|
||||
channel->vibratoExtentStart = 0;
|
||||
channel->vibratoExtentChangeDelay = 0;
|
||||
channel->vibratoDepthTarget = 0;
|
||||
channel->vibratoDepthStart = 0;
|
||||
channel->vibratoDepthChangeDelay = 0;
|
||||
channel->vibratoRateTarget = 0;
|
||||
channel->vibratoRateStart = 0;
|
||||
channel->vibratoRateChangeDelay = 0;
|
||||
|
@ -1515,8 +1515,8 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
channel->adsr.sustain = 0;
|
||||
channel->velocityRandomVariance = 0;
|
||||
channel->gateTimeRandomVariance = 0;
|
||||
channel->unk_0F = 0;
|
||||
channel->unk_20 = 0;
|
||||
channel->combFilterSize = 0;
|
||||
channel->combFilterGain = 0;
|
||||
channel->bookOffset = 0;
|
||||
channel->freqScale = 1.0f;
|
||||
break;
|
||||
|
@ -1578,7 +1578,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
break;
|
||||
|
||||
case 0xBD:
|
||||
temp2 = Audio_NextRandom();
|
||||
temp2 = AudioThread_NextRandom();
|
||||
channel->unk_22 = (cmdArgs[0] == 0) ? (temp2 & 0xFFFF) : (temp2 % cmdArgs[0]);
|
||||
channel->unk_22 += cmdArgs[1];
|
||||
temp2 = (channel->unk_22 / 0x100) + 0x80;
|
||||
|
@ -1595,8 +1595,8 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
break;
|
||||
|
||||
case 0xBB:
|
||||
channel->unk_0F = cmdArgs[0];
|
||||
channel->unk_20 = cmdArgs[1];
|
||||
channel->combFilterSize = cmdArgs[0];
|
||||
channel->combFilterGain = cmdArgs[1];
|
||||
break;
|
||||
|
||||
case 0xBC:
|
||||
|
@ -1642,7 +1642,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
break;
|
||||
|
||||
case 0x70:
|
||||
channel->soundScriptIO[lowBits] = scriptState->value;
|
||||
channel->seqScriptIO[lowBits] = scriptState->value;
|
||||
break;
|
||||
|
||||
case 0x78:
|
||||
|
@ -1664,26 +1664,26 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
|
||||
case 0x10:
|
||||
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:
|
||||
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:
|
||||
scriptState->value -= channel->soundScriptIO[lowBits];
|
||||
scriptState->value -= channel->seqScriptIO[lowBits];
|
||||
break;
|
||||
|
||||
case 0x20:
|
||||
|
@ -1693,12 +1693,12 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
|||
|
||||
case 0x30:
|
||||
cmd = AudioSeq_ScriptReadU8(scriptState);
|
||||
seqPlayer->channels[lowBits]->soundScriptIO[cmd] = scriptState->value;
|
||||
seqPlayer->channels[lowBits]->seqScriptIO[cmd] = scriptState->value;
|
||||
break;
|
||||
|
||||
case 0x40:
|
||||
cmd = AudioSeq_ScriptReadU8(scriptState);
|
||||
scriptState->value = seqPlayer->channels[lowBits]->soundScriptIO[cmd];
|
||||
scriptState->value = seqPlayer->channels[lowBits]->seqScriptIO[cmd];
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -1743,14 +1743,18 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
|||
}
|
||||
|
||||
seqPlayer->scriptCounter++;
|
||||
seqPlayer->tempoAcc += seqPlayer->tempo;
|
||||
seqPlayer->tempoAcc += (s16)seqPlayer->unk_0C;
|
||||
|
||||
if (seqPlayer->tempoAcc < gAudioCtx.tempoInternalToExternal) {
|
||||
// Apply the tempo by controlling the number of updates run on the .seq script.
|
||||
// Processing the .seq script every possible update will result in a tempo = maxTempo
|
||||
// Processing the .seq script a fraction of the updates will result in a `tempo = fraction * maxTempo`
|
||||
// where `fraction = (tempo + tempoChange) / maxTempo`
|
||||
// This algorithm uses `tempoAcc` to discretize `(tempo + tempoChange) / maxTempo`
|
||||
seqPlayer->tempoAcc += seqPlayer->tempo;
|
||||
seqPlayer->tempoAcc += (s16)seqPlayer->tempoChange;
|
||||
if (seqPlayer->tempoAcc < gAudioCtx.maxTempo) {
|
||||
return;
|
||||
}
|
||||
|
||||
seqPlayer->tempoAcc -= (u16)gAudioCtx.tempoInternalToExternal;
|
||||
seqPlayer->tempoAcc -= (u16)gAudioCtx.maxTempo;
|
||||
|
||||
if (seqPlayer->stopScript == true) {
|
||||
return;
|
||||
|
@ -1810,9 +1814,9 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
|||
break;
|
||||
|
||||
case 0xDD:
|
||||
seqPlayer->tempo = AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT;
|
||||
if (seqPlayer->tempo > gAudioCtx.tempoInternalToExternal) {
|
||||
seqPlayer->tempo = (u16)gAudioCtx.tempoInternalToExternal;
|
||||
seqPlayer->tempo = AudioSeq_ScriptReadU8(seqScript) * SEQTICKS_PER_BEAT;
|
||||
if (seqPlayer->tempo > gAudioCtx.maxTempo) {
|
||||
seqPlayer->tempo = (u16)gAudioCtx.maxTempo;
|
||||
}
|
||||
|
||||
if ((s16)seqPlayer->tempo <= 0) {
|
||||
|
@ -1821,7 +1825,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
|||
break;
|
||||
|
||||
case 0xDC:
|
||||
seqPlayer->unk_0C = (s8)AudioSeq_ScriptReadU8(seqScript) * TATUMS_PER_BEAT;
|
||||
seqPlayer->tempoChange = (s8)AudioSeq_ScriptReadU8(seqScript) * SEQTICKS_PER_BEAT;
|
||||
break;
|
||||
|
||||
case 0xDA:
|
||||
|
@ -1982,17 +1986,17 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
|||
break;
|
||||
|
||||
case 0x50:
|
||||
seqScript->value -= seqPlayer->soundScriptIO[cmdLowBits];
|
||||
seqScript->value -= seqPlayer->seqScriptIO[cmdLowBits];
|
||||
break;
|
||||
|
||||
case 0x70:
|
||||
seqPlayer->soundScriptIO[cmdLowBits] = seqScript->value;
|
||||
seqPlayer->seqScriptIO[cmdLowBits] = seqScript->value;
|
||||
break;
|
||||
|
||||
case 0x80:
|
||||
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;
|
||||
|
||||
|
@ -2014,14 +2018,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:
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
@ -2038,7 +2042,7 @@ void AudioSeq_ProcessSequences(s32 arg0) {
|
|||
SequencePlayer* seqPlayer;
|
||||
u32 i;
|
||||
|
||||
gAudioCtx.noteSubEuOffset = (gAudioCtx.audioBufferParameters.updatesPerFrame - arg0 - 1) * gAudioCtx.numNotes;
|
||||
gAudioCtx.noteSubEuOffset = (gAudioCtx.audioBufferParameters.ticksPerUpdate - arg0 - 1) * gAudioCtx.numNotes;
|
||||
|
||||
for (i = 0; i < (u32)gAudioCtx.audioBufferParameters.numSequencePlayers; i++) {
|
||||
seqPlayer = &gAudioCtx.seqPlayers[i];
|
||||
|
@ -2069,8 +2073,8 @@ void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer) {
|
|||
seqPlayer->fadeTimer = 0;
|
||||
seqPlayer->fadeTimerUnkEu = 0;
|
||||
seqPlayer->tempoAcc = 0;
|
||||
seqPlayer->tempo = 120 * TATUMS_PER_BEAT; // 120 BPM
|
||||
seqPlayer->unk_0C = 0;
|
||||
seqPlayer->tempo = 120 * SEQTICKS_PER_BEAT; // 120 BPM
|
||||
seqPlayer->tempoChange = 0;
|
||||
seqPlayer->transposition = 0;
|
||||
seqPlayer->noteAllocPolicy = 0;
|
||||
seqPlayer->shortNoteVelocityTable = gDefaultShortNoteVelocityTable;
|
||||
|
@ -2122,8 +2126,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->muteBehavior = MUTE_BEHAVIOR_SOFTEN | MUTE_BEHAVIOR_STOP_NOTES;
|
||||
|
|
|
@ -5,7 +5,7 @@
|
|||
#define DMEM_TEMP 0x3C0
|
||||
#define DMEM_UNCOMPRESSED_NOTE 0x580
|
||||
#define DMEM_HAAS_TEMP 0x5C0
|
||||
#define DMEM_SCRATCH2 0x760 // = DMEM_TEMP + DMEM_2CH_SIZE + a bit more
|
||||
#define DMEM_COMB_TEMP 0x760 // = DMEM_TEMP + DMEM_2CH_SIZE + a bit more
|
||||
#define DMEM_COMPRESSED_ADPCM_DATA 0x940 // = DMEM_LEFT_CH
|
||||
#define DMEM_LEFT_CH 0x940
|
||||
#define DMEM_RIGHT_CH 0xAE0
|
||||
|
@ -38,14 +38,14 @@ u32 sEnvMixerOp = _SHIFTL(A_ENVMIXER, 24, 8);
|
|||
|
||||
// Store the left dry channel in a temp space to be delayed to produce the haas effect
|
||||
u32 sEnvMixerLeftHaasDmemDests =
|
||||
MK_CMD(DMEM_HAAS_TEMP >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4);
|
||||
AUDIO_MK_CMD(DMEM_HAAS_TEMP >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4);
|
||||
|
||||
// Store the right dry channel in a temp space to be delayed to produce the haas effect
|
||||
u32 sEnvMixerRightHaasDmemDests =
|
||||
MK_CMD(DMEM_LEFT_CH >> 4, DMEM_HAAS_TEMP >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4);
|
||||
AUDIO_MK_CMD(DMEM_LEFT_CH >> 4, DMEM_HAAS_TEMP >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4);
|
||||
|
||||
u32 sEnvMixerDefaultDmemDests =
|
||||
MK_CMD(DMEM_LEFT_CH >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4);
|
||||
AUDIO_MK_CMD(DMEM_LEFT_CH >> 4, DMEM_RIGHT_CH >> 4, DMEM_WET_LEFT_CH >> 4, DMEM_WET_RIGHT_CH >> 4);
|
||||
|
||||
u16 D_801304B0[] = {
|
||||
0x7FFF, 0xD001, 0x3FFF, 0xF001, 0x5FFF, 0x9001, 0x7FFF, 0x8001,
|
||||
|
@ -158,32 +158,32 @@ Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen)
|
|||
SynthesisReverb* reverb;
|
||||
|
||||
cmdP = cmdStart;
|
||||
for (i = gAudioCtx.audioBufferParameters.updatesPerFrame; i > 0; i--) {
|
||||
for (i = gAudioCtx.audioBufferParameters.ticksPerUpdate; i > 0; i--) {
|
||||
AudioSeq_ProcessSequences(i - 1);
|
||||
func_800DB03C(gAudioCtx.audioBufferParameters.updatesPerFrame - i);
|
||||
func_800DB03C(gAudioCtx.audioBufferParameters.ticksPerUpdate - i);
|
||||
}
|
||||
|
||||
aiBufP = aiStart;
|
||||
gAudioCtx.curLoadedBook = NULL;
|
||||
|
||||
for (i = gAudioCtx.audioBufferParameters.updatesPerFrame; i > 0; i--) {
|
||||
for (i = gAudioCtx.audioBufferParameters.ticksPerUpdate; i > 0; i--) {
|
||||
if (i == 1) {
|
||||
chunkLen = aiBufLen;
|
||||
} else if ((aiBufLen / i) >= gAudioCtx.audioBufferParameters.samplesPerUpdateMax) {
|
||||
chunkLen = gAudioCtx.audioBufferParameters.samplesPerUpdateMax;
|
||||
} else if (gAudioCtx.audioBufferParameters.samplesPerUpdateMin >= (aiBufLen / i)) {
|
||||
chunkLen = gAudioCtx.audioBufferParameters.samplesPerUpdateMin;
|
||||
} else if ((aiBufLen / i) >= gAudioCtx.audioBufferParameters.samplesPerTickMax) {
|
||||
chunkLen = gAudioCtx.audioBufferParameters.samplesPerTickMax;
|
||||
} else if (gAudioCtx.audioBufferParameters.samplesPerTickMin >= (aiBufLen / i)) {
|
||||
chunkLen = gAudioCtx.audioBufferParameters.samplesPerTickMin;
|
||||
} else {
|
||||
chunkLen = gAudioCtx.audioBufferParameters.samplesPerUpdate;
|
||||
chunkLen = gAudioCtx.audioBufferParameters.samplesPerTick;
|
||||
}
|
||||
|
||||
for (j = 0; j < gAudioCtx.numSynthesisReverbs; j++) {
|
||||
if (gAudioCtx.synthesisReverbs[j].useReverb) {
|
||||
AudioSynth_InitNextRingBuf(chunkLen, gAudioCtx.audioBufferParameters.updatesPerFrame - i, j);
|
||||
AudioSynth_InitNextRingBuf(chunkLen, gAudioCtx.audioBufferParameters.ticksPerUpdate - i, j);
|
||||
}
|
||||
}
|
||||
|
||||
cmdP = AudioSynth_DoOneAudioUpdate(aiBufP, chunkLen, cmdP, gAudioCtx.audioBufferParameters.updatesPerFrame - i);
|
||||
cmdP = AudioSynth_DoOneAudioUpdate(aiBufP, chunkLen, cmdP, gAudioCtx.audioBufferParameters.ticksPerUpdate - i);
|
||||
aiBufLen -= chunkLen;
|
||||
aiBufP += 2 * chunkLen;
|
||||
}
|
||||
|
@ -203,7 +203,7 @@ void func_800DB2C0(s32 updateIndex, s32 noteIndex) {
|
|||
NoteSubEu* noteSubEu;
|
||||
s32 i;
|
||||
|
||||
for (i = updateIndex + 1; i < gAudioCtx.audioBufferParameters.updatesPerFrame; i++) {
|
||||
for (i = updateIndex + 1; i < gAudioCtx.audioBufferParameters.ticksPerUpdate; i++) {
|
||||
noteSubEu = &gAudioCtx.noteSubsEu[(gAudioCtx.numNotes * i) + noteIndex];
|
||||
if (!noteSubEu->bitField0.needsInit) {
|
||||
noteSubEu->bitField0.enabled = false;
|
||||
|
@ -717,7 +717,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
|||
s32 frameIndex;
|
||||
s32 skipBytes;
|
||||
s32 temp_v1_6;
|
||||
void* buf;
|
||||
s16* combFilterState;
|
||||
s32 nSamplesToDecode;
|
||||
u32 sampleAddr;
|
||||
u32 samplesLenFixedPoint;
|
||||
|
@ -740,12 +740,12 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
|||
s32 resampledTempLen;
|
||||
u16 sampleDmemBeforeResampling;
|
||||
s32 sampleDataOffset;
|
||||
s32 thing;
|
||||
s32 combFilterDmem;
|
||||
s32 s5;
|
||||
Note* note;
|
||||
u32 numSamplesToLoad;
|
||||
u16 unk7;
|
||||
u16 unkE;
|
||||
u16 combFilterSize;
|
||||
u16 combFilterGain;
|
||||
s16* filter;
|
||||
s32 bookOffset;
|
||||
s32 finished;
|
||||
|
@ -769,7 +769,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
|||
synthState->prevHaasEffectRightDelaySize = 0;
|
||||
synthState->reverbVol = noteSubEu->reverbVol;
|
||||
synthState->numParts = 0;
|
||||
synthState->unk_1A = 1;
|
||||
synthState->combFilterNeedsInit = true;
|
||||
note->noteSubEu.bitField0.finished = false;
|
||||
finished = false;
|
||||
}
|
||||
|
@ -1089,23 +1089,26 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
|||
AudioSynth_LoadFilterBuffer(cmd++, flags, DMEM_TEMP, synthState->synthesisBuffers->mixEnvelopeState);
|
||||
}
|
||||
|
||||
unk7 = noteSubEu->unk_07;
|
||||
unkE = noteSubEu->unk_0E;
|
||||
buf = synthState->synthesisBuffers->unkState;
|
||||
if (unk7 != 0 && noteSubEu->unk_0E != 0) {
|
||||
AudioSynth_DMemMove(cmd++, DMEM_TEMP, DMEM_SCRATCH2, aiBufLen * SAMPLE_SIZE);
|
||||
thing = DMEM_SCRATCH2 - unk7;
|
||||
if (synthState->unk_1A != 0) {
|
||||
AudioSynth_ClearBuffer(cmd++, thing, unk7);
|
||||
synthState->unk_1A = 0;
|
||||
// Apply the comb filter to the mono-signal by taking the signal with a small temporal offset,
|
||||
// and adding it back to itself
|
||||
combFilterSize = noteSubEu->combFilterSize;
|
||||
combFilterGain = noteSubEu->combFilterGain;
|
||||
combFilterState = synthState->synthesisBuffers->combFilterState;
|
||||
if ((combFilterSize != 0) && (noteSubEu->combFilterGain != 0)) {
|
||||
AudioSynth_DMemMove(cmd++, DMEM_TEMP, DMEM_COMB_TEMP, aiBufLen * SAMPLE_SIZE);
|
||||
combFilterDmem = DMEM_COMB_TEMP - combFilterSize;
|
||||
if (synthState->combFilterNeedsInit) {
|
||||
AudioSynth_ClearBuffer(cmd++, combFilterDmem, combFilterSize);
|
||||
synthState->combFilterNeedsInit = false;
|
||||
} else {
|
||||
AudioSynth_LoadBuffer(cmd++, thing, unk7, buf);
|
||||
AudioSynth_LoadBuffer(cmd++, combFilterDmem, combFilterSize, combFilterState);
|
||||
}
|
||||
AudioSynth_SaveBuffer(cmd++, DMEM_TEMP + (aiBufLen * SAMPLE_SIZE) - unk7, unk7, buf);
|
||||
AudioSynth_Mix(cmd++, (aiBufLen * (s32)SAMPLE_SIZE) >> 4, unkE, DMEM_SCRATCH2, thing);
|
||||
AudioSynth_DMemMove(cmd++, thing, DMEM_TEMP, aiBufLen * SAMPLE_SIZE);
|
||||
AudioSynth_SaveBuffer(cmd++, DMEM_TEMP + (aiBufLen * SAMPLE_SIZE) - combFilterSize, combFilterSize,
|
||||
combFilterState);
|
||||
AudioSynth_Mix(cmd++, (aiBufLen * (s32)SAMPLE_SIZE) >> 4, combFilterGain, DMEM_COMB_TEMP, combFilterDmem);
|
||||
AudioSynth_DMemMove(cmd++, combFilterDmem, DMEM_TEMP, aiBufLen * SAMPLE_SIZE);
|
||||
} else {
|
||||
synthState->unk_1A = 1;
|
||||
synthState->combFilterNeedsInit = true;
|
||||
}
|
||||
|
||||
if ((noteSubEu->haasEffectLeftDelaySize != 0) || (synthState->prevHaasEffectLeftDelaySize != 0)) {
|
||||
|
|
|
@ -3,42 +3,23 @@
|
|||
#define SAMPLES_TO_OVERPRODUCE 0x10
|
||||
#define EXTRA_BUFFERED_AI_SAMPLES_TARGET 0x80
|
||||
|
||||
typedef enum {
|
||||
CHAN_UPD_UNK_0, // 0
|
||||
CHAN_UPD_VOL_SCALE, // 1
|
||||
CHAN_UPD_VOL, // 2
|
||||
CHAN_UPD_PAN_SIGNED, // 3
|
||||
CHAN_UPD_FREQ_SCALE, // 4
|
||||
CHAN_UPD_REVERB, // 5
|
||||
CHAN_UPD_SCRIPT_IO, // 6
|
||||
CHAN_UPD_PAN_UNSIGNED, // 7
|
||||
CHAN_UPD_STOP_SOMETHING2, // 8
|
||||
CHAN_UPD_MUTE_BEHAVE, // 9
|
||||
CHAN_UPD_VIBE_X8, // 10
|
||||
CHAN_UPD_VIBE_X32, // 11
|
||||
CHAN_UPD_UNK_0F, // 12
|
||||
CHAN_UPD_UNK_20, // 13
|
||||
CHAN_UPD_STEREO // 14
|
||||
} ChannelUpdateType;
|
||||
|
||||
void func_800E6300(SequenceChannel* channel, AudioCmd* cmd);
|
||||
void func_800E59AC(s32 playerIdx, s32 fadeTimer);
|
||||
void Audio_InitMesgQueues(void);
|
||||
AudioTask* func_800E5000(void);
|
||||
void Audio_ProcessCmds(u32);
|
||||
void func_800E6128(SequencePlayer* seqPlayer, AudioCmd* cmd);
|
||||
void func_800E5958(s32 playerIdx, s32 fadeTimer);
|
||||
s32 func_800E66C0(s32 arg0);
|
||||
AudioTask* AudioThread_UpdateImpl(void);
|
||||
void AudioThread_SetFadeInTimer(s32 seqPlayerIndex, s32 fadeTimer);
|
||||
void AudioThread_SetFadeOutTimer(s32 seqPlayerIndex, s32 fadeTimer);
|
||||
void AudioThread_ProcessCmds(u32);
|
||||
void AudioThread_ProcessSeqPlayerCmd(SequencePlayer* seqPlayer, AudioCmd* cmd);
|
||||
void AudioThread_ProcessChannelCmd(SequenceChannel* channel, AudioCmd* cmd);
|
||||
s32 func_800E66C0(s32 flags);
|
||||
|
||||
// AudioMgr_Retrace
|
||||
AudioTask* func_800E4FE0(void) {
|
||||
return func_800E5000();
|
||||
AudioTask* AudioThread_Update(void) {
|
||||
return AudioThread_UpdateImpl();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is Audio_Update for the audio thread
|
||||
*/
|
||||
AudioTask* func_800E5000(void) {
|
||||
AudioTask* AudioThread_UpdateImpl(void) {
|
||||
static s32 sMaxAbiCmdCnt = 0x80;
|
||||
static AudioTask* sWaitingAudioTask = NULL;
|
||||
u32 samplesRemainingInAi;
|
||||
|
@ -55,8 +36,8 @@ AudioTask* func_800E5000(void) {
|
|||
|
||||
gAudioCtx.totalTaskCount++;
|
||||
if (gAudioCtx.totalTaskCount % (gAudioCtx.audioBufferParameters.specUnk4) != 0) {
|
||||
if (D_801755D0 != NULL) {
|
||||
D_801755D0();
|
||||
if (gAudioCustomUpdateFunction != NULL) {
|
||||
gAudioCustomUpdateFunction();
|
||||
}
|
||||
|
||||
if ((gAudioCtx.totalTaskCount % gAudioCtx.audioBufferParameters.specUnk4) + 1 ==
|
||||
|
@ -82,8 +63,8 @@ AudioTask* func_800E5000(void) {
|
|||
}
|
||||
}
|
||||
|
||||
if (D_801755D0 != NULL) {
|
||||
D_801755D0();
|
||||
if (gAudioCustomUpdateFunction != NULL) {
|
||||
gAudioCustomUpdateFunction();
|
||||
}
|
||||
|
||||
sp5C = gAudioCtx.curAudioFrameDmaCount;
|
||||
|
@ -114,7 +95,7 @@ AudioTask* func_800E5000(void) {
|
|||
if (gAudioCtx.resetStatus != 0) {
|
||||
if (AudioHeap_ResetStep() == 0) {
|
||||
if (gAudioCtx.resetStatus == 0) {
|
||||
osSendMesg(gAudioCtx.audioResetQueueP, (OSMesg)(u32)gAudioCtx.audioResetSpecIdToLoad, OS_MESG_NOBLOCK);
|
||||
osSendMesg(gAudioCtx.audioResetQueueP, (OSMesg)(u32)gAudioCtx.specId, OS_MESG_NOBLOCK);
|
||||
}
|
||||
|
||||
sWaitingAudioTask = NULL;
|
||||
|
@ -151,13 +132,13 @@ AudioTask* func_800E5000(void) {
|
|||
j = 0;
|
||||
if (gAudioCtx.resetStatus == 0) {
|
||||
// msg = 0000RREE R = read pos, E = End Pos
|
||||
while (osRecvMesg(gAudioCtx.cmdProcQueueP, (OSMesg*)&sp4C, OS_MESG_NOBLOCK) != -1) {
|
||||
while (osRecvMesg(gAudioCtx.threadCmdProcQueueP, (OSMesg*)&sp4C, OS_MESG_NOBLOCK) != -1) {
|
||||
if (1) {}
|
||||
Audio_ProcessCmds(sp4C);
|
||||
AudioThread_ProcessCmds(sp4C);
|
||||
j++;
|
||||
}
|
||||
if ((j == 0) && (gAudioCtx.cmdQueueFinished)) {
|
||||
Audio_ScheduleProcessCmds();
|
||||
if ((j == 0) && (gAudioCtx.threadCmdQueueFinished)) {
|
||||
AudioThread_ScheduleProcessCmds();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -169,9 +150,9 @@ AudioTask* func_800E5000(void) {
|
|||
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 func_800E4FE0, and offset it by a random number between 0 - 0xFFF0
|
||||
// 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*)func_800E4FE0) + (gAudioCtx.audioRandom & 0xFFF0));
|
||||
gWaveSamples[8] = (s16*)((u8*)AudioThread_Update + (gAudioCtx.audioRandom & 0xFFF0));
|
||||
|
||||
index = gAudioCtx.rspTaskIndex;
|
||||
gAudioCtx.curTask->msgQueue = NULL;
|
||||
|
@ -208,63 +189,57 @@ AudioTask* func_800E5000(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#define ACMD_SND_MDE ((u32)0xF0000000)
|
||||
#define ACMD_MUTE ((u32)0xF1000000)
|
||||
|
||||
void func_800E5584(AudioCmd* cmd) {
|
||||
void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) {
|
||||
s32 i;
|
||||
s32 pad;
|
||||
s32 pad2;
|
||||
u32 temp_a1_5;
|
||||
u32 temp_t7;
|
||||
s32 pad[3];
|
||||
u32 flags;
|
||||
|
||||
switch (cmd->op) {
|
||||
case 0x81:
|
||||
case AUDIOCMD_OP_GLOBAL_SYNC_LOAD_SEQ_PARTS:
|
||||
AudioLoad_SyncLoadSeqParts(cmd->arg1, cmd->arg2);
|
||||
break;
|
||||
|
||||
case 0x82:
|
||||
case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER:
|
||||
AudioLoad_SyncInitSeqPlayer(cmd->arg0, cmd->arg1, cmd->arg2);
|
||||
func_800E59AC(cmd->arg0, cmd->asInt);
|
||||
AudioThread_SetFadeInTimer(cmd->arg0, cmd->asInt);
|
||||
break;
|
||||
|
||||
case 0x85:
|
||||
case AUDIOCMD_OP_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS:
|
||||
AudioLoad_SyncInitSeqPlayerSkipTicks(cmd->arg0, cmd->arg1, cmd->asInt);
|
||||
break;
|
||||
|
||||
case 0x83:
|
||||
case AUDIOCMD_OP_GLOBAL_DISABLE_SEQPLAYER:
|
||||
if (gAudioCtx.seqPlayers[cmd->arg0].enabled) {
|
||||
if (cmd->asInt == 0) {
|
||||
AudioSeq_SequencePlayerDisableAsFinished(&gAudioCtx.seqPlayers[cmd->arg0]);
|
||||
} else {
|
||||
func_800E5958(cmd->arg0, cmd->asInt);
|
||||
AudioThread_SetFadeOutTimer(cmd->arg0, cmd->asInt);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xF0:
|
||||
case AUDIOCMD_OP_GLOBAL_SET_SOUND_MODE:
|
||||
gAudioCtx.soundMode = cmd->asUInt;
|
||||
break;
|
||||
|
||||
case 0xF1:
|
||||
case AUDIOCMD_OP_GLOBAL_MUTE:
|
||||
for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[i];
|
||||
|
||||
seqPlayer->muted = 1;
|
||||
seqPlayer->recalculateVolume = 1;
|
||||
seqPlayer->muted = true;
|
||||
seqPlayer->recalculateVolume = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xF2:
|
||||
case AUDIOCMD_OP_GLOBAL_UNMUTE:
|
||||
if (cmd->asUInt == 1) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
Note* note = &gAudioCtx.notes[i];
|
||||
NoteSubEu* subEu = ¬e->noteSubEu;
|
||||
|
||||
if (subEu->bitField0.enabled && note->playbackState.unk_04 == 0) {
|
||||
if (note->playbackState.parentLayer->channel->muteBehavior & MUTE_BEHAVIOR_3) {
|
||||
subEu->bitField0.finished = true;
|
||||
}
|
||||
if (subEu->bitField0.enabled && (note->playbackState.unk_04 == 0) &&
|
||||
(note->playbackState.parentLayer->channel->muteBehavior & MUTE_BEHAVIOR_3)) {
|
||||
subEu->bitField0.finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -272,53 +247,53 @@ void func_800E5584(AudioCmd* cmd) {
|
|||
for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[i];
|
||||
|
||||
seqPlayer->muted = 0;
|
||||
seqPlayer->recalculateVolume = 1;
|
||||
seqPlayer->muted = false;
|
||||
seqPlayer->recalculateVolume = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xF3:
|
||||
case AUDIOCMD_OP_GLOBAL_SYNC_LOAD_INSTRUMENT:
|
||||
AudioLoad_SyncLoadInstrument(cmd->arg0, cmd->arg1, cmd->arg2);
|
||||
break;
|
||||
|
||||
case 0xF4:
|
||||
case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SAMPLE_BANK:
|
||||
AudioLoad_AsyncLoadSampleBank(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioCtx.externalLoadQueue);
|
||||
break;
|
||||
|
||||
case 0xF5:
|
||||
case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_FONT:
|
||||
AudioLoad_AsyncLoadFont(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioCtx.externalLoadQueue);
|
||||
break;
|
||||
|
||||
case 0xFC:
|
||||
case AUDIOCMD_OP_GLOBAL_ASYNC_LOAD_SEQ:
|
||||
AudioLoad_AsyncLoadSeq(cmd->arg0, cmd->arg1, cmd->arg2, &gAudioCtx.externalLoadQueue);
|
||||
break;
|
||||
|
||||
case 0xF6:
|
||||
case AUDIOCMD_OP_GLOBAL_DISCARD_SEQ_FONTS:
|
||||
AudioLoad_DiscardSeqFonts(cmd->arg1);
|
||||
break;
|
||||
|
||||
case 0x90:
|
||||
gAudioCtx.unk_5BDC[cmd->arg0] = cmd->asUShort;
|
||||
case AUDIOCMD_OP_GLOBAL_SET_CHANNEL_MASK:
|
||||
gAudioCtx.threadCmdChannelMask[cmd->arg0] = cmd->asUShort;
|
||||
break;
|
||||
|
||||
case 0xF9:
|
||||
case AUDIOCMD_OP_GLOBAL_RESET_AUDIO_HEAP:
|
||||
gAudioCtx.resetStatus = 5;
|
||||
gAudioCtx.audioResetSpecIdToLoad = cmd->asUInt;
|
||||
gAudioCtx.specId = cmd->asUInt;
|
||||
break;
|
||||
|
||||
case 0xFB:
|
||||
D_801755D0 = (void (*)(void))cmd->asUInt;
|
||||
case AUDIOCMD_OP_GLOBAL_SET_CUSTOM_UPDATE_FUNCTION:
|
||||
gAudioCustomUpdateFunction = (AudioCustomUpdateFunction)cmd->asUInt;
|
||||
break;
|
||||
|
||||
case 0xE0:
|
||||
case 0xE1:
|
||||
case 0xE2:
|
||||
Audio_SetFontInstrument(cmd->op - 0xE0, cmd->arg0, cmd->arg1, cmd->data);
|
||||
case AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT:
|
||||
case AUDIOCMD_OP_GLOBAL_SET_SFX_FONT:
|
||||
case AUDIOCMD_OP_GLOBAL_SET_INSTRUMENT_FONT:
|
||||
Audio_SetFontInstrument(cmd->op - AUDIOCMD_OP_GLOBAL_SET_DRUM_FONT, cmd->arg0, cmd->arg1, cmd->data);
|
||||
break;
|
||||
|
||||
case 0xFE:
|
||||
temp_t7 = cmd->asUInt;
|
||||
if (temp_t7 == 1) {
|
||||
case AUDIOCMD_OP_GLOBAL_DISABLE_ALL_SEQPLAYERS:
|
||||
flags = cmd->asUInt;
|
||||
if (flags == 1) {
|
||||
for (i = 0; i < gAudioCtx.audioBufferParameters.numSequencePlayers; i++) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[i];
|
||||
|
||||
|
@ -327,10 +302,10 @@ void func_800E5584(AudioCmd* cmd) {
|
|||
}
|
||||
}
|
||||
}
|
||||
func_800E66C0(temp_t7);
|
||||
func_800E66C0(flags);
|
||||
break;
|
||||
|
||||
case 0xE3:
|
||||
case AUDIOCMD_OP_GLOBAL_POP_PERSISTENT_CACHE:
|
||||
AudioHeap_PopPersistentCache(cmd->asInt);
|
||||
break;
|
||||
|
||||
|
@ -339,9 +314,8 @@ void func_800E5584(AudioCmd* cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
// SetFadeOutTimer
|
||||
void func_800E5958(s32 playerIdx, s32 fadeTimer) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[playerIdx];
|
||||
void AudioThread_SetFadeOutTimer(s32 seqPlayerIndex, s32 fadeTimer) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex];
|
||||
|
||||
if (fadeTimer == 0) {
|
||||
fadeTimer = 1;
|
||||
|
@ -352,12 +326,11 @@ void func_800E5958(s32 playerIdx, s32 fadeTimer) {
|
|||
seqPlayer->fadeTimer = fadeTimer;
|
||||
}
|
||||
|
||||
// SetFadeInTimer
|
||||
void func_800E59AC(s32 playerIdx, s32 fadeTimer) {
|
||||
void AudioThread_SetFadeInTimer(s32 seqPlayerIndex, s32 fadeTimer) {
|
||||
SequencePlayer* seqPlayer;
|
||||
|
||||
if (fadeTimer != 0) {
|
||||
seqPlayer = &gAudioCtx.seqPlayers[playerIdx];
|
||||
seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex];
|
||||
seqPlayer->state = 1;
|
||||
seqPlayer->fadeTimerUnkEu = fadeTimer;
|
||||
seqPlayer->fadeTimer = fadeTimer;
|
||||
|
@ -366,63 +339,67 @@ void func_800E59AC(s32 playerIdx, s32 fadeTimer) {
|
|||
}
|
||||
}
|
||||
|
||||
void Audio_InitMesgQueuesInternal(void) {
|
||||
gAudioCtx.cmdWrPos = 0;
|
||||
gAudioCtx.cmdRdPos = 0;
|
||||
gAudioCtx.cmdQueueFinished = 0;
|
||||
void AudioThread_InitMesgQueuesImpl(void) {
|
||||
gAudioCtx.threadCmdWritePos = 0;
|
||||
gAudioCtx.threadCmdReadPos = 0;
|
||||
gAudioCtx.threadCmdQueueFinished = false;
|
||||
|
||||
gAudioCtx.taskStartQueueP = &gAudioCtx.taskStartQueue;
|
||||
gAudioCtx.cmdProcQueueP = &gAudioCtx.cmdProcQueue;
|
||||
gAudioCtx.threadCmdProcQueueP = &gAudioCtx.threadCmdProcQueue;
|
||||
gAudioCtx.audioResetQueueP = &gAudioCtx.audioResetQueue;
|
||||
|
||||
osCreateMesgQueue(gAudioCtx.taskStartQueueP, gAudioCtx.taskStartMsgBuf, ARRAY_COUNT(gAudioCtx.taskStartMsgBuf));
|
||||
osCreateMesgQueue(gAudioCtx.cmdProcQueueP, gAudioCtx.cmdProcMsgBuf, ARRAY_COUNT(gAudioCtx.cmdProcMsgBuf));
|
||||
osCreateMesgQueue(gAudioCtx.threadCmdProcQueueP, gAudioCtx.threadCmdProcMsgBuf,
|
||||
ARRAY_COUNT(gAudioCtx.threadCmdProcMsgBuf));
|
||||
osCreateMesgQueue(gAudioCtx.audioResetQueueP, gAudioCtx.audioResetMsgBuf, ARRAY_COUNT(gAudioCtx.audioResetMsgBuf));
|
||||
}
|
||||
|
||||
void Audio_QueueCmd(u32 opArgs, void** data) {
|
||||
AudioCmd* cmd = &gAudioCtx.cmdBuf[gAudioCtx.cmdWrPos & 0xFF];
|
||||
void AudioThread_QueueCmd(u32 opArgs, void** data) {
|
||||
AudioCmd* cmd = &gAudioCtx.threadCmdBuf[gAudioCtx.threadCmdWritePos & 0xFF];
|
||||
|
||||
cmd->opArgs = opArgs;
|
||||
cmd->data = *data;
|
||||
|
||||
gAudioCtx.cmdWrPos++;
|
||||
gAudioCtx.threadCmdWritePos++;
|
||||
|
||||
if (gAudioCtx.cmdWrPos == gAudioCtx.cmdRdPos) {
|
||||
gAudioCtx.cmdWrPos--;
|
||||
if (gAudioCtx.threadCmdWritePos == gAudioCtx.threadCmdReadPos) {
|
||||
gAudioCtx.threadCmdWritePos--;
|
||||
}
|
||||
}
|
||||
|
||||
void Audio_QueueCmdF32(u32 opArgs, f32 data) {
|
||||
Audio_QueueCmd(opArgs, (void**)&data);
|
||||
void AudioThread_QueueCmdF32(u32 opArgs, f32 data) {
|
||||
AudioThread_QueueCmd(opArgs, (void**)&data);
|
||||
}
|
||||
|
||||
void Audio_QueueCmdS32(u32 opArgs, s32 data) {
|
||||
Audio_QueueCmd(opArgs, (void**)&data);
|
||||
void AudioThread_QueueCmdS32(u32 opArgs, s32 data) {
|
||||
AudioThread_QueueCmd(opArgs, (void**)&data);
|
||||
}
|
||||
|
||||
void Audio_QueueCmdS8(u32 opArgs, s8 data) {
|
||||
void AudioThread_QueueCmdS8(u32 opArgs, s8 data) {
|
||||
u32 uData = data << 0x18;
|
||||
|
||||
Audio_QueueCmd(opArgs, (void**)&uData);
|
||||
AudioThread_QueueCmd(opArgs, (void**)&uData);
|
||||
}
|
||||
|
||||
void Audio_QueueCmdU16(u32 opArgs, u16 data) {
|
||||
void AudioThread_QueueCmdU16(u32 opArgs, u16 data) {
|
||||
u32 uData = data << 0x10;
|
||||
|
||||
Audio_QueueCmd(opArgs, (void**)&uData);
|
||||
AudioThread_QueueCmd(opArgs, (void**)&uData);
|
||||
}
|
||||
|
||||
s32 Audio_ScheduleProcessCmds(void) {
|
||||
s32 AudioThread_ScheduleProcessCmds(void) {
|
||||
static s32 D_801304E8 = 0;
|
||||
s32 ret;
|
||||
|
||||
if (D_801304E8 < (u8)((gAudioCtx.cmdWrPos - gAudioCtx.cmdRdPos) + 0x100)) {
|
||||
D_801304E8 = (u8)((gAudioCtx.cmdWrPos - gAudioCtx.cmdRdPos) + 0x100);
|
||||
if (D_801304E8 < (u8)((gAudioCtx.threadCmdWritePos - gAudioCtx.threadCmdReadPos) + 0x100)) {
|
||||
D_801304E8 = (u8)((gAudioCtx.threadCmdWritePos - gAudioCtx.threadCmdReadPos) + 0x100);
|
||||
}
|
||||
|
||||
ret = osSendMesg(gAudioCtx.cmdProcQueueP,
|
||||
(OSMesg)(((gAudioCtx.cmdRdPos & 0xFF) << 8) | (gAudioCtx.cmdWrPos & 0xFF)), OS_MESG_NOBLOCK);
|
||||
ret = osSendMesg(gAudioCtx.threadCmdProcQueueP,
|
||||
(OSMesg)(((gAudioCtx.threadCmdReadPos & 0xFF) << 8) | (gAudioCtx.threadCmdWritePos & 0xFF)),
|
||||
OS_MESG_NOBLOCK);
|
||||
if (ret != -1) {
|
||||
gAudioCtx.cmdRdPos = gAudioCtx.cmdWrPos;
|
||||
gAudioCtx.threadCmdReadPos = gAudioCtx.threadCmdWritePos;
|
||||
ret = 0;
|
||||
} else {
|
||||
return -1;
|
||||
|
@ -431,72 +408,72 @@ s32 Audio_ScheduleProcessCmds(void) {
|
|||
return ret;
|
||||
}
|
||||
|
||||
void Audio_ResetCmdQueue(void) {
|
||||
gAudioCtx.cmdQueueFinished = 0;
|
||||
gAudioCtx.cmdRdPos = gAudioCtx.cmdWrPos;
|
||||
void AudioThread_ResetCmdQueue(void) {
|
||||
gAudioCtx.threadCmdQueueFinished = false;
|
||||
gAudioCtx.threadCmdReadPos = gAudioCtx.threadCmdWritePos;
|
||||
}
|
||||
|
||||
void Audio_ProcessCmd(AudioCmd* cmd) {
|
||||
void AudioThread_ProcessCmd(AudioCmd* cmd) {
|
||||
SequencePlayer* seqPlayer;
|
||||
u16 phi_v0;
|
||||
s32 i;
|
||||
u16 threadCmdChannelMask;
|
||||
s32 channelIndex;
|
||||
|
||||
if ((cmd->op & 0xF0) == 0xF0) {
|
||||
func_800E5584(cmd);
|
||||
AudioThread_ProcessGlobalCmd(cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd->arg0 < gAudioCtx.audioBufferParameters.numSequencePlayers) {
|
||||
seqPlayer = &gAudioCtx.seqPlayers[cmd->arg0];
|
||||
if (cmd->op & 0x80) {
|
||||
func_800E5584(cmd);
|
||||
AudioThread_ProcessGlobalCmd(cmd);
|
||||
return;
|
||||
}
|
||||
if (cmd->op & 0x40) {
|
||||
func_800E6128(seqPlayer, cmd);
|
||||
AudioThread_ProcessSeqPlayerCmd(seqPlayer, cmd);
|
||||
return;
|
||||
}
|
||||
|
||||
if (cmd->arg1 < 0x10) {
|
||||
func_800E6300(seqPlayer->channels[cmd->arg1], cmd);
|
||||
if (cmd->arg1 < SEQ_NUM_CHANNELS) {
|
||||
AudioThread_ProcessChannelCmd(seqPlayer->channels[cmd->arg1], cmd);
|
||||
return;
|
||||
}
|
||||
if (cmd->arg1 == 0xFF) {
|
||||
phi_v0 = gAudioCtx.unk_5BDC[cmd->arg0];
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (phi_v0 & 1) {
|
||||
func_800E6300(seqPlayer->channels[i], cmd);
|
||||
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);
|
||||
}
|
||||
phi_v0 = phi_v0 >> 1;
|
||||
threadCmdChannelMask = threadCmdChannelMask >> 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Audio_ProcessCmds(u32 msg) {
|
||||
static u8 curCmdRdPos = 0;
|
||||
void AudioThread_ProcessCmds(u32 msg) {
|
||||
static u8 sCurCmdRdPos = 0;
|
||||
AudioCmd* cmd;
|
||||
u8 endPos;
|
||||
|
||||
if (!gAudioCtx.cmdQueueFinished) {
|
||||
curCmdRdPos = msg >> 8;
|
||||
if (!gAudioCtx.threadCmdQueueFinished) {
|
||||
sCurCmdRdPos = msg >> 8;
|
||||
}
|
||||
|
||||
while (true) {
|
||||
endPos = msg & 0xFF;
|
||||
if (curCmdRdPos == endPos) {
|
||||
gAudioCtx.cmdQueueFinished = 0;
|
||||
if (sCurCmdRdPos == endPos) {
|
||||
gAudioCtx.threadCmdQueueFinished = false;
|
||||
return;
|
||||
}
|
||||
|
||||
cmd = &gAudioCtx.cmdBuf[curCmdRdPos++ & 0xFF];
|
||||
if (cmd->op == 0xF8) {
|
||||
gAudioCtx.cmdQueueFinished = 1;
|
||||
cmd = &gAudioCtx.threadCmdBuf[sCurCmdRdPos++ & 0xFF];
|
||||
if (cmd->op == AUDIOCMD_OP_GLOBAL_STOP_AUDIOCMDS) {
|
||||
gAudioCtx.threadCmdQueueFinished = true;
|
||||
return;
|
||||
}
|
||||
|
||||
Audio_ProcessCmd(cmd);
|
||||
cmd->op = 0;
|
||||
AudioThread_ProcessCmd(cmd);
|
||||
cmd->op = AUDIOCMD_OP_NOOP;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -511,8 +488,8 @@ u32 func_800E5E20(u32* out) {
|
|||
return sp1C >> 0x18;
|
||||
}
|
||||
|
||||
u8* func_800E5E84(s32 arg0, u32* arg1) {
|
||||
return AudioLoad_GetFontsForSequence(arg0, arg1);
|
||||
u8* AudioThread_GetFontsForSequence(s32 seqId, u32* outNumFonts) {
|
||||
return AudioLoad_GetFontsForSequence(seqId, outNumFonts);
|
||||
}
|
||||
|
||||
void Audio_GetSampleBankIdsOfFont(s32 fontId, u32* sampleBankId1, u32* sampleBankId2) {
|
||||
|
@ -522,11 +499,11 @@ void Audio_GetSampleBankIdsOfFont(s32 fontId, u32* sampleBankId1, u32* sampleBan
|
|||
|
||||
s32 func_800E5EDC(void) {
|
||||
s32 pad;
|
||||
s32 sp18;
|
||||
s32 specId;
|
||||
|
||||
if (osRecvMesg(gAudioCtx.audioResetQueueP, (OSMesg*)&sp18, OS_MESG_NOBLOCK) == -1) {
|
||||
if (osRecvMesg(gAudioCtx.audioResetQueueP, (OSMesg*)&specId, OS_MESG_NOBLOCK) == -1) {
|
||||
return 0;
|
||||
} else if (gAudioCtx.audioResetSpecIdToLoad != sp18) {
|
||||
} else if (gAudioCtx.specId != specId) {
|
||||
return -1;
|
||||
} else {
|
||||
return 1;
|
||||
|
@ -540,7 +517,7 @@ void func_800E5F34(void) {
|
|||
// clang-format on
|
||||
}
|
||||
|
||||
s32 func_800E5F88(s32 resetPreloadID) {
|
||||
s32 AudioThread_ResetAudioHeap(s32 specId) {
|
||||
s32 resetStatus;
|
||||
OSMesg msg;
|
||||
s32 pad;
|
||||
|
@ -548,11 +525,11 @@ s32 func_800E5F88(s32 resetPreloadID) {
|
|||
func_800E5F34();
|
||||
resetStatus = gAudioCtx.resetStatus;
|
||||
if (resetStatus != 0) {
|
||||
Audio_ResetCmdQueue();
|
||||
if (gAudioCtx.audioResetSpecIdToLoad == resetPreloadID) {
|
||||
AudioThread_ResetCmdQueue();
|
||||
if (gAudioCtx.specId == specId) {
|
||||
return -2;
|
||||
} else if (resetStatus > 2) {
|
||||
gAudioCtx.audioResetSpecIdToLoad = resetPreloadID;
|
||||
gAudioCtx.specId = specId;
|
||||
return -3;
|
||||
} else {
|
||||
osRecvMesg(gAudioCtx.audioResetQueueP, &msg, OS_MESG_BLOCK);
|
||||
|
@ -560,81 +537,81 @@ s32 func_800E5F88(s32 resetPreloadID) {
|
|||
}
|
||||
|
||||
func_800E5F34();
|
||||
Audio_QueueCmdS32(0xF9000000, resetPreloadID);
|
||||
AUDIOCMD_GLOBAL_RESET_AUDIO_HEAP(specId);
|
||||
|
||||
return Audio_ScheduleProcessCmds();
|
||||
return AudioThread_ScheduleProcessCmds();
|
||||
}
|
||||
|
||||
void Audio_PreNMIInternal(void) {
|
||||
void AudioThread_PreNMIInternal(void) {
|
||||
gAudioCtx.resetTimer = 1;
|
||||
if (gAudioContextInitialized) {
|
||||
func_800E5F88(0);
|
||||
AudioThread_ResetAudioHeap(0);
|
||||
gAudioCtx.resetStatus = 0;
|
||||
}
|
||||
}
|
||||
|
||||
s8 func_800E6070(s32 playerIdx, s32 channelIdx, s32 scriptIdx) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[playerIdx];
|
||||
s8 AudioThread_GetChannelIO(s32 seqPlayerIndex, s32 channelIndex, s32 ioPort) {
|
||||
SequencePlayer* seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex];
|
||||
SequenceChannel* channel;
|
||||
|
||||
if (seqPlayer->enabled) {
|
||||
channel = seqPlayer->channels[channelIdx];
|
||||
return channel->soundScriptIO[scriptIdx];
|
||||
channel = seqPlayer->channels[channelIndex];
|
||||
return channel->seqScriptIO[ioPort];
|
||||
} else {
|
||||
return -1;
|
||||
return SEQ_IO_VAL_NONE;
|
||||
}
|
||||
}
|
||||
|
||||
s8 func_800E60C4(s32 playerIdx, s32 port) {
|
||||
return gAudioCtx.seqPlayers[playerIdx].soundScriptIO[port];
|
||||
s8 AudioThread_GetSeqPlayerIO(s32 seqPlayerIndex, s32 ioPort) {
|
||||
return gAudioCtx.seqPlayers[seqPlayerIndex].seqScriptIO[ioPort];
|
||||
}
|
||||
|
||||
void Audio_InitExternalPool(void* ramAddr, u32 size) {
|
||||
void AudioThread_InitExternalPool(void* ramAddr, u32 size) {
|
||||
AudioHeap_InitPool(&gAudioCtx.externalPool, ramAddr, size);
|
||||
}
|
||||
|
||||
void Audio_DestroyExternalPool(void) {
|
||||
void AudioThread_ResetExternalPool(void) {
|
||||
gAudioCtx.externalPool.startRamAddr = NULL;
|
||||
}
|
||||
|
||||
void func_800E6128(SequencePlayer* seqPlayer, AudioCmd* cmd) {
|
||||
void AudioThread_ProcessSeqPlayerCmd(SequencePlayer* seqPlayer, AudioCmd* cmd) {
|
||||
f32 fadeVolume;
|
||||
|
||||
switch (cmd->op) {
|
||||
case 0x41:
|
||||
case AUDIOCMD_OP_SEQPLAYER_FADE_VOLUME_SCALE:
|
||||
if (seqPlayer->fadeVolumeScale != cmd->asFloat) {
|
||||
seqPlayer->fadeVolumeScale = cmd->asFloat;
|
||||
seqPlayer->recalculateVolume = 1;
|
||||
seqPlayer->recalculateVolume = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case 0x47:
|
||||
seqPlayer->tempo = cmd->asInt * 0x30;
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_TEMPO:
|
||||
seqPlayer->tempo = cmd->asInt * SEQTICKS_PER_BEAT;
|
||||
break;
|
||||
|
||||
case 0x49:
|
||||
seqPlayer->unk_0C = cmd->asInt * 0x30;
|
||||
case AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO:
|
||||
seqPlayer->tempoChange = cmd->asInt * SEQTICKS_PER_BEAT;
|
||||
break;
|
||||
|
||||
case 0x4E:
|
||||
seqPlayer->unk_0C = cmd->asInt;
|
||||
case AUDIOCMD_OP_SEQPLAYER_CHANGE_TEMPO_SEQTICKS:
|
||||
seqPlayer->tempoChange = cmd->asInt;
|
||||
break;
|
||||
|
||||
case 0x48:
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_TRANSPOSITION:
|
||||
seqPlayer->transposition = cmd->asSbyte;
|
||||
break;
|
||||
|
||||
case 0x46:
|
||||
seqPlayer->soundScriptIO[cmd->arg2] = cmd->asSbyte;
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_IO:
|
||||
seqPlayer->seqScriptIO[cmd->arg2] = cmd->asSbyte;
|
||||
break;
|
||||
|
||||
case 0x4A:
|
||||
case AUDIOCMD_OP_SEQPLAYER_FADE_TO_SET_VOLUME:
|
||||
fadeVolume = (s32)cmd->arg1 / 127.0f;
|
||||
goto block_11;
|
||||
goto apply_fade;
|
||||
|
||||
case 0x4B:
|
||||
case AUDIOCMD_OP_SEQPLAYER_FADE_TO_SCALED_VOLUME:
|
||||
fadeVolume = ((s32)cmd->arg1 / 100.0f) * seqPlayer->fadeVolume;
|
||||
block_11:
|
||||
apply_fade:
|
||||
if (seqPlayer->state != 2) {
|
||||
seqPlayer->volume = seqPlayer->fadeVolume;
|
||||
if (cmd->asInt == 0) {
|
||||
|
@ -649,7 +626,7 @@ void func_800E6128(SequencePlayer* seqPlayer, AudioCmd* cmd) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 0x4C:
|
||||
case AUDIOCMD_OP_SEQPLAYER_RESET_VOLUME:
|
||||
if (seqPlayer->state != 2) {
|
||||
if (cmd->asInt == 0) {
|
||||
seqPlayer->fadeVolume = seqPlayer->volume;
|
||||
|
@ -663,7 +640,7 @@ void func_800E6128(SequencePlayer* seqPlayer, AudioCmd* cmd) {
|
|||
}
|
||||
break;
|
||||
|
||||
case 0x4D:
|
||||
case AUDIOCMD_OP_SEQPLAYER_SET_BEND:
|
||||
seqPlayer->bend = cmd->asFloat;
|
||||
if (seqPlayer->bend == 1.0f) {
|
||||
seqPlayer->applyBend = false;
|
||||
|
@ -677,82 +654,83 @@ void func_800E6128(SequencePlayer* seqPlayer, AudioCmd* cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
void func_800E6300(SequenceChannel* channel, AudioCmd* cmd) {
|
||||
void AudioThread_ProcessChannelCmd(SequenceChannel* channel, AudioCmd* cmd) {
|
||||
switch (cmd->op) {
|
||||
case CHAN_UPD_VOL_SCALE:
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VOL_SCALE:
|
||||
if (channel->volumeScale != cmd->asFloat) {
|
||||
channel->volumeScale = cmd->asFloat;
|
||||
channel->changes.s.volume = 1;
|
||||
channel->changes.s.volume = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAN_UPD_VOL:
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VOL:
|
||||
if (channel->volume != cmd->asFloat) {
|
||||
channel->volume = cmd->asFloat;
|
||||
channel->changes.s.volume = 1;
|
||||
channel->changes.s.volume = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAN_UPD_PAN_SIGNED:
|
||||
case AUDIOCMD_OP_CHANNEL_SET_PAN:
|
||||
if (channel->newPan != cmd->asSbyte) {
|
||||
channel->newPan = cmd->asSbyte;
|
||||
channel->changes.s.pan = 1;
|
||||
channel->changes.s.pan = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAN_UPD_PAN_UNSIGNED:
|
||||
case AUDIOCMD_OP_CHANNEL_SET_PAN_WEIGHT:
|
||||
//! @bug: Should compare `asSbyte` to `panChannelWeight`
|
||||
if (channel->newPan != cmd->asSbyte) {
|
||||
channel->panChannelWeight = cmd->asSbyte;
|
||||
channel->changes.s.pan = 1;
|
||||
channel->changes.s.pan = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAN_UPD_FREQ_SCALE:
|
||||
case AUDIOCMD_OP_CHANNEL_SET_FREQ_SCALE:
|
||||
if (channel->freqScale != cmd->asFloat) {
|
||||
channel->freqScale = cmd->asFloat;
|
||||
channel->changes.s.freqScale = 1;
|
||||
channel->changes.s.freqScale = true;
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAN_UPD_REVERB:
|
||||
if (channel->reverb != cmd->asSbyte) {
|
||||
channel->reverb = cmd->asSbyte;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_REVERB_VOLUME:
|
||||
if (channel->targetReverbVol != cmd->asSbyte) {
|
||||
channel->targetReverbVol = cmd->asSbyte;
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAN_UPD_SCRIPT_IO:
|
||||
if (cmd->arg2 < 8) {
|
||||
channel->soundScriptIO[cmd->arg2] = cmd->asSbyte;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_IO:
|
||||
if (cmd->arg2 < ARRAY_COUNT(channel->seqScriptIO)) {
|
||||
channel->seqScriptIO[cmd->arg2] = cmd->asSbyte;
|
||||
}
|
||||
break;
|
||||
|
||||
case CHAN_UPD_STOP_SOMETHING2:
|
||||
channel->stopSomething2 = cmd->asSbyte;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_MUTE:
|
||||
channel->muted = cmd->asSbyte;
|
||||
break;
|
||||
|
||||
case CHAN_UPD_MUTE_BEHAVE:
|
||||
case AUDIOCMD_OP_CHANNEL_SET_MUTE_BEHAVIOR:
|
||||
channel->muteBehavior = cmd->asSbyte;
|
||||
break;
|
||||
|
||||
case CHAN_UPD_VIBE_X8:
|
||||
channel->vibratoExtentTarget = cmd->asUbyte * 8;
|
||||
channel->vibratoExtentChangeDelay = 1;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VIBRATO_DEPTH:
|
||||
channel->vibratoDepthTarget = cmd->asUbyte * 8;
|
||||
channel->vibratoDepthChangeDelay = 1;
|
||||
break;
|
||||
|
||||
case CHAN_UPD_VIBE_X32:
|
||||
case AUDIOCMD_OP_CHANNEL_SET_VIBRATO_RATE:
|
||||
channel->vibratoRateTarget = cmd->asUbyte * 32;
|
||||
channel->vibratoRateChangeDelay = 1;
|
||||
break;
|
||||
|
||||
case CHAN_UPD_UNK_0F:
|
||||
channel->unk_0F = cmd->asUbyte;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_SIZE:
|
||||
channel->combFilterSize = cmd->asUbyte;
|
||||
break;
|
||||
|
||||
case CHAN_UPD_UNK_20:
|
||||
channel->unk_20 = cmd->asUShort;
|
||||
case AUDIOCMD_OP_CHANNEL_SET_COMB_FILTER_GAIN:
|
||||
channel->combFilterGain = cmd->asUShort;
|
||||
break;
|
||||
|
||||
case CHAN_UPD_STEREO:
|
||||
case AUDIOCMD_OP_CHANNEL_SET_STEREO:
|
||||
channel->stereo.asByte = cmd->asUbyte;
|
||||
break;
|
||||
|
||||
|
@ -761,24 +739,33 @@ void func_800E6300(SequenceChannel* channel, AudioCmd* cmd) {
|
|||
}
|
||||
}
|
||||
|
||||
void func_800E64B0(s32 arg0, s32 arg1, s32 arg2) {
|
||||
Audio_QueueCmdS32(((arg0 & 0xFF) << 0x10) | 0xFA000000 | ((arg1 & 0xFF) << 8) | (arg2 & 0xFF), 1);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
void func_800E64F8(void) {
|
||||
Audio_QueueCmdS32(0xFA000000, 0);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
void func_800E651C(u32 arg0, s32 arg1) {
|
||||
Audio_QueueCmdS32((arg1 & 0xFF) | 0xFD000000, arg0);
|
||||
/**
|
||||
* 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);
|
||||
}
|
||||
|
||||
void Audio_WaitForAudioTask(void) {
|
||||
void AudioThread_WaitForAudioTask(void) {
|
||||
osRecvMesg(gAudioCtx.taskStartQueueP, NULL, OS_MESG_NOBLOCK);
|
||||
osRecvMesg(gAudioCtx.taskStartQueueP, NULL, OS_MESG_BLOCK);
|
||||
}
|
||||
|
||||
s32 func_800E6590(s32 playerIdx, s32 arg1, s32 arg2) {
|
||||
s32 func_800E6590(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex) {
|
||||
SequencePlayer* seqPlayer;
|
||||
SequenceLayer* layer;
|
||||
Note* note;
|
||||
|
@ -786,9 +773,9 @@ s32 func_800E6590(s32 playerIdx, s32 arg1, s32 arg2) {
|
|||
s32 loopEnd;
|
||||
s32 samplePos;
|
||||
|
||||
seqPlayer = &gAudioCtx.seqPlayers[playerIdx];
|
||||
if (seqPlayer->enabled && seqPlayer->channels[arg1]->enabled) {
|
||||
layer = seqPlayer->channels[arg1]->layers[arg2];
|
||||
seqPlayer = &gAudioCtx.seqPlayers[seqPlayerIndex];
|
||||
if (seqPlayer->enabled && seqPlayer->channels[channelIndex]->enabled) {
|
||||
layer = seqPlayer->channels[channelIndex]->layers[layerIndex];
|
||||
if (layer == NULL) {
|
||||
return 0;
|
||||
}
|
||||
|
@ -826,7 +813,7 @@ void func_800E66A0(void) {
|
|||
func_800E66C0(2);
|
||||
}
|
||||
|
||||
s32 func_800E66C0(s32 arg0) {
|
||||
s32 func_800E66C0(s32 flags) {
|
||||
s32 phi_v1;
|
||||
NotePlaybackState* playbackState;
|
||||
NoteSubEu* noteSubEu;
|
||||
|
@ -841,7 +828,7 @@ s32 func_800E66C0(s32 arg0) {
|
|||
if (note->noteSubEu.bitField0.enabled) {
|
||||
noteSubEu = ¬e->noteSubEu;
|
||||
if (playbackState->adsr.action.s.state != 0) {
|
||||
if (arg0 >= 2) {
|
||||
if (flags >= 2) {
|
||||
tunedSample = noteSubEu->tunedSample;
|
||||
if (tunedSample == NULL || noteSubEu->bitField1.isSyntheticWave) {
|
||||
continue;
|
||||
|
@ -852,8 +839,8 @@ s32 func_800E66C0(s32 arg0) {
|
|||
}
|
||||
|
||||
phi_v1++;
|
||||
if ((arg0 & 1) == 1) {
|
||||
playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.updatesPerFrameInv;
|
||||
if ((flags & 1) == 1) {
|
||||
playbackState->adsr.fadeOutVel = gAudioCtx.audioBufferParameters.ticksPerUpdateInv;
|
||||
playbackState->adsr.action.s.release = 1;
|
||||
}
|
||||
}
|
||||
|
@ -862,14 +849,15 @@ s32 func_800E66C0(s32 arg0) {
|
|||
return phi_v1;
|
||||
}
|
||||
|
||||
u32 Audio_NextRandom(void) {
|
||||
static u32 audRand = 0x12345678;
|
||||
u32 AudioThread_NextRandom(void) {
|
||||
static u32 sAudioRandom = 0x12345678;
|
||||
|
||||
audRand = ((osGetCount() + 0x1234567) * (audRand + gAudioCtx.totalTaskCount));
|
||||
audRand += gAudioCtx.audioRandom;
|
||||
return audRand;
|
||||
sAudioRandom = ((osGetCount() + 0x1234567) * (sAudioRandom + gAudioCtx.totalTaskCount));
|
||||
sAudioRandom += gAudioCtx.audioRandom;
|
||||
|
||||
return sAudioRandom;
|
||||
}
|
||||
|
||||
void Audio_InitMesgQueues(void) {
|
||||
Audio_InitMesgQueuesInternal();
|
||||
void AudioThread_InitMesgQueues(void) {
|
||||
AudioThread_InitMesgQueuesImpl();
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
* These commands are generated using `Audio_QueueSeqCmd`, and a user-friendly interface for this function
|
||||
* can be found in `seqcmd.h`
|
||||
*
|
||||
* These commands change sequences by generating internal audio commands `Audio_QueueCmd` which allows these
|
||||
* These commands change sequences by generating internal audio commands `AudioThread_QueueCmd` which allows these
|
||||
* sequence requests to be passed onto the audio thread. It is worth noting all functions in this file are
|
||||
* called from the graph thread.
|
||||
*
|
||||
|
@ -22,14 +22,14 @@
|
|||
#include "ultra64/abi.h"
|
||||
|
||||
// Direct audio command (skips the queueing system)
|
||||
#define SEQCMD_SET_PLAYER_VOLUME_NOW(seqPlayerIndex, duration, volume) \
|
||||
Audio_ProcessSeqCmd((SEQCMD_OP_SET_PLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | ((u8)(duration) << 16) | \
|
||||
((u8)((volume)*127.0f)));
|
||||
#define SEQCMD_SET_SEQPLAYER_VOLUME_NOW(seqPlayerIndex, duration, volume) \
|
||||
Audio_ProcessSeqCmd((SEQCMD_OP_SET_SEQPLAYER_VOLUME << 28) | ((u8)(seqPlayerIndex) << 24) | \
|
||||
((u8)(duration) << 16) | ((u8)((volume)*127.0f)));
|
||||
|
||||
typedef struct {
|
||||
u8 seqId;
|
||||
u8 priority; // higher values have higher priority
|
||||
} SeqRequest;
|
||||
/* 0x0 */ u8 seqId;
|
||||
/* 0x1 */ u8 priority; // higher values have higher priority
|
||||
} SeqRequest; // size = 0x2
|
||||
|
||||
SeqRequest sSeqRequests[4][5];
|
||||
u8 sNumSeqRequests[4];
|
||||
|
@ -38,26 +38,26 @@ ActiveSequence gActiveSeqs[4];
|
|||
|
||||
void Audio_StartSequence(u8 seqPlayerIndex, u8 seqId, u8 seqArgs, u16 fadeInDuration) {
|
||||
u8 channelIndex;
|
||||
u16 duration;
|
||||
u16 skipTicks;
|
||||
s32 pad;
|
||||
|
||||
if (!gStartSeqDisabled || (seqPlayerIndex == SEQ_PLAYER_SFX)) {
|
||||
seqArgs &= 0x7F;
|
||||
if (OOT_DEBUG && (seqArgs == 0x7F)) {
|
||||
// `fadeInDuration` is interpreted as skip ticks
|
||||
duration = (fadeInDuration >> 3) * 60 * gAudioCtx.audioBufferParameters.updatesPerFrame;
|
||||
Audio_QueueCmdS32(0x85000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(seqId, 8, 8), duration);
|
||||
// `fadeInDuration` interpreted as seconds, 60 is refresh rate and does not account for PAL
|
||||
skipTicks = (fadeInDuration >> 3) * 60 * gAudioCtx.audioBufferParameters.ticksPerUpdate;
|
||||
AUDIOCMD_GLOBAL_INIT_SEQPLAYER_SKIP_TICKS((u32)seqPlayerIndex, (u32)seqId, skipTicks);
|
||||
} else {
|
||||
// `fadeInDuration` is interpreted as number of frames at 30 fps
|
||||
Audio_QueueCmdS32(0x82000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(seqId, 8, 8),
|
||||
(fadeInDuration * (u16)gAudioCtx.audioBufferParameters.updatesPerFrame) / 4);
|
||||
// `fadeInDuration` interpreted as 1/30th of a second, does not account for change in refresh rate for PAL
|
||||
AUDIOCMD_GLOBAL_INIT_SEQPLAYER((u32)seqPlayerIndex, (u32)seqId,
|
||||
(fadeInDuration * (u16)gAudioCtx.audioBufferParameters.ticksPerUpdate) / 4);
|
||||
}
|
||||
|
||||
gActiveSeqs[seqPlayerIndex].seqId = seqId | (seqArgs << 8);
|
||||
gActiveSeqs[seqPlayerIndex].prevSeqId = seqId | (seqArgs << 8);
|
||||
|
||||
if (gActiveSeqs[seqPlayerIndex].volCur != 1.0f) {
|
||||
Audio_QueueCmdF32(0x41000000 | _SHIFTL(seqPlayerIndex, 16, 8), gActiveSeqs[seqPlayerIndex].volCur);
|
||||
AUDIOCMD_SEQPLAYER_FADE_VOLUME_SCALE((u32)seqPlayerIndex, gActiveSeqs[seqPlayerIndex].volCur);
|
||||
}
|
||||
|
||||
gActiveSeqs[seqPlayerIndex].tempoTimer = 0;
|
||||
|
@ -77,8 +77,8 @@ void Audio_StartSequence(u8 seqPlayerIndex, u8 seqId, u8 seqArgs, u16 fadeInDura
|
|||
}
|
||||
|
||||
void Audio_StopSequence(u8 seqPlayerIndex, u16 fadeOutDuration) {
|
||||
Audio_QueueCmdS32(0x83000000 | ((u8)seqPlayerIndex << 16),
|
||||
(fadeOutDuration * (u16)gAudioCtx.audioBufferParameters.updatesPerFrame) / 4);
|
||||
AUDIOCMD_GLOBAL_DISABLE_SEQPLAYER(seqPlayerIndex,
|
||||
(fadeOutDuration * (u16)gAudioCtx.audioBufferParameters.ticksPerUpdate) / 4);
|
||||
gActiveSeqs[seqPlayerIndex].seqId = NA_BGM_DISABLED;
|
||||
}
|
||||
|
||||
|
@ -88,15 +88,15 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
u16 channelMaskDisable;
|
||||
u16 fadeTimer;
|
||||
u16 val;
|
||||
u8 oldSpec;
|
||||
u8 spec;
|
||||
u8 oldSpecId;
|
||||
u8 specId;
|
||||
u8 op;
|
||||
u8 subOp;
|
||||
u8 seqPlayerIndex;
|
||||
u8 seqId;
|
||||
u8 seqArgs;
|
||||
u8 found;
|
||||
u8 port;
|
||||
u8 ioPort;
|
||||
u8 duration;
|
||||
u8 channelIndex;
|
||||
u8 i;
|
||||
|
@ -104,7 +104,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
s32 pad;
|
||||
|
||||
#if OOT_DEBUG
|
||||
if (gAudioDebugPrintSeqCmd && (cmd & SEQCMD_OP_MASK) != (SEQCMD_OP_SET_PLAYER_IO << 28)) {
|
||||
if (gAudioDebugPrintSeqCmd && (cmd & SEQCMD_OP_MASK) != (SEQCMD_OP_SET_SEQPLAYER_IO << 28)) {
|
||||
AudioDebug_ScrPrt("SEQ H", (cmd >> 16) & 0xFFFF);
|
||||
AudioDebug_ScrPrt(" L", cmd & 0xFFFF);
|
||||
}
|
||||
|
@ -215,7 +215,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
}
|
||||
break;
|
||||
|
||||
case SEQCMD_OP_SET_PLAYER_VOLUME:
|
||||
case SEQCMD_OP_SET_SEQPLAYER_VOLUME:
|
||||
// Transition volume to a target volume for an entire player
|
||||
duration = (cmd & 0xFF0000) >> 15;
|
||||
val = cmd & 0xFF;
|
||||
|
@ -231,7 +231,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
}
|
||||
break;
|
||||
|
||||
case SEQCMD_OP_SET_PLAYER_FREQ:
|
||||
case SEQCMD_OP_SET_SEQPLAYER_FREQ:
|
||||
// Transition freq scale to a target freq for all channels
|
||||
duration = (cmd & 0xFF0000) >> 15;
|
||||
val = cmd & 0xFFFF;
|
||||
|
@ -287,29 +287,27 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
}
|
||||
break;
|
||||
|
||||
case SEQCMD_OP_SET_PLAYER_IO:
|
||||
case SEQCMD_OP_SET_SEQPLAYER_IO:
|
||||
// Set global io port
|
||||
port = (cmd & 0xFF0000) >> 16;
|
||||
ioPort = (cmd & 0xFF0000) >> 16;
|
||||
val = cmd & 0xFF;
|
||||
Audio_QueueCmdS8(0x46000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(port, 0, 8), val);
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(seqPlayerIndex, ioPort, val);
|
||||
break;
|
||||
|
||||
case SEQCMD_OP_SET_CHANNEL_IO:
|
||||
// Set io port if channel masked
|
||||
channelIndex = (cmd & 0xF00) >> 8;
|
||||
port = (cmd & 0xFF0000) >> 16;
|
||||
ioPort = (cmd & 0xFF0000) >> 16;
|
||||
val = cmd & 0xFF;
|
||||
if (!(gActiveSeqs[seqPlayerIndex].channelPortMask & (1 << channelIndex))) {
|
||||
Audio_QueueCmdS8(0x06000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(channelIndex, 8, 8) |
|
||||
_SHIFTL(port, 0, 8),
|
||||
val);
|
||||
AUDIOCMD_CHANNEL_SET_IO(seqPlayerIndex, (u32)channelIndex, ioPort, val);
|
||||
}
|
||||
break;
|
||||
|
||||
case SEQCMD_OP_SET_CHANNEL_IO_DISABLE_MASK:
|
||||
// Disable channel io specifically for
|
||||
// `SEQCMD_OP_SET_CHANNEL_IO` This can be bypassed by setting channel io through `Audio_QueueCmdS8` 0x6
|
||||
// directly. This is accomplished by setting a channel mask.
|
||||
// Disable channel io specifically for `SEQCMD_OP_SET_CHANNEL_IO`.
|
||||
// This can be bypassed by setting channel io through using `AUDIOCMD_CHANNEL_SET_IO` directly.
|
||||
// This is accomplished by setting a channel mask.
|
||||
gActiveSeqs[seqPlayerIndex].channelPortMask = cmd & 0xFFFF;
|
||||
break;
|
||||
|
||||
|
@ -320,18 +318,18 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
channelMaskDisable = cmd & 0xFFFF;
|
||||
if (channelMaskDisable != 0) {
|
||||
// Apply channel mask `channelMaskDisable`
|
||||
Audio_QueueCmdU16(0x90000000 | _SHIFTL(seqPlayerIndex, 16, 8), channelMaskDisable);
|
||||
AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(seqPlayerIndex, channelMaskDisable);
|
||||
// Disable channels
|
||||
Audio_QueueCmdS8(0x08000000 | _SHIFTL(seqPlayerIndex, 16, 8) | 0xFF00, 1);
|
||||
AUDIOCMD_CHANNEL_SET_MUTE(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, true);
|
||||
}
|
||||
|
||||
// Reenable channels
|
||||
channelMaskEnable = (channelMaskDisable ^ 0xFFFF);
|
||||
if (channelMaskEnable != 0) {
|
||||
// Apply channel mask `channelMaskEnable`
|
||||
Audio_QueueCmdU16(0x90000000 | _SHIFTL(seqPlayerIndex, 16, 8), channelMaskEnable);
|
||||
AUDIOCMD_GLOBAL_SET_CHANNEL_MASK(seqPlayerIndex, channelMaskEnable);
|
||||
// Enable channels
|
||||
Audio_QueueCmdS8(0x08000000 | _SHIFTL(seqPlayerIndex, 16, 8) | 0xFF00, 0);
|
||||
AUDIOCMD_CHANNEL_SET_MUTE(seqPlayerIndex, AUDIOCMD_ALL_CHANNELS, false);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -373,7 +371,7 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
switch (subOp) {
|
||||
case SEQCMD_SUB_OP_GLOBAL_SET_SOUND_MODE:
|
||||
// Set sound mode
|
||||
Audio_QueueCmdS32(0xF0000000, gSoundModeList[val]);
|
||||
AUDIOCMD_GLOBAL_SET_SOUND_MODE(gSoundModeList[val]);
|
||||
break;
|
||||
|
||||
case SEQCMD_SUB_OP_GLOBAL_DISABLE_NEW_SEQUENCES:
|
||||
|
@ -385,13 +383,13 @@ void Audio_ProcessSeqCmd(u32 cmd) {
|
|||
|
||||
case SEQCMD_OP_RESET_AUDIO_HEAP:
|
||||
// Resets the audio heap based on the audio specifications and sfx channel layout
|
||||
spec = cmd & 0xFF;
|
||||
specId = cmd & 0xFF;
|
||||
gSfxChannelLayout = (cmd & 0xFF00) >> 8;
|
||||
oldSpec = gAudioSpecId;
|
||||
gAudioSpecId = spec;
|
||||
func_800E5F88(spec);
|
||||
func_800F71BC(oldSpec);
|
||||
Audio_QueueCmdS32(0xF8000000, 0);
|
||||
oldSpecId = gAudioSpecId;
|
||||
gAudioSpecId = specId;
|
||||
AudioThread_ResetAudioHeap(specId);
|
||||
func_800F71BC(oldSpecId);
|
||||
AUDIOCMD_GLOBAL_STOP_AUDIOCMDS();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -435,7 +433,7 @@ void Audio_ResetSequenceRequests(u8 seqPlayerIndex) {
|
|||
|
||||
/**
|
||||
* Check if the setup command is queued. If it is, then replace the command
|
||||
* with `SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME`.
|
||||
* with `SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME`.
|
||||
* Unused
|
||||
*/
|
||||
void Audio_ReplaceSeqCmdSetupOpVolRestore(u8 seqPlayerIndex, u8 setupOpDisabled) {
|
||||
|
@ -464,7 +462,7 @@ void Audio_SetVolumeScale(u8 seqPlayerIndex, u8 scaleIndex, u8 targetVol, u8 vol
|
|||
volScale *= gActiveSeqs[seqPlayerIndex].volScales[i] / 127.0f;
|
||||
}
|
||||
|
||||
SEQCMD_SET_PLAYER_VOLUME_NOW(seqPlayerIndex, volFadeTimer, volScale);
|
||||
SEQCMD_SET_SEQPLAYER_VOLUME_NOW(seqPlayerIndex, volFadeTimer, volScale);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,7 +515,8 @@ void Audio_UpdateActiveSequences(void) {
|
|||
for (j = 0; j < VOL_SCALE_INDEX_MAX; j++) {
|
||||
volume *= (gActiveSeqs[seqPlayerIndex].volScales[j] / 127.0f);
|
||||
}
|
||||
SEQCMD_SET_PLAYER_VOLUME(seqPlayerIndex, gActiveSeqs[seqPlayerIndex].volFadeTimer, (u8)(volume * 127.0f));
|
||||
SEQCMD_SET_SEQPLAYER_VOLUME(seqPlayerIndex, gActiveSeqs[seqPlayerIndex].volFadeTimer,
|
||||
(u8)(volume * 127.0f));
|
||||
gActiveSeqs[seqPlayerIndex].fadeVolUpdate = false;
|
||||
}
|
||||
|
||||
|
@ -530,7 +529,7 @@ void Audio_UpdateActiveSequences(void) {
|
|||
gActiveSeqs[seqPlayerIndex].volCur = gActiveSeqs[seqPlayerIndex].volTarget;
|
||||
}
|
||||
|
||||
Audio_QueueCmdF32(0x41000000 | _SHIFTL(seqPlayerIndex, 16, 8), gActiveSeqs[seqPlayerIndex].volCur);
|
||||
AUDIOCMD_SEQPLAYER_FADE_VOLUME_SCALE((u32)seqPlayerIndex, gActiveSeqs[seqPlayerIndex].volCur);
|
||||
}
|
||||
|
||||
// Process tempo
|
||||
|
@ -544,7 +543,7 @@ void Audio_UpdateActiveSequences(void) {
|
|||
|
||||
// Process tempo commands
|
||||
if (gAudioCtx.seqPlayers[seqPlayerIndex].enabled) {
|
||||
tempoPrev = gAudioCtx.seqPlayers[seqPlayerIndex].tempo / TATUMS_PER_BEAT;
|
||||
tempoPrev = gAudioCtx.seqPlayers[seqPlayerIndex].tempo / SEQTICKS_PER_BEAT;
|
||||
tempoOp = (tempoCmd & 0xF000) >> 12;
|
||||
switch (tempoOp) {
|
||||
case SEQCMD_SUB_OP_TEMPO_SPEED_UP:
|
||||
|
@ -585,7 +584,7 @@ void Audio_UpdateActiveSequences(void) {
|
|||
}
|
||||
|
||||
gActiveSeqs[seqPlayerIndex].tempoTarget = tempoTarget;
|
||||
gActiveSeqs[seqPlayerIndex].tempoCur = gAudioCtx.seqPlayers[seqPlayerIndex].tempo / TATUMS_PER_BEAT;
|
||||
gActiveSeqs[seqPlayerIndex].tempoCur = gAudioCtx.seqPlayers[seqPlayerIndex].tempo / SEQTICKS_PER_BEAT;
|
||||
gActiveSeqs[seqPlayerIndex].tempoStep =
|
||||
(gActiveSeqs[seqPlayerIndex].tempoCur - gActiveSeqs[seqPlayerIndex].tempoTarget) / tempoTimer;
|
||||
gActiveSeqs[seqPlayerIndex].tempoTimer = tempoTimer;
|
||||
|
@ -601,8 +600,8 @@ void Audio_UpdateActiveSequences(void) {
|
|||
} else {
|
||||
gActiveSeqs[seqPlayerIndex].tempoCur = gActiveSeqs[seqPlayerIndex].tempoTarget;
|
||||
}
|
||||
// Set tempo
|
||||
Audio_QueueCmdS32(0x47000000 | _SHIFTL(seqPlayerIndex, 16, 8), gActiveSeqs[seqPlayerIndex].tempoCur);
|
||||
|
||||
AUDIOCMD_SEQPLAYER_SET_TEMPO((u32)seqPlayerIndex, gActiveSeqs[seqPlayerIndex].tempoCur);
|
||||
}
|
||||
|
||||
// Update channel volumes
|
||||
|
@ -618,9 +617,9 @@ void Audio_UpdateActiveSequences(void) {
|
|||
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volTarget;
|
||||
gActiveSeqs[seqPlayerIndex].volChannelFlags ^= (1 << channelIndex);
|
||||
}
|
||||
// `CHAN_UPD_VOL_SCALE`
|
||||
Audio_QueueCmdF32(0x01000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(channelIndex, 8, 8),
|
||||
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur);
|
||||
|
||||
AUDIOCMD_CHANNEL_SET_VOL_SCALE(seqPlayerIndex, (u32)channelIndex,
|
||||
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].volCur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -638,9 +637,9 @@ void Audio_UpdateActiveSequences(void) {
|
|||
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleTarget;
|
||||
gActiveSeqs[seqPlayerIndex].freqScaleChannelFlags ^= (1 << channelIndex);
|
||||
}
|
||||
// `CHAN_UPD_FREQ_SCALE`
|
||||
Audio_QueueCmdF32(0x04000000 | _SHIFTL(seqPlayerIndex, 16, 8) | _SHIFTL(channelIndex, 8, 8),
|
||||
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur);
|
||||
|
||||
AUDIOCMD_CHANNEL_SET_FREQ_SCALE(seqPlayerIndex, (u32)channelIndex,
|
||||
gActiveSeqs[seqPlayerIndex].channelData[channelIndex].freqScaleCur);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -672,12 +671,12 @@ void Audio_UpdateActiveSequences(void) {
|
|||
setupVal1 = gActiveSeqs[seqPlayerIndex].setupCmd[j] & 0xFF;
|
||||
|
||||
switch (setupOp) {
|
||||
case SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME:
|
||||
case SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME:
|
||||
// Restore `targetSeqPlayerIndex` volume back to normal levels
|
||||
Audio_SetVolumeScale(targetSeqPlayerIndex, VOL_SCALE_INDEX_FANFARE, 0x7F, setupVal1);
|
||||
break;
|
||||
|
||||
case SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME_IF_QUEUED:
|
||||
case SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_IF_QUEUED:
|
||||
// Restore `targetSeqPlayerIndex` volume back to normal levels,
|
||||
// but only if the number of sequence queue requests from `sSeqRequests`
|
||||
// exactly matches the argument to the command
|
||||
|
@ -731,7 +730,7 @@ void Audio_UpdateActiveSequences(void) {
|
|||
gActiveSeqs[seqPlayerIndex].setupFadeTimer = setupVal2;
|
||||
break;
|
||||
|
||||
case SEQCMD_SUB_OP_SETUP_RESTORE_VOLUME_WITH_SCALE_INDEX:
|
||||
case SEQCMD_SUB_OP_SETUP_RESTORE_SEQPLAYER_VOLUME_WITH_SCALE_INDEX:
|
||||
// Restore the volume back to default levels
|
||||
// Allows a `scaleIndex` to be specified.
|
||||
Audio_SetVolumeScale(targetSeqPlayerIndex, setupVal2, 0x7F, setupVal1);
|
||||
|
@ -740,13 +739,13 @@ void Audio_UpdateActiveSequences(void) {
|
|||
case SEQCMD_SUB_OP_SETUP_POP_PERSISTENT_CACHE:
|
||||
// Discard audio data by popping one more audio caches from the audio heap
|
||||
if (setupVal1 & (1 << SEQUENCE_TABLE)) {
|
||||
Audio_QueueCmdS32(0xE3000000, SEQUENCE_TABLE);
|
||||
AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(SEQUENCE_TABLE);
|
||||
}
|
||||
if (setupVal1 & (1 << FONT_TABLE)) {
|
||||
Audio_QueueCmdS32(0xE3000000, FONT_TABLE);
|
||||
AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(FONT_TABLE);
|
||||
}
|
||||
if (setupVal1 & (1 << SAMPLE_TABLE)) {
|
||||
Audio_QueueCmdS32(0xE3000000, SAMPLE_TABLE);
|
||||
AUDIOCMD_GLOBAL_POP_PERSISTENT_CACHE(SAMPLE_TABLE);
|
||||
}
|
||||
break;
|
||||
|
||||
|
@ -756,9 +755,9 @@ void Audio_UpdateActiveSequences(void) {
|
|||
SEQCMD_SET_CHANNEL_DISABLE_MASK(targetSeqPlayerIndex, channelMask);
|
||||
break;
|
||||
|
||||
case SEQCMD_SUB_OP_SETUP_SET_PLAYER_FREQ:
|
||||
case SEQCMD_SUB_OP_SETUP_SET_SEQPLAYER_FREQ:
|
||||
// Scale all channels of `targetSeqPlayerIndex`
|
||||
SEQCMD_SET_PLAYER_FREQ(targetSeqPlayerIndex, setupVal2, (setupVal1 * 10) & 0xFFFF);
|
||||
SEQCMD_SET_SEQPLAYER_FREQ(targetSeqPlayerIndex, setupVal2, (setupVal1 * 10) & 0xFFFF);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -773,13 +772,13 @@ u8 func_800FAD34(void) {
|
|||
if (D_80133418 == 1) {
|
||||
if (func_800E5EDC() == 1) {
|
||||
D_80133418 = 0;
|
||||
Audio_QueueCmdS8(0x46020000, gSfxChannelLayout);
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout);
|
||||
func_800F7170();
|
||||
}
|
||||
} else if (D_80133418 == 2) {
|
||||
while (func_800E5EDC() != 1) {}
|
||||
D_80133418 = 0;
|
||||
Audio_QueueCmdS8(0x46020000, gSfxChannelLayout);
|
||||
AUDIOCMD_SEQPLAYER_SET_IO(SEQ_PLAYER_SFX, 0, gSfxChannelLayout);
|
||||
func_800F7170();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,12 +2,12 @@
|
|||
|
||||
u8 D_8016F0E0[0xA0]; // unused
|
||||
AudioContext gAudioCtx;
|
||||
void (*D_801755D0)(void);
|
||||
AudioCustomUpdateFunction gAudioCustomUpdateFunction;
|
||||
s32 D_801755D8[3]; // unused
|
||||
|
||||
const s16 D_8014A6C0[] = {
|
||||
0x1C00, // unused
|
||||
0x0030, // gTatumsPerBeat
|
||||
const TempoData gTempoData = {
|
||||
0x1C00, // unk_00
|
||||
SEQTICKS_PER_BEAT, // seqTicksPerBeat
|
||||
};
|
||||
|
||||
// TODO: Extract from table?
|
||||
|
|
|
@ -30,7 +30,7 @@ u8 sSfxBankListEnd[7];
|
|||
u8 sSfxBankFreeListStart[7];
|
||||
u8 sSfxBankUnused[7];
|
||||
ActiveSfx gActiveSfx[7][3];
|
||||
u8 sCurSfxPlayerChannelIdx;
|
||||
u8 sCurSfxPlayerChannelIndex;
|
||||
u8 gSfxBankMuted[7];
|
||||
UnusedBankLerp sUnusedBankLerp[7];
|
||||
u16 gAudioSfxSwapSource[10];
|
||||
|
@ -50,14 +50,14 @@ void Audio_SetSfxBanksMute(u16 muteMask) {
|
|||
}
|
||||
}
|
||||
|
||||
void Audio_QueueSeqCmdMute(u8 channelIdx) {
|
||||
D_801333D0 |= (1 << channelIdx);
|
||||
void Audio_QueueSeqCmdMute(u8 channelIndex) {
|
||||
D_801333D0 |= (1 << channelIndex);
|
||||
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_SFX, 0x40, 0xF);
|
||||
Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_SFX, 0x40, 0xF);
|
||||
}
|
||||
|
||||
void Audio_ClearBGMMute(u8 channelIdx) {
|
||||
D_801333D0 &= ((1 << channelIdx) ^ 0xFFFF);
|
||||
void Audio_ClearBGMMute(u8 channelIndex) {
|
||||
D_801333D0 &= ((1 << channelIndex) ^ 0xFFFF);
|
||||
if (D_801333D0 == 0) {
|
||||
Audio_SetVolumeScale(SEQ_PLAYER_BGM_MAIN, VOL_SCALE_INDEX_SFX, 0x7F, 0xF);
|
||||
Audio_SetVolumeScale(SEQ_PLAYER_BGM_SUB, VOL_SCALE_INDEX_SFX, 0x7F, 0xF);
|
||||
|
@ -211,7 +211,7 @@ void Audio_ProcessSfxRequest(void) {
|
|||
if ((req->sfxId & 0xC00) || (sfxParams->params & SFX_FLAG_2) || (index == evictIndex)) {
|
||||
if ((gSfxBanks[bankId][index].sfxParams & SFX_FLAG_3) &&
|
||||
gSfxBanks[bankId][index].state != SFX_STATE_QUEUED) {
|
||||
Audio_ClearBGMMute(gSfxBanks[bankId][index].channelIdx);
|
||||
Audio_ClearBGMMute(gSfxBanks[bankId][index].channelIndex);
|
||||
}
|
||||
gSfxBanks[bankId][index].token = req->token;
|
||||
gSfxBanks[bankId][index].sfxId = req->sfxId;
|
||||
|
@ -262,7 +262,7 @@ void Audio_RemoveSfxBankEntry(u8 bankId, u8 entryIndex) {
|
|||
u8 i;
|
||||
|
||||
if (entry->sfxParams & SFX_FLAG_3) {
|
||||
Audio_ClearBGMMute(entry->channelIdx);
|
||||
Audio_ClearBGMMute(entry->channelIndex);
|
||||
}
|
||||
if (entryIndex == sSfxBankListEnd[bankId]) {
|
||||
sSfxBankListEnd[bankId] = entry->prev;
|
||||
|
@ -314,7 +314,7 @@ void Audio_ChooseActiveSfx(u8 bankId) {
|
|||
gSfxBanks[bankId][entryIndex].freshness--;
|
||||
} else if (!(gSfxBanks[bankId][entryIndex].sfxId & 0xC00) &&
|
||||
(gSfxBanks[bankId][entryIndex].state == SFX_STATE_PLAYING_2)) {
|
||||
Audio_QueueCmdS8((gSfxBanks[bankId][entryIndex].channelIdx << 8) | 0x6020000, 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, gSfxBanks[bankId][entryIndex].channelIndex, 0, 0);
|
||||
Audio_RemoveSfxBankEntry(bankId, entryIndex);
|
||||
}
|
||||
if (gSfxBanks[bankId][entryIndex].freshness == 0) {
|
||||
|
@ -346,7 +346,7 @@ void Audio_ChooseActiveSfx(u8 bankId) {
|
|||
}
|
||||
if (entry->dist > SQ(1e5f)) {
|
||||
if (entry->state == SFX_STATE_PLAYING_1) {
|
||||
Audio_QueueCmdS8((entry->channelIdx << 8) | 0x6020000, 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
if (entry->sfxId & 0xC00) {
|
||||
Audio_RemoveSfxBankEntry(bankId, entryIndex);
|
||||
entryIndex = k;
|
||||
|
@ -451,45 +451,51 @@ void Audio_PlayActiveSfx(u8 bankId) {
|
|||
entryIndex = gActiveSfx[bankId][i].entryIndex;
|
||||
if (entryIndex != 0xFF) {
|
||||
entry = &gSfxBanks[bankId][entryIndex];
|
||||
channel = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[sCurSfxPlayerChannelIdx];
|
||||
channel = gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[sCurSfxPlayerChannelIndex];
|
||||
if (entry->state == SFX_STATE_READY) {
|
||||
entry->channelIdx = sCurSfxPlayerChannelIdx;
|
||||
entry->channelIndex = sCurSfxPlayerChannelIndex;
|
||||
if (entry->sfxParams & SFX_FLAG_3) {
|
||||
Audio_QueueSeqCmdMute(sCurSfxPlayerChannelIdx);
|
||||
Audio_QueueSeqCmdMute(sCurSfxPlayerChannelIndex);
|
||||
}
|
||||
if ((entry->sfxParams & SFX_PARAM_67_MASK) != (0 << SFX_PARAM_67_SHIFT)) {
|
||||
switch (entry->sfxParams & SFX_PARAM_67_MASK) {
|
||||
case (1 << SFX_PARAM_67_SHIFT):
|
||||
entry->unk_2F = Audio_NextRandom() & 0xF;
|
||||
entry->unk_2F = AudioThread_NextRandom() & 0xF;
|
||||
break;
|
||||
case (2 << SFX_PARAM_67_SHIFT):
|
||||
entry->unk_2F = Audio_NextRandom() & 0x1F;
|
||||
entry->unk_2F = AudioThread_NextRandom() & 0x1F;
|
||||
break;
|
||||
case (3 << SFX_PARAM_67_SHIFT):
|
||||
entry->unk_2F = Audio_NextRandom() & 0x3F;
|
||||
entry->unk_2F = AudioThread_NextRandom() & 0x3F;
|
||||
break;
|
||||
default:
|
||||
entry->unk_2F = 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Audio_SetSfxProperties(bankId, entryIndex, sCurSfxPlayerChannelIdx);
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | ((sCurSfxPlayerChannelIdx & 0xFF) << 8), 1);
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | ((sCurSfxPlayerChannelIdx & 0xFF) << 8) | 4,
|
||||
entry->sfxId & 0xFF);
|
||||
Audio_SetSfxProperties(bankId, entryIndex, sCurSfxPlayerChannelIndex);
|
||||
|
||||
// ioPort 0, enable the sfx to play in `NA_BGM_GENERAL_SFX`
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 0, 1);
|
||||
|
||||
// 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
|
||||
if (gIsLargeSfxBank[bankId]) {
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | ((sCurSfxPlayerChannelIdx & 0xFF) << 8) | 5,
|
||||
(entry->sfxId & 0x100) >> 8);
|
||||
// ioPort 5, write the upper bits sfx index for `NA_BGM_GENERAL_SFX`, for banks with > 0xFF entries
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, sCurSfxPlayerChannelIndex, 5, (entry->sfxId & 0x100) >> 8);
|
||||
}
|
||||
if (entry->sfxId & 0xC00) {
|
||||
entry->state = SFX_STATE_PLAYING_1;
|
||||
} else {
|
||||
entry->state = SFX_STATE_PLAYING_2;
|
||||
}
|
||||
} else if ((u8)channel->soundScriptIO[1] == (u8)SEQ_IO_VAL_NONE) {
|
||||
} else if ((u8)channel->seqScriptIO[1] == (u8)SEQ_IO_VAL_NONE) {
|
||||
Audio_RemoveSfxBankEntry(bankId, entryIndex);
|
||||
} else if (entry->state == SFX_STATE_PLAYING_REFRESH) {
|
||||
Audio_SetSfxProperties(bankId, entryIndex, sCurSfxPlayerChannelIdx);
|
||||
Audio_SetSfxProperties(bankId, entryIndex, sCurSfxPlayerChannelIndex);
|
||||
if (entry->sfxId & 0xC00) {
|
||||
entry->state = SFX_STATE_PLAYING_1;
|
||||
} else {
|
||||
|
@ -497,7 +503,7 @@ void Audio_PlayActiveSfx(u8 bankId) {
|
|||
}
|
||||
}
|
||||
}
|
||||
sCurSfxPlayerChannelIdx++;
|
||||
sCurSfxPlayerChannelIndex++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -510,7 +516,7 @@ void Audio_StopSfxByBank(u8 bankId) {
|
|||
while (entryIndex != 0xFF) {
|
||||
entry = &gSfxBanks[bankId][entryIndex];
|
||||
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | ((entry->channelIdx & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
Audio_RemoveSfxBankEntry(bankId, entryIndex);
|
||||
|
@ -530,7 +536,7 @@ void func_800F8884(u8 bankId, Vec3f* pos) {
|
|||
entry = &gSfxBanks[bankId][entryIndex];
|
||||
if (entry->posX == &pos->x) {
|
||||
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | ((entry->channelIdx & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
Audio_RemoveSfxBankEntry(bankId, entryIndex);
|
||||
|
@ -572,7 +578,7 @@ void Audio_StopSfxByPosAndId(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) {
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | ((entry->channelIdx & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
Audio_RemoveSfxBankEntry(SFX_BANK(sfxId), entryIndex);
|
||||
|
@ -600,7 +606,7 @@ void Audio_StopSfxByTokenAndId(u8 token, u16 sfxId) {
|
|||
entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex];
|
||||
if (entry->token == token && entry->sfxId == sfxId) {
|
||||
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | ((entry->channelIdx & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
Audio_RemoveSfxBankEntry(SFX_BANK(sfxId), entryIndex);
|
||||
|
@ -627,7 +633,7 @@ void Audio_StopSfxById(u32 sfxId) {
|
|||
entry = &gSfxBanks[SFX_BANK(sfxId)][entryIndex];
|
||||
if (entry->sfxId == sfxId) {
|
||||
if (entry->state >= SFX_STATE_PLAYING_REFRESH) {
|
||||
Audio_QueueCmdS8(0x6 << 24 | SEQ_PLAYER_SFX << 16 | ((entry->channelIdx & 0xFF) << 8), 0);
|
||||
AUDIOCMD_CHANNEL_SET_IO(SEQ_PLAYER_SFX, entry->channelIndex, 0, 0);
|
||||
}
|
||||
if (entry->state != SFX_STATE_EMPTY) {
|
||||
Audio_RemoveSfxBankEntry(SFX_BANK(sfxId), entryIndex);
|
||||
|
@ -672,7 +678,7 @@ void func_800F8F88(void) {
|
|||
u8 bankId;
|
||||
|
||||
if (IS_SEQUENCE_CHANNEL_VALID(gAudioCtx.seqPlayers[SEQ_PLAYER_SFX].channels[0])) {
|
||||
sCurSfxPlayerChannelIdx = 0;
|
||||
sCurSfxPlayerChannelIndex = 0;
|
||||
for (bankId = 0; bankId < ARRAY_COUNT(gSfxBanks); bankId++) {
|
||||
Audio_ChooseActiveSfx(bankId);
|
||||
Audio_PlayActiveSfx(bankId);
|
||||
|
|
|
@ -51,7 +51,7 @@ void AudioMgr_HandleRetrace(AudioMgr* audioMgr) {
|
|||
// Skip update, no rsp task produced
|
||||
rspTask = NULL;
|
||||
} else {
|
||||
rspTask = func_800E4FE0();
|
||||
rspTask = AudioThread_Update();
|
||||
}
|
||||
|
||||
gAudioThreadUpdateTimeAcc += osGetTime() - gAudioThreadUpdateTimeStart;
|
||||
|
|
|
@ -456,7 +456,7 @@ void GameState_Init(GameState* gameState, GameStateFunc init, GraphicsContext* g
|
|||
void GameState_Destroy(GameState* gameState) {
|
||||
PRINTF("game デストラクタ開始\n"); // "game destructor start"
|
||||
AudioMgr_StopAllSfx();
|
||||
func_800F3054();
|
||||
Audio_Update();
|
||||
osRecvMesg(&gameState->gfxCtx->queue, NULL, OS_MESG_BLOCK);
|
||||
LOG_UTILS_CHECK_NULL_POINTER("this->cleanup", gameState->destroy, "../game.c", 1139);
|
||||
if (gameState->destroy != NULL) {
|
||||
|
|
|
@ -373,7 +373,7 @@ void Graph_Update(GraphicsContext* gfxCtx, GameState* gameState) {
|
|||
gfxCtx->fbIdx++;
|
||||
}
|
||||
|
||||
func_800F3054();
|
||||
Audio_Update();
|
||||
|
||||
{
|
||||
OSTime timeNow = osGetTime();
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include "terminal.h"
|
||||
|
||||
/**
|
||||
* How much time the audio update on the audio thread (`func_800E4FE0`) took in total, between scheduling the last two
|
||||
* graphics tasks.
|
||||
* How much time the audio update on the audio thread (`AudioThread_Update`) took in total, between scheduling the last
|
||||
* two graphics tasks.
|
||||
*/
|
||||
volatile OSTime gAudioThreadUpdateTimeTotalPerGfxTask;
|
||||
|
||||
|
|
|
@ -2553,44 +2553,44 @@ AudioLoad_Unused5 = 0x800BADE4; // type:func
|
|||
AudioLoad_ScriptLoad = 0x800BADEC; // type:func
|
||||
AudioLoad_ProcessScriptLoads = 0x800BAE58; // type:func
|
||||
AudioLoad_InitScriptLoads = 0x800BAEB0; // type:func
|
||||
func_800E4FE0 = 0x800BAEE0; // type:func
|
||||
func_800E5000 = 0x800BAF00; // type:func
|
||||
func_800E5584 = 0x800BB484; // type:func
|
||||
func_800E5958 = 0x800BB858; // type:func
|
||||
func_800E59AC = 0x800BB8AC; // type:func
|
||||
Audio_InitMesgQueuesInternal = 0x800BB8F4; // type:func
|
||||
Audio_QueueCmd = 0x800BB98C; // type:func
|
||||
Audio_QueueCmdF32 = 0x800BB9D8; // type:func
|
||||
Audio_QueueCmdS32 = 0x800BB9FC; // type:func
|
||||
Audio_QueueCmdS8 = 0x800BBA20; // type:func
|
||||
Audio_QueueCmdU16 = 0x800BBA50; // type:func
|
||||
Audio_ScheduleProcessCmds = 0x800BBA80; // type:func
|
||||
Audio_ResetCmdQueue = 0x800BBB10; // type:func
|
||||
Audio_ProcessCmd = 0x800BBB28; // type:func
|
||||
Audio_ProcessCmds = 0x800BBC6C; // type:func
|
||||
AudioThread_Update = 0x800BAEE0; // type:func
|
||||
AudioThread_UpdateImpl = 0x800BAF00; // type:func
|
||||
AudioThread_ProcessGlobalCmd = 0x800BB484; // type:func
|
||||
AudioThread_SetFadeOutTimer = 0x800BB858; // type:func
|
||||
AudioThread_SetFadeInTimer = 0x800BB8AC; // type:func
|
||||
AudioThread_InitMesgQueuesImpl = 0x800BB8F4; // type:func
|
||||
AudioThread_QueueCmd = 0x800BB98C; // type:func
|
||||
AudioThread_QueueCmdF32 = 0x800BB9D8; // type:func
|
||||
AudioThread_QueueCmdS32 = 0x800BB9FC; // type:func
|
||||
AudioThread_QueueCmdS8 = 0x800BBA20; // type:func
|
||||
AudioThread_QueueCmdU16 = 0x800BBA50; // type:func
|
||||
AudioThread_ScheduleProcessCmds = 0x800BBA80; // type:func
|
||||
AudioThread_ResetCmdQueue = 0x800BBB10; // type:func
|
||||
AudioThread_ProcessCmd = 0x800BBB28; // type:func
|
||||
AudioThread_ProcessCmds = 0x800BBC6C; // type:func
|
||||
func_800E5E20 = 0x800BBD20; // type:func
|
||||
func_800E5E84 = 0x800BBD84; // type:func
|
||||
AudioThread_GetFontsForSequence = 0x800BBD84; // type:func
|
||||
Audio_GetSampleBankIdsOfFont = 0x800BBDA4; // type:func
|
||||
func_800E5EDC = 0x800BBDDC; // type:func
|
||||
func_800E5F34 = 0x800BBE34; // type:func
|
||||
func_800E5F88 = 0x800BBE88; // type:func
|
||||
Audio_PreNMIInternal = 0x800BBF24; // type:func
|
||||
func_800E6070 = 0x800BBF70; // type:func
|
||||
func_800E60C4 = 0x800BBFC4; // type:func
|
||||
Audio_InitExternalPool = 0x800BBFEC; // type:func
|
||||
Audio_DestroyExternalPool = 0x800BC01C; // type:func
|
||||
func_800E6128 = 0x800BC028; // type:func
|
||||
func_800E6300 = 0x800BC200; // type:func
|
||||
func_800E64B0 = 0x800BC3B0; // type:func
|
||||
func_800E64F8 = 0x800BC3F8; // type:func
|
||||
func_800E651C = 0x800BC41C; // type:func
|
||||
Audio_WaitForAudioTask = 0x800BC450; // type:func
|
||||
AudioThread_ResetAudioHeap = 0x800BBE88; // type:func
|
||||
AudioThread_PreNMIInternal = 0x800BBF24; // type:func
|
||||
AudioThread_GetChannelIO = 0x800BBF70; // type:func
|
||||
AudioThread_GetSeqPlayerIO = 0x800BBFC4; // type:func
|
||||
AudioThread_InitExternalPool = 0x800BBFEC; // type:func
|
||||
AudioThread_ResetExternalPool = 0x800BC01C; // type:func
|
||||
AudioThread_ProcessSeqPlayerCmd = 0x800BC028; // type:func
|
||||
AudioThread_ProcessChannelCmd = 0x800BC200; // type:func
|
||||
AudioThread_Noop1Cmd = 0x800BC3B0; // type:func
|
||||
AudioThread_Noop1CmdZeroed = 0x800BC3F8; // type:func
|
||||
AudioThread_Noop2Cmd = 0x800BC41C; // type:func
|
||||
AudioThread_WaitForAudioTask = 0x800BC450; // type:func
|
||||
func_800E6590 = 0x800BC490; // type:func
|
||||
func_800E6680 = 0x800BC580; // type:func
|
||||
func_800E66A0 = 0x800BC5A0; // type:func
|
||||
func_800E66C0 = 0x800BC5C0; // type:func
|
||||
Audio_NextRandom = 0x800BC6C0; // type:func
|
||||
Audio_InitMesgQueues = 0x800BC718; // type:func
|
||||
AudioThread_NextRandom = 0x800BC6C0; // type:func
|
||||
AudioThread_InitMesgQueues = 0x800BC718; // type:func
|
||||
Audio_InvalDCache = 0x800BC740; // type:func
|
||||
Audio_WritebackDCache = 0x800BC780; // type:func
|
||||
osAiSetNextBuffer = 0x800BC7C0; // type:func
|
||||
|
@ -2702,7 +2702,7 @@ AudioOcarina_PlayLongScarecrowSong = 0x800C4724; // type:func
|
|||
AudioOcarina_ResetStaffs = 0x800C4830; // type:func
|
||||
AudioDebug_Draw = 0x800C487C; // type:func
|
||||
AudioDebug_ScrPrt = 0x800C4884; // type:func
|
||||
func_800F3054 = 0x800C4890; // type:func
|
||||
Audio_Update = 0x800C4890; // type:func
|
||||
func_800F3138 = 0x800C4934; // type:func
|
||||
func_800F3140 = 0x800C493C; // type:func
|
||||
func_800F314C = 0x800C4948; // type:func
|
||||
|
|
|
@ -472,7 +472,7 @@ zeroes = 0x80102694; // size:0x21
|
|||
__osPfsInodeCacheChannel = 0x80102730; // size:0x4
|
||||
__osPfsInodeCacheBank = 0x80102734; // size:0x1
|
||||
__osPfsLastChannel = 0x80102740; // size:0x4
|
||||
D_8014A6C0 = 0x80107240; // size:0x4
|
||||
gTempoData = 0x80107240; // size:0x4
|
||||
gAudioHeapInitSizes = 0x80107244; // size:0xC
|
||||
__libm_qnan_f = 0x80107740; // size:0x4
|
||||
sTextFade = 0x801077C0; // size:0x2
|
||||
|
@ -675,7 +675,7 @@ sSfxBankListEnd = 0x80123020; // size:0x7
|
|||
sSfxBankFreeListStart = 0x80123028; // size:0x7
|
||||
sSfxBankUnused = 0x80123030; // size:0x7
|
||||
gActiveSfx = 0x80123038; // size:0xA8
|
||||
sCurSfxPlayerChannelIdx = 0x801230E0; // size:0x1
|
||||
sCurSfxPlayerChannelIndex = 0x801230E0; // size:0x1
|
||||
gSfxBankMuted = 0x801230E4; // size:0x7
|
||||
sUnusedBankLerp = 0x801230F0; // size:0x70
|
||||
sSeqRequests = 0x80123160; // size:0x28
|
||||
|
@ -683,7 +683,7 @@ sNumSeqRequests = 0x80123188; // size:0x4
|
|||
sAudioSeqCmds = 0x80123190; // size:0x400
|
||||
gActiveSeqs = 0x80123590; // size:0x990
|
||||
gAudioCtx = 0x80123FC0; // size:0x6450
|
||||
D_801755D0 = 0x8012A410; // size:0x4
|
||||
gAudioCustomUpdateFunction = 0x8012A410; // size:0x4
|
||||
gUseAtanContFrac = 0x8012A440; // size:0x4
|
||||
gSystemArena = 0x8012A450; // size:0x24 type:Arena
|
||||
sArenaLockMsg = 0x8012A490; // size:0x4 type:OSMesg
|
||||
|
|
Loading…
Add table
Reference in a new issue