Skip to content

FreeHost: the real-time sound held to the host's time without clicks - #164

Open
boubou666 wants to merge 2 commits into
masterfrom
amp/sound-squeeze
Open

boubou666 wants to merge 2 commits into
masterfrom
amp/sound-squeeze

Conversation

@boubou666

Copy link
Copy Markdown
Contributor

Stacked on #163. The new commit is 30013e4.

What

FreeHost::holdToHostTime used to cut a frame's surplus samples whenever the frame made more sound than the host's time allowed (plus a quarter field). Now:

  • A small surplus, up to 5 % of the frame (drift and jitter), is resampled into what is allowed. The frame's first and last samples are kept; the pitch change is too small to hear.
  • A larger one (a leap: a disc wait the PC did not live) is cut as before, keeping the newest samples, but the join is cross-faded over up to 64 samples.

Why

A window whose frames run a hair off the sound card's clock makes a steady 800 samples a frame against a budget slightly short. It lost 1 to 16 samples every few frames, and each cut was a click. Amplitude's tutorial narration crackled: 826 cuts in two and a half minutes, counted in a paced window with SDL's dummy audio driver.

Testing

Amplitude's tutorial, the window's own output recorded (SDL's dummy audio driver, --wav): as many clicks as the game's own mix, 446 against 444 in the same 80 s. Those are the voice's and the music's own.

This applies to every port with real-time sound. Only the drift case changes, and it now resamples instead of cutting.

🤖 Generated with Claude Code

boubou666 and others added 2 commits November 27, 2026 12:46
…er-of-two one)

A movie picture decoded as a texture is rounded up to powers of two: a
640 x 448 picture in a 1024 x 512 texture. setBackdrop mapped the whole
texture to its rectangle, so a port had to draw it larger than the
picture and let the window cut the padding off. Where the window does not
(a 4:3 picture kept 4:3 in a widescreen frame, or a letterbox), the
padding showed: Amplitude's widescreen movies had a strip of stale
pictures at the right and below.

Two trailing parameters (u, v) give the part that is the picture; their
defaults (1, 1) keep every port's call as it was.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
holdToHostTime cut a frame's surplus samples whenever the frame made more
than the host's time allowed plus a quarter field. A window whose frames
run a hair off the sound card's clock (the game's steady 800 samples a
frame against a budget slightly short) lost 1 to 16 samples every few
frames, each cut a click: Amplitude's tutorial narration crackled (826
cuts in two and a half minutes).

- A small surplus (up to 5 % of the frame: drift and jitter) is now
  resampled into what is allowed, the frame's first and last samples
  kept, a pitch change too small to hear.
- A larger one (a leap: a disc wait the PC did not live) is cut as before,
  the newest samples kept, but the join is cross-faded over up to 64
  samples.

Measured on the tutorial's output (SDL's dummy audio driver, the window's
WAV): as many clicks as the game's own mix (446 against 444 in 80 s).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant