Skip to content

Commit

Permalink
Tighten up audio fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
worleydl committed Apr 8, 2024
1 parent 651df0b commit 64a5c0f
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
2 changes: 1 addition & 1 deletion soh-uwp/Package.appxmanifest
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<Identity
Name="uwpSOH"
Publisher="CN=datboi"
Version="1.1.2.0" />
Version="1.1.5.0" />

<mp:PhoneIdentity PhoneProductId="0587b567-7771-46ca-a4e2-0ec8ef4343c0" PhonePublisherId="00000000-0000-0000-0000-000000000000"/>

Expand Down
24 changes: 21 additions & 3 deletions soh/src/code/audio_synthesis.c
Original file line number Diff line number Diff line change
Expand Up @@ -905,11 +905,29 @@ Acmd* AudioSynth_ProcessNote(s32 noteIndex, NoteSubEu* noteSubEu, NoteSynthesisS
* S
* DDDDDDDDDPPPPPPPPPPPPPPPP
*
* This should return an "align" of 17, not 25
* For unknown reasons UWP is blowing up when reading RAM samples outside the allocation for the sample itself
* so the below code locks bounds to the actual size and restores any missing padding data. Normally we'd
* return an align of 25 for the above example but it needs to be 1.
*/
ramAlign = min((nFramesToDecode * frameSize) + 16, (audioFontSample->size + 16) - (sampleDataOffset + sampleDataStart));

ramAlign = min((nFramesToDecode * frameSize) + 16, (audioFontSample->size) - (sampleDataOffset - sampleDataStartPad + sampleDataStart));

// Debugging code for sample offsets
/*
uint8_t* beginning = (u8*)(sampleData - sampleDataStartPad);
s32 end = sampleDataOffset - sampleDataStartPad + sampleDataStart + ramAlign;
bool entryError = beginning < audioFontSample->sampleAddr;
bool exitError = end > audioFontSample->size;
if (entryError || exitError) {
// Bad mojo baby!
ramAlign = ramAlign; // No-op cmd to put a breakpoint on
}
*/

aLoadBufferNoRound(cmd++, sampleData - sampleDataStartPad, addr, ramAlign);
aBackfillBuffer(addr + ramAlign, aligned - ramAlign); // Dunno if needed but I make believe this fixes artifacts
aBackfillBuffer(addr + ramAlign, aligned - ramAlign); // Dunno if needed but I make believe this prevents artifacts
}

} else {
Expand Down

0 comments on commit 64a5c0f

Please sign in to comment.