{"record":{"id":"533654d75af9f180","repo":"google/ExoPlayer","slug":"default-channel-mixing-coefficients-for-inputchan","errorCode":null,"errorMessage":"Default channel mixing coefficients for {inputChannelCount}->{outputChannelCount} are not yet implemented.","messagePattern":"Default channel mixing coefficients for (.+?)->(.+?) are not yet implemented\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"library/common/src/main/java/com/google/android/exoplayer2/audio/ChannelMixingMatrix.java","lineNumber":173,"sourceCode":"    for (int i = 0; i < coefficients.length; i++) {\n      scaledCoefficients[i] = scale * coefficients[i];\n    }\n    return new ChannelMixingMatrix(inputChannelCount, outputChannelCount, scaledCoefficients);\n  }\n\n  private static float[] createMixingCoefficients(int inputChannelCount, int outputChannelCount) {\n    if (inputChannelCount == outputChannelCount) {\n      return initializeIdentityMatrix(outputChannelCount);\n    }\n    if (inputChannelCount == 1 && outputChannelCount == 2) {\n      // Mono -> stereo.\n      return new float[] {1f, 1f};\n    }\n    if (inputChannelCount == 2 && outputChannelCount == 1) {\n      // Stereo -> mono.\n      return new float[] {0.5f, 0.5f};\n    }\n    throw new UnsupportedOperationException(\n        \"Default channel mixing coefficients for \"\n            + inputChannelCount\n            + \"->\"\n            + outputChannelCount\n            + \" are not yet implemented.\");\n  }\n\n  private static float[] initializeIdentityMatrix(int channelCount) {\n    float[] coefficients = new float[channelCount * channelCount];\n    for (int c = 0; c < channelCount; c++) {\n      coefficients[channelCount * c + c] = 1f;\n    }\n    return coefficients;\n  }\n\n  private static float[] checkCoefficientsValid(float[] coefficients) {\n    for (int i = 0; i < coefficients.length; i++) {\n      if (coefficients[i] < 0f) {","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/google/ExoPlayer/blob/dd430f7053a1a3958deea3ead6a0565150c06bfc/library/common/src/main/java/com/google/android/exoplayer2/audio/ChannelMixingMatrix.java#L155-L191","documentation":"ChannelMixingMatrix.create(inputChannelCount, outputChannelCount) only has built-in coefficients for three cases: same count (identity), 1->2 (mono to stereo, both gains 1f) and 2->1 (stereo to mono, both gains 0.5f). Any other count combination throws UnsupportedOperationException stating the defaults are 'not yet implemented'. This is an API limitation, not a runtime media error.","triggerScenarios":"Calling ChannelMixingMatrix.create(6, 2), create(1, 6), create(8, 2) or any pair other than (n,n), (1,2), (2,1).","commonSituations":"Downmixing 5.1/7.1 surround to stereo for Bluetooth or TV speakers; upmixing mono to more than 2 channels for multichannel DSP pipelines.","solutions":["Supply explicit coefficients instead of defaults: build the matrix via the constructor ChannelMixingMatrix.create(inputCount, outputCount, float[] coefficients) with your own downmix gains (e.g. ITU-R BS.775 5.1-to-stereo coefficients).","For surround-to-stereo, route the extra surround channels with -0.707/0.707 style gains and LFE at 0 in a custom coefficient array.","Or chain two supported conversions where possible (e.g. 6->2 is not chainable, but 1->anything can go 1->2 then 2->N if you write N coefficients anyway — usually the custom array is the right answer)."],"exampleFix":"// before\nChannelMixingMatrix.create(6, 2); // throws UnsupportedOperationException\n\n// after\n// 5.1 -> stereo downmix (L R C LFE Ls Rs -> L R), ITU-R BS.775-ish\nfloat[] coeffs = {\n    1f, 0f,        // L -> L,R\n    0f, 1f,        // R\n    0.707f, 0.707f, // C\n    0f, 0f,        // LFE\n    0.707f, 0f,    // Ls (note: sign convention per spec)\n    0f, 0.707f     // Rs\n};\nChannelMixingMatrix.create(6, 2, coeffs);","handlingStrategy":"validation","validationCode":"public static boolean hasDefaultMixing(int in, int out) {\n  return in == out || (in == 1 && out == 2) || (in == 2 && out == 1);\n}\n// Use before calling ChannelMixingMatrix.create(in, out)\nif (!hasDefaultMixing(in, out)) {\n  coefficients = computeCustomCoefficients(in, out); // must be non-negative\n  matrix = ChannelMixingMatrix.create(in, out, coefficients);\n} else {\n  matrix = ChannelMixingMatrix.create(in, out);\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Memorize the supported default pairs: (n,n), (1,2), (2,1) — anything else needs explicit coefficients.","For surround downmix use published coefficient tables (ITU-R BS.775) with negatives clamped to 0 or abs().","Keep coefficient array length exactly inputCount * outputCount."],"tags":["exoplayer","media3","audio","channel-mixing","unsupported-operation"],"backgroundTag":null,"analyzedSha":"dd430f7053a1a3958deea3ead6a0565150c06bfc","analyzedAt":"2026-08-14T12:22:02.982Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}