all repos — mgba @ 76f02be7577549f92da7a4285679eacb471d1345

mGBA Game Boy Advance Emulator

Ability to disable sound
Jeffrey Pfau jeffrey@endrift.com
Sun, 20 Oct 2013 02:18:09 -0700
commit

76f02be7577549f92da7a4285679eacb471d1345

parent

ca80e5f32b913bdfd1309f769b744d21910e4f11

1 files changed, 54 insertions(+), 52 deletions(-)

jump to
M src/gba/gba-audio.csrc/gba/gba-audio.c

@@ -42,6 +42,7 @@ audio->nextSample = 0;

audio->sampleRate = 0x8000; audio->soundcntLo = 0; audio->soundcntHi = 0; + audio->soundcntX = 0; audio->sampleInterval = GBA_ARM7TDMI_FREQUENCY / audio->sampleRate; CircleBufferInit(&audio->left, GBA_AUDIO_SAMPLES * sizeof(int32_t));

@@ -67,77 +68,78 @@ audio->nextEvent -= cycles;

audio->eventDiff += cycles; while (audio->nextEvent <= 0) { audio->nextEvent = INT_MAX; + if (audio->enable) { + audio->nextCh1 -= audio->eventDiff; + audio->nextCh2 -= audio->eventDiff; + audio->nextCh3 -= audio->eventDiff; + audio->nextCh4 -= audio->eventDiff; - audio->nextCh1 -= audio->eventDiff; - audio->nextCh2 -= audio->eventDiff; - audio->nextCh3 -= audio->eventDiff; - audio->nextCh4 -= audio->eventDiff; - - if (audio->ch1.envelope.nextStep != INT_MAX) { - audio->ch1.envelope.nextStep -= audio->eventDiff; - if (audio->ch1.envelope.nextStep <= 0) { - _updateEnvelope(&audio->ch1.envelope); - if (audio->ch1.envelope.nextStep < audio->nextEvent) { - audio->nextEvent = audio->ch1.envelope.nextStep; + if (audio->ch1.envelope.nextStep != INT_MAX) { + audio->ch1.envelope.nextStep -= audio->eventDiff; + if (audio->ch1.envelope.nextStep <= 0) { + _updateEnvelope(&audio->ch1.envelope); + if (audio->ch1.envelope.nextStep < audio->nextEvent) { + audio->nextEvent = audio->ch1.envelope.nextStep; + } } } - } - if (audio->ch1.nextSweep != INT_MAX) { - audio->ch1.nextSweep -= audio->eventDiff; - if (audio->ch1.nextSweep <= 0) { - _updateSweep(&audio->ch1); - if (audio->ch1.nextSweep < audio->nextEvent) { - audio->nextEvent = audio->ch1.nextSweep; + if (audio->ch1.nextSweep != INT_MAX) { + audio->ch1.nextSweep -= audio->eventDiff; + if (audio->ch1.nextSweep <= 0) { + _updateSweep(&audio->ch1); + if (audio->ch1.nextSweep < audio->nextEvent) { + audio->nextEvent = audio->ch1.nextSweep; + } } } - } - if (audio->ch2.envelope.nextStep != INT_MAX) { - audio->ch2.envelope.nextStep -= audio->eventDiff; - if (audio->ch2.envelope.nextStep <= 0) { - _updateEnvelope(&audio->ch2.envelope); - if (audio->ch2.envelope.nextStep < audio->nextEvent) { - audio->nextEvent = audio->ch2.envelope.nextStep; + if (audio->ch2.envelope.nextStep != INT_MAX) { + audio->ch2.envelope.nextStep -= audio->eventDiff; + if (audio->ch2.envelope.nextStep <= 0) { + _updateEnvelope(&audio->ch2.envelope); + if (audio->ch2.envelope.nextStep < audio->nextEvent) { + audio->nextEvent = audio->ch2.envelope.nextStep; + } } } - } - if (audio->ch4.envelope.nextStep != INT_MAX) { - audio->ch4.envelope.nextStep -= audio->eventDiff; - if (audio->ch4.envelope.nextStep <= 0) { - _updateEnvelope(&audio->ch4.envelope); - if (audio->ch4.envelope.nextStep < audio->nextEvent) { - audio->nextEvent = audio->ch4.envelope.nextStep; + if (audio->ch4.envelope.nextStep != INT_MAX) { + audio->ch4.envelope.nextStep -= audio->eventDiff; + if (audio->ch4.envelope.nextStep <= 0) { + _updateEnvelope(&audio->ch4.envelope); + if (audio->ch4.envelope.nextStep < audio->nextEvent) { + audio->nextEvent = audio->ch4.envelope.nextStep; + } } } - } - if ((audio->ch1Right || audio->ch1Left) && audio->nextCh1 <= 0) { - audio->nextCh1 += _updateChannel1(&audio->ch1); - if (audio->nextCh1 < audio->nextEvent) { - audio->nextEvent = audio->nextCh1; + if ((audio->ch1Right || audio->ch1Left) && audio->nextCh1 <= 0) { + audio->nextCh1 += _updateChannel1(&audio->ch1); + if (audio->nextCh1 < audio->nextEvent) { + audio->nextEvent = audio->nextCh1; + } } - } - if ((audio->ch2Right || audio->ch2Left) && audio->nextCh2 <= 0) { - audio->nextCh2 += _updateChannel2(&audio->ch2); - if (audio->nextCh2 < audio->nextEvent) { - audio->nextEvent = audio->nextCh2; + if ((audio->ch2Right || audio->ch2Left) && audio->nextCh2 <= 0) { + audio->nextCh2 += _updateChannel2(&audio->ch2); + if (audio->nextCh2 < audio->nextEvent) { + audio->nextEvent = audio->nextCh2; + } } - } - if ((audio->ch3Right || audio->ch3Left) && audio->nextCh3 <= 0) { - audio->nextCh3 += _updateChannel3(&audio->ch3); - if (audio->nextCh3 < audio->nextEvent) { - audio->nextEvent = audio->nextCh3; + if ((audio->ch3Right || audio->ch3Left) && audio->nextCh3 <= 0) { + audio->nextCh3 += _updateChannel3(&audio->ch3); + if (audio->nextCh3 < audio->nextEvent) { + audio->nextEvent = audio->nextCh3; + } } - } - if ((audio->ch4Right || audio->ch4Left) && audio->nextCh4 <= 0) { - audio->nextCh4 += _updateChannel4(&audio->ch4); - if (audio->nextCh4 < audio->nextEvent) { - audio->nextEvent = audio->nextCh4; + if ((audio->ch4Right || audio->ch4Left) && audio->nextCh4 <= 0) { + audio->nextCh4 += _updateChannel4(&audio->ch4); + if (audio->nextCh4 < audio->nextEvent) { + audio->nextEvent = audio->nextCh4; + } } }