dsp: add option to swap left and right channels

Change-Id: Id4b518638436576cfb5e747548f10ece6e58eba0
This commit is contained in:
Christian Soffke 2026-04-16 10:52:16 +02:00 committed by Solomon Peachy
parent 5ac105c837
commit cc7418dd8b
5 changed files with 44 additions and 3 deletions

View file

@ -17085,3 +17085,17 @@
*: "Show in Files" *: "Show in Files"
</voice> </voice>
</phrase> </phrase>
<phrase>
id: LANG_CHANNEL_SWAP
desc: in sound_settings
user: core
<source>
*: "Swap Left & Right"
</source>
<dest>
*: "Swap Left & Right"
</dest>
<voice>
*: "Swap Left & Right"
</voice>
</phrase>

View file

@ -1060,11 +1060,12 @@ const struct settings_list settings[] = {
/* 3-d enhancement effect */ /* 3-d enhancement effect */
CHOICE_SETTING(0, channel_config, LANG_CHANNEL_CONFIGURATION, CHOICE_SETTING(0, channel_config, LANG_CHANNEL_CONFIGURATION,
0,"channels", 0,"channels",
"stereo,mono,custom,mono left,mono right,karaoke", "stereo,mono,custom,mono left,mono right,karaoke,swap",
sound_set_channels, 6, sound_set_channels, 7,
ID2P(LANG_CHANNEL_STEREO), ID2P(LANG_CHANNEL_MONO), ID2P(LANG_CHANNEL_STEREO), ID2P(LANG_CHANNEL_MONO),
ID2P(LANG_CHANNEL_CUSTOM), ID2P(LANG_CHANNEL_LEFT), ID2P(LANG_CHANNEL_CUSTOM), ID2P(LANG_CHANNEL_LEFT),
ID2P(LANG_CHANNEL_RIGHT), ID2P(LANG_CHANNEL_KARAOKE)), ID2P(LANG_CHANNEL_RIGHT), ID2P(LANG_CHANNEL_KARAOKE),
ID2P(LANG_CHANNEL_SWAP)),
SOUND_SETTING(0, stereo_width, LANG_STEREO_WIDTH, SOUND_SETTING(0, stereo_width, LANG_STEREO_WIDTH,
"stereo_width", SOUND_STEREO_WIDTH), "stereo_width", SOUND_STEREO_WIDTH),
#ifdef AUDIOHW_HAVE_DEPTH_3D #ifdef AUDIOHW_HAVE_DEPTH_3D

View file

@ -674,6 +674,7 @@ enum AUDIOHW_CHANNEL_CONFIG
SOUND_CHAN_MONO_LEFT, SOUND_CHAN_MONO_LEFT,
SOUND_CHAN_MONO_RIGHT, SOUND_CHAN_MONO_RIGHT,
SOUND_CHAN_KARAOKE, SOUND_CHAN_KARAOKE,
SOUND_CHAN_SWAP,
SOUND_CHAN_NUM_MODES, SOUND_CHAN_NUM_MODES,
}; };

View file

@ -43,6 +43,8 @@ void channel_mode_proc_custom(struct dsp_proc_entry *this,
struct dsp_buffer **buf_p); struct dsp_buffer **buf_p);
void channel_mode_proc_karaoke(struct dsp_proc_entry *this, void channel_mode_proc_karaoke(struct dsp_proc_entry *this,
struct dsp_buffer **buf_p); struct dsp_buffer **buf_p);
void channel_mode_proc_swap(struct dsp_proc_entry *this,
struct dsp_buffer **buf_p);
static struct channel_mode_data static struct channel_mode_data
{ {
@ -131,6 +133,25 @@ void channel_mode_proc_karaoke(struct dsp_proc_entry *this,
} }
#endif /* CPU */ #endif /* CPU */
void channel_mode_proc_swap(struct dsp_proc_entry *this,
struct dsp_buffer **buf_p)
{
struct dsp_buffer *buf = *buf_p;
int32_t *sl = buf->p32[0];
int32_t *sr = buf->p32[1];
int count = buf->remcount;
do
{
int32_t l = *sl;
*sl++ = *sr;
*sr++ = l;
}
while (--count > 0);
(void)this;
}
void channel_mode_proc_mono_left(struct dsp_proc_entry *this, void channel_mode_proc_mono_left(struct dsp_proc_entry *this,
struct dsp_buffer **buf_p) struct dsp_buffer **buf_p)
{ {
@ -194,6 +215,7 @@ static void update_process_fn(struct dsp_proc_entry *this)
[SOUND_CHAN_MONO_LEFT] = channel_mode_proc_mono_left, [SOUND_CHAN_MONO_LEFT] = channel_mode_proc_mono_left,
[SOUND_CHAN_MONO_RIGHT] = channel_mode_proc_mono_right, [SOUND_CHAN_MONO_RIGHT] = channel_mode_proc_mono_right,
[SOUND_CHAN_KARAOKE] = channel_mode_proc_karaoke, [SOUND_CHAN_KARAOKE] = channel_mode_proc_karaoke,
[SOUND_CHAN_SWAP] = channel_mode_proc_swap,
}; };
this->process = fns[((struct channel_mode_data *)this->data)->mode]; this->process = fns[((struct channel_mode_data *)this->data)->mode];

View file

@ -178,6 +178,9 @@ change to customise your listening experience.
to make the singer sound centrally placed, this often (but not to make the singer sound centrally placed, this often (but not
always) has the effect of removing the voice track from a song. This always) has the effect of removing the voice track from a song. This
setting also very often has other undesirable effects on the sound. setting also very often has other undesirable effects on the sound.
\item[Swap Left \& Right.]
Plays the left channel in the right stereo channel, and the right
channel in the left stereo channel.
\end{description} \end{description}
\section{Stereo Width} \section{Stereo Width}