all repos — mgba @ a51ae873bd3c71ae1f2493f393169b53c360a9b9

mGBA Game Boy Advance Emulator

GBA Audio: Fix audio pitch changing when adjusting buffer size
Jeffrey Pfau jeffrey@endrift.com
Sun, 07 Jun 2015 22:47:13 -0700
commit

a51ae873bd3c71ae1f2493f393169b53c360a9b9

parent

c0909c871301e56b044cd6205f291d5e86f92bae

2 files changed, 7 insertions(+), 3 deletions(-)

jump to
M CHANGESCHANGES

@@ -39,6 +39,7 @@ - GBA: Check for improperly sized savestates when loading

- GBA: Check for savestates made from differently sized ROMs - GBA Video: Fix out-of-bounds tiles in mosaic - GBA Memory: Fix potential DMA issue when loading a savestate + - GBA Audio: Fix audio pitch changing when adjusting buffer size Misc: - Qt: Handle saving input settings better - Debugger: Free watchpoints in addition to breakpoints
M src/gba/audio.csrc/gba/audio.c

@@ -17,6 +17,10 @@ const unsigned GBA_AUDIO_FIFO_SIZE = 8 * sizeof(int32_t);

const int GBA_AUDIO_VOLUME_MAX = 0x100; #define SWEEP_CYCLES (GBA_ARM7TDMI_FREQUENCY / 128) +#if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF +static const int CLOCKS_PER_FRAME = 0x400; +#endif + static bool _writeEnvelope(struct GBAAudioEnvelope* envelope, uint16_t value); static int32_t _updateSquareChannel(struct GBAAudioSquareControl* envelope, int duty); static void _updateEnvelope(struct GBAAudioEnvelope* envelope);

@@ -815,11 +819,10 @@ blip_add_delta(audio->right, audio->clock, sampleRight - audio->lastRight);

audio->lastLeft = sampleLeft; audio->lastRight = sampleRight; audio->clock += audio->sampleInterval; - int clockNeeded = blip_clocks_needed(audio->left, audio->samples / 32); - if (audio->clock >= clockNeeded) { + if (audio->clock >= CLOCKS_PER_FRAME) { blip_end_frame(audio->left, audio->clock); blip_end_frame(audio->right, audio->clock); - audio->clock -= clockNeeded; + audio->clock -= CLOCKS_PER_FRAME; } } produced = blip_samples_avail(audio->left);