/** * Play the given sample chunk to the Java sound line. The line should be * set up to accept the samples that we're going to give it, as we did that * in the {@link #openJavaSound()} method. * * @param chunk * The chunk to play. */ private void playJavaSound(final SampleChunk chunk) { final byte[] rawBytes = chunk.getSamples(); this.mLine.write(rawBytes, 0, rawBytes.length); }
/** * Create a new 16-bit sample buffer using the given samples and the given * audio format. * * @param samples * The samples to buffer. * @param af * The audio format. */ public SampleBuffer16Bit(final SampleChunk samples, final AudioFormat af) { this.format = af; this.shortBuffer = samples.getSamplesAsByteBuffer().asShortBuffer(); this.samples = samples.getSamples(); this.setStartTimecode(samples.getStartTimecode()); }
/** * Create a new 16-bit sample buffer using the given samples and the given * audio format. * * @param samples * The samples to buffer. * @param af * The audio format. */ public SampleBuffer16Bit(final SampleChunk samples, final AudioFormat af) { this.format = af; this.shortBuffer = samples.getSamplesAsByteBuffer().asShortBuffer(); this.samples = samples.getSamples(); this.setStartTimecode(samples.getStartTimecode()); }
/** * Play the given sample chunk to the Java sound line. The line should be * set up to accept the samples that we're going to give it, as we did that * in the {@link #openJavaSound()} method. * * @param chunk * The chunk to play. */ private void playJavaSound(final SampleChunk chunk) { final byte[] rawBytes = chunk.getSamples(); this.mLine.write(rawBytes, 0, rawBytes.length); }
/** * Create a new 8-bit sample buffer using the given samples and the given * audio format. * * @param samples * The samples to buffer. * @param af * The audio format. */ public SampleBuffer8Bit(final SampleChunk samples, final AudioFormat af) { this.format = af; if (this.format == null || this.format.getNBits() != 8) throw new IllegalArgumentException("Number of bits " + "must be 8 if you're instantiating an 8 bit " + "sample buffer. However " + (this.format == null ? "format object was null." : "number of bits in format was " + this.format.getNBits())); this.byteBuffer = samples.getSamples(); this.timecode = samples.getStartTimecode(); }
/** * Create a new 8-bit sample buffer using the given samples and the given * audio format. * * @param samples * The samples to buffer. * @param af * The audio format. */ public SampleBuffer8Bit(final SampleChunk samples, final AudioFormat af) { this.format = af; if (this.format == null || this.format.getNBits() != 8) throw new IllegalArgumentException("Number of bits " + "must be 8 if you're instantiating an 8 bit " + "sample buffer. However " + (this.format == null ? "format object was null." : "number of bits in format was " + this.format.getNBits())); this.byteBuffer = samples.getSamples(); this.timecode = samples.getStartTimecode(); }