mirror of
https://github.com/zeldaret/oot
synced 2026-05-22 22:44:26 -04:00
Rename NoteSubEu -> NoteSampleState (#2738)
This commit is contained in:
+12
-12
@@ -31,7 +31,7 @@ typedef void (*AudioCustomUpdateFunction)(void);
|
||||
#define SEQ_NUM_CHANNELS 16
|
||||
#define SEQ_IO_VAL_NONE -1
|
||||
|
||||
#define MUTE_BEHAVIOR_3 (1 << 3) // prevent further noteSubEus from playing
|
||||
#define MUTE_BEHAVIOR_3 (1 << 3) // prevent further NoteSampleStates from playing
|
||||
#define MUTE_BEHAVIOR_4 (1 << 4) // stop something in seqLayer scripts
|
||||
#define MUTE_BEHAVIOR_SOFTEN (1 << 5) // lower volume, by default to half
|
||||
#define MUTE_BEHAVIOR_STOP_NOTES (1 << 6) // prevent further notes from playing
|
||||
@@ -587,7 +587,7 @@ typedef struct NotePlaybackState {
|
||||
} NotePlaybackState; // size = 0x88
|
||||
|
||||
// JAudio: "commonch"
|
||||
typedef struct NoteSubEu {
|
||||
typedef struct NoteSampleState {
|
||||
struct {
|
||||
/* 0x00 */ volatile u8 enabled : 1;
|
||||
/* 0x00 */ u8 needsInit : 1;
|
||||
@@ -621,7 +621,7 @@ typedef struct NoteSubEu {
|
||||
};
|
||||
/* 0x14 */ s16* filter;
|
||||
/* 0x18 */ char pad_18[0x8];
|
||||
} NoteSubEu; // size = 0x20
|
||||
} NoteSampleState; // size = 0x20
|
||||
|
||||
// JAudio: "channel"
|
||||
typedef struct Note {
|
||||
@@ -630,7 +630,7 @@ typedef struct Note {
|
||||
/* 0x30 */ NotePlaybackState playbackState;
|
||||
/* 0xB8 */ char unk_B8[0x4];
|
||||
/* 0xBC */ u32 startSamplePos; // initial position/index to start processing s16 samples
|
||||
/* 0xC0 */ NoteSubEu noteSubEu;
|
||||
/* 0xC0 */ NoteSampleState sampleState;
|
||||
} Note; // size = 0xE0
|
||||
|
||||
typedef struct ReverbSettings {
|
||||
@@ -888,7 +888,7 @@ typedef struct AudioContext {
|
||||
/* 0x0004 */ u16 unk_4;
|
||||
/* 0x0006 */ char unk_0006[0x0A];
|
||||
/* 0x0010 */ s16* curLoadedBook;
|
||||
/* 0x0014 */ NoteSubEu* noteSubsEu;
|
||||
/* 0x0014 */ NoteSampleState* sampleStates;
|
||||
/* 0x0018 */ SynthesisReverb synthesisReverbs[4];
|
||||
/* 0x0B38 */ char unk_0B38[0x30];
|
||||
/* 0x0B68 */ Sample* usedSamples[128];
|
||||
@@ -988,7 +988,7 @@ typedef struct AudioContext {
|
||||
/* 0x3530 */ SequencePlayer seqPlayers[4];
|
||||
/* 0x3AB0 */ SequenceLayer sequenceLayers[64];
|
||||
/* 0x5AB0 */ SequenceChannel sequenceChannelNone;
|
||||
/* 0x5B84 */ s32 noteSubEuOffset;
|
||||
/* 0x5B84 */ s32 sampleStateOffset;
|
||||
/* 0x5B88 */ AudioListItem layerFreeList;
|
||||
/* 0x5B98 */ NotePool noteFreeLists;
|
||||
/* 0x5BD8 */ u8 threadCmdWritePos;
|
||||
@@ -1007,7 +1007,7 @@ typedef struct AudioContext {
|
||||
/* 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 NoteSubAttributes {
|
||||
typedef struct NoteSampleStateAttributes {
|
||||
/* 0x00 */ u8 reverbVol;
|
||||
/* 0x01 */ u8 gain; // Increases volume by a multiplicative scaling factor. Represented as a UQ4.4 number
|
||||
/* 0x02 */ u8 pan;
|
||||
@@ -1018,7 +1018,7 @@ typedef struct NoteSubAttributes {
|
||||
/* 0x10 */ s16* filter;
|
||||
/* 0x14 */ u8 combFilterSize;
|
||||
/* 0x16 */ u16 combFilterGain;
|
||||
} NoteSubAttributes; // size = 0x18
|
||||
} NoteSampleStateAttributes; // size = 0x18
|
||||
|
||||
typedef struct TempoData {
|
||||
/* 0x0 */ s16 unk_00; // set to 0x1C00, unused
|
||||
@@ -1103,8 +1103,8 @@ void AudioThread_InitMesgQueues(void);
|
||||
void Audio_InvalDCache(void* buf, s32 size);
|
||||
void Audio_WritebackDCache(void* buf, s32 size);
|
||||
s32 osAiSetNextBuffer(void*, u32);
|
||||
void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs);
|
||||
void Audio_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput);
|
||||
void Audio_InitSampleState(Note* note, NoteSampleState* sampleState, NoteSampleStateAttributes* attrs);
|
||||
void Audio_NoteSetResamplingRate(NoteSampleState* sampleState, f32 resamplingRateInput);
|
||||
void Audio_NoteInit(Note* note);
|
||||
void Audio_NoteDisable(Note* note);
|
||||
void Audio_ProcessNotes(void);
|
||||
@@ -1230,8 +1230,8 @@ extern f32 gPitchFrequencies[];
|
||||
extern u8 gDefaultShortNoteVelocityTable[16];
|
||||
extern u8 gDefaultShortNoteGateTimeTable[16];
|
||||
extern EnvelopePoint gDefaultEnvelope[4];
|
||||
extern NoteSubEu gZeroNoteSub;
|
||||
extern NoteSubEu gDefaultNoteSub;
|
||||
extern NoteSampleState gZeroNoteSampleState;
|
||||
extern NoteSampleState gDefaultNoteSampleState;
|
||||
extern u16 gHaasEffectDelaySizes[64];
|
||||
extern s16 D_8012FBA8[];
|
||||
extern f32 gHeadsetPanVolume[128];
|
||||
|
||||
@@ -109,7 +109,7 @@ void AudioDebug_Draw(GfxPrint* printer) {
|
||||
GfxPrint_Printf(printer, "- %s -", sAudioDebugPageNames[sAudioDebugPage]);
|
||||
|
||||
for (i = 0; i < gAudioSpecs[gAudioSpecId].numNotes; i++) {
|
||||
if (gAudioCtx.notes[i].noteSubEu.bitField0.enabled == 1) {
|
||||
if (gAudioCtx.notes[i].sampleState.bitField0.enabled == 1) {
|
||||
numEnabledNotes++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -552,9 +552,9 @@ EnvelopePoint gDefaultEnvelope[] = {
|
||||
{ ADSR_DISABLE, 0 },
|
||||
};
|
||||
|
||||
NoteSubEu gZeroNoteSub = { 0 };
|
||||
NoteSampleState gZeroNoteSampleState = { 0 };
|
||||
|
||||
NoteSubEu gDefaultNoteSub = {
|
||||
NoteSampleState gDefaultNoteSampleState = {
|
||||
{ 1, 1, 0, 0, 0, 0, 0, 0 }, { 0 }, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, NULL, NULL, 0,
|
||||
};
|
||||
|
||||
|
||||
@@ -442,7 +442,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_MAYBE_DISCARDABLE) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
if (gAudioCtx.notes[i].playbackState.fontId == temporaryCache->entries[0].id &&
|
||||
gAudioCtx.notes[i].noteSubEu.bitField0.enabled) {
|
||||
gAudioCtx.notes[i].sampleState.bitField0.enabled) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -456,7 +456,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
|
||||
if (loadStatusEntry1 == LOAD_STATUS_MAYBE_DISCARDABLE) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
if (gAudioCtx.notes[i].playbackState.fontId == temporaryCache->entries[1].id &&
|
||||
gAudioCtx.notes[i].noteSubEu.bitField0.enabled) {
|
||||
gAudioCtx.notes[i].sampleState.bitField0.enabled) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -512,7 +512,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
|
||||
if (loadStatusEntry0 == LOAD_STATUS_COMPLETE) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
if (gAudioCtx.notes[i].playbackState.fontId == temporaryCache->entries[0].id &&
|
||||
gAudioCtx.notes[i].noteSubEu.bitField0.enabled) {
|
||||
gAudioCtx.notes[i].sampleState.bitField0.enabled) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -525,7 +525,7 @@ void* AudioHeap_AllocCached(s32 tableType, s32 size, s32 cache, s32 id) {
|
||||
if (loadStatusEntry1 == LOAD_STATUS_COMPLETE) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
if (gAudioCtx.notes[i].playbackState.fontId == temporaryCache->entries[1].id &&
|
||||
gAudioCtx.notes[i].noteSubEu.bitField0.enabled) {
|
||||
gAudioCtx.notes[i].sampleState.bitField0.enabled) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -891,7 +891,7 @@ s32 AudioHeap_ResetStep(void) {
|
||||
AudioHeap_UpdateReverbs();
|
||||
} else {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
if (gAudioCtx.notes[i].noteSubEu.bitField0.enabled &&
|
||||
if (gAudioCtx.notes[i].sampleState.bitField0.enabled &&
|
||||
gAudioCtx.notes[i].playbackState.adsr.action.s.state != ADSR_STATE_DISABLED) {
|
||||
gAudioCtx.notes[i].playbackState.adsr.fadeOutVel =
|
||||
gAudioCtx.audioBufferParameters.ticksPerUpdateInv;
|
||||
@@ -1056,8 +1056,9 @@ 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.ticksPerUpdate *
|
||||
gAudioCtx.numNotes * sizeof(NoteSubEu));
|
||||
gAudioCtx.sampleStates =
|
||||
AudioHeap_AllocZeroed(&gAudioCtx.miscPool, gAudioCtx.audioBufferParameters.ticksPerUpdate * gAudioCtx.numNotes *
|
||||
sizeof(NoteSampleState));
|
||||
// Initialize audio binary interface command list buffers
|
||||
for (i = 0; i != 2; i++) {
|
||||
gAudioCtx.abiCmdBufs[i] =
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
/**
|
||||
* original name: Nas_smzSetParam
|
||||
*/
|
||||
void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
|
||||
void Audio_InitSampleState(Note* note, NoteSampleState* sampleState, NoteSampleStateAttributes* attrs) {
|
||||
f32 volLeft;
|
||||
f32 volRight;
|
||||
s32 halfPanIndex;
|
||||
@@ -25,36 +25,36 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
|
||||
reverbVol = attrs->reverbVol;
|
||||
stereoData = attrs->stereo.s;
|
||||
|
||||
sub->bitField0 = note->noteSubEu.bitField0;
|
||||
sub->bitField1 = note->noteSubEu.bitField1;
|
||||
sub->waveSampleAddr = note->noteSubEu.waveSampleAddr;
|
||||
sub->harmonicIndexCurAndPrev = note->noteSubEu.harmonicIndexCurAndPrev;
|
||||
sampleState->bitField0 = note->sampleState.bitField0;
|
||||
sampleState->bitField1 = note->sampleState.bitField1;
|
||||
sampleState->waveSampleAddr = note->sampleState.waveSampleAddr;
|
||||
sampleState->harmonicIndexCurAndPrev = note->sampleState.harmonicIndexCurAndPrev;
|
||||
|
||||
Audio_NoteSetResamplingRate(sub, attrs->frequency);
|
||||
Audio_NoteSetResamplingRate(sampleState, attrs->frequency);
|
||||
|
||||
pan &= 0x7F;
|
||||
|
||||
sub->bitField0.stereoStrongRight = false;
|
||||
sub->bitField0.stereoStrongLeft = false;
|
||||
sub->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects;
|
||||
sub->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects;
|
||||
sampleState->bitField0.stereoStrongRight = false;
|
||||
sampleState->bitField0.stereoStrongLeft = false;
|
||||
sampleState->bitField0.stereoHeadsetEffects = stereoData.stereoHeadsetEffects;
|
||||
sampleState->bitField0.usesHeadsetPanEffects = stereoData.usesHeadsetPanEffects;
|
||||
if (stereoHeadsetEffects && (gAudioCtx.soundOutputMode == SOUND_OUTPUT_HEADSET)) {
|
||||
halfPanIndex = pan >> 1;
|
||||
if (halfPanIndex > 0x3F) {
|
||||
halfPanIndex = 0x3F;
|
||||
}
|
||||
|
||||
sub->haasEffectRightDelaySize = gHaasEffectDelaySizes[halfPanIndex];
|
||||
sub->haasEffectLeftDelaySize = gHaasEffectDelaySizes[0x3F - halfPanIndex];
|
||||
sub->bitField1.useHaasEffect = true;
|
||||
sampleState->haasEffectRightDelaySize = gHaasEffectDelaySizes[halfPanIndex];
|
||||
sampleState->haasEffectLeftDelaySize = gHaasEffectDelaySizes[0x3F - halfPanIndex];
|
||||
sampleState->bitField1.useHaasEffect = true;
|
||||
|
||||
volLeft = gHeadsetPanVolume[pan];
|
||||
volRight = gHeadsetPanVolume[0x7F - pan];
|
||||
} else if (stereoHeadsetEffects && (gAudioCtx.soundOutputMode == SOUND_OUTPUT_STEREO)) {
|
||||
strongLeft = strongRight = 0;
|
||||
sub->haasEffectLeftDelaySize = 0;
|
||||
sub->haasEffectRightDelaySize = 0;
|
||||
sub->bitField1.useHaasEffect = false;
|
||||
sampleState->haasEffectLeftDelaySize = 0;
|
||||
sampleState->haasEffectRightDelaySize = 0;
|
||||
sampleState->bitField1.useHaasEffect = false;
|
||||
|
||||
volLeft = gStereoPanVolume[pan];
|
||||
volRight = gStereoPanVolume[0x7F - pan];
|
||||
@@ -64,37 +64,37 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
|
||||
strongRight = 1;
|
||||
}
|
||||
|
||||
sub->bitField0.stereoStrongRight = strongRight;
|
||||
sub->bitField0.stereoStrongLeft = strongLeft;
|
||||
sampleState->bitField0.stereoStrongRight = strongRight;
|
||||
sampleState->bitField0.stereoStrongLeft = strongLeft;
|
||||
|
||||
switch (stereoData.bit2) {
|
||||
case 0:
|
||||
break;
|
||||
|
||||
case 1:
|
||||
sub->bitField0.stereoStrongRight = stereoData.strongRight;
|
||||
sub->bitField0.stereoStrongLeft = stereoData.strongLeft;
|
||||
sampleState->bitField0.stereoStrongRight = stereoData.strongRight;
|
||||
sampleState->bitField0.stereoStrongLeft = stereoData.strongLeft;
|
||||
break;
|
||||
|
||||
case 2:
|
||||
sub->bitField0.stereoStrongRight = stereoData.strongRight | strongRight;
|
||||
sub->bitField0.stereoStrongLeft = stereoData.strongLeft | strongLeft;
|
||||
sampleState->bitField0.stereoStrongRight = stereoData.strongRight | strongRight;
|
||||
sampleState->bitField0.stereoStrongLeft = stereoData.strongLeft | strongLeft;
|
||||
break;
|
||||
|
||||
case 3:
|
||||
sub->bitField0.stereoStrongRight = stereoData.strongRight ^ strongRight;
|
||||
sub->bitField0.stereoStrongLeft = stereoData.strongLeft ^ strongLeft;
|
||||
sampleState->bitField0.stereoStrongRight = stereoData.strongRight ^ strongRight;
|
||||
sampleState->bitField0.stereoStrongLeft = stereoData.strongLeft ^ strongLeft;
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (gAudioCtx.soundOutputMode == SOUND_OUTPUT_MONO) {
|
||||
sub->bitField0.stereoHeadsetEffects = false;
|
||||
sub->bitField0.usesHeadsetPanEffects = false;
|
||||
sampleState->bitField0.stereoHeadsetEffects = false;
|
||||
sampleState->bitField0.usesHeadsetPanEffects = false;
|
||||
volLeft = 0.707f; // approx 1/sqrt(2)
|
||||
volRight = 0.707f;
|
||||
} else {
|
||||
sub->bitField0.stereoStrongRight = stereoData.strongRight;
|
||||
sub->bitField0.stereoStrongLeft = stereoData.strongLeft;
|
||||
sampleState->bitField0.stereoStrongRight = stereoData.strongRight;
|
||||
sampleState->bitField0.stereoStrongLeft = stereoData.strongLeft;
|
||||
volLeft = gDefaultPanVolume[pan];
|
||||
volRight = gDefaultPanVolume[0x7F - pan];
|
||||
}
|
||||
@@ -102,35 +102,35 @@ void Audio_InitNoteSub(Note* note, NoteSubEu* sub, NoteSubAttributes* attrs) {
|
||||
vel = 0.0f > vel ? 0.0f : vel;
|
||||
vel = 1.0f < vel ? 1.0f : vel;
|
||||
|
||||
sub->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f));
|
||||
sub->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f));
|
||||
sampleState->targetVolLeft = (s32)((vel * volLeft) * (0x1000 - 0.001f));
|
||||
sampleState->targetVolRight = (s32)((vel * volRight) * (0x1000 - 0.001f));
|
||||
|
||||
sub->gain = attrs->gain;
|
||||
sub->filter = attrs->filter;
|
||||
sub->combFilterSize = attrs->combFilterSize;
|
||||
sub->combFilterGain = attrs->combFilterGain;
|
||||
sub->reverbVol = reverbVol;
|
||||
sampleState->gain = attrs->gain;
|
||||
sampleState->filter = attrs->filter;
|
||||
sampleState->combFilterSize = attrs->combFilterSize;
|
||||
sampleState->combFilterGain = attrs->combFilterGain;
|
||||
sampleState->reverbVol = reverbVol;
|
||||
}
|
||||
|
||||
/**
|
||||
* original name: Nas_smzSetPitch
|
||||
*/
|
||||
void Audio_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput) {
|
||||
void Audio_NoteSetResamplingRate(NoteSampleState* sampleState, f32 resamplingRateInput) {
|
||||
f32 resamplingRate = 0.0f;
|
||||
|
||||
if (resamplingRateInput < 2.0f) {
|
||||
noteSubEu->bitField1.hasTwoParts = false;
|
||||
sampleState->bitField1.hasTwoParts = false;
|
||||
resamplingRate = CLAMP_MAX(resamplingRateInput, 1.99998f);
|
||||
|
||||
} else {
|
||||
noteSubEu->bitField1.hasTwoParts = true;
|
||||
sampleState->bitField1.hasTwoParts = true;
|
||||
if (resamplingRateInput > 3.99996f) {
|
||||
resamplingRate = 1.99998f;
|
||||
} else {
|
||||
resamplingRate = resamplingRateInput * 0.5f;
|
||||
}
|
||||
}
|
||||
noteSubEu->resamplingRateFixedPoint = (s32)(resamplingRate * 32768.0f);
|
||||
sampleState->resamplingRateFixedPoint = (s32)(resamplingRate * 32768.0f);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -147,20 +147,20 @@ void Audio_NoteInit(Note* note) {
|
||||
|
||||
note->playbackState.unk_04 = 0;
|
||||
note->playbackState.adsr.action.s.state = ADSR_STATE_INITIAL;
|
||||
note->noteSubEu = gDefaultNoteSub;
|
||||
note->sampleState = gDefaultNoteSampleState;
|
||||
}
|
||||
|
||||
/**
|
||||
* original name: Nas_StopVoice
|
||||
*/
|
||||
void Audio_NoteDisable(Note* note) {
|
||||
if (note->noteSubEu.bitField0.needsInit == true) {
|
||||
note->noteSubEu.bitField0.needsInit = false;
|
||||
if (note->sampleState.bitField0.needsInit == true) {
|
||||
note->sampleState.bitField0.needsInit = false;
|
||||
}
|
||||
note->playbackState.priority = 0;
|
||||
note->noteSubEu.bitField0.enabled = false;
|
||||
note->sampleState.bitField0.enabled = false;
|
||||
note->playbackState.unk_04 = 0;
|
||||
note->noteSubEu.bitField0.finished = false;
|
||||
note->sampleState.bitField0.finished = false;
|
||||
note->playbackState.parentLayer = NO_LAYER;
|
||||
note->playbackState.prevParentLayer = NO_LAYER;
|
||||
note->playbackState.adsr.action.s.state = ADSR_STATE_DISABLED;
|
||||
@@ -173,18 +173,18 @@ void Audio_NoteDisable(Note* note) {
|
||||
void Audio_ProcessNotes(void) {
|
||||
s32 pad[2];
|
||||
NoteAttributes* attrs;
|
||||
NoteSubEu* noteSubEu2;
|
||||
NoteSubEu* noteSubEu;
|
||||
NoteSampleState* sampleState2;
|
||||
NoteSampleState* sampleState;
|
||||
Note* note;
|
||||
NotePlaybackState* playbackState;
|
||||
NoteSubAttributes subAttrs;
|
||||
NoteSampleStateAttributes sampleStateAttrs;
|
||||
u8 bookOffset;
|
||||
f32 scale;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
note = &gAudioCtx.notes[i];
|
||||
noteSubEu2 = &gAudioCtx.noteSubsEu[gAudioCtx.noteSubEuOffset + i];
|
||||
sampleState2 = &gAudioCtx.sampleStates[gAudioCtx.sampleStateOffset + i];
|
||||
playbackState = ¬e->playbackState;
|
||||
if (playbackState->parentLayer != NO_LAYER) {
|
||||
if ((u32)playbackState->parentLayer < 0x7FFFFFFF) {
|
||||
@@ -224,9 +224,9 @@ void Audio_ProcessNotes(void) {
|
||||
out:
|
||||
if (playbackState->priority != 0) {
|
||||
if (1) {}
|
||||
noteSubEu = ¬e->noteSubEu;
|
||||
if (playbackState->unk_04 >= 1 || noteSubEu->bitField0.finished) {
|
||||
if (playbackState->adsr.action.s.state == ADSR_STATE_DISABLED || noteSubEu->bitField0.finished) {
|
||||
sampleState = ¬e->sampleState;
|
||||
if (playbackState->unk_04 >= 1 || sampleState->bitField0.finished) {
|
||||
if (playbackState->adsr.action.s.state == ADSR_STATE_DISABLED || sampleState->bitField0.finished) {
|
||||
if (playbackState->wantedParentLayer != NO_LAYER) {
|
||||
Audio_NoteDisable(note);
|
||||
if (playbackState->wantedParentLayer->channel != NULL) {
|
||||
@@ -268,46 +268,46 @@ void Audio_ProcessNotes(void) {
|
||||
Audio_NoteVibratoUpdate(note);
|
||||
attrs = &playbackState->attributes;
|
||||
if (playbackState->unk_04 == 1 || playbackState->unk_04 == 2) {
|
||||
subAttrs.frequency = attrs->freqScale;
|
||||
subAttrs.velocity = attrs->velocity;
|
||||
subAttrs.pan = attrs->pan;
|
||||
subAttrs.reverbVol = attrs->reverb;
|
||||
subAttrs.stereo = attrs->stereo;
|
||||
subAttrs.gain = attrs->gain;
|
||||
subAttrs.filter = attrs->filter;
|
||||
subAttrs.combFilterSize = attrs->combFilterSize;
|
||||
subAttrs.combFilterGain = attrs->combFilterGain;
|
||||
bookOffset = noteSubEu->bitField1.bookOffset;
|
||||
sampleStateAttrs.frequency = attrs->freqScale;
|
||||
sampleStateAttrs.velocity = attrs->velocity;
|
||||
sampleStateAttrs.pan = attrs->pan;
|
||||
sampleStateAttrs.reverbVol = attrs->reverb;
|
||||
sampleStateAttrs.stereo = attrs->stereo;
|
||||
sampleStateAttrs.gain = attrs->gain;
|
||||
sampleStateAttrs.filter = attrs->filter;
|
||||
sampleStateAttrs.combFilterSize = attrs->combFilterSize;
|
||||
sampleStateAttrs.combFilterGain = attrs->combFilterGain;
|
||||
bookOffset = sampleState->bitField1.bookOffset;
|
||||
} else {
|
||||
SequenceLayer* layer = playbackState->parentLayer;
|
||||
SequenceChannel* channel = layer->channel;
|
||||
|
||||
subAttrs.frequency = layer->noteFreqScale;
|
||||
subAttrs.velocity = layer->noteVelocity;
|
||||
subAttrs.pan = layer->notePan;
|
||||
sampleStateAttrs.frequency = layer->noteFreqScale;
|
||||
sampleStateAttrs.velocity = layer->noteVelocity;
|
||||
sampleStateAttrs.pan = layer->notePan;
|
||||
if (layer->stereo.asByte == 0) {
|
||||
subAttrs.stereo = channel->stereo;
|
||||
sampleStateAttrs.stereo = channel->stereo;
|
||||
} else {
|
||||
subAttrs.stereo = layer->stereo;
|
||||
sampleStateAttrs.stereo = layer->stereo;
|
||||
}
|
||||
subAttrs.reverbVol = channel->targetReverbVol;
|
||||
subAttrs.gain = channel->gain;
|
||||
subAttrs.filter = channel->filter;
|
||||
subAttrs.combFilterSize = channel->combFilterSize;
|
||||
subAttrs.combFilterGain = channel->combFilterGain;
|
||||
sampleStateAttrs.reverbVol = channel->targetReverbVol;
|
||||
sampleStateAttrs.gain = channel->gain;
|
||||
sampleStateAttrs.filter = channel->filter;
|
||||
sampleStateAttrs.combFilterSize = channel->combFilterSize;
|
||||
sampleStateAttrs.combFilterGain = channel->combFilterGain;
|
||||
bookOffset = channel->bookOffset & 0x7;
|
||||
|
||||
if (channel->seqPlayer->muted && (channel->muteBehavior & MUTE_BEHAVIOR_3)) {
|
||||
subAttrs.frequency = 0.0f;
|
||||
subAttrs.velocity = 0.0f;
|
||||
sampleStateAttrs.frequency = 0.0f;
|
||||
sampleStateAttrs.velocity = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
subAttrs.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale;
|
||||
subAttrs.frequency *= gAudioCtx.audioBufferParameters.resampleRate;
|
||||
subAttrs.velocity *= scale;
|
||||
Audio_InitNoteSub(note, noteSubEu2, &subAttrs);
|
||||
noteSubEu->bitField1.bookOffset = bookOffset;
|
||||
sampleStateAttrs.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale;
|
||||
sampleStateAttrs.frequency *= gAudioCtx.audioBufferParameters.resampleRate;
|
||||
sampleStateAttrs.velocity *= scale;
|
||||
Audio_InitSampleState(note, sampleState2, &sampleStateAttrs);
|
||||
sampleState->bitField1.bookOffset = bookOffset;
|
||||
skip:;
|
||||
}
|
||||
}
|
||||
@@ -520,7 +520,7 @@ void Audio_SeqLayerDecayRelease(SequenceLayer* layer, s32 target) {
|
||||
attrs->combFilterGain = channel->combFilterGain;
|
||||
attrs->combFilterSize = channel->combFilterSize;
|
||||
if (channel->seqPlayer->muted && (channel->muteBehavior & MUTE_BEHAVIOR_3)) {
|
||||
note->noteSubEu.bitField0.finished = true;
|
||||
note->sampleState.bitField0.finished = true;
|
||||
}
|
||||
|
||||
if (layer->stereo.asByte == 0) {
|
||||
@@ -617,7 +617,7 @@ s32 Audio_BuildSyntheticWave(Note* note, SequenceLayer* layer, s32 waveId) {
|
||||
|
||||
// Save the pointer to the synthethic wave
|
||||
// waveId index starts at 128, there are WAVE_SAMPLE_COUNT samples to read from
|
||||
note->noteSubEu.waveSampleAddr = &gWaveSamples[waveId - 128][harmonicIndex * WAVE_SAMPLE_COUNT];
|
||||
note->sampleState.waveSampleAddr = &gWaveSamples[waveId - 128][harmonicIndex * WAVE_SAMPLE_COUNT];
|
||||
|
||||
return harmonicIndex;
|
||||
}
|
||||
@@ -635,7 +635,7 @@ void Audio_InitSyntheticWave(Note* note, SequenceLayer* layer) {
|
||||
curHarmonicIndex = Audio_BuildSyntheticWave(note, layer, waveId);
|
||||
|
||||
if (curHarmonicIndex != prevHarmonicIndex) {
|
||||
note->noteSubEu.harmonicIndexCurAndPrev = (curHarmonicIndex << 2) + prevHarmonicIndex;
|
||||
note->sampleState.harmonicIndexCurAndPrev = (curHarmonicIndex << 2) + prevHarmonicIndex;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -831,7 +831,7 @@ void Audio_NoteInitForLayer(Note* note, SequenceLayer* layer) {
|
||||
s32 pad[3];
|
||||
s16 instId;
|
||||
NotePlaybackState* playbackState = ¬e->playbackState;
|
||||
NoteSubEu* sub = ¬e->noteSubEu;
|
||||
NoteSampleState* sampleState = ¬e->sampleState;
|
||||
|
||||
note->playbackState.prevParentLayer = NO_LAYER;
|
||||
note->playbackState.parentLayer = layer;
|
||||
@@ -848,21 +848,21 @@ void Audio_NoteInitForLayer(Note* note, SequenceLayer* layer) {
|
||||
if (instId == 0xFF) {
|
||||
instId = layer->channel->instOrWave;
|
||||
}
|
||||
sub->tunedSample = layer->tunedSample;
|
||||
sampleState->tunedSample = layer->tunedSample;
|
||||
|
||||
if (instId >= 0x80 && instId < 0xC0) {
|
||||
sub->bitField1.isSyntheticWave = true;
|
||||
sampleState->bitField1.isSyntheticWave = true;
|
||||
} else {
|
||||
sub->bitField1.isSyntheticWave = false;
|
||||
sampleState->bitField1.isSyntheticWave = false;
|
||||
}
|
||||
|
||||
if (sub->bitField1.isSyntheticWave) {
|
||||
if (sampleState->bitField1.isSyntheticWave) {
|
||||
Audio_BuildSyntheticWave(note, layer, instId);
|
||||
}
|
||||
|
||||
playbackState->fontId = layer->channel->fontId;
|
||||
playbackState->stereoHeadsetEffects = layer->channel->stereoHeadsetEffects;
|
||||
sub->bitField1.reverbIndex = layer->channel->reverbIndex & 3;
|
||||
sampleState->bitField1.reverbIndex = layer->channel->reverbIndex & 3;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -1016,7 +1016,7 @@ void Audio_NoteInitAll(void) {
|
||||
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
note = &gAudioCtx.notes[i];
|
||||
note->noteSubEu = gZeroNoteSub;
|
||||
note->sampleState = gZeroNoteSampleState;
|
||||
note->playbackState.priority = 0;
|
||||
note->playbackState.unk_04 = 0;
|
||||
note->playbackState.parentLayer = NO_LAYER;
|
||||
|
||||
@@ -2151,7 +2151,7 @@ void AudioSeq_ProcessSequences(s32 arg0) {
|
||||
SequencePlayer* seqPlayer;
|
||||
u32 i;
|
||||
|
||||
gAudioCtx.noteSubEuOffset = (gAudioCtx.audioBufferParameters.ticksPerUpdate - arg0 - 1) * gAudioCtx.numNotes;
|
||||
gAudioCtx.sampleStateOffset = (gAudioCtx.audioBufferParameters.ticksPerUpdate - arg0 - 1) * gAudioCtx.numNotes;
|
||||
|
||||
for (i = 0; i < (u32)gAudioCtx.audioBufferParameters.numSequencePlayers; i++) {
|
||||
seqPlayer = &gAudioCtx.seqPlayers[i];
|
||||
|
||||
@@ -28,12 +28,13 @@ Acmd* AudioSynth_LoadRingBufferPart(Acmd* cmd, u16 dmem, u16 startPos, s32 size,
|
||||
Acmd* AudioSynth_SaveBufferOffset(Acmd* cmd, u16 dmem, u16 offset, s32 size, s16* buf);
|
||||
Acmd* AudioSynth_SaveRingBufferPart(Acmd* cmd, u16 dmem, u16 startPos, s32 size, SynthesisReverb* reverb);
|
||||
Acmd* AudioSynth_DoOneAudioUpdate(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updateIndex);
|
||||
Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s16* aiBuf,
|
||||
Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSampleState* sampleState, NoteSynthesisState* synthState, s16* aiBuf,
|
||||
s32 aiBufLen, Acmd* cmd, s32 updateIndex);
|
||||
Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s32 numSamplesToLoad);
|
||||
Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s32 size, s32 flags,
|
||||
s32 haasEffectDelaySide);
|
||||
Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s32 aiBufLen,
|
||||
Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState,
|
||||
s32 numSamplesToLoad);
|
||||
Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size,
|
||||
s32 flags, s32 haasEffectDelaySide);
|
||||
Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 aiBufLen,
|
||||
u16 dmemSrc, s32 haasEffectDelaySide, s32 flags);
|
||||
Acmd* AudioSynth_FinalResample(Acmd* cmd, NoteSynthesisState* synthState, s32 size, u16 pitch, u16 inpDmem,
|
||||
s32 resampleFlags);
|
||||
@@ -140,22 +141,21 @@ void AudioSynth_InitNextRingBuf(s32 chunkLen, s32 updateIndex, s32 reverbIndex)
|
||||
* original name: __Nas_PushDrvReg
|
||||
*/
|
||||
void func_800DB03C(s32 updateIndex) {
|
||||
NoteSubEu* subEu;
|
||||
NoteSubEu* subEu2;
|
||||
NoteSampleState* sampleState;
|
||||
NoteSampleState* sampleState2;
|
||||
s32 baseIndex;
|
||||
s32 i;
|
||||
|
||||
baseIndex = gAudioCtx.numNotes * updateIndex;
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
subEu = &gAudioCtx.notes[i].noteSubEu;
|
||||
subEu2 = &gAudioCtx.noteSubsEu[baseIndex + i];
|
||||
if (subEu->bitField0.enabled) {
|
||||
subEu->bitField0.needsInit = false;
|
||||
sampleState = &gAudioCtx.notes[i].sampleState;
|
||||
sampleState2 = &gAudioCtx.sampleStates[baseIndex + i];
|
||||
if (sampleState->bitField0.enabled) {
|
||||
sampleState->bitField0.needsInit = false;
|
||||
} else {
|
||||
subEu2->bitField0.enabled = false;
|
||||
sampleState2->bitField0.enabled = false;
|
||||
}
|
||||
|
||||
subEu->harmonicIndexCurAndPrev = 0;
|
||||
sampleState->harmonicIndexCurAndPrev = 0;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -216,13 +216,13 @@ Acmd* AudioSynth_Update(Acmd* cmdStart, s32* cmdCnt, s16* aiStart, s32 aiBufLen)
|
||||
* original name: __Nas_WaveTerminateProcess
|
||||
*/
|
||||
void func_800DB2C0(s32 updateIndex, s32 noteIndex) {
|
||||
NoteSubEu* noteSubEu;
|
||||
NoteSampleState* sampleState;
|
||||
s32 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;
|
||||
sampleState = &gAudioCtx.sampleStates[(gAudioCtx.numNotes * i) + noteIndex];
|
||||
if (!sampleState->bitField0.needsInit) {
|
||||
sampleState->bitField0.enabled = false;
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -656,31 +656,31 @@ Acmd* AudioSynth_DoOneAudioUpdate(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updat
|
||||
s32 useReverb;
|
||||
s32 t;
|
||||
s32 i;
|
||||
NoteSubEu* noteSubEu;
|
||||
NoteSubEu* noteSubEu2;
|
||||
NoteSampleState* sampleState;
|
||||
NoteSampleState* sampleState2;
|
||||
s32 unk14;
|
||||
|
||||
t = gAudioCtx.numNotes * updateIndex;
|
||||
count = 0;
|
||||
if (gAudioCtx.numSynthesisReverbs == 0) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
if (gAudioCtx.noteSubsEu[t + i].bitField0.enabled) {
|
||||
if (gAudioCtx.sampleStates[t + i].bitField0.enabled) {
|
||||
noteIndices[count++] = i;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
for (reverbIndex = 0; reverbIndex < gAudioCtx.numSynthesisReverbs; reverbIndex++) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
noteSubEu = &gAudioCtx.noteSubsEu[t + i];
|
||||
if (noteSubEu->bitField0.enabled && noteSubEu->bitField1.reverbIndex == reverbIndex) {
|
||||
sampleState = &gAudioCtx.sampleStates[t + i];
|
||||
if (sampleState->bitField0.enabled && sampleState->bitField1.reverbIndex == reverbIndex) {
|
||||
noteIndices[count++] = i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
noteSubEu = &gAudioCtx.noteSubsEu[t + i];
|
||||
if (noteSubEu->bitField0.enabled && noteSubEu->bitField1.reverbIndex >= gAudioCtx.numSynthesisReverbs) {
|
||||
sampleState = &gAudioCtx.sampleStates[t + i];
|
||||
if (sampleState->bitField0.enabled && sampleState->bitField1.reverbIndex >= gAudioCtx.numSynthesisReverbs) {
|
||||
noteIndices[count++] = i;
|
||||
}
|
||||
}
|
||||
@@ -733,11 +733,11 @@ Acmd* AudioSynth_DoOneAudioUpdate(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updat
|
||||
}
|
||||
|
||||
while (i < count) {
|
||||
noteSubEu2 = &gAudioCtx.noteSubsEu[noteIndices[i] + t];
|
||||
if (noteSubEu2->bitField1.reverbIndex == reverbIndex) {
|
||||
cmd =
|
||||
AudioSynth_ProcessNote(noteIndices[i], noteSubEu2, &gAudioCtx.notes[noteIndices[i]].synthesisState,
|
||||
aiBuf, aiBufLen, cmd, updateIndex);
|
||||
sampleState2 = &gAudioCtx.sampleStates[noteIndices[i] + t];
|
||||
if (sampleState2->bitField1.reverbIndex == reverbIndex) {
|
||||
cmd = AudioSynth_ProcessNote(noteIndices[i], sampleState2,
|
||||
&gAudioCtx.notes[noteIndices[i]].synthesisState, aiBuf, aiBufLen, cmd,
|
||||
updateIndex);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
@@ -763,7 +763,7 @@ Acmd* AudioSynth_DoOneAudioUpdate(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updat
|
||||
|
||||
while (i < count) {
|
||||
cmd =
|
||||
AudioSynth_ProcessNote(noteIndices[i], &gAudioCtx.noteSubsEu[t + noteIndices[i]],
|
||||
AudioSynth_ProcessNote(noteIndices[i], &gAudioCtx.sampleStates[t + noteIndices[i]],
|
||||
&gAudioCtx.notes[noteIndices[i]].synthesisState, aiBuf, aiBufLen, cmd, updateIndex);
|
||||
i++;
|
||||
}
|
||||
@@ -777,7 +777,7 @@ Acmd* AudioSynth_DoOneAudioUpdate(s16* aiBuf, s32 aiBufLen, Acmd* cmd, s32 updat
|
||||
/**
|
||||
* original name: Nas_SynthMain
|
||||
*/
|
||||
Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s16* aiBuf,
|
||||
Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSampleState* sampleState, NoteSynthesisState* synthState, s16* aiBuf,
|
||||
s32 aiBufLen, Acmd* cmd, s32 updateIndex) {
|
||||
s32 pad1[3];
|
||||
Sample* sample;
|
||||
@@ -830,12 +830,12 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
s16 addr;
|
||||
u16 unused;
|
||||
|
||||
bookOffset = noteSubEu->bitField1.bookOffset;
|
||||
finished = noteSubEu->bitField0.finished;
|
||||
bookOffset = sampleState->bitField1.bookOffset;
|
||||
finished = sampleState->bitField0.finished;
|
||||
note = &gAudioCtx.notes[noteIndex];
|
||||
flags = A_CONTINUE;
|
||||
|
||||
if (noteSubEu->bitField0.needsInit == true) {
|
||||
if (sampleState->bitField0.needsInit == true) {
|
||||
flags = A_INIT;
|
||||
synthState->restart = 0;
|
||||
synthState->samplePosInt = note->startSamplePos;
|
||||
@@ -844,15 +844,15 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
synthState->curVolRight = 0;
|
||||
synthState->prevHaasEffectLeftDelaySize = 0;
|
||||
synthState->prevHaasEffectRightDelaySize = 0;
|
||||
synthState->reverbVol = noteSubEu->reverbVol;
|
||||
synthState->reverbVol = sampleState->reverbVol;
|
||||
synthState->numParts = 0;
|
||||
synthState->combFilterNeedsInit = true;
|
||||
note->noteSubEu.bitField0.finished = false;
|
||||
note->sampleState.bitField0.finished = false;
|
||||
finished = false;
|
||||
}
|
||||
|
||||
resamplingRateFixedPoint = noteSubEu->resamplingRateFixedPoint;
|
||||
nParts = noteSubEu->bitField1.hasTwoParts + 1;
|
||||
resamplingRateFixedPoint = sampleState->resamplingRateFixedPoint;
|
||||
nParts = sampleState->bitField1.hasTwoParts + 1;
|
||||
samplesLenFixedPoint = (resamplingRateFixedPoint * aiBufLen * 2) + synthState->samplePosFrac;
|
||||
numSamplesToLoad = samplesLenFixedPoint >> 16;
|
||||
|
||||
@@ -873,12 +873,12 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
|
||||
synthState->numParts = nParts;
|
||||
|
||||
if (noteSubEu->bitField1.isSyntheticWave) {
|
||||
cmd = AudioSynth_LoadWaveSamples(cmd, noteSubEu, synthState, numSamplesToLoad);
|
||||
if (sampleState->bitField1.isSyntheticWave) {
|
||||
cmd = AudioSynth_LoadWaveSamples(cmd, sampleState, synthState, numSamplesToLoad);
|
||||
sampleDmemBeforeResampling = DMEM_UNCOMPRESSED_NOTE + (synthState->samplePosInt * (s32)SAMPLE_SIZE);
|
||||
synthState->samplePosInt += numSamplesToLoad;
|
||||
} else {
|
||||
sample = noteSubEu->tunedSample->sample;
|
||||
sample = sampleState->tunedSample->sample;
|
||||
loopInfo = sample->loop;
|
||||
loopEndPos = loopInfo->header.end;
|
||||
sampleAddr = (u32)sample->sampleAddr;
|
||||
@@ -1097,7 +1097,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
AudioSynth_ClearBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE + s5,
|
||||
(samplesLenAdjusted - nSamplesProcessed) * SAMPLE_SIZE);
|
||||
finished = true;
|
||||
note->noteSubEu.bitField0.finished = true;
|
||||
note->sampleState.bitField0.finished = true;
|
||||
func_800DB2C0(updateIndex, noteIndex);
|
||||
break;
|
||||
} else {
|
||||
@@ -1143,8 +1143,8 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
}
|
||||
|
||||
flags = A_CONTINUE;
|
||||
if (noteSubEu->bitField0.needsInit == true) {
|
||||
noteSubEu->bitField0.needsInit = false;
|
||||
if (sampleState->bitField0.needsInit == true) {
|
||||
sampleState->bitField0.needsInit = false;
|
||||
flags = A_INIT;
|
||||
}
|
||||
|
||||
@@ -1158,7 +1158,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
AudioSynth_UnkCmd3(cmd++, DMEM_TEMP, DMEM_TEMP, aiBufLen * SAMPLE_SIZE);
|
||||
}
|
||||
|
||||
gain = noteSubEu->gain;
|
||||
gain = sampleState->gain;
|
||||
if (gain != 0) {
|
||||
// A gain of 0x10 (a UQ4.4 number) is equivalent to 1.0 and represents no volume change
|
||||
if (gain < 0x10) {
|
||||
@@ -1167,7 +1167,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
AudioSynth_HiLoGain(cmd++, gain, DMEM_TEMP, 0, (aiBufLen + SAMPLES_PER_FRAME) * SAMPLE_SIZE);
|
||||
}
|
||||
|
||||
filter = noteSubEu->filter;
|
||||
filter = sampleState->filter;
|
||||
if (filter != NULL) {
|
||||
AudioSynth_LoadFilterSize(cmd++, aiBufLen * SAMPLE_SIZE, filter);
|
||||
AudioSynth_LoadFilterBuffer(cmd++, flags, DMEM_TEMP, synthState->synthesisBuffers->mixEnvelopeState);
|
||||
@@ -1175,10 +1175,10 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
|
||||
// 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;
|
||||
combFilterSize = sampleState->combFilterSize;
|
||||
combFilterGain = sampleState->combFilterGain;
|
||||
combFilterState = synthState->synthesisBuffers->combFilterState;
|
||||
if ((combFilterSize != 0) && (noteSubEu->combFilterGain != 0)) {
|
||||
if ((combFilterSize != 0) && (sampleState->combFilterGain != 0)) {
|
||||
AudioSynth_DMemMove(cmd++, DMEM_TEMP, DMEM_COMB_TEMP, aiBufLen * SAMPLE_SIZE);
|
||||
combFilterDmem = DMEM_COMB_TEMP - combFilterSize;
|
||||
if (synthState->combFilterNeedsInit) {
|
||||
@@ -1195,21 +1195,21 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
synthState->combFilterNeedsInit = true;
|
||||
}
|
||||
|
||||
if ((noteSubEu->haasEffectLeftDelaySize != 0) || (synthState->prevHaasEffectLeftDelaySize != 0)) {
|
||||
if ((sampleState->haasEffectLeftDelaySize != 0) || (synthState->prevHaasEffectLeftDelaySize != 0)) {
|
||||
haasEffectDelaySide = HAAS_EFFECT_DELAY_LEFT;
|
||||
} else if ((noteSubEu->haasEffectRightDelaySize != 0) || (synthState->prevHaasEffectRightDelaySize != 0)) {
|
||||
} else if ((sampleState->haasEffectRightDelaySize != 0) || (synthState->prevHaasEffectRightDelaySize != 0)) {
|
||||
haasEffectDelaySide = HAAS_EFFECT_DELAY_RIGHT;
|
||||
} else {
|
||||
haasEffectDelaySide = HAAS_EFFECT_DELAY_NONE;
|
||||
}
|
||||
|
||||
cmd = AudioSynth_ProcessEnvelope(cmd, noteSubEu, synthState, aiBufLen, DMEM_TEMP, haasEffectDelaySide, flags);
|
||||
cmd = AudioSynth_ProcessEnvelope(cmd, sampleState, synthState, aiBufLen, DMEM_TEMP, haasEffectDelaySide, flags);
|
||||
|
||||
if (noteSubEu->bitField1.useHaasEffect) {
|
||||
if (sampleState->bitField1.useHaasEffect) {
|
||||
if (!(flags & A_INIT)) {
|
||||
flags = A_CONTINUE;
|
||||
}
|
||||
cmd = AudioSynth_ApplyHaasEffect(cmd, noteSubEu, synthState, aiBufLen * (s32)SAMPLE_SIZE, flags,
|
||||
cmd = AudioSynth_ApplyHaasEffect(cmd, sampleState, synthState, aiBufLen * (s32)SAMPLE_SIZE, flags,
|
||||
haasEffectDelaySide);
|
||||
}
|
||||
|
||||
@@ -1233,7 +1233,7 @@ Acmd* AudioSynth_FinalResample(Acmd* cmd, NoteSynthesisState* synthState, s32 si
|
||||
/**
|
||||
* original name: Nas_Synth_Envelope
|
||||
*/
|
||||
Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s32 aiBufLen,
|
||||
Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 aiBufLen,
|
||||
u16 dmemSrc, s32 haasEffectDelaySide, s32 flags) {
|
||||
u32 dmemDests;
|
||||
u16 curVolLeft;
|
||||
@@ -1249,11 +1249,11 @@ Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
s32 pad;
|
||||
|
||||
curVolLeft = synthState->curVolLeft;
|
||||
targetVolLeft = noteSubEu->targetVolLeft;
|
||||
targetVolLeft = sampleState->targetVolLeft;
|
||||
targetVolLeft <<= 4;
|
||||
reverbVol = noteSubEu->reverbVol;
|
||||
reverbVol = sampleState->reverbVol;
|
||||
curVolRight = synthState->curVolRight;
|
||||
targetVolRight = noteSubEu->targetVolRight;
|
||||
targetVolRight = sampleState->targetVolRight;
|
||||
targetVolRight <<= 4;
|
||||
|
||||
if (targetVolLeft != curVolLeft) {
|
||||
@@ -1280,7 +1280,7 @@ Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
synthState->curVolLeft = curVolLeft + (rampLeft * (aiBufLen >> 3));
|
||||
synthState->curVolRight = curVolRight + (rampRight * (aiBufLen >> 3));
|
||||
|
||||
if (noteSubEu->bitField1.useHaasEffect) {
|
||||
if (sampleState->bitField1.useHaasEffect) {
|
||||
AudioSynth_ClearBuffer(cmd++, DMEM_HAAS_TEMP, DMEM_1CH_SIZE);
|
||||
AudioSynth_EnvSetup1(cmd++, phi_t1 * 2, rampReverb, rampLeft, rampRight);
|
||||
AudioSynth_EnvSetup2(cmd++, curVolLeft, curVolRight);
|
||||
@@ -1306,21 +1306,21 @@ Acmd* AudioSynth_ProcessEnvelope(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
dmemDests = sEnvMixerDefaultDmemDests;
|
||||
}
|
||||
|
||||
aEnvMixer(cmd++, dmemSrc, aiBufLen, (sourceReverbVol & 0x80) >> 7, noteSubEu->bitField0.stereoHeadsetEffects,
|
||||
noteSubEu->bitField0.usesHeadsetPanEffects, noteSubEu->bitField0.stereoStrongRight,
|
||||
noteSubEu->bitField0.stereoStrongLeft, dmemDests, sEnvMixerOp);
|
||||
aEnvMixer(cmd++, dmemSrc, aiBufLen, (sourceReverbVol & 0x80) >> 7, sampleState->bitField0.stereoHeadsetEffects,
|
||||
sampleState->bitField0.usesHeadsetPanEffects, sampleState->bitField0.stereoStrongRight,
|
||||
sampleState->bitField0.stereoStrongLeft, dmemDests, sEnvMixerOp);
|
||||
|
||||
return cmd;
|
||||
}
|
||||
|
||||
Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthState,
|
||||
Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState,
|
||||
s32 numSamplesToLoad) {
|
||||
s32 numSamplesAvail;
|
||||
s32 harmonicIndexCurAndPrev = noteSubEu->harmonicIndexCurAndPrev;
|
||||
s32 harmonicIndexCurAndPrev = sampleState->harmonicIndexCurAndPrev;
|
||||
s32 samplePosInt = synthState->samplePosInt;
|
||||
s32 numDuplicates;
|
||||
|
||||
if (noteSubEu->bitField1.bookOffset != 0) {
|
||||
if (sampleState->bitField1.bookOffset != 0) {
|
||||
// Move the noise wave (that reads compiled assembly as samples) from ram to dmem
|
||||
AudioSynth_LoadBuffer(cmd++, DMEM_UNCOMPRESSED_NOTE, ALIGN16(numSamplesToLoad * SAMPLE_SIZE), gWaveSamples[8]);
|
||||
// Offset the address for the samples read by gWaveSamples[8] to the next set of samples
|
||||
@@ -1328,7 +1328,7 @@ Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
return cmd;
|
||||
} else {
|
||||
// Move the synthetic wave from ram to dmem
|
||||
aLoadBuffer(cmd++, noteSubEu->waveSampleAddr, DMEM_UNCOMPRESSED_NOTE, WAVE_SAMPLE_COUNT * SAMPLE_SIZE);
|
||||
aLoadBuffer(cmd++, sampleState->waveSampleAddr, DMEM_UNCOMPRESSED_NOTE, WAVE_SAMPLE_COUNT * SAMPLE_SIZE);
|
||||
|
||||
// If the harmonic changes, map the offset in the wave from one harmonic to another for continuity
|
||||
if (harmonicIndexCurAndPrev != 0) {
|
||||
@@ -1364,8 +1364,8 @@ Acmd* AudioSynth_LoadWaveSamples(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
*
|
||||
* original name: Nas_Synth_Delay
|
||||
*/
|
||||
Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisState* synthState, s32 size, s32 flags,
|
||||
s32 haasEffectDelaySide) {
|
||||
Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSampleState* sampleState, NoteSynthesisState* synthState, s32 size,
|
||||
s32 flags, s32 haasEffectDelaySide) {
|
||||
u16 dmemDest;
|
||||
u16 pitch;
|
||||
u8 prevHaasEffectDelaySize;
|
||||
@@ -1376,7 +1376,7 @@ Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
// Delay the sample on the left channel
|
||||
// This allows the right channel to be heard first
|
||||
dmemDest = DMEM_LEFT_CH;
|
||||
haasEffectDelaySize = noteSubEu->haasEffectLeftDelaySize;
|
||||
haasEffectDelaySize = sampleState->haasEffectLeftDelaySize;
|
||||
prevHaasEffectDelaySize = synthState->prevHaasEffectLeftDelaySize;
|
||||
synthState->prevHaasEffectRightDelaySize = 0;
|
||||
synthState->prevHaasEffectLeftDelaySize = haasEffectDelaySize;
|
||||
@@ -1386,7 +1386,7 @@ Acmd* AudioSynth_ApplyHaasEffect(Acmd* cmd, NoteSubEu* noteSubEu, NoteSynthesisS
|
||||
// Delay the sample on the right channel
|
||||
// This allows the left channel to be heard first
|
||||
dmemDest = DMEM_RIGHT_CH;
|
||||
haasEffectDelaySize = noteSubEu->haasEffectRightDelaySize;
|
||||
haasEffectDelaySize = sampleState->haasEffectRightDelaySize;
|
||||
prevHaasEffectDelaySize = synthState->prevHaasEffectRightDelaySize;
|
||||
synthState->prevHaasEffectRightDelaySize = haasEffectDelaySize;
|
||||
synthState->prevHaasEffectLeftDelaySize = 0;
|
||||
|
||||
@@ -255,11 +255,11 @@ void AudioThread_ProcessGlobalCmd(AudioCmd* cmd) {
|
||||
if (cmd->asUInt == 1) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
Note* note = &gAudioCtx.notes[i];
|
||||
NoteSubEu* subEu = ¬e->noteSubEu;
|
||||
NoteSampleState* sampleState = ¬e->sampleState;
|
||||
|
||||
if (subEu->bitField0.enabled && (note->playbackState.unk_04 == 0) &&
|
||||
if (sampleState->bitField0.enabled && (note->playbackState.unk_04 == 0) &&
|
||||
(note->playbackState.parentLayer->channel->muteBehavior & MUTE_BEHAVIOR_3)) {
|
||||
subEu->bitField0.finished = true;
|
||||
sampleState->bitField0.finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -874,7 +874,7 @@ s32 func_800E6590(s32 seqPlayerIndex, s32 channelIndex, s32 layerIndex) {
|
||||
|
||||
note = layer->note;
|
||||
if (layer == note->playbackState.parentLayer) {
|
||||
tunedSample = note->noteSubEu.tunedSample;
|
||||
tunedSample = note->sampleState.tunedSample;
|
||||
if (tunedSample == NULL) {
|
||||
return 0;
|
||||
}
|
||||
@@ -905,7 +905,7 @@ void func_800E66A0(void) {
|
||||
s32 func_800E66C0(s32 flags) {
|
||||
s32 phi_v1;
|
||||
NotePlaybackState* playbackState;
|
||||
NoteSubEu* noteSubEu;
|
||||
NoteSampleState* sampleState;
|
||||
s32 i;
|
||||
Note* note;
|
||||
TunedSample* tunedSample;
|
||||
@@ -914,12 +914,12 @@ s32 func_800E66C0(s32 flags) {
|
||||
for (i = 0; i < gAudioCtx.numNotes; i++) {
|
||||
note = &gAudioCtx.notes[i];
|
||||
playbackState = ¬e->playbackState;
|
||||
if (note->noteSubEu.bitField0.enabled) {
|
||||
noteSubEu = ¬e->noteSubEu;
|
||||
if (note->sampleState.bitField0.enabled) {
|
||||
sampleState = ¬e->sampleState;
|
||||
if (playbackState->adsr.action.s.state != 0) {
|
||||
if (flags >= 2) {
|
||||
tunedSample = noteSubEu->tunedSample;
|
||||
if (tunedSample == NULL || noteSubEu->bitField1.isSyntheticWave) {
|
||||
tunedSample = sampleState->tunedSample;
|
||||
if (tunedSample == NULL || sampleState->bitField1.isSyntheticWave) {
|
||||
continue;
|
||||
}
|
||||
if (tunedSample->sample->medium == MEDIUM_RAM) {
|
||||
|
||||
Reference in New Issue
Block a user