ChannelMixingMatrix


@UnstableApi
class ChannelMixingMatrix


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).

Examples:

  • 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]

Summary

Public constructors

ChannelMixingMatrix(
    inputChannelCount: Int,
    outputChannelCount: Int,
    coefficients: FloatArray!
)

Creates a matrix with the given coefficients in row-major order.

Public functions

java-static ChannelMixingMatrix!
create(inputChannelCount: Int, outputChannelCount: Int)

Creates a standard channel mixing matrix that converts from inputChannelCount channels to outputChannelCount channels.

Float
getMixingCoefficient(inputChannel: Int, outputChannel: Int)

Gets the scaling factor for the given input and output channel.

Boolean

Returns whether the input and output channel count is the same.

ChannelMixingMatrix!
scaleBy(scale: Float)

Returns a new matrix with the given scaling factor applied to all coefficients.

Public constructors

ChannelMixingMatrix

ChannelMixingMatrix(
    inputChannelCount: Int,
    outputChannelCount: Int,
    coefficients: FloatArray!
)

Creates a matrix with the given coefficients in row-major order.

Parameters
inputChannelCount: Int

Number of input channels (rows in the matrix).

outputChannelCount: Int

Number of output channels (columns in the matrix).

coefficients: FloatArray!

Non-negative matrix coefficients in row-major order.

Public functions

create

java-static fun create(inputChannelCount: Int, outputChannelCount: Int): ChannelMixingMatrix!

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.

Parameters
inputChannelCount: Int

Number of input channels.

outputChannelCount: Int

Number of output channels.

Returns
ChannelMixingMatrix!

New channel mixing matrix.

Throws
java.lang.UnsupportedOperationException

If no default matrix coefficients are implemented for the given input and output channel counts.

getMixingCoefficient

fun getMixingCoefficient(inputChannel: Int, outputChannel: Int): Float

Gets the scaling factor for the given input and output channel.

isSquare

fun isSquare(): Boolean

Returns whether the input and output channel count is the same.

scaleBy

fun scaleBy(scale: Float): ChannelMixingMatrix!

Returns a new matrix with the given scaling factor applied to all coefficients.

Public properties

inputChannelCount

val inputChannelCountInt

isDiagonal

val isDiagonalBoolean

isIdentity

val isIdentityBoolean

isZero

val isZeroBoolean

outputChannelCount

val outputChannelCountInt