GBA Audio: Fix audio pitch changing when adjusting buffer size
Jeffrey Pfau jeffrey@endrift.com
Sun, 07 Jun 2015 22:47:13 -0700
2 files changed,
7 insertions(+),
3 deletions(-)
M
CHANGES
→
CHANGES
@@ -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.c
→
src/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);