mirror of
https://github.com/izzy2lost/2ship2harkinian-Android.git
synced 2026-06-19 01:20:08 -07:00
Audio: Various Cleanup and Docs (#1034)
* cleanup and docs * pr suggestions * audio errors * fix bss * Empty-Commit
This commit is contained in:
+4
-4
@@ -3037,8 +3037,8 @@ void* AudioHeap_AllocAttemptExternal(AudioAllocPool* pool, size_t size);
|
||||
void* AudioHeap_AllocDmaMemory(AudioAllocPool* pool, size_t size);
|
||||
void* AudioHeap_AllocZeroed(AudioAllocPool* pool, size_t size);
|
||||
void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size);
|
||||
void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size);
|
||||
void AudioHeap_PopCache(s32 tableType);
|
||||
void AudioHeap_InitPool(AudioAllocPool* pool, void* addr, size_t size);
|
||||
void AudioHeap_PopPersistentCache(s32 tableType);
|
||||
void AudioHeap_InitMainPool(size_t initPoolSize);
|
||||
void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id);
|
||||
void* AudioHeap_SearchCaches(s32 tableType, s32 cache, s32 id);
|
||||
@@ -3123,10 +3123,10 @@ s32 osAiSetNextBuffer(void* buf, u32 size);
|
||||
|
||||
void AudioPlayback_NoteDisable(Note* note);
|
||||
void AudioPlayback_ProcessNotes(void);
|
||||
SoundFontSound* AudioPlayback_InstrumentGetSound(Instrument* instrument, s32 semitone);
|
||||
TunedSample* AudioPlayback_GetInstrumentTunedSample(Instrument* instrument, s32 semitone);
|
||||
Instrument* AudioPlayback_GetInstrumentInner(s32 fontId, s32 instId);
|
||||
Drum* AudioPlayback_GetDrum(s32 fontId, s32 drumId);
|
||||
SoundFontSound* AudioPlayback_GetSfx(s32 fontId, s32 sfxId);
|
||||
SoundEffect* AudioPlayback_GetSoundEffect(s32 fontId, s32 sfxId);
|
||||
s32 AudioPlayback_SetFontInstrument(s32 instrumentType, s32 fontId, s32 index, void* value);
|
||||
void AudioPlayback_SeqLayerNoteDecay(SequenceLayer* layer);
|
||||
void AudioPlayback_SeqLayerNoteRelease(SequenceLayer* layer);
|
||||
|
||||
+2
-2
@@ -2968,7 +2968,7 @@ extern f64 D_801E0EB0;
|
||||
// extern UNK_TYPE4 D_801E1068;
|
||||
extern UNK_PTR D_801E10B0;
|
||||
extern const s16 gAudioTatumInit[];
|
||||
extern const AudioContextInitSizes gAudioContextInitSizes;
|
||||
extern const AudioHeapInitSizes gAudioHeapInitSizes;
|
||||
// extern UNK_TYPE4 D_801E1108;
|
||||
// extern UNK_TYPE4 D_801E110C;
|
||||
extern u8 gSoundFontTable[];
|
||||
@@ -3489,7 +3489,7 @@ extern ActiveSfx gActiveSfx[7][3];
|
||||
extern AudioContext gAudioContext; // at 0x80200C70
|
||||
extern void (*D_80208E68)(void);
|
||||
extern u32 (*D_80208E6C)(s8 value, SequenceChannel* channel);
|
||||
extern s32 (*D_80208E70)(SoundFontSample*, s32, s8, s32);
|
||||
extern s32 (*D_80208E70)(Sample*, s32, s8, s32);
|
||||
extern Acmd* (*D_80208E74)(Acmd*, s32, s32);
|
||||
|
||||
// post-code buffers
|
||||
|
||||
+85
-56
@@ -10,6 +10,12 @@
|
||||
#define IS_SEQUENCE_CHANNEL_VALID(ptr) ((uintptr_t)(ptr) != (uintptr_t)&gAudioContext.sequenceChannelNone)
|
||||
#define SEQ_NUM_CHANNELS 16
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ SEQPLAYER_STATE_0,
|
||||
/* 1 */ SEQPLAYER_STATE_1, // Fading in
|
||||
/* 2 */ SEQPLAYER_STATE_2 // Fading out
|
||||
} SeqPlayerState;
|
||||
|
||||
#define MAX_CHANNELS_PER_BANK 3
|
||||
|
||||
#define MUTE_FLAGS_3 (1 << 3) // prevent further noteSubEus from playing
|
||||
@@ -27,6 +33,21 @@
|
||||
|
||||
#define AIBUF_LEN 0x580
|
||||
|
||||
// Must be the same amount of samples as copied by aDuplicate() (audio microcode)
|
||||
#define WAVE_SAMPLE_COUNT 64
|
||||
|
||||
#define AUDIO_RELOCATED_ADDRESS_START K0BASE
|
||||
|
||||
typedef enum {
|
||||
/* 0x1 */ AUDIO_ERROR_NO_INST = 1,
|
||||
/* 0x3 */ AUDIO_ERROR_INVALID_INST_ID = 3,
|
||||
/* 0x4 */ AUDIO_ERROR_INVALID_DRUM_SFX_ID,
|
||||
/* 0x5 */ AUDIO_ERROR_NO_DRUM_SFX,
|
||||
/* 0x10 */ AUDIO_ERROR_FONT_NOT_LOADED = 0x10
|
||||
} AudioError;
|
||||
|
||||
#define AUDIO_ERROR(fontId, id, err) (((fontId << 8) + id) + (err << 24))
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ SOUNDMODE_STEREO,
|
||||
/* 1 */ SOUNDMODE_HEADSET,
|
||||
@@ -157,20 +178,20 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u32 unk_0 : 1;
|
||||
/* 0x00 */ u32 codec : 3;
|
||||
/* 0x00 */ u32 medium : 2;
|
||||
/* 0x00 */ u32 unk_bit26 : 1;
|
||||
/* 0x00 */ u32 unk_bit25 : 1;
|
||||
/* 0x01 */ u32 size : 24;
|
||||
/* 0x04 */ u8* sampleAddr;
|
||||
/* 0x08 */ AdpcmLoop* loop;
|
||||
/* 0x0C */ AdpcmBook* book;
|
||||
} SoundFontSample; // size = 0x10
|
||||
/* 0x00 */ u32 codec : 3; // The state of compression or decompression
|
||||
/* 0x00 */ u32 medium : 2; // Medium where sample is currently stored
|
||||
/* 0x00 */ u32 unk_bit26 : 1; // Has the sample header been relocated (offsets to pointers)
|
||||
/* 0x00 */ u32 isRelocated : 1; // Size of the sample
|
||||
/* 0x01 */ u32 size : 24; // Size of the sample
|
||||
/* 0x04 */ u8* sampleAddr; // Raw sample data. Offset from the start of the sample bank or absolute address to either rom or ram
|
||||
/* 0x08 */ AdpcmLoop* loop; // Adpcm loop parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
||||
/* 0x0C */ AdpcmBook* book; // Adpcm book parameters used by the sample. Offset from the start of the sound font / pointer to ram
|
||||
} Sample; // size = 0x10
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ SoundFontSample* sample;
|
||||
/* 0x00 */ Sample* sample;
|
||||
/* 0x04 */ f32 tuning; // frequency scale factor
|
||||
} SoundFontSound; // size = 0x8
|
||||
} TunedSample; // size = 0x8
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ s16 numSamplesAfterDownsampling; // never read
|
||||
@@ -222,29 +243,33 @@ typedef struct {
|
||||
/* 0x27C */ s16* unk_27C;
|
||||
/* 0x280 */ s16* filterLeftState;
|
||||
/* 0x284 */ s16* filterRightState;
|
||||
/* 0x288 */ SoundFontSound sound;
|
||||
/* 0x290 */ SoundFontSample sample;
|
||||
/* 0x288 */ TunedSample tunedSample;
|
||||
/* 0x290 */ Sample sample;
|
||||
/* 0x2A0 */ AdpcmLoop loop;
|
||||
} SynthesisReverb; // size = 0x2D0
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 loaded;
|
||||
/* 0x00 */ u8 isRelocated; // have the envelope and all samples been relocated (offsets to pointers)
|
||||
/* 0x01 */ u8 normalRangeLo;
|
||||
/* 0x02 */ u8 normalRangeHi;
|
||||
/* 0x03 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable
|
||||
/* 0x04 */ EnvelopePoint* envelope;
|
||||
/* 0x08 */ SoundFontSound lowNotesSound;
|
||||
/* 0x10 */ SoundFontSound normalNotesSound;
|
||||
/* 0x18 */ SoundFontSound highNotesSound;
|
||||
/* 0x08 */ TunedSample lowPitchTunedSample;
|
||||
/* 0x10 */ TunedSample normalPitchTunedSample;
|
||||
/* 0x18 */ TunedSample highPitchTunedSample;
|
||||
} Instrument; // size = 0x20
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 adsrDecayIndex; // index used to obtain adsr decay rate from adsrDecayTable
|
||||
/* 0x01 */ u8 pan;
|
||||
/* 0x02 */ u8 loaded;
|
||||
/* 0x04 */ SoundFontSound sound;
|
||||
/* 0x14 */ EnvelopePoint* envelope;
|
||||
} Drum; // size = 0x18
|
||||
/* 0x02 */ u8 isRelocated; // have tunedSample.sample and envelope been relocated (offsets to pointers)
|
||||
/* 0x04 */ TunedSample tunedSample;
|
||||
/* 0x0C */ EnvelopePoint* envelope;
|
||||
} Drum; // size = 0x10
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ TunedSample tunedSample;
|
||||
} SoundEffect; // size = 0x08
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 numInstruments;
|
||||
@@ -254,7 +279,7 @@ typedef struct {
|
||||
/* 0x04 */ u16 numSfx;
|
||||
/* 0x08 */ Instrument** instruments;
|
||||
/* 0x0C */ Drum** drums;
|
||||
/* 0x10 */ SoundFontSound* soundEffects;
|
||||
/* 0x10 */ SoundEffect* soundEffects;
|
||||
} SoundFont; // size = 0x14
|
||||
|
||||
typedef struct {
|
||||
@@ -290,10 +315,7 @@ typedef struct {
|
||||
/* 0x012 */ u16 fadeTimer;
|
||||
/* 0x014 */ u16 fadeTimerUnkEu;
|
||||
/* 0x016 */ u16 unk_16;
|
||||
union {
|
||||
/* 0x018 */ u8* seqData;
|
||||
/* 0x018 */ u16* seqData16;
|
||||
};
|
||||
/* 0x018 */ u8* seqData;
|
||||
/* 0x01C */ f32 fadeVolume;
|
||||
/* 0x020 */ f32 fadeVelocity;
|
||||
/* 0x024 */ f32 volume;
|
||||
@@ -437,7 +459,7 @@ typedef struct SequenceChannel {
|
||||
/* 0xD0 */ u8* sfxState; // SfxChannelState
|
||||
/* 0xD4 */ s16* filter;
|
||||
/* 0xD8 */ Stereo stereo;
|
||||
/* 0xDC */ s32 unk_DC;
|
||||
/* 0xDC */ s32 startSamplePos;
|
||||
/* 0xE0 */ s32 unk_E0;
|
||||
} SequenceChannel; // size = 0xE4
|
||||
|
||||
@@ -501,7 +523,7 @@ typedef struct SequenceLayer {
|
||||
/* 0x50 */ f32 noteVelocity;
|
||||
/* 0x54 */ f32 noteFreqScale;
|
||||
/* 0x58 */ Instrument* instrument;
|
||||
/* 0x5C */ SoundFontSound* sound;
|
||||
/* 0x5C */ TunedSample* tunedSample;
|
||||
/* 0x60 */ SequenceChannel* channel; // Not SequenceChannel?
|
||||
/* 0x64 */ SeqScriptState scriptState;
|
||||
/* 0x80 */ AudioListItem listItem;
|
||||
@@ -557,12 +579,18 @@ typedef struct {
|
||||
/* 0x1A */ u16 delay;
|
||||
} VibratoState; // size = 0x1C
|
||||
|
||||
typedef enum {
|
||||
/* 0 */ PLAYBACK_STATUS_0,
|
||||
/* 1 */ PLAYBACK_STATUS_1,
|
||||
/* 2 */ PLAYBACK_STATUS_2
|
||||
} NotePlaybackStatus;
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u8 priority;
|
||||
/* 0x01 */ u8 waveId;
|
||||
/* 0x02 */ u8 sampleCountIndex;
|
||||
/* 0x02 */ u8 harmonicIndex; // the harmonic index for the synthetic wave contained in gWaveSamples (also matches the base 2 logarithm of the harmonic order)
|
||||
/* 0x03 */ u8 fontId;
|
||||
/* 0x04 */ u8 unk_04;
|
||||
/* 0x04 */ u8 status;
|
||||
/* 0x05 */ u8 stereoHeadsetEffects;
|
||||
/* 0x06 */ s16 adsrVolScaleUnused;
|
||||
/* 0x08 */ f32 portamentoFreqScale;
|
||||
@@ -575,7 +603,7 @@ typedef struct {
|
||||
/* 0x54 */ Portamento portamento;
|
||||
/* 0x60 */ VibratoState vibratoState;
|
||||
/* 0x7C */ char unk_7C[0x8];
|
||||
/* 0x84 */ u32 unk_84;
|
||||
/* 0x84 */ u32 startSamplePos;
|
||||
} NotePlaybackState; // size = 0x88
|
||||
|
||||
typedef struct {
|
||||
@@ -600,16 +628,16 @@ typedef struct {
|
||||
/* 0x03 */ u8 headsetPanRight;
|
||||
/* 0x04 */ u8 headsetPanLeft;
|
||||
/* 0x05 */ u8 reverbVol;
|
||||
/* 0x06 */ u8 unk_06;
|
||||
/* 0x06 */ u8 harmonicIndexCurAndPrev; // bits 3..2 store curHarmonicIndex, bits 1..0 store prevHarmonicIndex
|
||||
/* 0x07 */ u8 unk_07;
|
||||
/* 0x08 */ u16 targetVolLeft;
|
||||
/* 0x0A */ u16 targetVolRight;
|
||||
/* 0x0C */ u16 resamplingRateFixedPoint;
|
||||
/* 0x0E */ u16 unk_0E;
|
||||
union {
|
||||
/* 0x10 */ SoundFontSound* soundFontSound;
|
||||
/* 0x10 */ s16* samples; // used for synthetic waves
|
||||
} sound;
|
||||
union {
|
||||
/* 0x10 */ TunedSample* tunedSample;
|
||||
/* 0x10 */ s16* waveSampleAddr; // used for synthetic waves
|
||||
};
|
||||
/* 0x14 */ s16* filter;
|
||||
/* 0x18 */ u8 unk_18;
|
||||
/* 0x19 */ u8 unk_19;
|
||||
@@ -640,7 +668,7 @@ typedef struct {
|
||||
} ReverbSettings; // size = 0x18
|
||||
|
||||
/**
|
||||
* The high-level audio specifications requested when initializing or resetting the audio heap.
|
||||
* The high-level audio specifications requested when initializing or resetting the audio pool.
|
||||
* Most often resets during scene transitions, but will highly depend on game play.
|
||||
*/
|
||||
typedef struct {
|
||||
@@ -648,7 +676,8 @@ typedef struct {
|
||||
/* 0x04 */ u8 unk_04;
|
||||
/* 0x05 */ u8 numNotes;
|
||||
/* 0x06 */ u8 numSequencePlayers;
|
||||
/* 0x07 */ u8 unk_07[0x2]; // unused, set to zero
|
||||
/* 0x07 */ u8 unk_07; // unused, set to zero
|
||||
/* 0x08 */ u8 unk_08; // unused, set to zero
|
||||
/* 0x09 */ u8 numReverbs;
|
||||
/* 0x0C */ ReverbSettings* reverbSettings;
|
||||
/* 0x10 */ u16 sampleDmaBufSize1;
|
||||
@@ -675,17 +704,17 @@ typedef struct {
|
||||
/* 0x02 */ u16 samplingFreq; // Target sampling rate in Hz
|
||||
/* 0x04 */ u16 aiSamplingFreq; // True sampling rate set to the audio interface (AI) for the audio digital-analog converter (DAC)
|
||||
/* 0x06 */ s16 samplesPerFrameTarget;
|
||||
/* 0x08 */ s16 maxAiBufferLength;
|
||||
/* 0x0A */ s16 minAiBufferLength;
|
||||
/* 0x0C */ s16 updatesPerFrame;
|
||||
/* 0x08 */ s16 maxAiBufNumSamples;
|
||||
/* 0x0A */ s16 minAiBufNumSamples;
|
||||
/* 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;
|
||||
/* 0x14 */ s16 numSequencePlayers;
|
||||
/* 0x18 */ f32 resampleRate;
|
||||
/* 0x1C */ f32 updatesPerFrameInv;
|
||||
/* 0x20 */ f32 unkUpdatesPerFrameScaled;
|
||||
/* 0x24 */ f32 unk_24;
|
||||
/* 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
|
||||
} AudioBufferParameters; // size = 0x28
|
||||
|
||||
/**
|
||||
@@ -767,7 +796,7 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ u32 endAndMediumKey;
|
||||
/* 0x04 */ SoundFontSample* sample;
|
||||
/* 0x04 */ Sample* sample;
|
||||
/* 0x08 */ u8* ramAddr;
|
||||
/* 0x0C */ u32 encodedInfo;
|
||||
/* 0x10 */ s32 isFree;
|
||||
@@ -822,7 +851,7 @@ typedef struct {
|
||||
/* 0x14 */ s32 status;
|
||||
/* 0x18 */ size_t bytesRemaining;
|
||||
/* 0x1C */ s8* isDone; // TODO: rename in OoT and sync up here. This is an external status while (s32 status) is an internal status
|
||||
/* 0x20 */ SoundFontSample sample;
|
||||
/* 0x20 */ Sample sample;
|
||||
/* 0x30 */ OSMesgQueue msgqueue;
|
||||
/* 0x48 */ OSMesg msg;
|
||||
/* 0x4C */ OSIoMesg ioMesg;
|
||||
@@ -873,7 +902,7 @@ typedef struct {
|
||||
/* 0x0014 */ NoteSubEu* noteSubsEu;
|
||||
/* 0x0018 */ SynthesisReverb synthesisReverbs[4];
|
||||
/* 0x0B58 */ char unk_0B58[0x30];
|
||||
/* 0x0B88 */ SoundFontSample* usedSamples[128];
|
||||
/* 0x0B88 */ Sample* usedSamples[128];
|
||||
/* 0x0D88 */ AudioPreloadReq preloadSampleStack[128];
|
||||
/* 0x1788 */ s32 numUsedSamples;
|
||||
/* 0x178C */ s32 preloadSampleStackTop;
|
||||
@@ -889,7 +918,7 @@ typedef struct {
|
||||
/* 0x1E58 */ OSMesg externalLoadMesgBuf[0x10];
|
||||
/* 0x1E98 */ OSMesgQueue preloadSampleQueue;
|
||||
/* 0x1EB0 */ OSMesg preloadSampleMesgBuf[0x10];
|
||||
/* 0x1EF0 */ OSMesgQueue currAudioFrameDmaQueue;
|
||||
/* 0x1EF0 */ OSMesgQueue curAudioFrameDmaQueue;
|
||||
/* 0x1F08 */ OSMesg currAudioFrameDmaMesgBuf[0x40];
|
||||
/* 0x2008 */ OSIoMesg currAudioFrameDmaIoMesgBuf[0x40];
|
||||
/* 0x2608 */ OSMesgQueue syncDmaQueue;
|
||||
@@ -911,7 +940,7 @@ typedef struct {
|
||||
/* 0x285C */ char unk_285C[0x4];
|
||||
/* 0x2860 */ u8* sequenceFontTable;
|
||||
/* 0x2864 */ u16 numSequences;
|
||||
/* 0x2868 */ SoundFont* soundFonts;
|
||||
/* 0x2868 */ SoundFont* soundFontList;
|
||||
/* 0x286C */ AudioBufferParameters audioBufferParameters;
|
||||
/* 0x2994 */ f32 unk_2870;
|
||||
/* 0x2898 */ s32 sampleDmaBufSize1;
|
||||
@@ -925,7 +954,7 @@ typedef struct {
|
||||
/* 0x28C0 */ s32 totalTaskCount; // The total number of times the top-level function on the audio thread is run since the last audio reset
|
||||
/* 0x28C4 */ s32 curAudioFrameDmaCount;
|
||||
/* 0x28C8 */ s32 rspTaskIndex;
|
||||
/* 0x28CC */ s32 curAiBuffferIndex;
|
||||
/* 0x28CC */ s32 curAiBufferIndex;
|
||||
/* 0x28AC */ Acmd* abiCmdBufs[2]; // Pointer to audio heap where the audio binary interface command lists are stored. Two lists that alternative every frame
|
||||
/* 0x28B4 */ Acmd* curAbiCmdBuf;
|
||||
/* 0x28DC */ AudioTask* curTask;
|
||||
@@ -933,16 +962,16 @@ typedef struct {
|
||||
/* 0x2980 */ f32 unk_2960;
|
||||
/* 0x2984*/ s32 refreshRate;
|
||||
/* 0x2988 */ s16* aiBuffers[3]; // Pointers to the audio buffer allocated on the initPool contained in the audio heap. Stores fully processed digital audio before transferring to the audio interface (AI)
|
||||
/* 0x2994 */ s16 aiBufLengths[3]; // Number of bytes to transfer to the audio interface buffer
|
||||
/* 0x2994 */ s16 aiBufNumSamples[3]; // Number of samples to transfer to the audio interface buffer
|
||||
/* 0x299C */ u32 audioRandom;
|
||||
/* 0x29A0 */ s32 audioErrorFlags;
|
||||
/* 0x29A4 */ volatile u32 resetTimer;
|
||||
/* 0x29A8 */ u32 (*unk_29A8[4])(s8 value, SequenceChannel* channel);
|
||||
/* 0x29B8 */ s8 unk_29B8;
|
||||
/* 0x29BC */ s32 unk_29BC; // sMaxAbiCmdCnt
|
||||
/* 0x29C0 */ AudioAllocPool audioSessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset
|
||||
/* 0x29C0 */ AudioAllocPool sessionPool; // A sub-pool to main pool, contains all sub-pools and data that changes every audio reset
|
||||
/* 0x29D0 */ AudioAllocPool externalPool; // pool allocated on an external device. Never used in game
|
||||
/* 0x29E0 */ AudioAllocPool audioInitPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset
|
||||
/* 0x29E0 */ AudioAllocPool initPool; // A sub-pool to the main pool, contains all sub-pools and data that persists every audio reset
|
||||
/* 0x29F0 */ AudioAllocPool miscPool; // A sub-pool to the session pool,
|
||||
/* 0x2A00 */ char unk_29D0[0x20]; // probably two unused pools
|
||||
/* 0x2A20 */ AudioAllocPool cachePool; // The common pool for all cache entries
|
||||
@@ -978,7 +1007,7 @@ typedef struct {
|
||||
/* 0x7978 */ u8 cmdWritePos;
|
||||
/* 0x7979 */ u8 cmdReadPos;
|
||||
/* 0x797A */ u8 cmdQueueFinished;
|
||||
/* 0x797C */ u16 activeChannelsFlags[5]; // bitwise flag for 16 channels. Only channels with bit turned on will be processed
|
||||
/* 0x797C */ u16 activeChannelsFlags[5]; // bit-packed for 16 channels. Only channels with bit turned on will be processed
|
||||
/* 0x7988 */ OSMesgQueue* audioResetQueueP;
|
||||
/* 0x798C */ OSMesgQueue* taskStartQueueP;
|
||||
/* 0x7990 */ OSMesgQueue* cmdProcQueueP;
|
||||
@@ -1008,9 +1037,9 @@ typedef struct {
|
||||
|
||||
typedef struct {
|
||||
/* 0x0 */ size_t heapSize; // total number of bytes allocated to the audio heap. Must be <= the size of `gAudioHeap` (ideally about the same size)
|
||||
/* 0x4 */ size_t mainPoolSplitSize; // The entire audio heap is split into two pools.
|
||||
/* 0x4 */ size_t initPoolSize; // The entire audio heap is split into two pools.
|
||||
/* 0x8 */ size_t permanentPoolSize;
|
||||
} AudioContextInitSizes; // size = 0xC
|
||||
} AudioHeapInitSizes; // size = 0xC
|
||||
|
||||
typedef struct {
|
||||
/* 0x00 */ f32 unk_00;
|
||||
|
||||
@@ -63,7 +63,7 @@ void AudioEffects_SequencePlayerProcessSound(SequencePlayer* seqPlayer) {
|
||||
}
|
||||
|
||||
seqPlayer->fadeTimer--;
|
||||
if (seqPlayer->fadeTimer == 0 && seqPlayer->state == 2) {
|
||||
if ((seqPlayer->fadeTimer == 0) && (seqPlayer->state == SEQPLAYER_STATE_2)) {
|
||||
AudioSeq_SequencePlayerDisable(seqPlayer);
|
||||
return;
|
||||
}
|
||||
@@ -243,12 +243,10 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr) {
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_START_LOOP:
|
||||
adsr->envIndex = 0;
|
||||
adsr->action.s.state = ADSR_STATE_LOOP;
|
||||
// fallthrough
|
||||
|
||||
retry:
|
||||
case ADSR_STATE_LOOP:
|
||||
adsr->delay = adsr->envelope[adsr->envIndex].delay;
|
||||
@@ -256,18 +254,21 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr) {
|
||||
case ADSR_DISABLE:
|
||||
adsr->action.s.state = ADSR_STATE_DISABLED;
|
||||
break;
|
||||
|
||||
case ADSR_HANG:
|
||||
adsr->action.s.state = ADSR_STATE_HANG;
|
||||
break;
|
||||
|
||||
case ADSR_GOTO:
|
||||
adsr->envIndex = adsr->envelope[adsr->envIndex].arg;
|
||||
goto retry;
|
||||
|
||||
case ADSR_RESTART:
|
||||
adsr->action.s.state = ADSR_STATE_INITIAL;
|
||||
break;
|
||||
|
||||
default:
|
||||
adsr->delay *= gAudioContext.audioBufferParameters.unk_24;
|
||||
adsr->delay *= gAudioContext.audioBufferParameters.updatesPerFrameScaled;
|
||||
if (adsr->delay == 0) {
|
||||
adsr->delay = 1;
|
||||
}
|
||||
@@ -282,14 +283,13 @@ f32 AudioEffects_AdsrUpdate(AdsrState* adsr) {
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_FADE:
|
||||
adsr->current += adsr->velocity;
|
||||
if (--adsr->delay <= 0) {
|
||||
adsr->delay--;
|
||||
if (adsr->delay <= 0) {
|
||||
adsr->action.s.state = ADSR_STATE_LOOP;
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_HANG:
|
||||
break;
|
||||
|
||||
|
||||
+117
-112
@@ -4,7 +4,7 @@ void* AudioHeap_SearchRegularCaches(s32 tableType, s32 cache, s32 id);
|
||||
void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t temporarySampleCacheSize);
|
||||
SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size);
|
||||
void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry);
|
||||
void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample);
|
||||
void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, Sample* sample);
|
||||
SampleCacheEntry* AudioHeap_AllocPersistentSampleCacheEntry(size_t size);
|
||||
void AudioHeap_DiscardSampleCaches(void);
|
||||
void AudioHeap_DiscardSampleBank(s32 sampleBankId);
|
||||
@@ -14,29 +14,37 @@ void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags);
|
||||
|
||||
#define gTatumsPerBeat (gAudioTatumInit[1])
|
||||
|
||||
f32 func_8018B0F0(f32 arg0) {
|
||||
return 256.0f * gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled / arg0;
|
||||
/**
|
||||
* 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`
|
||||
*/
|
||||
f32 AudioHeap_CalculateAdsrDecay(f32 scaleInv) {
|
||||
return 256.0f * gAudioContext.audioBufferParameters.updatesPerFrameInvScaled / scaleInv;
|
||||
}
|
||||
|
||||
void func_8018B10C(void) {
|
||||
/**
|
||||
* Initialize the decay rate table used for decaying notes as part of adsr
|
||||
*/
|
||||
void AudioHeap_InitAdsrDecayTable(void) {
|
||||
s32 i;
|
||||
|
||||
gAudioContext.adsrDecayTable[255] = func_8018B0F0(0.25f);
|
||||
gAudioContext.adsrDecayTable[254] = func_8018B0F0(0.33f);
|
||||
gAudioContext.adsrDecayTable[253] = func_8018B0F0(0.5f);
|
||||
gAudioContext.adsrDecayTable[252] = func_8018B0F0(0.66f);
|
||||
gAudioContext.adsrDecayTable[251] = func_8018B0F0(0.75f);
|
||||
gAudioContext.adsrDecayTable[255] = AudioHeap_CalculateAdsrDecay(0.25f);
|
||||
gAudioContext.adsrDecayTable[254] = AudioHeap_CalculateAdsrDecay(0.33f);
|
||||
gAudioContext.adsrDecayTable[253] = AudioHeap_CalculateAdsrDecay(0.5f);
|
||||
gAudioContext.adsrDecayTable[252] = AudioHeap_CalculateAdsrDecay(0.66f);
|
||||
gAudioContext.adsrDecayTable[251] = AudioHeap_CalculateAdsrDecay(0.75f);
|
||||
|
||||
for (i = 128; i < 251; i++) {
|
||||
gAudioContext.adsrDecayTable[i] = func_8018B0F0(251 - i);
|
||||
gAudioContext.adsrDecayTable[i] = AudioHeap_CalculateAdsrDecay(251 - i);
|
||||
}
|
||||
|
||||
for (i = 16; i < 128; i++) {
|
||||
gAudioContext.adsrDecayTable[i] = func_8018B0F0(4 * (143 - i));
|
||||
gAudioContext.adsrDecayTable[i] = AudioHeap_CalculateAdsrDecay(4 * (143 - i));
|
||||
}
|
||||
|
||||
for (i = 1; i < 16; i++) {
|
||||
gAudioContext.adsrDecayTable[i] = func_8018B0F0(60 * (23 - i));
|
||||
gAudioContext.adsrDecayTable[i] = AudioHeap_CalculateAdsrDecay(60 * (23 - i));
|
||||
}
|
||||
|
||||
gAudioContext.adsrDecayTable[0] = 0.0f;
|
||||
@@ -71,7 +79,7 @@ void AudioHeap_DiscardFont(s32 fontId) {
|
||||
Note* note = &gAudioContext.notes[i];
|
||||
|
||||
if (note->playbackState.fontId == fontId) {
|
||||
if ((note->playbackState.unk_04 == 0) && (note->playbackState.priority != 0)) {
|
||||
if ((note->playbackState.status == PLAYBACK_STATUS_0) && (note->playbackState.priority != 0)) {
|
||||
note->playbackState.parentLayer->enabled = false;
|
||||
note->playbackState.parentLayer->finished = true;
|
||||
}
|
||||
@@ -233,19 +241,19 @@ void* AudioHeap_Alloc(AudioAllocPool* pool, size_t size) {
|
||||
* Initialize a pool at the requested address with the requested size.
|
||||
* Store the metadata of this pool in AudioAllocPool* pool
|
||||
*/
|
||||
void AudioHeap_AllocPoolInit(AudioAllocPool* pool, void* addr, size_t size) {
|
||||
void AudioHeap_InitPool(AudioAllocPool* pool, void* addr, size_t size) {
|
||||
pool->curAddr = pool->startAddr = (u8*)ALIGN16((uintptr_t)addr);
|
||||
pool->size = size - ((uintptr_t)addr & 0xF);
|
||||
pool->count = 0;
|
||||
}
|
||||
|
||||
void AudioHeap_ClearPersistentCache(AudioPersistentCache* persistent) {
|
||||
void AudioHeap_InitPersistentCache(AudioPersistentCache* persistent) {
|
||||
persistent->pool.count = 0;
|
||||
persistent->numEntries = 0;
|
||||
persistent->pool.curAddr = persistent->pool.startAddr;
|
||||
}
|
||||
|
||||
void AudioHeap_ClearTemporaryCache(AudioTemporaryCache* temporary) {
|
||||
void AudioHeap_InitTemporaryCache(AudioTemporaryCache* temporary) {
|
||||
temporary->pool.count = 0;
|
||||
temporary->pool.curAddr = temporary->pool.startAddr;
|
||||
temporary->nextSide = 0;
|
||||
@@ -260,7 +268,7 @@ void AudioHeap_ResetPool(AudioAllocPool* pool) {
|
||||
pool->curAddr = pool->startAddr;
|
||||
}
|
||||
|
||||
void AudioHeap_PopCache(s32 tableType) {
|
||||
void AudioHeap_PopPersistentCache(s32 tableType) {
|
||||
AudioCache* loadedCache;
|
||||
AudioAllocPool* persistentHeap;
|
||||
AudioPersistentCache* persistent;
|
||||
@@ -306,69 +314,65 @@ void AudioHeap_PopCache(s32 tableType) {
|
||||
persistent->numEntries--;
|
||||
}
|
||||
|
||||
void AudioHeap_InitMainPool(size_t mainPoolSplitSize) {
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.audioInitPool, gAudioContext.audioHeap, mainPoolSplitSize);
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.audioSessionPool, gAudioContext.audioHeap + mainPoolSplitSize,
|
||||
gAudioContext.audioHeapSize - mainPoolSplitSize);
|
||||
void AudioHeap_InitMainPool(size_t initPoolSize) {
|
||||
AudioHeap_InitPool(&gAudioContext.initPool, gAudioContext.audioHeap, initPoolSize);
|
||||
AudioHeap_InitPool(&gAudioContext.sessionPool, gAudioContext.audioHeap + initPoolSize,
|
||||
gAudioContext.audioHeapSize - initPoolSize);
|
||||
|
||||
gAudioContext.externalPool.startAddr = NULL;
|
||||
}
|
||||
|
||||
void AudioHeap_InitSessionPool(AudioSessionPoolSplit* split) {
|
||||
gAudioContext.audioSessionPool.curAddr = gAudioContext.audioSessionPool.startAddr;
|
||||
gAudioContext.sessionPool.curAddr = gAudioContext.sessionPool.startAddr;
|
||||
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.miscPool,
|
||||
AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->miscPoolSize), split->miscPoolSize);
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.cachePool,
|
||||
AudioHeap_Alloc(&gAudioContext.audioSessionPool, split->cachePoolSize),
|
||||
split->cachePoolSize);
|
||||
AudioHeap_InitPool(&gAudioContext.miscPool, AudioHeap_Alloc(&gAudioContext.sessionPool, split->miscPoolSize),
|
||||
split->miscPoolSize);
|
||||
AudioHeap_InitPool(&gAudioContext.cachePool, AudioHeap_Alloc(&gAudioContext.sessionPool, split->cachePoolSize),
|
||||
split->cachePoolSize);
|
||||
}
|
||||
|
||||
void AudioHeap_InitCachePool(AudioCachePoolSplit* split) {
|
||||
gAudioContext.cachePool.curAddr = gAudioContext.cachePool.startAddr;
|
||||
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.persistentCommonPool,
|
||||
AudioHeap_Alloc(&gAudioContext.cachePool, split->persistentCommonPoolSize),
|
||||
split->persistentCommonPoolSize);
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.temporaryCommonPool,
|
||||
AudioHeap_Alloc(&gAudioContext.cachePool, split->temporaryCommonPoolSize),
|
||||
split->temporaryCommonPoolSize);
|
||||
AudioHeap_InitPool(&gAudioContext.persistentCommonPool,
|
||||
AudioHeap_Alloc(&gAudioContext.cachePool, split->persistentCommonPoolSize),
|
||||
split->persistentCommonPoolSize);
|
||||
AudioHeap_InitPool(&gAudioContext.temporaryCommonPool,
|
||||
AudioHeap_Alloc(&gAudioContext.cachePool, split->temporaryCommonPoolSize),
|
||||
split->temporaryCommonPoolSize);
|
||||
}
|
||||
|
||||
void AudioHeap_InitPersistentCache(AudioCommonPoolSplit* split) {
|
||||
void AudioHeap_InitPersistentPoolsAndCaches(AudioCommonPoolSplit* split) {
|
||||
gAudioContext.persistentCommonPool.curAddr = gAudioContext.persistentCommonPool.startAddr;
|
||||
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.seqCache.persistent.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->seqCacheSize),
|
||||
split->seqCacheSize);
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.fontCache.persistent.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->fontCacheSize),
|
||||
split->fontCacheSize);
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.persistent.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->sampleBankCacheSize),
|
||||
split->sampleBankCacheSize);
|
||||
AudioHeap_InitPool(&gAudioContext.seqCache.persistent.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->seqCacheSize), split->seqCacheSize);
|
||||
AudioHeap_InitPool(&gAudioContext.fontCache.persistent.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->fontCacheSize),
|
||||
split->fontCacheSize);
|
||||
AudioHeap_InitPool(&gAudioContext.sampleBankCache.persistent.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.persistentCommonPool, split->sampleBankCacheSize),
|
||||
split->sampleBankCacheSize);
|
||||
|
||||
AudioHeap_ClearPersistentCache(&gAudioContext.seqCache.persistent);
|
||||
AudioHeap_ClearPersistentCache(&gAudioContext.fontCache.persistent);
|
||||
AudioHeap_ClearPersistentCache(&gAudioContext.sampleBankCache.persistent);
|
||||
AudioHeap_InitPersistentCache(&gAudioContext.seqCache.persistent);
|
||||
AudioHeap_InitPersistentCache(&gAudioContext.fontCache.persistent);
|
||||
AudioHeap_InitPersistentCache(&gAudioContext.sampleBankCache.persistent);
|
||||
}
|
||||
|
||||
void AudioHeap_InitTemporaryCache(AudioCommonPoolSplit* split) {
|
||||
void AudioHeap_InitTemporaryPoolsAndCaches(AudioCommonPoolSplit* split) {
|
||||
gAudioContext.temporaryCommonPool.curAddr = gAudioContext.temporaryCommonPool.startAddr;
|
||||
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.seqCache.temporary.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->seqCacheSize),
|
||||
split->seqCacheSize);
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.fontCache.temporary.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->fontCacheSize),
|
||||
split->fontCacheSize);
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.sampleBankCache.temporary.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->sampleBankCacheSize),
|
||||
split->sampleBankCacheSize);
|
||||
AudioHeap_InitPool(&gAudioContext.seqCache.temporary.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->seqCacheSize), split->seqCacheSize);
|
||||
AudioHeap_InitPool(&gAudioContext.fontCache.temporary.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->fontCacheSize), split->fontCacheSize);
|
||||
AudioHeap_InitPool(&gAudioContext.sampleBankCache.temporary.pool,
|
||||
AudioHeap_Alloc(&gAudioContext.temporaryCommonPool, split->sampleBankCacheSize),
|
||||
split->sampleBankCacheSize);
|
||||
|
||||
AudioHeap_ClearTemporaryCache(&gAudioContext.seqCache.temporary);
|
||||
AudioHeap_ClearTemporaryCache(&gAudioContext.fontCache.temporary);
|
||||
AudioHeap_ClearTemporaryCache(&gAudioContext.sampleBankCache.temporary);
|
||||
AudioHeap_InitTemporaryCache(&gAudioContext.seqCache.temporary);
|
||||
AudioHeap_InitTemporaryCache(&gAudioContext.fontCache.temporary);
|
||||
AudioHeap_InitTemporaryCache(&gAudioContext.sampleBankCache.temporary);
|
||||
}
|
||||
|
||||
void* AudioHeap_AllocCached(s32 tableType, size_t size, s32 cache, s32 id) {
|
||||
@@ -764,7 +768,7 @@ void AudioHeap_LoadFilter(s16* filter, s32 lowPassCutoff, s32 highPassCutoff) {
|
||||
s32 cutOff;
|
||||
|
||||
//! @bug filter is never set if (lowPassCutoff == highPassCutoff) and does not equal 0
|
||||
if (lowPassCutoff == 0 && highPassCutoff == 0) {
|
||||
if ((lowPassCutoff == 0) && (highPassCutoff == 0)) {
|
||||
// Identity filter
|
||||
AudioHeap_LoadLowPassFilter(filter, 0);
|
||||
} else if (highPassCutoff == 0) {
|
||||
@@ -830,13 +834,13 @@ void AudioHeap_UpdateReverbs(void) {
|
||||
* Clear the Audio Interface Buffers
|
||||
*/
|
||||
void AudioHeap_ClearAiBuffers(void) {
|
||||
s32 curAiBuffferIndex = gAudioContext.curAiBuffferIndex;
|
||||
s32 curAiBufferIndex = gAudioContext.curAiBufferIndex;
|
||||
s32 i;
|
||||
|
||||
gAudioContext.aiBufLengths[curAiBuffferIndex] = gAudioContext.audioBufferParameters.minAiBufferLength;
|
||||
gAudioContext.aiBufNumSamples[curAiBufferIndex] = gAudioContext.audioBufferParameters.minAiBufNumSamples;
|
||||
|
||||
for (i = 0; i < AIBUF_LEN; i++) {
|
||||
gAudioContext.aiBuffers[curAiBuffferIndex][i] = 0;
|
||||
gAudioContext.aiBuffers[curAiBufferIndex][i] = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -902,8 +906,8 @@ s32 AudioHeap_ResetStep(void) {
|
||||
case 1:
|
||||
AudioHeap_Init();
|
||||
gAudioContext.resetStatus = 0;
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufLengths); i++) {
|
||||
gAudioContext.aiBufLengths[i] = gAudioContext.audioBufferParameters.maxAiBufferLength;
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioContext.aiBufNumSamples); i++) {
|
||||
gAudioContext.aiBufNumSamples[i] = gAudioContext.audioBufferParameters.maxAiBufNumSamples;
|
||||
for (j = 0; j < AIBUF_LEN; j++) {
|
||||
gAudioContext.aiBuffers[i][j] = 0;
|
||||
}
|
||||
@@ -940,9 +944,9 @@ void AudioHeap_Init(void) {
|
||||
|
||||
gAudioContext.audioBufferParameters.samplesPerFrameTarget =
|
||||
ALIGN16(gAudioContext.audioBufferParameters.samplingFreq / gAudioContext.refreshRate);
|
||||
gAudioContext.audioBufferParameters.minAiBufferLength =
|
||||
gAudioContext.audioBufferParameters.minAiBufNumSamples =
|
||||
gAudioContext.audioBufferParameters.samplesPerFrameTarget - 0x10;
|
||||
gAudioContext.audioBufferParameters.maxAiBufferLength =
|
||||
gAudioContext.audioBufferParameters.maxAiBufNumSamples =
|
||||
gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10;
|
||||
gAudioContext.audioBufferParameters.updatesPerFrame =
|
||||
((gAudioContext.audioBufferParameters.samplesPerFrameTarget + 0x10) / 0xD0) + 1;
|
||||
@@ -952,9 +956,10 @@ void AudioHeap_Init(void) {
|
||||
gAudioContext.audioBufferParameters.samplesPerUpdateMax = gAudioContext.audioBufferParameters.samplesPerUpdate + 8;
|
||||
gAudioContext.audioBufferParameters.samplesPerUpdateMin = gAudioContext.audioBufferParameters.samplesPerUpdate - 8;
|
||||
gAudioContext.audioBufferParameters.resampleRate = 32000.0f / (s32)gAudioContext.audioBufferParameters.samplingFreq;
|
||||
gAudioContext.audioBufferParameters.unkUpdatesPerFrameScaled =
|
||||
gAudioContext.audioBufferParameters.updatesPerFrameInvScaled =
|
||||
(1.0f / 256.0f) / gAudioContext.audioBufferParameters.updatesPerFrame;
|
||||
gAudioContext.audioBufferParameters.unk_24 = gAudioContext.audioBufferParameters.updatesPerFrame * 0.25f;
|
||||
gAudioContext.audioBufferParameters.updatesPerFrameScaled =
|
||||
gAudioContext.audioBufferParameters.updatesPerFrame / 4.0f;
|
||||
gAudioContext.audioBufferParameters.updatesPerFrameInv = 1.0f / gAudioContext.audioBufferParameters.updatesPerFrame;
|
||||
|
||||
// sample dma size
|
||||
@@ -980,12 +985,12 @@ void AudioHeap_Init(void) {
|
||||
|
||||
gAudioContext.audioBufferParameters.specUnk4 = spec->unk_04;
|
||||
gAudioContext.audioBufferParameters.samplesPerFrameTarget *= gAudioContext.audioBufferParameters.specUnk4;
|
||||
gAudioContext.audioBufferParameters.maxAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4;
|
||||
gAudioContext.audioBufferParameters.minAiBufferLength *= gAudioContext.audioBufferParameters.specUnk4;
|
||||
gAudioContext.audioBufferParameters.maxAiBufNumSamples *= gAudioContext.audioBufferParameters.specUnk4;
|
||||
gAudioContext.audioBufferParameters.minAiBufNumSamples *= gAudioContext.audioBufferParameters.specUnk4;
|
||||
gAudioContext.audioBufferParameters.updatesPerFrame *= gAudioContext.audioBufferParameters.specUnk4;
|
||||
|
||||
if (gAudioContext.audioBufferParameters.specUnk4 >= 2) {
|
||||
gAudioContext.audioBufferParameters.maxAiBufferLength -= 0x10;
|
||||
gAudioContext.audioBufferParameters.maxAiBufNumSamples -= 0x10;
|
||||
}
|
||||
|
||||
// Determine the maximum allowable number of audio command list entries for the rsp microcode
|
||||
@@ -998,7 +1003,7 @@ void AudioHeap_Init(void) {
|
||||
temporarySize =
|
||||
spec->temporarySeqCacheSize + spec->temporaryFontCacheSize + spec->temporarySampleBankCacheSize + 0x10;
|
||||
cachePoolSize = persistentSize + temporarySize;
|
||||
miscPoolSize = gAudioContext.audioSessionPool.size - cachePoolSize - 0x100;
|
||||
miscPoolSize = gAudioContext.sessionPool.size - cachePoolSize - 0x100;
|
||||
|
||||
if (gAudioContext.externalPool.startAddr != NULL) {
|
||||
gAudioContext.externalPool.curAddr = gAudioContext.externalPool.startAddr;
|
||||
@@ -1018,13 +1023,13 @@ void AudioHeap_Init(void) {
|
||||
gAudioContext.persistentCommonPoolSplit.seqCacheSize = spec->persistentSeqCacheSize;
|
||||
gAudioContext.persistentCommonPoolSplit.fontCacheSize = spec->persistentFontCacheSize;
|
||||
gAudioContext.persistentCommonPoolSplit.sampleBankCacheSize = spec->persistentSampleBankCacheSize;
|
||||
AudioHeap_InitPersistentCache(&gAudioContext.persistentCommonPoolSplit);
|
||||
AudioHeap_InitPersistentPoolsAndCaches(&gAudioContext.persistentCommonPoolSplit);
|
||||
|
||||
// Temporary Pool Split (Split into Sequences, SoundFonts, Samples)
|
||||
gAudioContext.temporaryCommonPoolSplit.seqCacheSize = spec->temporarySeqCacheSize;
|
||||
gAudioContext.temporaryCommonPoolSplit.fontCacheSize = spec->temporaryFontCacheSize;
|
||||
gAudioContext.temporaryCommonPoolSplit.sampleBankCacheSize = spec->temporarySampleBankCacheSize;
|
||||
AudioHeap_InitTemporaryCache(&gAudioContext.temporaryCommonPoolSplit);
|
||||
AudioHeap_InitTemporaryPoolsAndCaches(&gAudioContext.temporaryCommonPoolSplit);
|
||||
|
||||
AudioHeap_ResetLoadStatus();
|
||||
|
||||
@@ -1039,12 +1044,12 @@ void AudioHeap_Init(void) {
|
||||
// Initialize audio binary interface command list buffer
|
||||
for (j = 0; j < ARRAY_COUNT(gAudioContext.abiCmdBufs); j++) {
|
||||
gAudioContext.abiCmdBufs[j] =
|
||||
AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(u64));
|
||||
AudioHeap_AllocDmaMemoryZeroed(&gAudioContext.miscPool, gAudioContext.maxAudioCmds * sizeof(Acmd));
|
||||
}
|
||||
|
||||
// Initialize adsrDecayTable (fadeOutVelocities for ADSR)
|
||||
// Initialize the decay rate table for ADSR
|
||||
gAudioContext.adsrDecayTable = AudioHeap_Alloc(&gAudioContext.miscPool, 0x100 * sizeof(f32));
|
||||
func_8018B10C();
|
||||
AudioHeap_InitAdsrDecayTable();
|
||||
|
||||
// Initialize reverbs
|
||||
for (i = 0; i < ARRAY_COUNT(gAudioContext.synthesisReverbs); i++) {
|
||||
@@ -1139,14 +1144,14 @@ void AudioHeap_InitSampleCaches(size_t persistentSampleCacheSize, size_t tempora
|
||||
if (addr == NULL) {
|
||||
gAudioContext.persistentSampleCache.pool.size = 0;
|
||||
} else {
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.persistentSampleCache.pool, addr, persistentSampleCacheSize);
|
||||
AudioHeap_InitPool(&gAudioContext.persistentSampleCache.pool, addr, persistentSampleCacheSize);
|
||||
}
|
||||
|
||||
addr = AudioHeap_AllocAttemptExternal(&gAudioContext.miscPool, temporarySampleCacheSize);
|
||||
if (addr == NULL) {
|
||||
gAudioContext.temporarySampleCache.pool.size = 0;
|
||||
} else {
|
||||
AudioHeap_AllocPoolInit(&gAudioContext.temporarySampleCache.pool, addr, temporarySampleCacheSize);
|
||||
AudioHeap_InitPool(&gAudioContext.temporarySampleCache.pool, addr, temporarySampleCacheSize);
|
||||
}
|
||||
|
||||
gAudioContext.persistentSampleCache.numEntries = 0;
|
||||
@@ -1257,35 +1262,35 @@ SampleCacheEntry* AudioHeap_AllocTemporarySampleCacheEntry(size_t size) {
|
||||
void AudioHeap_UnapplySampleCacheForFont(SampleCacheEntry* entry, s32 fontId) {
|
||||
Drum* drum;
|
||||
Instrument* inst;
|
||||
SoundFontSound* sfx;
|
||||
SoundEffect* soundEffect;
|
||||
s32 instId;
|
||||
s32 drumId;
|
||||
s32 sfxId;
|
||||
|
||||
for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) {
|
||||
for (instId = 0; instId < gAudioContext.soundFontList[fontId].numInstruments; instId++) {
|
||||
inst = AudioPlayback_GetInstrumentInner(fontId, instId);
|
||||
if (inst != NULL) {
|
||||
if (inst->normalRangeLo != 0) {
|
||||
AudioHeap_UnapplySampleCache(entry, inst->lowNotesSound.sample);
|
||||
AudioHeap_UnapplySampleCache(entry, inst->lowPitchTunedSample.sample);
|
||||
}
|
||||
if (inst->normalRangeHi != 0x7F) {
|
||||
AudioHeap_UnapplySampleCache(entry, inst->highNotesSound.sample);
|
||||
AudioHeap_UnapplySampleCache(entry, inst->highPitchTunedSample.sample);
|
||||
}
|
||||
AudioHeap_UnapplySampleCache(entry, inst->normalNotesSound.sample);
|
||||
AudioHeap_UnapplySampleCache(entry, inst->normalPitchTunedSample.sample);
|
||||
}
|
||||
}
|
||||
|
||||
for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) {
|
||||
for (drumId = 0; drumId < gAudioContext.soundFontList[fontId].numDrums; drumId++) {
|
||||
drum = AudioPlayback_GetDrum(fontId, drumId);
|
||||
if (drum != NULL) {
|
||||
AudioHeap_UnapplySampleCache(entry, drum->sound.sample);
|
||||
AudioHeap_UnapplySampleCache(entry, drum->tunedSample.sample);
|
||||
}
|
||||
}
|
||||
|
||||
for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) {
|
||||
sfx = AudioPlayback_GetSfx(fontId, sfxId);
|
||||
if (sfx != NULL) {
|
||||
AudioHeap_UnapplySampleCache(entry, sfx->sample);
|
||||
for (sfxId = 0; sfxId < gAudioContext.soundFontList[fontId].numSfx; sfxId++) {
|
||||
soundEffect = AudioPlayback_GetSoundEffect(fontId, sfxId);
|
||||
if (soundEffect != NULL) {
|
||||
AudioHeap_UnapplySampleCache(entry, soundEffect->tunedSample.sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1298,8 +1303,8 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) {
|
||||
|
||||
numFonts = gAudioContext.soundFontTable->numEntries;
|
||||
for (fontId = 0; fontId < numFonts; fontId++) {
|
||||
sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1;
|
||||
sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2;
|
||||
sampleBankId1 = gAudioContext.soundFontList[fontId].sampleBankId1;
|
||||
sampleBankId2 = gAudioContext.soundFontList[fontId].sampleBankId2;
|
||||
if (((sampleBankId1 != 0xFF) && (entry->sampleBankId == sampleBankId1)) ||
|
||||
((sampleBankId2 != 0xFF) && (entry->sampleBankId == sampleBankId2)) || entry->sampleBankId == 0 ||
|
||||
entry->sampleBankId == 0xFE) {
|
||||
@@ -1313,7 +1318,7 @@ void AudioHeap_DiscardSampleCacheEntry(SampleCacheEntry* entry) {
|
||||
}
|
||||
}
|
||||
|
||||
void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, SoundFontSample* sample) {
|
||||
void AudioHeap_UnapplySampleCache(SampleCacheEntry* entry, Sample* sample) {
|
||||
if (sample != NULL) {
|
||||
if (sample->sampleAddr == entry->allocatedAddr) {
|
||||
sample->sampleAddr = entry->sampleAddr;
|
||||
@@ -1362,8 +1367,8 @@ void AudioHeap_DiscardSampleCaches(void) {
|
||||
|
||||
numFonts = gAudioContext.soundFontTable->numEntries;
|
||||
for (fontId = 0; fontId < numFonts; fontId++) {
|
||||
sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1;
|
||||
sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2;
|
||||
sampleBankId1 = gAudioContext.soundFontList[fontId].sampleBankId1;
|
||||
sampleBankId2 = gAudioContext.soundFontList[fontId].sampleBankId2;
|
||||
if ((sampleBankId1 == 0xFF) && (sampleBankId2 == 0xFF)) {
|
||||
continue;
|
||||
}
|
||||
@@ -1390,7 +1395,7 @@ typedef struct {
|
||||
u8 newMedium;
|
||||
} StorageChange;
|
||||
|
||||
void AudioHeap_ChangeStorage(StorageChange* change, SoundFontSample* sample) {
|
||||
void AudioHeap_ChangeStorage(StorageChange* change, Sample* sample) {
|
||||
if (sample != NULL && ((sample->medium == change->newMedium) || (D_801FD120 != 1)) &&
|
||||
((sample->medium == MEDIUM_RAM) || (D_801FD120 != 0))) {
|
||||
uintptr_t startAddr = change->oldAddr;
|
||||
@@ -1430,7 +1435,7 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) {
|
||||
s32 fontId;
|
||||
Drum* drum;
|
||||
Instrument* inst;
|
||||
SoundFontSound* sfx;
|
||||
SoundEffect* soundEffect;
|
||||
uintptr_t* newAddr;
|
||||
s32 pad[4];
|
||||
|
||||
@@ -1457,8 +1462,8 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) {
|
||||
}
|
||||
|
||||
for (fontId = 0; fontId < numFonts; fontId++) {
|
||||
sampleBankId1 = gAudioContext.soundFonts[fontId].sampleBankId1;
|
||||
sampleBankId2 = gAudioContext.soundFonts[fontId].sampleBankId2;
|
||||
sampleBankId1 = gAudioContext.soundFontList[fontId].sampleBankId1;
|
||||
sampleBankId2 = gAudioContext.soundFontList[fontId].sampleBankId2;
|
||||
if ((sampleBankId1 != 0xFF) || (sampleBankId2 != 0xFF)) {
|
||||
if (!AudioLoad_IsFontLoadComplete(fontId) ||
|
||||
AudioHeap_SearchCaches(FONT_TABLE, CACHE_EITHER, fontId) == NULL) {
|
||||
@@ -1471,30 +1476,30 @@ void AudioHeap_ApplySampleBankCacheInternal(s32 apply, s32 sampleBankId) {
|
||||
continue;
|
||||
}
|
||||
|
||||
for (instId = 0; instId < gAudioContext.soundFonts[fontId].numInstruments; instId++) {
|
||||
for (instId = 0; instId < gAudioContext.soundFontList[fontId].numInstruments; instId++) {
|
||||
inst = AudioPlayback_GetInstrumentInner(fontId, instId);
|
||||
if (inst != NULL) {
|
||||
if (inst->normalRangeLo != 0) {
|
||||
AudioHeap_ChangeStorage(&change, inst->lowNotesSound.sample);
|
||||
AudioHeap_ChangeStorage(&change, inst->lowPitchTunedSample.sample);
|
||||
}
|
||||
if (inst->normalRangeHi != 0x7F) {
|
||||
AudioHeap_ChangeStorage(&change, inst->highNotesSound.sample);
|
||||
AudioHeap_ChangeStorage(&change, inst->highPitchTunedSample.sample);
|
||||
}
|
||||
AudioHeap_ChangeStorage(&change, inst->normalNotesSound.sample);
|
||||
AudioHeap_ChangeStorage(&change, inst->normalPitchTunedSample.sample);
|
||||
}
|
||||
}
|
||||
|
||||
for (drumId = 0; drumId < gAudioContext.soundFonts[fontId].numDrums; drumId++) {
|
||||
for (drumId = 0; drumId < gAudioContext.soundFontList[fontId].numDrums; drumId++) {
|
||||
drum = AudioPlayback_GetDrum(fontId, drumId);
|
||||
if (drum != NULL) {
|
||||
AudioHeap_ChangeStorage(&change, drum->sound.sample);
|
||||
AudioHeap_ChangeStorage(&change, drum->tunedSample.sample);
|
||||
}
|
||||
}
|
||||
|
||||
for (sfxId = 0; sfxId < gAudioContext.soundFonts[fontId].numSfx; sfxId++) {
|
||||
sfx = AudioPlayback_GetSfx(fontId, sfxId);
|
||||
if (sfx != NULL) {
|
||||
AudioHeap_ChangeStorage(&change, sfx->sample);
|
||||
for (sfxId = 0; sfxId < gAudioContext.soundFontList[fontId].numSfx; sfxId++) {
|
||||
soundEffect = AudioPlayback_GetSoundEffect(fontId, sfxId);
|
||||
if (soundEffect != NULL) {
|
||||
AudioHeap_ChangeStorage(&change, soundEffect->tunedSample.sample);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1671,9 +1676,9 @@ void AudioHeap_InitReverb(s32 reverbIndex, ReverbSettings* settings, s32 flags)
|
||||
reverb->framesToIgnore = 2;
|
||||
}
|
||||
|
||||
reverb->sound.sample = &reverb->sample;
|
||||
reverb->tunedSample.sample = &reverb->sample;
|
||||
reverb->sample.loop = &reverb->loop;
|
||||
reverb->sound.tuning = 1.0f;
|
||||
reverb->tunedSample.tuning = 1.0f;
|
||||
reverb->sample.codec = CODEC_REVERB;
|
||||
reverb->sample.medium = MEDIUM_RAM;
|
||||
reverb->sample.size = reverb->windowSize * 2;
|
||||
|
||||
@@ -5,8 +5,8 @@ const s16 gAudioTatumInit[] = {
|
||||
0x30, // gTatumsPerBeat
|
||||
};
|
||||
|
||||
const AudioContextInitSizes gAudioContextInitSizes = {
|
||||
const AudioHeapInitSizes gAudioHeapInitSizes = {
|
||||
0x137F00, // heapSize
|
||||
0x1C480, // mainPoolSplitSize
|
||||
0x1C480, // initPoolSize
|
||||
0x1A000, // permanentPoolSize
|
||||
};
|
||||
|
||||
+265
-184
File diff suppressed because it is too large
Load Diff
+156
-136
File diff suppressed because it is too large
Load Diff
@@ -33,7 +33,7 @@ u8 AudioSeq_ScriptReadU8(SeqScriptState* state);
|
||||
s16 AudioSeq_ScriptReadS16(SeqScriptState* state);
|
||||
u16 AudioSeq_ScriptReadCompressedU16(SeqScriptState* state);
|
||||
void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer);
|
||||
s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameSound);
|
||||
s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSample);
|
||||
s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer);
|
||||
s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd);
|
||||
s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd);
|
||||
@@ -320,7 +320,7 @@ void AudioSeq_InitSequenceChannel(SequenceChannel* channel) {
|
||||
|
||||
channel->unused = false;
|
||||
AudioPlayback_InitNoteLists(&channel->notePool);
|
||||
channel->unk_DC = 0;
|
||||
channel->startSamplePos = 0;
|
||||
channel->unk_E0 = 0;
|
||||
channel->sfxState = NULL;
|
||||
}
|
||||
@@ -582,7 +582,7 @@ void AudioSeq_SeqLayerProcessScript(SequenceLayer* layer) {
|
||||
} while ((cmd == -1) && (layer->delay == 0));
|
||||
|
||||
if (cmd != PROCESS_SCRIPT_END) {
|
||||
// returns `sameSound` instead of a command
|
||||
// returns `sameTunedSample` instead of a command
|
||||
cmd = AudioSeq_SeqLayerProcessScriptStep4(layer, cmd);
|
||||
}
|
||||
|
||||
@@ -611,20 +611,20 @@ void AudioSeq_SeqLayerProcessScriptStep1(SequenceLayer* layer) {
|
||||
layer->notePropertiesNeedInit = true;
|
||||
}
|
||||
|
||||
s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameSound) {
|
||||
s32 AudioSeq_SeqLayerProcessScriptStep5(SequenceLayer* layer, s32 sameTunedSample) {
|
||||
Note* note;
|
||||
|
||||
if ((layer->continuousNotes == true) && (layer->bit1 == true)) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if ((layer->continuousNotes == true) && (layer->note != NULL) && layer->bit3 && (sameSound == true) &&
|
||||
if ((layer->continuousNotes == true) && (layer->note != NULL) && layer->bit3 && (sameTunedSample == true) &&
|
||||
(layer->note->playbackState.parentLayer == layer)) {
|
||||
if (layer->sound == NULL) {
|
||||
if (layer->tunedSample == NULL) {
|
||||
AudioPlayback_InitSyntheticWave(layer->note, layer);
|
||||
}
|
||||
} else {
|
||||
if (!sameSound) {
|
||||
if (!sameTunedSample) {
|
||||
AudioPlayback_SeqLayerNoteDecay(layer);
|
||||
}
|
||||
|
||||
@@ -815,7 +815,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep2(SequenceLayer* layer) {
|
||||
}
|
||||
|
||||
s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
s32 sameSound = true;
|
||||
s32 sameTunedSample = true;
|
||||
s32 instOrWave;
|
||||
s32 speed;
|
||||
f32 temp_f14;
|
||||
@@ -823,10 +823,10 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
Portamento* portamento;
|
||||
f32 freqScale;
|
||||
f32 freqScale2;
|
||||
SoundFontSound* sound;
|
||||
TunedSample* tunedSample;
|
||||
Instrument* instrument;
|
||||
Drum* drum;
|
||||
s32 pad;
|
||||
SoundEffect* soundEffect;
|
||||
SequenceChannel* channel;
|
||||
SequencePlayer* seqPlayer;
|
||||
u8 semitone = cmd;
|
||||
@@ -861,15 +861,15 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
sound = &drum->sound;
|
||||
tunedSample = &drum->tunedSample;
|
||||
layer->adsr.envelope = drum->envelope;
|
||||
layer->adsr.decayIndex = drum->adsrDecayIndex;
|
||||
if (!layer->ignoreDrumPan) {
|
||||
layer->pan = drum->pan;
|
||||
}
|
||||
|
||||
layer->sound = sound;
|
||||
layer->freqScale = sound->tuning;
|
||||
layer->tunedSample = tunedSample;
|
||||
layer->freqScale = tunedSample->tuning;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
@@ -877,15 +877,16 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
layer->semitone = semitone;
|
||||
sfxId = (layer->transposition << 6) + semitone;
|
||||
|
||||
sound = AudioPlayback_GetSfx(channel->fontId, sfxId);
|
||||
if (sound == NULL) {
|
||||
soundEffect = AudioPlayback_GetSoundEffect(channel->fontId, sfxId);
|
||||
if (soundEffect == NULL) {
|
||||
layer->stopSomething = true;
|
||||
layer->delay2 = layer->delay + 1;
|
||||
return PROCESS_SCRIPT_END;
|
||||
}
|
||||
|
||||
layer->sound = sound;
|
||||
layer->freqScale = sound->tuning;
|
||||
tunedSample = &soundEffect->tunedSample;
|
||||
layer->tunedSample = tunedSample;
|
||||
layer->freqScale = tunedSample->tuning;
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -909,15 +910,15 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
vel = (semitone > layer->portamentoTargetNote) ? semitone : layer->portamentoTargetNote;
|
||||
|
||||
if (instrument != NULL) {
|
||||
sound = AudioPlayback_InstrumentGetSound(instrument, vel);
|
||||
sameSound = (layer->sound == sound);
|
||||
layer->sound = sound;
|
||||
tuning = sound->tuning;
|
||||
tunedSample = AudioPlayback_GetInstrumentTunedSample(instrument, vel);
|
||||
sameTunedSample = (layer->tunedSample == tunedSample);
|
||||
layer->tunedSample = tunedSample;
|
||||
tuning = tunedSample->tuning;
|
||||
} else {
|
||||
layer->sound = NULL;
|
||||
layer->tunedSample = NULL;
|
||||
tuning = 1.0f;
|
||||
if (instOrWave >= 0xC0) {
|
||||
layer->sound = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].sound;
|
||||
layer->tunedSample = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].tunedSample;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -971,15 +972,15 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
}
|
||||
|
||||
if (instrument != NULL) {
|
||||
sound = AudioPlayback_InstrumentGetSound(instrument, semitone);
|
||||
sameSound = (sound == layer->sound);
|
||||
layer->sound = sound;
|
||||
layer->freqScale = gPitchFrequencies[semitone2] * sound->tuning;
|
||||
tunedSample = AudioPlayback_GetInstrumentTunedSample(instrument, semitone);
|
||||
sameTunedSample = (tunedSample == layer->tunedSample);
|
||||
layer->tunedSample = tunedSample;
|
||||
layer->freqScale = gPitchFrequencies[semitone2] * tunedSample->tuning;
|
||||
} else {
|
||||
layer->sound = NULL;
|
||||
layer->tunedSample = NULL;
|
||||
layer->freqScale = gPitchFrequencies[semitone2];
|
||||
if (instOrWave >= 0xC0) {
|
||||
layer->sound = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].sound;
|
||||
layer->tunedSample = &gAudioContext.synthesisReverbs[instOrWave - 0xC0].tunedSample;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -989,8 +990,8 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
layer->freqScale *= layer->bend;
|
||||
|
||||
if (layer->delay == 0) {
|
||||
if (layer->sound != NULL) {
|
||||
time = layer->sound->sample->loop->end;
|
||||
if (layer->tunedSample != NULL) {
|
||||
time = layer->tunedSample->sample->loop->end;
|
||||
} else {
|
||||
time = 0.0f;
|
||||
}
|
||||
@@ -1020,7 +1021,7 @@ s32 AudioSeq_SeqLayerProcessScriptStep4(SequenceLayer* layer, s32 cmd) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return sameSound;
|
||||
return sameTunedSample;
|
||||
}
|
||||
|
||||
s32 AudioSeq_SeqLayerProcessScriptStep3(SequenceLayer* layer, s32 cmd) {
|
||||
@@ -1571,7 +1572,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
channel->unk_0F = 0;
|
||||
channel->unk_20 = 0;
|
||||
channel->bookOffset = 0;
|
||||
channel->unk_DC = 0;
|
||||
channel->startSamplePos = 0;
|
||||
channel->unk_E0 = 0;
|
||||
channel->freqScale = 1.0f;
|
||||
break;
|
||||
@@ -1659,7 +1660,7 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
break;
|
||||
|
||||
case 0xBD: // channel:
|
||||
channel->unk_DC = cmdArgs[0];
|
||||
channel->startSamplePos = cmdArgs[0];
|
||||
break;
|
||||
|
||||
case 0xBE: // channel:
|
||||
@@ -1672,10 +1673,10 @@ void AudioSeq_SequenceChannelProcessScript(SequenceChannel* channel) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 0xA0: // channel:
|
||||
case 0xA1: // channel:
|
||||
case 0xA2: // channel:
|
||||
case 0xA3: // channel:
|
||||
case 0xA0: // channel: read from SfxChannelState using arg
|
||||
case 0xA1: // channel: read from SfxChannelState using unk_22
|
||||
case 0xA2: // channel: write to SfxChannelState using arg
|
||||
case 0xA3: // channel: write to SfxChannelState using unk_22
|
||||
if ((cmd == 0xA0) || (cmd == 0xA2)) {
|
||||
cmdArgU16 = (u16)cmdArgs[0];
|
||||
} else {
|
||||
@@ -1958,15 +1959,15 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
cmd = AudioSeq_ScriptReadU8(seqScript);
|
||||
temp = AudioSeq_ScriptReadS16(seqScript);
|
||||
switch (cmd) {
|
||||
case 0:
|
||||
case 1:
|
||||
if (seqPlayer->state != 2) {
|
||||
case SEQPLAYER_STATE_0:
|
||||
case SEQPLAYER_STATE_1:
|
||||
if (seqPlayer->state != SEQPLAYER_STATE_2) {
|
||||
seqPlayer->fadeTimerUnkEu = temp;
|
||||
seqPlayer->state = cmd;
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case SEQPLAYER_STATE_2:
|
||||
seqPlayer->fadeTimer = temp;
|
||||
seqPlayer->state = cmd;
|
||||
seqPlayer->fadeVelocity = (0.0f - seqPlayer->fadeVolume) / (s32)seqPlayer->fadeTimer;
|
||||
@@ -1977,11 +1978,11 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
case 0xDB: // seqPlayer: set volume
|
||||
value = AudioSeq_ScriptReadU8(seqScript);
|
||||
switch (seqPlayer->state) {
|
||||
case 1:
|
||||
seqPlayer->state = 0;
|
||||
case SEQPLAYER_STATE_1:
|
||||
seqPlayer->state = SEQPLAYER_STATE_0;
|
||||
seqPlayer->fadeVolume = 0.0f;
|
||||
// fallthrough
|
||||
case 0:
|
||||
case SEQPLAYER_STATE_0:
|
||||
seqPlayer->fadeTimer = seqPlayer->fadeTimerUnkEu;
|
||||
if (seqPlayer->fadeTimerUnkEu != 0) {
|
||||
seqPlayer->fadeVelocity =
|
||||
@@ -1991,7 +1992,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
}
|
||||
break;
|
||||
|
||||
case 2:
|
||||
case SEQPLAYER_STATE_2:
|
||||
break;
|
||||
}
|
||||
break;
|
||||
@@ -2102,7 +2103,7 @@ void AudioSeq_SequencePlayerProcessSequence(SequencePlayer* seqPlayer) {
|
||||
cmd = AudioSeq_ScriptReadU8(seqScript);
|
||||
if (cmd == 0xFF) {
|
||||
cmd = seqPlayer->playerIndex;
|
||||
if (seqPlayer->state == 2) {
|
||||
if (seqPlayer->state == SEQPLAYER_STATE_2) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2224,7 +2225,7 @@ void AudioSeq_ResetSequencePlayer(SequencePlayer* seqPlayer) {
|
||||
AudioSeq_SequencePlayerDisable(seqPlayer);
|
||||
seqPlayer->stopScript = false;
|
||||
seqPlayer->delay = 0;
|
||||
seqPlayer->state = 1;
|
||||
seqPlayer->state = SEQPLAYER_STATE_1;
|
||||
seqPlayer->fadeTimer = 0;
|
||||
seqPlayer->fadeTimerUnkEu = 0;
|
||||
seqPlayer->tempoAcc = 0;
|
||||
|
||||
@@ -53,6 +53,7 @@
|
||||
* - Seaweed
|
||||
*/
|
||||
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "z_boss_03.h"
|
||||
#include "overlays/actors/ovl_Door_Warp1/z_door_warp1.h"
|
||||
#include "overlays/actors/ovl_En_Water_Effect/z_en_water_effect.h"
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
* Description: Breakable Pot With Grass
|
||||
*/
|
||||
|
||||
#include "prevent_bss_reordering.h"
|
||||
#include "z_obj_flowerpot.h"
|
||||
#include "objects/object_flowerpot/object_flowerpot.h"
|
||||
|
||||
|
||||
+11
-11
@@ -3546,8 +3546,8 @@
|
||||
0x8018A808:("func_8018A808",),
|
||||
0x8018ACC4:("func_8018ACC4",),
|
||||
0x8018AE34:("func_8018AE34",),
|
||||
0x8018B0F0:("func_8018B0F0",),
|
||||
0x8018B10C:("func_8018B10C",),
|
||||
0x8018B0F0:("AudioHeap_CalculateAdsrDecay",),
|
||||
0x8018B10C:("AudioHeap_InitAdsrDecayTable",),
|
||||
0x8018B250:("AudioHeap_ResetLoadStatus",),
|
||||
0x8018B318:("AudioHeap_DiscardFont",),
|
||||
0x8018B3FC:("AudioHeap_ReleaseNotesForFont",),
|
||||
@@ -3560,16 +3560,16 @@
|
||||
0x8018B640:("AudioHeap_AllocZeroed",),
|
||||
0x8018B69C:("AudioHeap_TestAlloc",),
|
||||
0x8018B6E8:("AudioHeap_Alloc",),
|
||||
0x8018B740:("AudioHeap_AllocPoolInit",),
|
||||
0x8018B768:("AudioHeap_ClearPersistentCache",),
|
||||
0x8018B77C:("AudioHeap_ClearTemporaryCache",),
|
||||
0x8018B740:("AudioHeap_InitPool",),
|
||||
0x8018B768:("AudioHeap_InitPersistentCache",),
|
||||
0x8018B77C:("AudioHeap_InitTemporaryCache",),
|
||||
0x8018B7AC:("AudioHeap_ResetPool",),
|
||||
0x8018B7BC:("AudioHeap_PopCache",),
|
||||
0x8018B7BC:("AudioHeap_PopPersistentCache",),
|
||||
0x8018B8FC:("AudioHeap_InitMainPool",),
|
||||
0x8018B95C:("AudioHeap_InitSessionPool",),
|
||||
0x8018B9E0:("AudioHeap_InitCachePool",),
|
||||
0x8018BA64:("AudioHeap_InitPersistentCache",),
|
||||
0x8018BB28:("AudioHeap_InitTemporaryCache",),
|
||||
0x8018BA64:("AudioHeap_InitPersistentPoolsAndCaches",),
|
||||
0x8018BB28:("AudioHeap_InitTemporaryPoolsAndCaches",),
|
||||
0x8018BBEC:("AudioHeap_AllocCached",),
|
||||
0x8018C380:("AudioHeap_SearchCaches",),
|
||||
0x8018C3D8:("AudioHeap_SearchRegularCaches",),
|
||||
@@ -3645,7 +3645,7 @@
|
||||
0x80190B08:("AudioLoad_ProcessLoads",),
|
||||
0x80190B38:("AudioLoad_SetDmaHandler",),
|
||||
0x80190B44:("AudioLoad_SetUnusedHandler",),
|
||||
0x80190B50:("AudioLoad_InitSoundFontMeta",),
|
||||
0x80190B50:("AudioLoad_InitSoundFont",),
|
||||
0x80190BB0:("AudioLoad_Init",),
|
||||
0x80190F50:("AudioLoad_InitSlowLoads",),
|
||||
0x80190F64:("AudioLoad_SlowLoadSample",),
|
||||
@@ -3731,10 +3731,10 @@
|
||||
0x80194E60:("AudioPlayback_NoteInit",),
|
||||
0x80194F20:("AudioPlayback_NoteDisable",),
|
||||
0x80194F84:("AudioPlayback_ProcessNotes",),
|
||||
0x801954CC:("AudioPlayback_InstrumentGetSound",),
|
||||
0x801954CC:("AudioPlayback_GetInstrumentTunedSample",),
|
||||
0x80195508:("AudioPlayback_GetInstrumentInner",),
|
||||
0x801955DC:("AudioPlayback_GetDrum",),
|
||||
0x801956C0:("AudioPlayback_GetSfx",),
|
||||
0x801956C0:("AudioPlayback_GetSoundEffect",),
|
||||
0x801957B4:("AudioPlayback_SetFontInstrument",),
|
||||
0x801958F8:("AudioPlayback_SeqLayerDecayRelease",),
|
||||
0x80195C40:("AudioPlayback_SeqLayerNoteDecay",),
|
||||
|
||||
@@ -3814,7 +3814,7 @@
|
||||
0x801E10B0:("jtbl_801E10B0","UNK_PTR","",0x4),
|
||||
0x801E10C4:("jtbl_801E10C4","UNK_PTR","",0x4),
|
||||
0x801E1100:("gAudioTatumInit","s16","[2]",0x4),
|
||||
0x801E1104:("gAudioContextInitSizes","AudioContextInitSizes","",0xC),
|
||||
0x801E1104:("gAudioHeapInitSizes","AudioHeapInitSizes","",0xC),
|
||||
0x801E1110:("sGameOverTimer","UNK_TYPE2","",0x2),
|
||||
0x801E1120:("jtbl_801E1120","UNK_PTR","",0x4),
|
||||
0x801E1180:("gSoundFontTable","UNK_TYPE2","",0x2),
|
||||
|
||||
@@ -3076,16 +3076,16 @@ asm/non_matchings/code/audio_heap/AudioHeap_AllocDmaMemoryZeroed.s,AudioHeap_All
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_AllocZeroed.s,AudioHeap_AllocZeroed,0x8018B640,0x17
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_TestAlloc.s,AudioHeap_TestAlloc,0x8018B69C,0x13
|
||||
asm/non_matchings/code/audio_heap/Audio_Alloc.s,Audio_Alloc,0x8018B6E8,0x16
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_AllocPoolInit.s,AudioHeap_AllocPoolInit,0x8018B740,0xA
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_ClearPersistentCache.s,AudioHeap_ClearPersistentCache,0x8018B768,0x5
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_ClearTemporaryCache.s,AudioHeap_ClearTemporaryCache,0x8018B77C,0xC
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitPool.s,AudioHeap_InitPool,0x8018B740,0xA
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentCache.s,AudioHeap_InitPersistentCache,0x8018B768,0x5
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryCache.s,AudioHeap_InitTemporaryCache,0x8018B77C,0xC
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_ResetPool.s,AudioHeap_ResetPool,0x8018B7AC,0x4
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_PopCache.s,AudioHeap_PopCache,0x8018B7BC,0x50
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_PopPersistentCache.s,AudioHeap_PopPersistentCache,0x8018B7BC,0x50
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitMainPool.s,AudioHeap_InitMainPool,0x8018B8FC,0x18
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitSessionPool.s,AudioHeap_InitSessionPool,0x8018B95C,0x21
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitCachePool.s,AudioHeap_InitCachePool,0x8018B9E0,0x21
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentCache.s,AudioHeap_InitPersistentCache,0x8018BA64,0x31
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryCache.s,AudioHeap_InitTemporaryCache,0x8018BB28,0x31
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitPersistentPoolsAndCaches.s,AudioHeap_InitPersistentPoolsAndCaches,0x8018BA64,0x31
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_InitTemporaryPoolsAndCaches.s,AudioHeap_InitTemporaryPoolsAndCaches,0x8018BB28,0x31
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_AllocCached.s,AudioHeap_AllocCached,0x8018BBEC,0x1E5
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_SearchCaches.s,AudioHeap_SearchCaches,0x8018C380,0x16
|
||||
asm/non_matchings/code/audio_heap/AudioHeap_SearchRegularCaches.s,AudioHeap_SearchRegularCaches,0x8018C3D8,0x43
|
||||
@@ -3161,7 +3161,7 @@ asm/non_matchings/code/audio_load/AudioLoad_AsyncLoadInner.s,AudioLoad_AsyncLoad
|
||||
asm/non_matchings/code/audio_load/AudioLoad_ProcessLoads.s,AudioLoad_ProcessLoads,0x80190B08,0xC
|
||||
asm/non_matchings/code/audio_load/AudioLoad_SetDmaHandler.s,AudioLoad_SetDmaHandler,0x80190B38,0x3
|
||||
asm/non_matchings/code/audio_load/AudioLoad_SetUnusedHandler.s,AudioLoad_SetUnusedHandler,0x80190B44,0x3
|
||||
asm/non_matchings/code/audio_load/AudioLoad_InitSoundFontMeta.s,AudioLoad_InitSoundFontMeta,0x80190B50,0x18
|
||||
asm/non_matchings/code/audio_load/AudioLoad_InitSoundFont.s,AudioLoad_InitSoundFont,0x80190B50,0x18
|
||||
asm/non_matchings/code/audio_load/AudioLoad_Init.s,AudioLoad_Init,0x80190BB0,0xE8
|
||||
asm/non_matchings/code/audio_load/AudioLoad_InitSlowLoads.s,AudioLoad_InitSlowLoads,0x80190F50,0x5
|
||||
asm/non_matchings/code/audio_load/AudioLoad_SlowLoadSample.s,AudioLoad_SlowLoadSample,0x80190F64,0x74
|
||||
@@ -3247,10 +3247,10 @@ asm/non_matchings/code/audio_playback/AudioPlayback_NoteSetResamplingRate.s,Audi
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_NoteInit.s,AudioPlayback_NoteInit,0x80194E60,0x30
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_NoteDisable.s,AudioPlayback_NoteDisable,0x80194F20,0x19
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_ProcessNotes.s,AudioPlayback_ProcessNotes,0x80194F84,0x152
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_InstrumentGetSound.s,AudioPlayback_InstrumentGetSound,0x801954CC,0xF
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_GetInstrumentTunedSample.s,AudioPlayback_GetInstrumentTunedSample,0x801954CC,0xF
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_GetInstrumentInner.s,AudioPlayback_GetInstrumentInner,0x80195508,0x35
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_GetDrum.s,AudioPlayback_GetDrum,0x801955DC,0x39
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_GetSfx.s,AudioPlayback_GetSfx,0x801956C0,0x3D
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_GetSoundEffect.s,AudioPlayback_GetSoundEffect,0x801956C0,0x3D
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_SetFontInstrument.s,AudioPlayback_SetFontInstrument,0x801957B4,0x51
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_SeqLayerDecayRelease.s,AudioPlayback_SeqLayerDecayRelease,0x801958F8,0xD2
|
||||
asm/non_matchings/code/audio_playback/AudioPlayback_SeqLayerNoteDecay.s,AudioPlayback_SeqLayerNoteDecay,0x80195C40,0x8
|
||||
|
||||
|
Reference in New Issue
Block a user