Ability to disable sound

This commit is contained in:
Jeffrey Pfau 2013-10-20 02:18:09 -07:00
parent ca80e5f32b
commit 76f02be757
1 changed files with 54 additions and 52 deletions

View File

@ -42,6 +42,7 @@ void GBAAudioInit(struct GBAAudio* audio) {
audio->sampleRate = 0x8000; audio->sampleRate = 0x8000;
audio->soundcntLo = 0; audio->soundcntLo = 0;
audio->soundcntHi = 0; audio->soundcntHi = 0;
audio->soundcntX = 0;
audio->sampleInterval = GBA_ARM7TDMI_FREQUENCY / audio->sampleRate; audio->sampleInterval = GBA_ARM7TDMI_FREQUENCY / audio->sampleRate;
CircleBufferInit(&audio->left, GBA_AUDIO_SAMPLES * sizeof(int32_t)); CircleBufferInit(&audio->left, GBA_AUDIO_SAMPLES * sizeof(int32_t));
@ -67,7 +68,7 @@ int32_t GBAAudioProcessEvents(struct GBAAudio* audio, int32_t cycles) {
audio->eventDiff += cycles; audio->eventDiff += cycles;
while (audio->nextEvent <= 0) { while (audio->nextEvent <= 0) {
audio->nextEvent = INT_MAX; audio->nextEvent = INT_MAX;
if (audio->enable) {
audio->nextCh1 -= audio->eventDiff; audio->nextCh1 -= audio->eventDiff;
audio->nextCh2 -= audio->eventDiff; audio->nextCh2 -= audio->eventDiff;
audio->nextCh3 -= audio->eventDiff; audio->nextCh3 -= audio->eventDiff;
@ -140,6 +141,7 @@ int32_t GBAAudioProcessEvents(struct GBAAudio* audio, int32_t cycles) {
audio->nextEvent = audio->nextCh4; audio->nextEvent = audio->nextCh4;
} }
} }
}
audio->nextSample -= audio->eventDiff; audio->nextSample -= audio->eventDiff;
if (audio->nextSample <= 0) { if (audio->nextSample <= 0) {