Skip to content

Preserve stereo audio in playback and visualization - #782

Open
rcombs wants to merge 13 commits into
TypesettingTools:masterfrom
rcombs:codex/stereo-audio-pr
Open

rcombs wants to merge 13 commits into
TypesettingTools:masterfrom
rcombs:codex/stereo-audio-pr

Conversation

@rcombs

@rcombs rcombs commented Nov 28, 2026

Copy link
Copy Markdown
Contributor

Aegisub currently downmixes stereo sources to mono before playback. This preserves the left and right channels through decoding, caching, and playback. Surround sources are mixed to stereo. The waveform uses peaks from both channels, and the spectrum combines their power so opposite-phase sounds remain visible.

OpenAL playback on macOS was tested and works well. The macOS build and Meson test suite passed, including a separate native OpenAL run that verified stereo buffer format and frame alignment.

Before merging, please validate stereo playback on the other platforms and backends, especially DirectSound on Windows and the Linux audio backends.

🤖 Codex

Use symmetric rounding for signed PCM samples and clamp the result before converting to 16-bit.
Calculating the byte count first can leave a partial frame even for
16-bit mono. At 44110 Hz the old calculation gives 5513 bytes per
buffer. The player can only fill 5512 bytes with complete samples,
but submits all 5513. OpenAL implementations that require whole PCM
frames can reject the upload, leaving the queue without that audio.

Round down in frames so the buffer size matches the audio it holds.
Run the transform on each channel before combining power so opposite-phase signals remain visible.
Enable stereo after the caches, playback backends, and renderers support interleaved frames. Update the existing converter test to expect stereo samples.
Keep FFMS2's layout-aware downmix and use a stereo matrix for providers without speaker metadata. Let AviSynth use the shared converter in place of its mono-only preference.
@rcombs
rcombs marked this pull request as ready for review November 28, 2026 02:14

This branch has not been deployed

No deployments
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