Add a side/rear channel swap for speaker output
build / windows (push) Canceled after 0s
build / release (push) Canceled after 0s

Some receivers and players expect the side pair (Ls/Rs) where the renderer puts
the rear pair (Lrs/Rrs) and the other way round, and the layouts here follow the
reference table, so the delivered PCM cannot match both. The new preference does
the reorder on the way out: Ls with Lrs, Rs with Rrs, everything else untouched.

Which channels to move is decided by name in the layout table, not by channel
count. 7.1, 7.1.2, 7.1.4, 9.1.4 and 9.1.6 carry both pairs; 5.1.2 and 5.1.4 fill
the last two slots with top channels and are left alone, and a layout that has no
rear pair makes the swap a no-op. The decoder only enables it when the layout the
core rendered is the one being delivered, so a binaural stream is never touched.

The reorder happens once per read, before the float32 and the forced int24
delivery branch, so both formats carry it and the peak and clip accounting see the
same samples as before. Decoding, object positions, the layout table and the
rendering itself are unchanged.

channel_swap_test checks the layout selection, the reorder, its inverse and the
int24 packing order. The render harness gained --swap-side-rear and the text fit
check now measures the new label in both languages.

Verified on a 7.1 render: only channels 5-8 change, 5<->7 and 6<->8 byte-exactly,
with float32 and int24 alike; a 5.1.2 render is identical with the switch on.
This commit is contained in:
TheM14 committed 2026-11-01 23:53:54 +08:00
1 parent a06ffbdcb9
commit 43b16687cc
16 files changed
+302 -14

No files matched your search

+8 -1
View File
@@ -284,7 +284,8 @@ private:
notify();
return TRUE;
}
if (id == IDC_CHECK_GAIN || id == IDC_CHECK_INT24) {
if (id == IDC_CHECK_GAIN || id == IDC_CHECK_INT24 ||
id == IDC_CHECK_SWAP_SIDE_REAR) {
update_status();
notify();
return TRUE;
@@ -367,6 +368,7 @@ private:
label(IDC_LABEL_MODE, joc_lang::Text::kLabelMode);
label(IDC_LABEL_TAIL, joc_lang::Text::kLabelTail);
label(IDC_CHECK_INT24, joc_lang::Text::kCheckInt24);
label(IDC_CHECK_SWAP_SIDE_REAR, joc_lang::Text::kCheckSwapSideRear);
label(IDC_LABEL_INT24_HINT, joc_lang::Text::kInt24Hint);
label(IDC_GROUP_HRTF, joc_lang::Text::kGroupHrtf);
label(IDC_RADIO_HRTF_ROSELLA, joc_lang::Text::kRadioRosella);
@@ -406,6 +408,8 @@ private:
values.gain_enabled ? BST_CHECKED : BST_UNCHECKED, 0);
SendMessageW(GetDlgItem(m_hwnd, IDC_CHECK_INT24), BM_SETCHECK,
values.force_int24 ? BST_CHECKED : BST_UNCHECKED, 0);
SendMessageW(GetDlgItem(m_hwnd, IDC_CHECK_SWAP_SIDE_REAR), BM_SETCHECK,
values.swap_side_rear ? BST_CHECKED : BST_UNCHECKED, 0);
// The item lists are language-dependent, so they are built (in the stored
// language) before the selections are restored, and the texts are applied
@@ -457,6 +461,8 @@ private:
IsDlgButtonChecked(m_hwnd, IDC_CHECK_GAIN) == BST_CHECKED;
values.force_int24 =
IsDlgButtonChecked(m_hwnd, IDC_CHECK_INT24) == BST_CHECKED;
values.swap_side_rear =
IsDlgButtonChecked(m_hwnd, IDC_CHECK_SWAP_SIDE_REAR) == BST_CHECKED;
values.language = selected_language();
// Advanced values are not on this page; keep whatever is stored.
const joc_settings::Values stored = joc_settings::read();
@@ -519,6 +525,7 @@ private:
if (now.binaural_mode != m_initial.binaural_mode) return true;
if (now.gain_enabled != m_initial.gain_enabled) return true;
if (now.force_int24 != m_initial.force_int24) return true;
if (now.swap_side_rear != m_initial.swap_side_rear) return true;
if (now.gain_db != m_initial.gain_db) return true;
if (now.tail_seconds != m_initial.tail_seconds) return true;
if (now.ffmpeg_path != m_initial.ffmpeg_path) return true;