1
0
mirror of https://github.com/zeldaret/oot.git synced 2024-09-21 04:24:43 +00:00

Cleanup NotePlaybackState (#1255)

* Audio Cleanup

* more

* missed one

* Audio docs imported from MM

* Suggestions from Discord

* Small fix

* Fix sizes in z64audio.h

* numSamples

* Cleanup comments

* Revert overlap with soundFont PR

* revert Audio_AdsrUpdate cleanup (move to different PR)

* PR Suggestion

* Mainly typos

* PR suggestion, vol -> volume

* Better description

* Name sampling frequency

* A good number of PR suggestions

* Missed a suggestion

* More PR Suggestions

* Cleanup NotePlaybackState

* one more

* Add comments for new variable names

* Reverb samplePosInt

* Missed one

* Remove `Always set to 0`
This commit is contained in:
engineer124 2022-06-05 05:29:01 +10:00 committed by GitHub
parent 1a41694d58
commit bd4912a1bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 15 additions and 16 deletions

View File

@ -496,8 +496,9 @@ typedef struct {
/* 0x18 */ SequenceLayer* wantedParentLayer;
/* 0x1C */ NoteAttributes attributes;
/* 0x40 */ AdsrState adsr;
// Majora's Mask suggests this struct contains portamento, vibratoState
} NotePlaybackState; // size = 0x60
/* 0x60 */ Portamento portamento;
/* 0x6C */ VibratoState vibratoState;
} NotePlaybackState; // size = 0x88
typedef struct {
struct {
@ -539,10 +540,8 @@ typedef struct Note {
/* 0x00 */ AudioListItem listItem;
/* 0x10 */ NoteSynthesisState synthesisState;
/* 0x30 */ NotePlaybackState playbackState;
/* 0x90 */ Portamento portamento;
/* 0x9C */ VibratoState vibratoState;
/* 0xB8 */ char unk_B8[0x4];
/* 0xBC */ u32 unk_BC;
/* 0xBC */ u32 startSamplePos; // initial position/index to start processing s16 samples
/* 0xC0 */ NoteSubEu noteSubEu;
} Note; // size = 0xE0

View File

@ -174,11 +174,11 @@ f32 Audio_GetVibratoFreqScale(VibratoState* vib) {
}
void Audio_NoteVibratoUpdate(Note* note) {
if (note->portamento.mode != 0) {
note->playbackState.portamentoFreqScale = Audio_GetPortamentoFreqScale(&note->portamento);
if (note->playbackState.portamento.mode != 0) {
note->playbackState.portamentoFreqScale = Audio_GetPortamentoFreqScale(&note->playbackState.portamento);
}
if (note->vibratoState.active) {
note->playbackState.vibratoFreqScale = Audio_GetVibratoFreqScale(&note->vibratoState);
if (note->playbackState.vibratoState.active) {
note->playbackState.vibratoFreqScale = Audio_GetVibratoFreqScale(&note->playbackState.vibratoState);
}
}
@ -188,7 +188,7 @@ void Audio_NoteVibratoInit(Note* note) {
note->playbackState.vibratoFreqScale = 1.0f;
vib = &note->vibratoState;
vib = &note->playbackState.vibratoState;
vib->active = 1;
vib->time = 0;
@ -212,7 +212,7 @@ void Audio_NoteVibratoInit(Note* note) {
void Audio_NotePortamentoInit(Note* note) {
note->playbackState.portamentoFreqScale = 1.0f;
note->portamento = note->playbackState.parentLayer->portamento;
note->playbackState.portamento = note->playbackState.parentLayer->portamento;
}
void Audio_AdsrInit(AdsrState* adsr, AdsrEnvelope* envelope, s16* volOut) {

View File

@ -926,11 +926,11 @@ void Audio_NoteInitAll(void) {
note->playbackState.attributes.velocity = 0.0f;
note->playbackState.adsrVolScaleUnused = 0;
note->playbackState.adsr.action.asByte = 0;
note->vibratoState.active = 0;
note->portamento.cur = 0;
note->portamento.speed = 0;
note->playbackState.vibratoState.active = 0;
note->playbackState.portamento.cur = 0;
note->playbackState.portamento.speed = 0;
note->playbackState.stereoHeadsetEffects = false;
note->unk_BC = 0;
note->startSamplePos = 0;
note->synthesisState.synthesisBuffers = AudioHeap_AllocDmaMemory(&gAudioContext.miscPool, 0x1E0);
}
}

View File

@ -745,7 +745,7 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
if (noteSubEu->bitField0.needsInit == true) {
flags = A_INIT;
synthState->restart = 0;
synthState->samplePosInt = note->unk_BC;
synthState->samplePosInt = note->startSamplePos;
synthState->samplePosFrac = 0;
synthState->curVolLeft = 0;
synthState->curVolRight = 0;