mirror of
https://github.com/zeldaret/oot.git
synced 2025-07-03 22:44:30 +00:00
audio_playback, audio_effects OK (#313)
* audio_playback.c * format.sh * rename functions * Audio_SequenceChannelProcessSound * Audio_SequencePlayerProcessSound * Audio_GetPortamentoFreqScale * Audio_GetVibratoPitchChange * Audio_GetVibratoFreqScale * Audio_NoteVibratoInit, Audio_NoteVibratoUpdate * Audio_NotePortamentoInit * Audio_AdsrInit * Audio_AdsrUpdate * Common bitfield formatting * format.sh * review Co-authored-by: zelda2774 <zelda2774@invalid>
This commit is contained in:
parent
ac8796cbc9
commit
d68f9893fd
115 changed files with 1014 additions and 1825 deletions
331
src/code/audio_effects.c
Normal file
331
src/code/audio_effects.c
Normal file
|
@ -0,0 +1,331 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
void Audio_SequenceChannelProcessSound(SequenceChannel* seqChannel, s32 recalculateVolume, s32 b) {
|
||||
f32 channelVolume;
|
||||
f32 chanFreqScale;
|
||||
s32 i;
|
||||
|
||||
if (seqChannel->changes.s.volume || recalculateVolume) {
|
||||
channelVolume = seqChannel->volume * seqChannel->volumeScale * seqChannel->seqPlayer->appliedFadeVolume;
|
||||
if (seqChannel->seqPlayer->muted && (seqChannel->muteBehavior & 0x20)) {
|
||||
channelVolume = seqChannel->seqPlayer->muteVolumeScale * channelVolume;
|
||||
}
|
||||
seqChannel->appliedVolume = channelVolume * channelVolume;
|
||||
}
|
||||
|
||||
if (seqChannel->changes.s.pan) {
|
||||
seqChannel->pan = seqChannel->newPan * seqChannel->panChannelWeight;
|
||||
}
|
||||
|
||||
chanFreqScale = seqChannel->freqScale;
|
||||
if (b != 0) {
|
||||
chanFreqScale *= seqChannel->seqPlayer->unk_34;
|
||||
seqChannel->changes.s.freqScale = 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 4; i++) {
|
||||
SequenceChannelLayer* layer = seqChannel->layers[i];
|
||||
if (layer != NULL && layer->enabled && layer->note != NULL) {
|
||||
if (layer->notePropertiesNeedInit) {
|
||||
layer->noteFreqScale = layer->freqScale * chanFreqScale;
|
||||
layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume;
|
||||
layer->notePan = (seqChannel->pan + layer->pan * (0x80 - seqChannel->panChannelWeight)) >> 7;
|
||||
layer->notePropertiesNeedInit = 0;
|
||||
} else {
|
||||
if (seqChannel->changes.s.freqScale) {
|
||||
layer->noteFreqScale = layer->freqScale * chanFreqScale;
|
||||
}
|
||||
if (seqChannel->changes.s.volume || recalculateVolume) {
|
||||
layer->noteVelocity = layer->velocitySquare * seqChannel->appliedVolume;
|
||||
}
|
||||
if (seqChannel->changes.s.pan) {
|
||||
layer->notePan = (seqChannel->pan + layer->pan * (0x80 - seqChannel->panChannelWeight)) >> 7;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
seqChannel->changes.asByte = 0;
|
||||
}
|
||||
|
||||
void Audio_SequencePlayerProcessSound(SequencePlayer* seqPlayer) {
|
||||
s32 i;
|
||||
|
||||
if (seqPlayer->fadeTimer != 0) {
|
||||
seqPlayer->fadeVolume += seqPlayer->fadeVelocity;
|
||||
seqPlayer->recalculateVolume = 1;
|
||||
|
||||
if (seqPlayer->fadeVolume > 1.0f) {
|
||||
seqPlayer->fadeVolume = 1.0f;
|
||||
}
|
||||
if (seqPlayer->fadeVolume < 0) {
|
||||
seqPlayer->fadeVolume = 0;
|
||||
}
|
||||
|
||||
if (--seqPlayer->fadeTimer == 0 && seqPlayer->state == 2) {
|
||||
Audio_SequencePlayerDisable(seqPlayer);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (seqPlayer->recalculateVolume) {
|
||||
seqPlayer->appliedFadeVolume = seqPlayer->fadeVolume * seqPlayer->fadeVolumeScale;
|
||||
}
|
||||
|
||||
for (i = 0; i < 16; i++) {
|
||||
if (seqPlayer->channels[i]->enabled == 1) {
|
||||
Audio_SequenceChannelProcessSound(seqPlayer->channels[i], seqPlayer->recalculateVolume, seqPlayer->unk_0b1);
|
||||
}
|
||||
}
|
||||
|
||||
seqPlayer->recalculateVolume = 0;
|
||||
}
|
||||
|
||||
f32 Audio_GetPortamentoFreqScale(Portamento* p) {
|
||||
u32 loResCur;
|
||||
f32 result;
|
||||
|
||||
p->cur += p->speed;
|
||||
loResCur = (p->cur >> 8) & 0xff;
|
||||
|
||||
if (loResCur >= 127) {
|
||||
loResCur = 127;
|
||||
p->mode = 0;
|
||||
}
|
||||
|
||||
result = 1.0f + p->extent * (gPitchBendFrequencyScale[loResCur + 128] - 1.0f);
|
||||
return result;
|
||||
}
|
||||
|
||||
s16 Audio_GetVibratoPitchChange(VibratoState* vib) {
|
||||
s32 index;
|
||||
vib->time += (s32)vib->rate;
|
||||
index = (vib->time >> 10) & 0x3F;
|
||||
return vib->curve[index];
|
||||
}
|
||||
|
||||
f32 Audio_GetVibratoFreqScale(VibratoState* vib) {
|
||||
f32 pitchChange;
|
||||
f32 extent;
|
||||
f32 invExtent;
|
||||
f32 result;
|
||||
f32 temp;
|
||||
f32 twoToThe16th = 65536.0f;
|
||||
s32 one = 1;
|
||||
SequenceChannel* channel = vib->seqChannel;
|
||||
|
||||
if (vib->delay != 0) {
|
||||
vib->delay--;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (channel != NO_CHANNEL) {
|
||||
if (vib->extentChangeTimer) {
|
||||
if (vib->extentChangeTimer == 1) {
|
||||
vib->extent = (s32)channel->vibratoExtentTarget;
|
||||
} else {
|
||||
vib->extent += ((s32)channel->vibratoExtentTarget - vib->extent) / (s32)vib->extentChangeTimer;
|
||||
}
|
||||
|
||||
vib->extentChangeTimer--;
|
||||
} else if (channel->vibratoExtentTarget != (s32)vib->extent) {
|
||||
if ((vib->extentChangeTimer = channel->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = (s32)channel->vibratoExtentTarget;
|
||||
}
|
||||
}
|
||||
|
||||
if (vib->rateChangeTimer) {
|
||||
if (vib->rateChangeTimer == 1) {
|
||||
vib->rate = (s32)channel->vibratoRateTarget;
|
||||
} else {
|
||||
vib->rate += ((s32)channel->vibratoRateTarget - vib->rate) / (s32)vib->rateChangeTimer;
|
||||
}
|
||||
|
||||
vib->rateChangeTimer--;
|
||||
} else if (channel->vibratoRateTarget != (s32)vib->rate) {
|
||||
if ((vib->rateChangeTimer = channel->vibratoRateChangeDelay) == 0) {
|
||||
vib->rate = (s32)channel->vibratoRateTarget;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vib->extent == 0) {
|
||||
return 1.0f;
|
||||
}
|
||||
|
||||
pitchChange = Audio_GetVibratoPitchChange(vib) + 32768.0f;
|
||||
temp = vib->extent / 4096.0f;
|
||||
extent = temp + 1.0f;
|
||||
invExtent = 1.0f / extent;
|
||||
|
||||
// fakematch: 2^16 and 1 need to be set at the very top of this function,
|
||||
// or else the addresses of D_80130510 and D_80130514 get computed once
|
||||
// instead of twice. 'temp' is also a fakematch sign; removing it causes
|
||||
// regalloc differences and reorderings at the top of the function.
|
||||
result = 1.0f / ((extent - invExtent) * pitchChange / twoToThe16th + invExtent);
|
||||
D_80130510 += result;
|
||||
D_80130514 += one;
|
||||
return result;
|
||||
}
|
||||
|
||||
void Audio_NoteVibratoUpdate(Note* note) {
|
||||
if (note->portamento.mode != 0) {
|
||||
note->playbackState.portamentoFreqScale = Audio_GetPortamentoFreqScale(¬e->portamento);
|
||||
}
|
||||
if (note->vibratoState.active) {
|
||||
note->playbackState.vibratoFreqScale = Audio_GetVibratoFreqScale(¬e->vibratoState);
|
||||
}
|
||||
}
|
||||
|
||||
void Audio_NoteVibratoInit(Note* note) {
|
||||
VibratoState* vib;
|
||||
SequenceChannel* seqChannel;
|
||||
|
||||
note->playbackState.vibratoFreqScale = 1.0f;
|
||||
|
||||
vib = ¬e->vibratoState;
|
||||
|
||||
vib->active = 1;
|
||||
vib->time = 0;
|
||||
|
||||
vib->curve = gWaveSamples[2];
|
||||
vib->seqChannel = note->playbackState.parentLayer->seqChannel;
|
||||
seqChannel = vib->seqChannel;
|
||||
if ((vib->extentChangeTimer = seqChannel->vibratoExtentChangeDelay) == 0) {
|
||||
vib->extent = (s32)seqChannel->vibratoExtentTarget;
|
||||
} else {
|
||||
vib->extent = (s32)seqChannel->vibratoExtentStart;
|
||||
}
|
||||
|
||||
if ((vib->rateChangeTimer = seqChannel->vibratoRateChangeDelay) == 0) {
|
||||
vib->rate = (s32)seqChannel->vibratoRateTarget;
|
||||
} else {
|
||||
vib->rate = (s32)seqChannel->vibratoRateStart;
|
||||
}
|
||||
vib->delay = seqChannel->vibratoDelay;
|
||||
}
|
||||
|
||||
void Audio_NotePortamentoInit(Note* note) {
|
||||
note->playbackState.portamentoFreqScale = 1.0f;
|
||||
note->portamento = note->playbackState.parentLayer->portamento;
|
||||
}
|
||||
|
||||
void Audio_AdsrInit(AdsrState* adsr, AdsrEnvelope* envelope, s16* volOut) {
|
||||
adsr->action.asByte = 0;
|
||||
adsr->delay = 0;
|
||||
adsr->envelope = envelope;
|
||||
adsr->sustain = 0.0f;
|
||||
adsr->current = 0.0f;
|
||||
// (An older versions of the audio engine used in Super Mario 64 did
|
||||
// adsr->volOut = volOut. That line and associated struct member were
|
||||
// removed, but the function parameter was forgotten and remains.)
|
||||
}
|
||||
|
||||
f32 Audio_AdsrUpdate(AdsrState* adsr) {
|
||||
u8 state = adsr->action.s.state;
|
||||
switch (state) {
|
||||
case ADSR_STATE_DISABLED:
|
||||
return 0.0f;
|
||||
|
||||
case ADSR_STATE_INITIAL: {
|
||||
if (adsr->action.s.hang) {
|
||||
adsr->action.s.state = ADSR_STATE_HANG;
|
||||
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;
|
||||
switch (adsr->delay) {
|
||||
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 *= D_801719EC;
|
||||
if (adsr->delay == 0) {
|
||||
adsr->delay = 1;
|
||||
}
|
||||
adsr->target = adsr->envelope[adsr->envIndex].arg / 32767.0f;
|
||||
adsr->target = adsr->target * adsr->target;
|
||||
adsr->velocity = (adsr->target - adsr->current) / adsr->delay;
|
||||
adsr->action.s.state = ADSR_STATE_FADE;
|
||||
adsr->envIndex++;
|
||||
break;
|
||||
}
|
||||
if (adsr->action.s.state != ADSR_STATE_FADE) {
|
||||
break;
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_FADE:
|
||||
adsr->current += adsr->velocity;
|
||||
if (--adsr->delay <= 0) {
|
||||
adsr->action.s.state = ADSR_STATE_LOOP;
|
||||
}
|
||||
// fallthrough
|
||||
|
||||
case ADSR_STATE_HANG:
|
||||
break;
|
||||
|
||||
case ADSR_STATE_DECAY:
|
||||
case ADSR_STATE_RELEASE: {
|
||||
adsr->current -= adsr->fadeOutVel;
|
||||
if (adsr->sustain != 0.0f && state == ADSR_STATE_DECAY) {
|
||||
if (adsr->current < adsr->sustain) {
|
||||
adsr->current = adsr->sustain;
|
||||
adsr->delay = 128;
|
||||
adsr->action.s.state = ADSR_STATE_SUSTAIN;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (adsr->current < 0.00001f) {
|
||||
adsr->current = 0.0f;
|
||||
adsr->action.s.state = ADSR_STATE_DISABLED;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case ADSR_STATE_SUSTAIN:
|
||||
adsr->delay -= 1;
|
||||
if (adsr->delay == 0) {
|
||||
adsr->action.s.state = ADSR_STATE_RELEASE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
if (adsr->action.s.decay) {
|
||||
adsr->action.s.state = ADSR_STATE_DECAY;
|
||||
adsr->action.s.decay = 0;
|
||||
}
|
||||
|
||||
if (adsr->action.s.release) {
|
||||
adsr->action.s.state = ADSR_STATE_RELEASE;
|
||||
adsr->action.s.release = 0;
|
||||
}
|
||||
|
||||
if (adsr->current < 0.0f) {
|
||||
return 0.0f;
|
||||
}
|
||||
if (adsr->current > 1.0f) {
|
||||
return 1.0f;
|
||||
}
|
||||
return adsr->current;
|
||||
}
|
106
src/code/audio_heap.c
Normal file
106
src/code/audio_heap.c
Normal file
|
@ -0,0 +1,106 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DDE20.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DDE3C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DDF80.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE048.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE12C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE1B4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE238.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE258.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE2B0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/Audio_SoundAlloc.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE344.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE380.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE3DC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE434.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE45C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE470.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE4A0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE4B0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE5F0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE650.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE6D4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE758.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE81C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DE8E0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF074.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF0CC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF1D8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF5AC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF5DC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF630.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF688.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF7BC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF7C4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF888.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DF8F4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800DFBF8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E04E8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0540.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E05C4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0634.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E06CC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0964.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0AD8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0BB4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0BF8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0C80.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0CBC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0E0C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0E6C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0E90.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E0EB4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_heap/func_800E1148.s")
|
|
@ -10,27 +10,27 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
|
|||
f32 vel;
|
||||
u8 pan;
|
||||
u8 reverbVol;
|
||||
ReverbBits sp24;
|
||||
ReverbBitsData sp24;
|
||||
s32 stereoHeadsetEffects = note->playbackState.stereoHeadsetEffects;
|
||||
vel = reverb->unk_8;
|
||||
vel = reverb->velocity;
|
||||
|
||||
pan = reverb->pan;
|
||||
reverbVol = reverb->reverb;
|
||||
sp24 = reverb->reverbBits;
|
||||
sp24 = reverb->reverbBits.s;
|
||||
|
||||
sub->bitField0.asByte = note->noteSubEu.bitField0.asByte & 0xFF;
|
||||
sub->bitField1.asByte = note->noteSubEu.bitField1.asByte & 0xFF;
|
||||
sub->bitField0.s = note->noteSubEu.bitField0.s;
|
||||
sub->bitField1.s = note->noteSubEu.bitField1.s;
|
||||
sub->sound.samples = note->noteSubEu.sound.samples;
|
||||
sub->unk_06 = note->noteSubEu.unk_06;
|
||||
|
||||
Audio_NoteSetResamplingRate(sub, reverb->velocity);
|
||||
Audio_NoteSetResamplingRate(sub, reverb->frequency);
|
||||
|
||||
pan &= 0x7F;
|
||||
|
||||
sub->bitField0.asBitfields.stereoStrongRight = 0;
|
||||
sub->bitField0.asBitfields.stereoStrongLeft = 0;
|
||||
sub->bitField0.asBitfields.stereoHeadsetEffects = sp24.stereoHeadsetEffects;
|
||||
sub->bitField0.asBitfields.usesHeadsetPanEffects = sp24.usesHeadsetPanEffects;
|
||||
sub->bitField0.s.stereoStrongRight = 0;
|
||||
sub->bitField0.s.stereoStrongLeft = 0;
|
||||
sub->bitField0.s.stereoHeadsetEffects = sp24.stereoHeadsetEffects;
|
||||
sub->bitField0.s.usesHeadsetPanEffects = sp24.usesHeadsetPanEffects;
|
||||
if (stereoHeadsetEffects && gSoundMode == 1) {
|
||||
smallPanIndex = pan >> 1;
|
||||
if (smallPanIndex > 0x3f) {
|
||||
|
@ -39,7 +39,7 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
|
|||
|
||||
sub->headsetPanLeft = gHeadsetPanQuantization[smallPanIndex];
|
||||
sub->headsetPanRight = gHeadsetPanQuantization[0x3f - smallPanIndex];
|
||||
sub->bitField1.asBitfields.hasTwoAdpcmParts = 1;
|
||||
sub->bitField1.s.hasTwoAdpcmParts = 1;
|
||||
|
||||
volLeft = gHeadsetPanVolume[pan];
|
||||
volRight = gHeadsetPanVolume[0x7f - pan];
|
||||
|
@ -47,7 +47,7 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
|
|||
strongLeft = strongRight = 0;
|
||||
sub->headsetPanRight = 0;
|
||||
sub->headsetPanLeft = 0;
|
||||
sub->bitField1.asBitfields.hasTwoAdpcmParts = 0;
|
||||
sub->bitField1.s.hasTwoAdpcmParts = 0;
|
||||
|
||||
volLeft = gStereoPanVolume[pan];
|
||||
volRight = gStereoPanVolume[0x7f - pan];
|
||||
|
@ -57,34 +57,34 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
|
|||
strongRight = 1;
|
||||
}
|
||||
|
||||
sub->bitField0.asBitfields.stereoStrongRight = strongRight;
|
||||
sub->bitField0.asBitfields.stereoStrongLeft = strongLeft;
|
||||
sub->bitField0.s.stereoStrongRight = strongRight;
|
||||
sub->bitField0.s.stereoStrongLeft = strongLeft;
|
||||
|
||||
switch (sp24.bit2) {
|
||||
case 0:
|
||||
break;
|
||||
case 1:
|
||||
sub->bitField0.asBitfields.stereoStrongRight = sp24.strongRight;
|
||||
sub->bitField0.asBitfields.stereoStrongLeft = sp24.strongLeft;
|
||||
sub->bitField0.s.stereoStrongRight = sp24.strongRight;
|
||||
sub->bitField0.s.stereoStrongLeft = sp24.strongLeft;
|
||||
break;
|
||||
case 2:
|
||||
sub->bitField0.asBitfields.stereoStrongRight = sp24.strongRight | strongRight;
|
||||
sub->bitField0.asBitfields.stereoStrongLeft = sp24.strongLeft | strongLeft;
|
||||
sub->bitField0.s.stereoStrongRight = sp24.strongRight | strongRight;
|
||||
sub->bitField0.s.stereoStrongLeft = sp24.strongLeft | strongLeft;
|
||||
break;
|
||||
case 3:
|
||||
sub->bitField0.asBitfields.stereoStrongRight = sp24.strongRight ^ strongRight;
|
||||
sub->bitField0.asBitfields.stereoStrongLeft = sp24.strongLeft ^ strongLeft;
|
||||
sub->bitField0.s.stereoStrongRight = sp24.strongRight ^ strongRight;
|
||||
sub->bitField0.s.stereoStrongLeft = sp24.strongLeft ^ strongLeft;
|
||||
break;
|
||||
}
|
||||
|
||||
} else if (gSoundMode == 3) {
|
||||
sub->bitField0.asBitfields.stereoHeadsetEffects = 0;
|
||||
sub->bitField0.asBitfields.usesHeadsetPanEffects = 0;
|
||||
sub->bitField0.s.stereoHeadsetEffects = 0;
|
||||
sub->bitField0.s.usesHeadsetPanEffects = 0;
|
||||
volLeft = 0.707f;
|
||||
volRight = 0.707f;
|
||||
} else {
|
||||
sub->bitField0.asBitfields.stereoStrongRight = sp24.strongRight;
|
||||
sub->bitField0.asBitfields.stereoStrongLeft = sp24.strongLeft;
|
||||
sub->bitField0.s.stereoStrongRight = sp24.strongRight;
|
||||
sub->bitField0.s.stereoStrongLeft = sp24.strongLeft;
|
||||
volLeft = gDefaultPanVolume[pan];
|
||||
volRight = gDefaultPanVolume[0x7f - pan];
|
||||
}
|
||||
|
@ -95,7 +95,7 @@ void Audio_NoteSetVelPanReverb(Note* note, NoteSubEu* sub, Reverb* reverb) {
|
|||
sub->targetVolLeft = (s32)((vel * volLeft) * 4095.999f);
|
||||
sub->targetVolRight = (s32)((vel * volRight) * 4095.999f);
|
||||
|
||||
sub->bankId = reverb->bankId;
|
||||
sub->unk_2 = reverb->unk_1;
|
||||
sub->unk_14 = reverb->unk_10;
|
||||
sub->unk_07 = reverb->unk_14;
|
||||
sub->unk_10 = reverb->unk_16;
|
||||
|
@ -106,7 +106,7 @@ void Audio_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput)
|
|||
f32 resamplingRate = 0.0f;
|
||||
|
||||
if (resamplingRateInput < 2.0f) {
|
||||
noteSubEu->bitField1.asBitfields.isSyntheticWave = 0;
|
||||
noteSubEu->bitField1.s.isSyntheticWave = 0;
|
||||
|
||||
if (1.99998f < resamplingRateInput) {
|
||||
resamplingRate = 1.99998f;
|
||||
|
@ -115,7 +115,7 @@ void Audio_NoteSetResamplingRate(NoteSubEu* noteSubEu, f32 resamplingRateInput)
|
|||
}
|
||||
|
||||
} else {
|
||||
noteSubEu->bitField1.asBitfields.isSyntheticWave = 1;
|
||||
noteSubEu->bitField1.s.isSyntheticWave = 1;
|
||||
if (3.99996f < resamplingRateInput) {
|
||||
resamplingRate = 1.99998f;
|
||||
} else {
|
||||
|
@ -135,25 +135,166 @@ void Audio_NoteInit(Note* note) {
|
|||
}
|
||||
|
||||
note->playbackState.unk_04 = 0;
|
||||
note->playbackState.adsr.adsrAction.adsrBits.bits0 = 1;
|
||||
note->playbackState.adsr.action.s.state = ADSR_STATE_INITIAL;
|
||||
note->noteSubEu = gDefaultNoteSub;
|
||||
}
|
||||
|
||||
void Audio_NoteDisable(Note* note) {
|
||||
if (note->noteSubEu.bitField0.asBitfields.needsInit == 1) {
|
||||
note->noteSubEu.bitField0.asBitfields.needsInit = 0;
|
||||
if (note->noteSubEu.bitField0.s.needsInit == 1) {
|
||||
note->noteSubEu.bitField0.s.needsInit = 0;
|
||||
}
|
||||
note->playbackState.priority = 0;
|
||||
note->noteSubEu.bitField0.asBitfields.enabled = 0;
|
||||
note->noteSubEu.bitField0.s.enabled = 0;
|
||||
note->playbackState.unk_04 = 0;
|
||||
note->noteSubEu.bitField0.asBitfields.finished = 0;
|
||||
note->noteSubEu.bitField0.s.finished = 0;
|
||||
note->playbackState.parentLayer = NO_LAYER;
|
||||
note->playbackState.prevParentLayer = NO_LAYER;
|
||||
note->playbackState.adsr.adsrAction.adsrBits.bits0 = 0;
|
||||
note->playbackState.adsr.fadeOutVel = 0;
|
||||
note->playbackState.adsr.action.s.state = ADSR_STATE_DISABLED;
|
||||
note->playbackState.adsr.current = 0;
|
||||
}
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/Audio_ProcessNotes.s")
|
||||
void Audio_ProcessNotes(void) {
|
||||
s32 pad[2];
|
||||
NoteAttributes* attributes;
|
||||
NoteSubEu* noteSubEu2;
|
||||
NoteSubEu* noteSubEu;
|
||||
Note* note;
|
||||
NotePlaybackState* playbackState;
|
||||
Reverb reverb;
|
||||
u8 bookOffset;
|
||||
f32 scale;
|
||||
s32 i;
|
||||
|
||||
for (i = 0; i < gAudioContext.gMaxSimultaneousNotes; i++) {
|
||||
note = &gAudioContext.gNotes[i];
|
||||
noteSubEu2 = &gAudioContext.gNoteSubsEu[gAudioContext.gNoteSubEuOffset + i];
|
||||
playbackState = ¬e->playbackState;
|
||||
if (playbackState->parentLayer != NO_LAYER) {
|
||||
if ((u32)playbackState->parentLayer < 0x7FFFFFFFU) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (note != playbackState->parentLayer->note && playbackState->unk_04 == 0) {
|
||||
playbackState->adsr.action.s.release = 1;
|
||||
playbackState->adsr.fadeOutVel = gAudioContext.gAudioBufferParameters.updatesPerFrameInv;
|
||||
playbackState->priority = 1;
|
||||
playbackState->unk_04 = 2;
|
||||
goto out;
|
||||
} else if (!playbackState->parentLayer->enabled && playbackState->unk_04 == 0 &&
|
||||
playbackState->priority >= 1) {
|
||||
// do nothing
|
||||
} else if (playbackState->parentLayer->seqChannel->seqPlayer == NULL) {
|
||||
Audio_SequenceChannelDisable(playbackState->parentLayer->seqChannel);
|
||||
playbackState->priority = 1;
|
||||
playbackState->unk_04 = 1;
|
||||
continue;
|
||||
} else if (playbackState->parentLayer->seqChannel->seqPlayer->muted &&
|
||||
(playbackState->parentLayer->seqChannel->muteBehavior & 0x40)) {
|
||||
// do nothing
|
||||
} else {
|
||||
goto out;
|
||||
}
|
||||
|
||||
Audio_SeqChanLayerNoteRelease(playbackState->parentLayer);
|
||||
Audio_AudioListRemove(¬e->listItem);
|
||||
Audio_AudioListPushFront(¬e->listItem.pool->decaying, ¬e->listItem);
|
||||
playbackState->priority = 1;
|
||||
playbackState->unk_04 = 2;
|
||||
} else if (playbackState->unk_04 == 0 && playbackState->priority >= 1) {
|
||||
continue;
|
||||
}
|
||||
|
||||
out:
|
||||
if (playbackState->priority != 0) {
|
||||
if (1) {}
|
||||
noteSubEu = ¬e->noteSubEu;
|
||||
if (playbackState->unk_04 >= 1 || noteSubEu->bitField0.s.finished) {
|
||||
if (playbackState->adsr.action.s.state == ADSR_STATE_DISABLED || noteSubEu->bitField0.s.finished) {
|
||||
if (playbackState->wantedParentLayer != NO_LAYER) {
|
||||
Audio_NoteDisable(note);
|
||||
if (playbackState->wantedParentLayer->seqChannel != NULL) {
|
||||
Audio_NoteInitForLayer(note, playbackState->wantedParentLayer);
|
||||
Audio_NoteVibratoInit(note);
|
||||
Audio_NotePortamentoInit(note);
|
||||
Audio_AudioListRemove(¬e->listItem);
|
||||
Audio_AudioListPushBack(¬e->listItem.pool->active, ¬e->listItem);
|
||||
playbackState->wantedParentLayer = NO_LAYER;
|
||||
// don't skip
|
||||
} else {
|
||||
Audio_NoteDisable(note);
|
||||
Audio_AudioListRemove(¬e->listItem);
|
||||
Audio_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem);
|
||||
playbackState->wantedParentLayer = NO_LAYER;
|
||||
goto skip;
|
||||
}
|
||||
} else {
|
||||
if (playbackState->parentLayer != NO_LAYER) {
|
||||
playbackState->parentLayer->ignoreDrumPan = 1; // wrong field name
|
||||
}
|
||||
Audio_NoteDisable(note);
|
||||
Audio_AudioListRemove(¬e->listItem);
|
||||
Audio_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
} else if (playbackState->adsr.action.s.state == ADSR_STATE_DISABLED) {
|
||||
if (playbackState->parentLayer != NO_LAYER) {
|
||||
playbackState->parentLayer->ignoreDrumPan = 1; // wrong field name
|
||||
}
|
||||
Audio_NoteDisable(note);
|
||||
Audio_AudioListRemove(¬e->listItem);
|
||||
Audio_AudioListPushBack(¬e->listItem.pool->disabled, ¬e->listItem);
|
||||
continue;
|
||||
}
|
||||
|
||||
scale = Audio_AdsrUpdate(&playbackState->adsr);
|
||||
Audio_NoteVibratoUpdate(note);
|
||||
attributes = &playbackState->attributes;
|
||||
if (playbackState->unk_04 == 1 || playbackState->unk_04 == 2) {
|
||||
reverb.frequency = attributes->freqScale;
|
||||
reverb.velocity = attributes->velocity;
|
||||
reverb.pan = attributes->pan;
|
||||
reverb.reverb = attributes->reverb;
|
||||
reverb.reverbBits = attributes->reverbBits;
|
||||
reverb.unk_1 = attributes->unk_1;
|
||||
reverb.unk_10 = attributes->unk_10;
|
||||
reverb.unk_14 = attributes->unk_4;
|
||||
reverb.unk_16 = attributes->unk_6;
|
||||
bookOffset = noteSubEu->bitField1.s.bookOffset;
|
||||
} else {
|
||||
SequenceChannelLayer* layer = playbackState->parentLayer;
|
||||
SequenceChannel* channel = layer->seqChannel;
|
||||
|
||||
reverb.frequency = layer->noteFreqScale;
|
||||
reverb.velocity = layer->noteVelocity;
|
||||
reverb.pan = layer->notePan;
|
||||
if (layer->reverbBits.asByte == 0) {
|
||||
reverb.reverbBits = channel->reverbBits;
|
||||
} else {
|
||||
reverb.reverbBits = layer->reverbBits;
|
||||
}
|
||||
reverb.reverb = channel->reverb;
|
||||
reverb.unk_1 = channel->unk_0C;
|
||||
reverb.unk_10 = channel->unk_CC;
|
||||
reverb.unk_14 = channel->unk_0F;
|
||||
reverb.unk_16 = channel->unk_20;
|
||||
bookOffset = channel->bookOffset & 0x7;
|
||||
|
||||
if (channel->seqPlayer->muted && (channel->muteBehavior & 8)) {
|
||||
reverb.frequency = 0.0f;
|
||||
reverb.velocity = 0.0f;
|
||||
}
|
||||
}
|
||||
|
||||
reverb.frequency *= playbackState->vibratoFreqScale * playbackState->portamentoFreqScale;
|
||||
reverb.frequency *= gAudioContext.gAudioBufferParameters.resampleRate;
|
||||
reverb.velocity *= scale;
|
||||
Audio_NoteSetVelPanReverb(note, noteSubEu2, &reverb);
|
||||
noteSubEu->bitField1.s.bookOffset = bookOffset;
|
||||
skip:;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AudioBankSound* Audio_InstrumentGetAudioBankSound(Instrument* instrument, s32 semitone) {
|
||||
AudioBankSound* sound;
|
||||
|
@ -256,8 +397,6 @@ UnkInstrument* Audio_GetUnkInstrument(s32 bankId, s32 unkInstrumentId) {
|
|||
}
|
||||
|
||||
s32 func_800E7744(s32 instrument, s32 bankId, s32 instId, UnkInstrument* arg3) {
|
||||
UnkInstrument* temp_t7;
|
||||
|
||||
if (bankId == 0xFF) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -271,7 +410,7 @@ s32 func_800E7744(s32 instrument, s32 bankId, s32 instId, UnkInstrument* arg3) {
|
|||
if (instId >= (gAudioContext.gCtlEntries[bankId].numDrums)) {
|
||||
return -3;
|
||||
}
|
||||
gAudioContext.gCtlEntries[bankId].drums[instId] = arg3;
|
||||
gAudioContext.gCtlEntries[bankId].drums[instId] = (void*)arg3;
|
||||
break;
|
||||
|
||||
case 1:
|
||||
|
@ -285,19 +424,18 @@ s32 func_800E7744(s32 instrument, s32 bankId, s32 instId, UnkInstrument* arg3) {
|
|||
if (instId >= (gAudioContext.gCtlEntries[bankId].numInstruments)) {
|
||||
return -3;
|
||||
}
|
||||
gAudioContext.gCtlEntries[bankId].instruments[instId] = arg3;
|
||||
gAudioContext.gCtlEntries[bankId].instruments[instId] = (void*)arg3;
|
||||
break;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef NON_EQUIVALENT
|
||||
// This code is SM64 PAL's version with changes made to build here (and a couple legitimate changes made in the
|
||||
// function). This function needs massive work, hence why it is not set for NON_MATCHING
|
||||
void Audio_SeqChanLayerDecayRelease(SequenceChannelLayer* seqLayer, s32 target) {
|
||||
Note* note;
|
||||
NoteAttributes* attributes;
|
||||
SequenceChannel* chan;
|
||||
s32 i;
|
||||
|
||||
if (seqLayer == NO_LAYER) {
|
||||
return;
|
||||
|
@ -318,56 +456,79 @@ void Audio_SeqChanLayerDecayRelease(SequenceChannelLayer* seqLayer, s32 target)
|
|||
|
||||
if (note->playbackState.parentLayer != seqLayer) {
|
||||
if (note->playbackState.parentLayer == NO_LAYER && note->playbackState.wantedParentLayer == NO_LAYER &&
|
||||
note->playbackState.prevParentLayer == seqLayer && target != 6) {
|
||||
note->playbackState.prevParentLayer == seqLayer && target != ADSR_STATE_DECAY) {
|
||||
note->playbackState.adsr.fadeOutVel = gAudioContext.gAudioBufferParameters.updatesPerFrameInv;
|
||||
note->playbackState.adsr.adsrAction.action |= 0x10;
|
||||
note->playbackState.adsr.action.s.release = 1;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
seqLayer->status = 0;
|
||||
if (note->playbackState.adsr.state != 6) {
|
||||
if (note->playbackState.adsr.action.s.state != ADSR_STATE_DECAY) {
|
||||
attributes->freqScale = seqLayer->noteFreqScale;
|
||||
attributes->velocity = seqLayer->noteVelocity;
|
||||
attributes->pan = seqLayer->notePan;
|
||||
|
||||
if (seqLayer->seqChannel != NULL) {
|
||||
attributes->reverb = seqLayer->seqChannel->reverb;
|
||||
chan = seqLayer->seqChannel;
|
||||
attributes->reverb = chan->reverb;
|
||||
attributes->unk_1 = chan->unk_0C;
|
||||
attributes->unk_10 = chan->unk_CC;
|
||||
|
||||
if (attributes->unk_10 != NULL) {
|
||||
for (i = 0; i < 8; i++) {
|
||||
attributes->unk_14[i] = attributes->unk_10[i];
|
||||
}
|
||||
attributes->unk_10 = attributes->unk_14;
|
||||
}
|
||||
|
||||
attributes->unk_6 = chan->unk_20;
|
||||
attributes->unk_4 = chan->unk_0F;
|
||||
if (chan->seqPlayer->muted && (chan->muteBehavior & 8)) {
|
||||
note->noteSubEu.bitField0.s.finished = 1;
|
||||
}
|
||||
|
||||
if (seqLayer->reverbBits.asByte == 0) {
|
||||
attributes->reverbBits = chan->reverbBits;
|
||||
} else {
|
||||
attributes->reverbBits = seqLayer->reverbBits;
|
||||
}
|
||||
note->playbackState.priority = chan->someOtherPriority;
|
||||
} else {
|
||||
attributes->reverbBits = seqLayer->reverbBits;
|
||||
note->playbackState.priority = 1;
|
||||
}
|
||||
note->playbackState.priority = 1;
|
||||
|
||||
note->playbackState.prevParentLayer = note->playbackState.parentLayer;
|
||||
note->playbackState.parentLayer = NO_LAYER;
|
||||
if (target == 7) {
|
||||
if (target == ADSR_STATE_RELEASE) {
|
||||
note->playbackState.adsr.fadeOutVel = gAudioContext.gAudioBufferParameters.updatesPerFrameInv;
|
||||
note->playbackState.adsr.adsrAction.action |= 0x10;
|
||||
note->playbackState.adsr.action.s.release = 1;
|
||||
note->playbackState.unk_04 = 2;
|
||||
} else {
|
||||
note->playbackState.adsr.adsrAction.action |= 0x20;
|
||||
note->playbackState.unk_04 = 1;
|
||||
note->playbackState.adsr.action.s.decay = 1;
|
||||
if (seqLayer->adsr.releaseRate == 0) {
|
||||
note->playbackState.adsr.fadeOutVel = seqLayer->seqChannel->adsr.releaseRate *
|
||||
gAudioContext.gAudioBufferParameters.unkUpdatesPerFrameScaled;
|
||||
note->playbackState.adsr.fadeOutVel = D_801726A0[seqLayer->seqChannel->adsr.releaseRate];
|
||||
} else {
|
||||
note->playbackState.adsr.fadeOutVel =
|
||||
seqLayer->adsr.releaseRate * gAudioContext.gAudioBufferParameters.unkUpdatesPerFrameScaled;
|
||||
note->playbackState.adsr.fadeOutVel = D_801726A0[seqLayer->adsr.releaseRate];
|
||||
}
|
||||
note->playbackState.adsr.sustain =
|
||||
((f32)(s32)(seqLayer->seqChannel->adsr.sustain) * note->playbackState.adsr.current) / 256.0f;
|
||||
}
|
||||
}
|
||||
|
||||
if (target == 6) {
|
||||
if (target == ADSR_STATE_DECAY) {
|
||||
Audio_AudioListRemove(¬e->listItem);
|
||||
Audio_AudioListPushFront(¬e->listItem.pool->decaying, ¬e->listItem);
|
||||
}
|
||||
}
|
||||
#else
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_playback/Audio_SeqChanLayerDecayRelease.s")
|
||||
#endif
|
||||
|
||||
void Audio_SeqChanLayerNoteDecay(SequenceChannelLayer* seqLayer) {
|
||||
Audio_SeqChanLayerDecayRelease(seqLayer, 6);
|
||||
Audio_SeqChanLayerDecayRelease(seqLayer, ADSR_STATE_DECAY);
|
||||
}
|
||||
|
||||
void Audio_SeqChanLayerNoteRelease(SequenceChannelLayer* seqLayer) {
|
||||
Audio_SeqChanLayerDecayRelease(seqLayer, 7);
|
||||
Audio_SeqChanLayerDecayRelease(seqLayer, ADSR_STATE_RELEASE);
|
||||
}
|
||||
|
||||
s32 Audio_BuildSyntheticWave(Note* note, SequenceChannelLayer* seqLayer, s32 waveId) {
|
||||
|
@ -379,9 +540,9 @@ s32 Audio_BuildSyntheticWave(Note* note, SequenceChannelLayer* seqLayer, s32 wav
|
|||
waveId = 128;
|
||||
}
|
||||
|
||||
freqScale = seqLayer->noteFreqScale;
|
||||
if (seqLayer->portamento.mode != 0 && 0.0f < seqLayer->portamento.speed) {
|
||||
freqScale *= (seqLayer->portamento.speed + 1.0f);
|
||||
freqScale = seqLayer->freqScale;
|
||||
if (seqLayer->portamento.mode != 0 && 0.0f < seqLayer->portamento.extent) {
|
||||
freqScale *= (seqLayer->portamento.extent + 1.0f);
|
||||
}
|
||||
if (freqScale < 0.99999f) {
|
||||
sampleCountIndex = 0;
|
||||
|
@ -396,7 +557,7 @@ s32 Audio_BuildSyntheticWave(Note* note, SequenceChannelLayer* seqLayer, s32 wav
|
|||
sampleCountIndex = 3;
|
||||
ratio = 0.13081f;
|
||||
}
|
||||
seqLayer->noteFreqScale *= ratio;
|
||||
seqLayer->freqScale *= ratio;
|
||||
note->playbackState.waveId = waveId;
|
||||
note->playbackState.sampleCountIndex = sampleCountIndex;
|
||||
|
||||
|
@ -592,12 +753,12 @@ void Audio_NoteInitForLayer(Note* note, SequenceChannelLayer* seqLayer) {
|
|||
note->playbackState.prevParentLayer = NO_LAYER;
|
||||
note->playbackState.parentLayer = seqLayer;
|
||||
playback->priority = seqLayer->seqChannel->notePriority;
|
||||
seqLayer->bit0 = 1;
|
||||
seqLayer->notePropertiesNeedInit = 1;
|
||||
seqLayer->unusedEu0b8 = 1;
|
||||
seqLayer->note = note;
|
||||
seqLayer->seqChannel->noteUnused = note;
|
||||
seqLayer->seqChannel->layerUnused = seqLayer;
|
||||
seqLayer->unk_40 = 0.0f;
|
||||
seqLayer->noteVelocity = 0.0f;
|
||||
Audio_NoteInit(note);
|
||||
instId = seqLayer->instOrWave;
|
||||
|
||||
|
@ -607,18 +768,18 @@ void Audio_NoteInitForLayer(Note* note, SequenceChannelLayer* seqLayer) {
|
|||
sub->sound.audioBankSound = seqLayer->sound;
|
||||
|
||||
if (instId >= 0x80 && instId < 0xC0) {
|
||||
sub->bitField1.asBitfields.bit2 = 1;
|
||||
sub->bitField1.s.bit2 = 1;
|
||||
} else {
|
||||
sub->bitField1.asBitfields.bit2 = 0;
|
||||
sub->bitField1.s.bit2 = 0;
|
||||
}
|
||||
|
||||
if (sub->bitField1.asBitfields.bit2) {
|
||||
if (sub->bitField1.s.bit2) {
|
||||
Audio_BuildSyntheticWave(note, seqLayer, instId);
|
||||
}
|
||||
|
||||
playback->bankId = seqLayer->seqChannel->bankId;
|
||||
playback->stereoHeadsetEffects = seqLayer->seqChannel->stereoHeadsetEffects;
|
||||
sub->bitField1.asBitfields.reverbIndex = seqLayer->seqChannel->reverbIndex & 3;
|
||||
sub->bitField1.s.reverbIndex = seqLayer->seqChannel->reverbIndex & 3;
|
||||
}
|
||||
|
||||
void func_800E82C0(Note* note, SequenceChannelLayer* seqLayer) {
|
||||
|
@ -630,8 +791,8 @@ void Audio_NoteReleaseAndTakeOwnership(Note* note, SequenceChannelLayer* seqLaye
|
|||
note->playbackState.wantedParentLayer = seqLayer;
|
||||
note->playbackState.priority = seqLayer->seqChannel->notePriority;
|
||||
|
||||
note->playbackState.adsr.velocity = gAudioContext.gAudioBufferParameters.updatesPerFrameInv;
|
||||
note->playbackState.adsr.adsrAction.adsrBits.bits4 = 1;
|
||||
note->playbackState.adsr.fadeOutVel = gAudioContext.gAudioBufferParameters.updatesPerFrameInv;
|
||||
note->playbackState.adsr.action.s.release = 1;
|
||||
}
|
||||
|
||||
Note* Audio_AllocNoteFromDisabled(NotePool* pool, SequenceChannelLayer* seqLayer) {
|
||||
|
@ -764,10 +925,10 @@ void Audio_NoteInitAll(void) {
|
|||
note->playbackState.waveId = 0;
|
||||
note->playbackState.attributes.velocity = 0.0f;
|
||||
note->playbackState.adsrVolScale = 0;
|
||||
note->playbackState.adsr.adsrAction.action = 0;
|
||||
note->unk_B0 = 0;
|
||||
note->unk_92 = 0;
|
||||
note->unk_94 = 0;
|
||||
note->playbackState.adsr.action.asByte = 0;
|
||||
note->vibratoState.active = 0;
|
||||
note->portamento.cur = 0;
|
||||
note->portamento.speed = 0;
|
||||
note->playbackState.stereoHeadsetEffects = 0;
|
||||
note->unk_BC = 0;
|
||||
note->synthesisState.synthesisBuffers = Audio_SoundAlloc(&gAudioContext.gNotesAndBuffersPool, 0x1E0);
|
||||
|
|
74
src/code/audio_seqplayer.c
Normal file
74
src/code/audio_seqplayer.c
Normal file
|
@ -0,0 +1,74 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9340.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E93A8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9584.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E96D8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E97FC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9878.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/Audio_SequenceChannelDisable.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9934.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9A2C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9AAC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9B44.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/Audio_SequencePlayerDisable.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/Audio_AudioListPushBack.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/Audio_AudioListPopBack.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9CA8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9D48.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9D5C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9D94.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9DD4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9ED8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800E9F64.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EA0C0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EA440.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EAAE0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EAEF4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EAF24.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EAF98.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EB044.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EB068.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EBD58.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EC564.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EC618.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EC668.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EC734.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EC80C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/audio_seqplayer/func_800EC8DC.s")
|
|
@ -1,106 +0,0 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DDE20.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DDE3C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DDF80.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE048.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE12C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE1B4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE238.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE258.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE2B0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/Audio_SoundAlloc.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE344.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE380.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE3DC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE434.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE45C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE470.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE4A0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE4B0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE5F0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE650.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE6D4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE758.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE81C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DE8E0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF074.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF0CC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF1D8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF5AC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF5DC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF630.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF688.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF7BC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF7C4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF888.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DF8F4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800DFBF8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E04E8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0540.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E05C4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0634.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E06CC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0964.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0AD8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0BB4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0BF8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0C80.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0CBC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0E0C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0E6C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0E90.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E0EB4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800DDE20/func_800E1148.s")
|
|
@ -1,6 +1,8 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
// like audio_load in sm64, but completely rewritten
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/func_800E11F0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E11F0/func_800E12DC.s")
|
||||
|
|
|
@ -1,22 +0,0 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/func_800E88C0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/func_800E8A88.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/func_800E8BD4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/func_800E8C30.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/func_800E8C68.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/func_800E8EA4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/func_800E8F00.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/func_800E8FB8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/Audio_AdsrInit.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E88C0/func_800E9004.s")
|
|
@ -1,74 +0,0 @@
|
|||
#include <ultra64.h>
|
||||
#include <global.h>
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9340.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E93A8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9584.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E96D8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E97FC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9878.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E98C8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9934.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9A2C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9AAC.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9B44.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9B6C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/Audio_AudioListPushBack.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/Audio_AudioListPopBack.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9CA8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9D48.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9D5C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9D94.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9DD4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9ED8.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800E9F64.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EA0C0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EA440.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EAAE0.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EAEF4.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EAF24.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EAF98.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EB044.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EB068.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EBD58.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EC564.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EC618.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EC668.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EC734.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EC80C.s")
|
||||
|
||||
#pragma GLOBAL_ASM("asm/non_matchings/code/code_800E9340/func_800EC8DC.s")
|
Loading…
Add table
Add a link
Reference in a new issue