@Override public int getNOutputs() { return format.getChannels(); } }
@Override public int getNInputs() { return format.getChannels(); }
public static void out(AudioFormat fmt, byte[] samples, int[] func) { out16BitSignedLE(samples, fmt.getChannels(), func); } }
public static void _in(AudioFormat fmt, byte[] samples, int[] func) { in16BitSignedLE(samples, fmt.getChannels(), func); }
@Override 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 != format.getChannels()) { throw new IllegalArgumentException("Channel split must be supplied with " + 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() >= format.getChannels()) { for (int i = 0; i < out.length; i++) { out[i].put(in0.get()); } } }
void addAudioSampleEntry(AudioFormat format) { AudioSampleEntry ase = AudioSampleEntry.compressedAudioSampleEntry(codec2fourcc.get(codec), (short) 1, (short) 16, format.getChannels(), format.getSampleRate(), 0, 0, 0); addSampleEntry(ase); } }
@Override public void filter(FloatBuffer[] _in, long[] inPos, FloatBuffer[] out) { if (_in.length != format.getChannels()) { throw new IllegalArgumentException("Channel merge must be supplied with " + format.getChannels() + " input buffers to hold the channels."); } if (out.length != 1) { throw new IllegalArgumentException("Channel merget invoked on more then one output"); } FloatBuffer out0 = out[0]; int min = Integer.MAX_VALUE; for (int i = 0; i < _in.length; i++) { if (_in[i].remaining() < min) min = _in[i].remaining(); } for (int i = 0; i < _in.length; i++) { Assert.assertEquals(_in[i].remaining(), min); } if (out0.remaining() < min * _in.length) throw new IllegalArgumentException("Supplied output buffer is not big enough to hold " + min + " * " + _in.length + " = " + (min * _in.length) + " output samples."); for (int i = 0; i < min; i++) { for (int j = 0; j < _in.length; j++) out0.put(_in[j].get()); } }
/** * Creates wav header for the specified audio format * * @param format * @param samples */ public static WavHeader createWavHeader(AudioFormat format, int samples) { WavHeader w = new WavHeader("RIFF", 40, "WAVE", new FmtChunk((short) 1, (short) format.getChannels(), format.getSampleRate(), format.getSampleRate() * format.getChannels() * (format.getSampleSizeInBits() >> 3), (short) (format.getChannels() * (format.getSampleSizeInBits() >> 3)), (short) format.getSampleSizeInBits()), 44, calcDataSize(format.getChannels(), format.getSampleSizeInBits() >> 3, samples)); return w; }
public static AudioCodecMeta createAudioCodecMeta3(String fourcc, ByteBuffer codecPrivate, AudioFormat format, boolean pcm, Label[] labels) { AudioCodecMeta self = new AudioCodecMeta(fourcc, codecPrivate); self.sampleSize = format.getSampleSizeInBits() >> 3; self.channelCount = format.getChannels(); self.sampleRate = format.getSampleRate(); self.endian = format.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; self.pcm = pcm; self.labels = labels; return self; }
public static AudioCodecMeta fromAudioFormat(AudioFormat format) { AudioCodecMeta self = new AudioCodecMeta(null, null); self.sampleSize = format.getSampleSizeInBits() >> 3; self.channelCount = format.getChannels(); self.sampleRate = format.getSampleRate(); self.endian = format.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; self.pcm = false; return self; } }
public PCMMP4MuxerTrack addPCMAudioTrack(AudioFormat format) { return addPCMTrack((int) format.getSampleRate(), 1, (format.getSampleSizeInBits() >> 3) * format.getChannels(), audioSampleEntry(format)); }
public PCMMP4MuxerTrack addPCMAudioTrack(AudioFormat format) { return addPCMTrack((int) format.getSampleRate(), 1, (format.getSampleSizeInBits() >> 3) * format.getChannels(), audioSampleEntry(format)); }
public static AudioSampleEntry audioSampleEntryPCM(AudioFormat format) { return audioSampleEntry(AudioSampleEntry.lookupFourcc(format), 1, format.getSampleSizeInBits() >> 3, format.getChannels(), (int) format.getSampleRate(), format.isBigEndian() ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN); }
public static AudioSampleEntry audioSampleEntry(AudioFormat format) { return MP4Muxer.audioSampleEntry(lookupFourcc(format), 1, format.getSampleSizeInBits() >> 3, format.getChannels(), (int) format.getSampleRate(), format.isBigEndian() ? Endian.BIG_ENDIAN : Endian.LITTLE_ENDIAN); }
public static AudioSampleEntry audioSampleEntry(AudioFormat format) { return MP4Muxer.audioSampleEntry(lookupFourcc(format), 1, format.getSampleSizeInBits() >> 3, format.getChannels(), (int) format.getSampleRate(), format.isBigEndian() ? Endian.BIG_ENDIAN : Endian.LITTLE_ENDIAN); }
public static void main1(String[] args) throws Exception { Cmd cmd = MainUtils.parseArguments(args, ALL_FLAGS); if (cmd.argsLength() < 1) { MainUtils.printHelp(ALL_FLAGS, asList("filename.wav")); System.exit(-1); } File s = new File(args[0]); String pattern = cmd.getStringFlagD(FLAG_PATTERN, "c%02d.wav"); WavHeader wavHeader = WavHeader.read(s); System.out.println("WAV: " + wavHeader.getFormat()); Assert.assertEquals(2, wavHeader.fmt.numChannels); int dataOffset = wavHeader.dataOffset; FileChannelWrapper is = NIOUtils.readableChannel(s); is.setPosition(dataOffset); int channels = wavHeader.getFormat().getChannels(); SeekableByteChannel[] out = new SeekableByteChannel[channels]; for (int i = 0; i < channels; i++) { out[i] = NIOUtils.writableChannel((new File(s.getParentFile(), String.format(pattern, i)))); WavHeader.copyWithChannels(wavHeader, 1).write(out[i]); } copy(wavHeader.getFormat(), is, out); for (int i = 0; i < channels; i++) { out[i].close(); } }
public PCMMP4MuxerTrack(int trackId, AudioFormat format) { super(trackId, MP4TrackType.SOUND); this.chunkOffsets = LongArrayList.createLongArrayList(); this.frameDuration = 1; this.frameSize = (format.getSampleSizeInBits() >> 3) * format.getChannels(); addSampleEntry(AudioSampleEntry.audioSampleEntryPCM(format)); this._timescale = format.getSampleRate(); setTgtChunkDuration(new Rational(1, 2), Unit.SEC); }
AudioFormat format = at.getAudioFormat(); System.out.print("|C=" + at.getCodec() + "|SR=" + format.getSampleRate() + "|SS=" + (format.getSampleSizeInBits() >> 3) + "|CH=" + format.getChannels()); } else if (pkt.getType() == Type.SCRIPT) { FLVMetadata metadata = FLVReader.parseMetadata(pkt.getData().duplicate());
public static WavHeader create(AudioFormat af, int size) { WavHeader w = emptyWavHeader(); w.dataSize = size; FmtChunk fmt = newFmtChunk(); int bitsPerSample = af.getSampleSizeInBits(); int bytesPerSample = bitsPerSample / 8; int sampleRate = (int) af.getSampleRate(); w.fmt.bitsPerSample = (short) bitsPerSample; w.fmt.blockAlign = (short) (af.getFrameSize()); w.fmt.byteRate = (int) af.getFrameRate() * af.getFrameSize(); w.fmt.numChannels = (short) af.getChannels(); w.fmt.sampleRate = (int) af.getSampleRate(); return w; }