Class ChannelMixingMatrix

  • @Deprecated
    public final class ChannelMixingMatrix
    extends Object
    Deprecated. is deprecated. Please migrate to androidx.media3 (which contains the same ExoPlayer code). See the migration guide for more details, including a script to help with the migration.
    An immutable matrix that describes the mapping of input channels to output channels.

    The matrix coefficients define the scaling factor to use when mixing samples from the input channel (row) to the output channel (column).


    • Stereo to mono with each channel at half volume:
               [0.5 0.5]
    • Stereo to stereo with no mixing or scaling:
               [1 0
                0 1]
    • Stereo to stereo with 0.7 volume:
               [0.7 0
                0 0.7]
    • Constructor Detail

      • ChannelMixingMatrix

        public ChannelMixingMatrix​(int inputChannelCount,
                                   int outputChannelCount,
                                   float[] coefficients)
        Creates a matrix with the given coefficients in row-major order.
        inputChannelCount - Number of input channels (rows in the matrix).
        outputChannelCount - Number of output channels (columns in the matrix).
        coefficients - Non-negative matrix coefficients in row-major order.
    • Method Detail

      • create

        public static ChannelMixingMatrix create​(int inputChannelCount,
                                                 int outputChannelCount)
        Creates a standard channel mixing matrix that converts from inputChannelCount channels to outputChannelCount channels.

        If the input and output channel counts match then a simple identity matrix will be returned. Otherwise, default matrix coefficients will be used to best match channel locations and overall power level.

        inputChannelCount - Number of input channels.
        outputChannelCount - Number of output channels.
        New channel mixing matrix.
        UnsupportedOperationException - If no default matrix coefficients are implemented for the given input and output channel counts.
      • getInputChannelCount

        public int getInputChannelCount()
      • getOutputChannelCount

        public int getOutputChannelCount()
      • getMixingCoefficient

        public float getMixingCoefficient​(int inputChannel,
                                          int outputChannel)
        Gets the scaling factor for the given input and output channel.
      • isZero

        public boolean isZero()
        Returns whether all mixing coefficients are zero.
      • isSquare

        public boolean isSquare()
        Returns whether the input and output channel count is the same.
      • isDiagonal

        public boolean isDiagonal()
        Returns whether the matrix is square and all non-diagonal coefficients are zero.
      • isIdentity

        public boolean isIdentity()
        Returns whether this is an identity matrix.
      • scaleBy

        public ChannelMixingMatrix scaleBy​(float scale)
        Returns a new matrix with the given scaling factor applied to all coefficients.