Skip to content

Commit

Permalink
Testing resampling audio in Push mode
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Nov 24, 2024
1 parent 1089c31 commit 5e08907
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions src/sounddep/sound.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -564,6 +564,24 @@ static void finish_sound_buffer_sdl2_push(struct sound_data* sd, uae_u16* sndbuf
memset(sndbuffer, 0, sd->sndbufsize);
s->silence_written++; // In push mode no sound gen means no audio push so this might not be incremented frequently
}
auto avail = SDL_GetQueuedAudioSize(s->dev);
//docorrection(s, (s->sndbufsize - avail) * 1000 / s->sndbufsize, (float)(s->sndbufsize - avail), 100);

float vdiff = static_cast<float>(s->sndbufsize - avail) / static_cast<float>(sd->samplesize);
float m = 100.0f * vdiff / (s->sndbufsize / sd->samplesize);
float skipmode = sync_sound(m);

gui_data.sndbuf = (s->sndbufsize - avail) * 1000 / s->sndbufsize;
s->avg_correct += vdiff;
s->cnt_correct++;
float adj = (s->avg_correct / s->cnt_correct) / 50.0f;

if (skipmode > ADJUST_LIMIT2)
skipmode = ADJUST_LIMIT2;
if (skipmode < -ADJUST_LIMIT2)
skipmode = -ADJUST_LIMIT2;
sound_setadjust(skipmode + adj);

SDL_QueueAudio(s->dev, sndbuffer, sd->sndbufsize);
}

Expand Down

0 comments on commit 5e08907

Please sign in to comment.