diff options
| author | engineer124 <47598039+engineer124@users.noreply.github.com> | 2023-11-22 20:19:31 +1100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-11-22 04:19:31 -0500 |
| commit | f2c06ce441a38a032202b9024fdfa57bb36a67c2 (patch) | |
| tree | bb924e2c2b577db8138ac67a6e44a00b5f15b1f8 /src/audio/lib | |
| parent | 2aaa286cf85a51a46bbf1e4ad8f8a36588fd22ad (diff) | |
Misc Cleanup (#1585)
* misc cleanup
* more fake matches
* revert for sym
Diffstat (limited to 'src/audio/lib')
| -rw-r--r-- | src/audio/lib/effects.c | 2 | ||||
| -rw-r--r-- | src/audio/lib/heap.c | 4 | ||||
| -rw-r--r-- | src/audio/lib/load.c | 36 |
3 files changed, 23 insertions, 19 deletions
diff --git a/src/audio/lib/effects.c b/src/audio/lib/effects.c index 6844d8ae5..8de03887e 100644 --- a/src/audio/lib/effects.c +++ b/src/audio/lib/effects.c @@ -269,7 +269,7 @@ f32 Audio_AdsrUpdate(AdsrState* adsr) { adsr->delay = 1; } adsr->target = adsr->envelope[adsr->envIndex].arg / 32767.0f; - adsr->target = adsr->target * adsr->target; + adsr->target = SQ(adsr->target); adsr->velocity = (adsr->target - adsr->current) / adsr->delay; adsr->action.s.state = ADSR_STATE_FADE; adsr->envIndex++; diff --git a/src/audio/lib/heap.c b/src/audio/lib/heap.c index 4b586c8c5..899cf912b 100644 --- a/src/audio/lib/heap.c +++ b/src/audio/lib/heap.c @@ -1356,8 +1356,8 @@ void AudioHeap_ChangeStorage(StorageChange* change, Sample* sample) { u32 startAddr = change->oldAddr; u32 endAddr = change->oldAddr + change->size; - if (startAddr <= (u32)sample->sampleAddr && (u32)sample->sampleAddr < endAddr) { - sample->sampleAddr = sample->sampleAddr - startAddr + change->newAddr; + if (((u32)sample->sampleAddr >= startAddr) && ((u32)sample->sampleAddr < endAddr)) { + sample->sampleAddr += -startAddr + change->newAddr; sample->medium = change->newMedium; } } diff --git a/src/audio/lib/load.c b/src/audio/lib/load.c index f30527d97..b7b674a23 100644 --- a/src/audio/lib/load.c +++ b/src/audio/lib/load.c @@ -789,7 +789,7 @@ AudioTable* AudioLoad_GetLoadTable(s32 tableType) { * Also relocate offsets into pointers within this loaded soundFont * * @param fontId index of font being processed - * @param fontData ram address of raw soundfont binary loaded into cache + * @param fontDataStartAddr ram address of raw soundfont binary loaded into cache * @param sampleBankReloc information on the sampleBank containing raw audio samples */ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, SampleBankRelocInfo* sampleBankReloc) { @@ -811,7 +811,6 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample // The first u32 in fontData is an offset to a list of offsets to the drums soundListOffset = fontData[0]; - if (1) {} // If the soundFont has drums if ((soundListOffset != 0) && (numDrums != 0)) { @@ -824,20 +823,24 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample soundOffset = (u32)((Drum**)fontData[0])[i]; // Some drum data entries are empty, represented by an offset of 0 in the list of drum offsets - if (soundOffset != 0) { - soundOffset = RELOC_TO_RAM(soundOffset); - ((Drum**)fontData[0])[i] = drum = (Drum*)soundOffset; - - // The drum may be in the list multiple times and already relocated - if (!drum->isRelocated) { - AudioLoad_RelocateSample(&drum->tunedSample, fontDataStartAddr, sampleBankReloc); + if (soundOffset == 0) { + continue; + } - soundOffset = (u32)drum->envelope; - drum->envelope = (EnvelopePoint*)RELOC_TO_RAM(soundOffset); + soundOffset = RELOC_TO_RAM(soundOffset); + ((Drum**)fontData[0])[i] = drum = (Drum*)soundOffset; - drum->isRelocated = true; - } + // The drum may be in the list multiple times and already relocated + if (drum->isRelocated) { + continue; } + + AudioLoad_RelocateSample(&drum->tunedSample, fontDataStartAddr, sampleBankReloc); + + soundOffset = (u32)drum->envelope; + drum->envelope = (EnvelopePoint*)RELOC_TO_RAM(soundOffset); + + drum->isRelocated = true; } } @@ -845,7 +848,6 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample // The second u32 in fontData is an offset to the first sound effect entry soundListOffset = fontData[1]; - if (1) {} // If the soundFont has sound effects if ((soundListOffset != 0) && (numSfx != 0)) { @@ -859,9 +861,11 @@ void AudioLoad_RelocateFont(s32 fontId, SoundFontData* fontDataStartAddr, Sample soundEffect = (SoundEffect*)soundOffset; // Check for NULL (note: the pointer is guaranteed to be in fontData and can never be NULL) - if ((soundEffect != NULL) && ((u32)soundEffect->tunedSample.sample != 0)) { - AudioLoad_RelocateSample(&soundEffect->tunedSample, fontDataStartAddr, sampleBankReloc); + if ((soundEffect == NULL) || ((u32)soundEffect->tunedSample.sample == 0)) { + continue; } + + AudioLoad_RelocateSample(&soundEffect->tunedSample, fontDataStartAddr, sampleBankReloc); } } |
