Skip to content

Commit c7033c9

Browse files
committed
Avoided load_wave_samples to load if synthesisBuffer is null
1 parent dfd60c8 commit c7033c9

1 file changed

Lines changed: 9 additions & 7 deletions

File tree

src/audio/synthesis.c

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,14 +1196,16 @@ u64 *load_wave_samples(u64 *cmd, struct NoteSubEu *noteSubEu, struct NoteSynthes
11961196
u64 *load_wave_samples(u64 *cmd, struct Note *note, s32 nSamplesToLoad) {
11971197
s32 a3;
11981198
s32 i;
1199-
aSetBuffer(cmd++, /*flags*/ 0, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ 0,
1199+
if (note->synthesisBuffers != NULL) {
1200+
aSetBuffer(cmd++, /*flags*/ 0, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ 0,
12001201
/*count*/ sizeof(note->synthesisBuffers->samples));
1201-
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->samples));
1202-
note->samplePosInt &= (note->sampleCount - 1);
1203-
a3 = 64 - note->samplePosInt;
1204-
if (a3 < nSamplesToLoad) {
1205-
for (i = 0; i <= (nSamplesToLoad - a3 + 63) / 64 - 1; i++) {
1206-
aDMEMMove(cmd++, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ DMEM_ADDR_UNCOMPRESSED_NOTE + (1 + i) * sizeof(note->synthesisBuffers->samples), /*count*/ sizeof(note->synthesisBuffers->samples));
1202+
aLoadBuffer(cmd++, VIRTUAL_TO_PHYSICAL2(note->synthesisBuffers->samples));
1203+
note->samplePosInt &= (note->sampleCount - 1);
1204+
a3 = 64 - note->samplePosInt;
1205+
if (a3 < nSamplesToLoad) {
1206+
for (i = 0; i <= (nSamplesToLoad - a3 + 63) / 64 - 1; i++) {
1207+
aDMEMMove(cmd++, /*dmemin*/ DMEM_ADDR_UNCOMPRESSED_NOTE, /*dmemout*/ DMEM_ADDR_UNCOMPRESSED_NOTE + (1 + i) * sizeof(note->synthesisBuffers->samples), /*count*/ sizeof(note->synthesisBuffers->samples));
1208+
}
12071209
}
12081210
}
12091211
return cmd;

0 commit comments

Comments
 (0)