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(Creates a matrix with the given coefficients in row-major order. |
Public functions |
|
|---|---|
java-static ChannelMixingMatrix! |
This function is deprecated. Use |
java-static ChannelMixingMatrix! |
createForConstantGain(Returns a default constant gain channel mixing matrix that mixes |
java-static ChannelMixingMatrix! |
createForConstantPower(Returns a default constant power channel mixing matrix that mixes |
Float |
getMixingCoefficient(inputChannel: Int, outputChannel: Int)Gets the scaling factor for the given input and output channel. |
Boolean |
isSquare()Returns whether the input and output channel count is the same. |
ChannelMixingMatrix! |
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 funcreate(
inputChannelCount: @IntRange(from = 1, to = 2) Int,
outputChannelCount: @IntRange(from = 1, to = 2) Int
): ChannelMixingMatrix!
Returns a default constant gain channel mixing matrix that mixes inputChannelCount channels into outputChannelCount channels.
This method returns an identity matrix if inputChannelCount and
outputChannelCount are equal.
| Parameters | |
|---|---|
inputChannelCount: @IntRange(from = 1, to = 2) Int |
Number of input channels. |
outputChannelCount: @IntRange(from = 1, to = 2) Int |
Number of output channels. |
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
If no default coefficients are available for the given input and output channel counts. |
createForConstantGain
java-static fun createForConstantGain(
inputChannelCount: @IntRange(from = 1, to = 2) Int,
outputChannelCount: @IntRange(from = 1, to = 2) Int
): ChannelMixingMatrix!
Returns a default constant gain channel mixing matrix that mixes inputChannelCount channels into outputChannelCount channels.
This method returns an identity matrix if inputChannelCount and
outputChannelCount are equal.
| Parameters | |
|---|---|
inputChannelCount: @IntRange(from = 1, to = 2) Int |
Number of input channels. |
outputChannelCount: @IntRange(from = 1, to = 2) Int |
Number of output channels. |
| Throws | |
|---|---|
java.lang.UnsupportedOperationException |
If no default coefficients are available for the given input and output channel counts. |
createForConstantPower
java-static fun createForConstantPower(
inputChannelCount: @IntRange(from = 1, to = 6) Int,
outputChannelCount: @IntRange(from = 1, to = 2) Int
): ChannelMixingMatrix!
Returns a default constant power channel mixing matrix that mixes inputChannelCount channels into outputChannelCount channels.
This method returns an identity matrix if inputChannelCount and
outputChannelCount are equal.
Channel counts map to the following layouts:
- [MONO]
- [FRONT_LEFT, FRONT_RIGHT]
- [FRONT_LEFT, FRONT_RIGHT, FRONT_CENTER]
- [FRONT_LEFT, FRONT_RIGHT, BACK_LEFT, BACK_RIGHT]
- [FRONT_LEFT, FRONT_RIGHT, FRONT_CENTER, BACK_LEFT, BACK_RIGHT]
- [FRONT_LEFT, FRONT_RIGHT, FRONT_CENTER, LOW_FREQUENCY, BACK_LEFT, BACK_RIGHT]
| Parameters | |
|---|---|
inputChannelCount: @IntRange(from = 1, to = 6) Int |
Number of input channels. |
outputChannelCount: @IntRange(from = 1, to = 2) Int |
Number of output channels. |
| 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.
scaleBy
fun scaleBy(scale: Float): ChannelMixingMatrix!
Returns a new matrix with the given scaling factor applied to all coefficients.