/** * Appends the given samples to the end of this sample chunk. It is expected * that the given samples are in the same format as this sample chunk; if * they are not an exception is thrown. Side-affects this sample chunk and * will return a reference to this sample chunk. * * @param sample * the samples to add * @return This sample chunk with the bytes appended */ public SampleChunk append(final SampleChunk sample) { // Check the sample formats are the same if (!sample.getFormat().equals(this.format)) throw new IllegalArgumentException("Sample types are not equivalent"); // Get the samples from the given chunk final byte[] x1 = sample.getSamplesAsByteBuffer().array(); // Create an array for the concatenated pair final byte[] newSamples = new byte[this.samples.length + x1.length]; synchronized (this.samples) { System.arraycopy(this.samples, 0, newSamples, 0, this.samples.length); } System.arraycopy(x1, 0, newSamples, this.samples.length, x1.length); // Update this object this.samples = newSamples; return this; }
/** * Appends the given samples to the end of this sample chunk. It is expected * that the given samples are in the same format as this sample chunk; if * they are not an exception is thrown. Side-affects this sample chunk and * will return a reference to this sample chunk. * * @param sample * the samples to add * @return This sample chunk with the bytes appended */ public SampleChunk append(final SampleChunk sample) { // Check the sample formats are the same if (!sample.getFormat().equals(this.format)) throw new IllegalArgumentException("Sample types are not equivalent"); // Get the samples from the given chunk final byte[] x1 = sample.getSamplesAsByteBuffer().array(); // Create an array for the concatenated pair final byte[] newSamples = new byte[this.samples.length + x1.length]; synchronized (this.samples) { System.arraycopy(this.samples, 0, newSamples, 0, this.samples.length); } System.arraycopy(x1, 0, newSamples, this.samples.length, x1.length); // Update this object this.samples = newSamples; return this; }
if (as.format.equals(this.getFormat()))
if (as.format.equals(this.getFormat()))
/** * Prepends the given samples to the front of this sample chunk. It is * expected that the given samples are in the same format as this sample * chunk; if they are not an exception is thrown. Side-affects this sample * chunk and will return a reference to this sample chunk. * * @param sample * the samples to add * @return This sample chunk with the bytes prepended */ public SampleChunk prepend(final SampleChunk sample) { // Check the sample formats are the same if (!sample.getFormat().equals(this.format)) throw new IllegalArgumentException("Sample types are not equivalent"); // Get the samples from the given chunk final byte[] x1 = sample.getSamplesAsByteBuffer().array(); // Create an array for the concatenated pair final byte[] newSamples = new byte[this.samples.length + x1.length]; // Loop through adding the new samples System.arraycopy(x1, 0, newSamples, 0, x1.length); synchronized (this.samples) { System.arraycopy(this.samples, 0, newSamples, x1.length, this.samples.length); } // Update this object this.samples = newSamples; this.setStartTimecode(sample.getStartTimecode().clone()); return this; }
/** * Prepends the given samples to the front of this sample chunk. It is * expected that the given samples are in the same format as this sample * chunk; if they are not an exception is thrown. Side-affects this sample * chunk and will return a reference to this sample chunk. * * @param sample * the samples to add * @return This sample chunk with the bytes prepended */ public SampleChunk prepend(final SampleChunk sample) { // Check the sample formats are the same if (!sample.getFormat().equals(this.format)) throw new IllegalArgumentException("Sample types are not equivalent"); // Get the samples from the given chunk final byte[] x1 = sample.getSamplesAsByteBuffer().array(); // Create an array for the concatenated pair final byte[] newSamples = new byte[this.samples.length + x1.length]; // Loop through adding the new samples System.arraycopy(x1, 0, newSamples, 0, x1.length); synchronized (this.samples) { System.arraycopy(this.samples, 0, newSamples, x1.length, this.samples.length); } // Update this object this.samples = newSamples; this.setStartTimecode(sample.getStartTimecode().clone()); return this; }
if( input.equals( output ) ) return null;
if( input.equals( output ) ) return null;