Skip to content

Commit 7994559

Browse files
committed
Audio stability fix
1 parent 03c06ee commit 7994559

File tree

3 files changed

+6
-8
lines changed

3 files changed

+6
-8
lines changed

src/chips/sgu1.c

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ void sgu1_reset(sgu1_t* sgu) {
4848
static uint64_t _sgu1_tick(sgu1_t* sgu, uint64_t pins) {
4949
/* next sample? */
5050
sgu->tick_counter -= SGU1_FIXEDPOINT_SCALE;
51-
if (sgu->tick_counter <= 0) {
51+
while (sgu->tick_counter <= 0) {
5252
sgu->tick_counter += sgu->tick_period;
5353
int32_t l, r;
5454
SoundUnit_NextSample(&sgu->su, &l, &r);
@@ -66,16 +66,14 @@ static uint64_t _sgu1_tick(sgu1_t* sgu, uint64_t pins) {
6666
}
6767

6868
/* new sample? */
69+
pins &= ~SGU1_SAMPLE;
6970
sgu->sample_counter -= SGU1_FIXEDPOINT_SCALE;
70-
if (sgu->sample_counter <= 0) {
71+
while (sgu->sample_counter <= 0) {
7172
sgu->sample_counter += sgu->sample_period;
7273
sgu->sample[0] = sgu->sample_mag * sgu->sample[0];
7374
sgu->sample[1] = sgu->sample_mag * sgu->sample[1];
7475
pins |= SGU1_SAMPLE;
7576
}
76-
else {
77-
pins &= ~SGU1_SAMPLE;
78-
}
7977
return pins;
8078
}
8179

src/systems/x65.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ static uint64_t _x65_tick(x65_t* sys, uint64_t pins) {
235235
}
236236
}
237237

238-
// tick the SID
238+
// tick the SGU
239239
{
240240
sgu_pins = sgu1_tick(&sys->sgu, sgu_pins);
241241
if (sgu_pins & SGU1_SAMPLE) {

src/systems/x65.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,8 +48,8 @@ extern "C" {
4848
#define X65_SNAPSHOT_VERSION (1)
4949

5050
#define X65_FREQUENCY (3140000) // clock frequency in Hz
51-
#define X65_MAX_AUDIO_SAMPLES (1024) // max number of audio samples in internal sample buffer
52-
#define X65_DEFAULT_AUDIO_SAMPLES (128) // default number of samples in internal sample buffer
51+
#define X65_MAX_AUDIO_SAMPLES (2048) // max number of audio samples in internal sample buffer
52+
#define X65_DEFAULT_AUDIO_SAMPLES (512) // default number of samples in internal sample buffer
5353
#define X65_AUDIO_CHANNELS (2) // stereo output
5454

5555
// X65 joystick types

0 commit comments

Comments
 (0)