Regalamiunsorriso/decompiled-libs/www/acxent-videoj-1.0.0/org/jcodec/audio/ChannelSplit.java

43 lines
1.4 KiB
Java
Raw Normal View History

2026-04-22 18:41:37 +02:00
package org.jcodec.audio;
import java.nio.FloatBuffer;
import org.jcodec.common.AudioFormat;
public class ChannelSplit implements AudioFilter {
private AudioFormat format;
public ChannelSplit(AudioFormat format) {
this.format = format;
}
public void filter(FloatBuffer[] _in, long[] inPos, FloatBuffer[] out) {
if (_in.length != 1)
throw new IllegalArgumentException("Channel split invoked on more then one input");
if (out.length != this.format.getChannels())
throw new IllegalArgumentException("Channel split must be supplied with " + this.format.getChannels() + " output buffers to hold the channels.");
FloatBuffer in0 = _in[0];
int outSampleCount = in0.remaining() / out.length;
for (int i = 0; i < out.length; i++) {
if (out[i].remaining() < outSampleCount)
throw new IllegalArgumentException("Supplied buffer for " + i + "th channel doesn't have sufficient space to put the samples ( required: " + outSampleCount + ", actual: " + out[i]
.remaining() + ")");
}
while (in0.remaining() >= this.format.getChannels()) {
for (int j = 0; j < out.length; j++)
out[j].put(in0.get());
}
}
public int getDelay() {
return 0;
}
public int getNInputs() {
return 1;
}
public int getNOutputs() {
return this.format.getChannels();
}
}