Skip to content

Commit

Permalink
Rework side/back channel positions
Browse files Browse the repository at this point in the history
Before this commit, there were:

- SL/SC/SR - surround left/center/right
  (in 5.x behind user, in 7.x on the sides)

- BL/BR - back left/right
  (7.x-only, behind user)

After this commit, there are:

- SL/SR - side left/right
  (7.x-only, always on the sides)

- BL/BC/BR - back left/center/right
  (both 5.x and 7.x, always behind user)

Previous approach was chosen because it's more widely used
in actual surround system specifications.

However, it did not allow to define ALSA channel ordering. The
new approach both allows to define it, and is more logical.
  • Loading branch information
gavv committed Oct 9, 2023
1 parent 2ed3c96 commit adc90bf
Show file tree
Hide file tree
Showing 4 changed files with 283 additions and 281 deletions.
10 changes: 5 additions & 5 deletions src/internal_modules/roc_audio/channel_layout.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,18 +37,18 @@ const char* channel_position_to_str(ChannelPosition position) {
case ChanPos_FrontRight:
return "FR";

case ChanPos_SurroundLeft:
case ChanPos_SideLeft:
return "SL";

case ChanPos_SurroundCenter:
return "SC";

case ChanPos_SurroundRight:
case ChanPos_SideRight:
return "SR";

case ChanPos_BackLeft:
return "BL";

case ChanPos_BackCenter:
return "BC";

case ChanPos_BackRight:
return "BR";

Expand Down
66 changes: 34 additions & 32 deletions src/internal_modules/roc_audio/channel_layout.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,16 @@ enum ChannelLayout {
//! Multi-channel mono / stereo / surround sound.
//! @remarks
//! The meaning of channel index is defined by ChannelPosition enum.
//! Channels are mapped according to their position in space, e.g. if
//! top-left channel is missing, it can be mixed from front-left and
//! side-left channels.
ChanLayout_Surround,

//! Multi-channel multi-track sound.
//! @remarks
//! There is no special meaning of channels, they are considered to
//! be independent tracks.
//! There is no special meaning of channels, they are considered to be
//! independent tracks. Channels are mapped according to their numbers;
//! channel N is mapped to channel N and nothing else.
ChanLayout_Multitrack
};

Expand All @@ -57,22 +61,21 @@ enum ChannelPosition {

//! @name Surround speakers.
//! @remarks
//! Placed behind the user (in surround 4.x, 5.x, or 6.x),
//! or on the sides (in surround 7.x).
//! Also known as "mid" or "side" speakers.
//! Placed on the sides of the user (in surround 7.x).
//! Also known as "mid" speakers.
// @{
ChanPos_SurroundLeft, //!< Surround left (SL).
ChanPos_SurroundCenter, //!< Surround center (SC).
ChanPos_SurroundRight, //!< Surround right (SR).
ChanPos_SideLeft, //!< Side left (SL).
ChanPos_SideRight, //!< Side right (SR).
// @}

//! @name Back speakers.
//! @remarks
//! Placed behind the user (in surround 7.x).
//! Placed behind the user.
//! Also known as "rear" speakers.
// @{
ChanPos_BackLeft, //!< Back left (BL).
ChanPos_BackRight, //!< Back right (BR).
ChanPos_BackLeft, //!< Back left (BL).
ChanPos_BackCenter, //!< Back center (BC).
ChanPos_BackRight, //!< Back right (BR).
// @}

//! @name Top speakers.
Expand Down Expand Up @@ -165,68 +168,68 @@ static const ChannelMask ChanMask_Surround_3_1 = //
| (1 << ChanPos_LowFrequency);

//! Surround 4.0.
//! Mask: FL, FR, SL, SR.
//! Mask: FL, FR, BL, BR.
//! @code
//! +------------------+
//! | FL FR |
//! | user |
//! | SL SR |
//! | BL BR |
//! +------------------+
//! @endcode
static const ChannelMask ChanMask_Surround_4_0 = //
(1 << ChanPos_FrontLeft) | (1 << ChanPos_FrontRight) //
| (1 << ChanPos_SurroundLeft) | (1 << ChanPos_SurroundRight);
| (1 << ChanPos_BackLeft) | (1 << ChanPos_BackRight);

//! Surround 4.1.
//! Mask: FL, FR, SL, SR | LFE.
//! Mask: FL, FR, BL, BR | LFE.
//! @code
//! +------------------+
//! | FL FR |
//! | user |
//! | LFE |
//! | SL SR |
//! | BL BR |
//! +------------------+
//! @endcode
static const ChannelMask ChanMask_Surround_4_1 = //
ChanMask_Surround_4_0 //
| (1 << ChanPos_LowFrequency);

//! Surround 5.0.
//! Mask: FL, FC, FR, SL, SR.
//! Mask: FL, FC, FR, BL, BR.
//! @code
//! +------------------+
//! | FL FC FR |
//! | user |
//! | SL SR |
//! | BL BR |
//! +------------------+
//! @endcode
static const ChannelMask ChanMask_Surround_5_0 = //
(1 << ChanPos_FrontLeft) | (1 << ChanPos_FrontCenter) | (1 << ChanPos_FrontRight) //
| (1 << ChanPos_SurroundLeft) | (1 << ChanPos_SurroundRight);
| (1 << ChanPos_BackLeft) | (1 << ChanPos_BackRight);

//! Surround 5.1.
//! Mask: FL, FC, FR, SL, SR | LFE.
//! Mask: FL, FC, FR, BL, BR | LFE.
//! @code
//! +------------------+
//! | FL FC FR |
//! | user |
//! | LFE |
//! | SL SR |
//! | BL BR |
//! +------------------+
//! @endcode
static const ChannelMask ChanMask_Surround_5_1 = //
ChanMask_Surround_5_0 //
| (1 << ChanPos_LowFrequency);

//! Surround 5.1.2.
//! Mask: FL, FC, FR, SL, SR | LFE | TML, TMR.
//! Mask: FL, FC, FR, BL, BR | LFE | TML, TMR.
//! @code
//! +------------------+
//! | FL FC FR |
//! | |
//! | TML user TMR |
//! | LFE |
//! | SL SR |
//! | BL BR |
//! +------------------+
//! @endcode
static const ChannelMask ChanMask_Surround_5_1_2 = //
Expand All @@ -235,15 +238,15 @@ static const ChannelMask ChanMask_Surround_5_1_2 = //
| (1 << ChanPos_TopMidLeft) | (1 << ChanPos_TopMidRight);

//! Surround 5.1.4.
//! Mask: FL, FC, FR, SL, SR | LFE | TFL, TFR, TBL, TBR.
//! Mask: FL, FC, FR, BL, BR | LFE | TFL, TFR, TBL, TBR.
//! @code
//! +------------------+
//! | FL FC FR |
//! | TFL TFR |
//! | user |
//! | LFE |
//! | TBL TBR |
//! | SL SR |
//! | BL BR |
//! +------------------+
//! @endcode
static const ChannelMask ChanMask_Surround_5_1_4 = //
Expand All @@ -253,27 +256,26 @@ static const ChannelMask ChanMask_Surround_5_1_4 = //
| (1 << ChanPos_TopBackLeft) | (1 << ChanPos_TopBackRight);

//! Surround 6.0.
//! Mask: FL, FC, FR, SL, SC, SR.
//! Mask: FL, FC, FR, BL, BC, BR.
//! @code
//! +------------------+
//! | FL FC FR |
//! | user |
//! | SL SC SR |
//! | BL BC BR |
//! +------------------+
//! @endcode
static const ChannelMask ChanMask_Surround_6_0 = //
(1 << ChanPos_FrontLeft) | (1 << ChanPos_FrontCenter) | (1 << ChanPos_FrontRight) //
| (1 << ChanPos_SurroundLeft) | (1 << ChanPos_SurroundCenter)
| (1 << ChanPos_SurroundRight);
| (1 << ChanPos_BackLeft) | (1 << ChanPos_BackCenter) | (1 << ChanPos_BackRight);

//! Surround 6.1.
//! Mask: FL, FC, FR, SL, SC, SR | LFE.
//! Mask: FL, FC, FR, BL, BC, BR | LFE.
//! @code
//! +------------------+
//! | FL FC FR |
//! | user |
//! | LFE |
//! | SL SC SR |
//! | BL BC BR |
//! +------------------+
//! @endcode
static const ChannelMask ChanMask_Surround_6_1 = //
Expand All @@ -291,7 +293,7 @@ static const ChannelMask ChanMask_Surround_6_1 = //
//! @endcode
static const ChannelMask ChanMask_Surround_7_0 = //
(1 << ChanPos_FrontLeft) | (1 << ChanPos_FrontCenter) | (1 << ChanPos_FrontRight) //
| (1 << ChanPos_SurroundLeft) | (1 << ChanPos_SurroundRight) //
| (1 << ChanPos_SideLeft) | (1 << ChanPos_SideRight) //
| (1 << ChanPos_BackLeft) | (1 << ChanPos_BackRight);

//! Surround 7.1.
Expand Down
Loading

0 comments on commit adc90bf

Please sign in to comment.