/** * @param samples * The samples to use * @param af * The audio format of the samples */ public FloatSampleBuffer(final float[] samples, final AudioFormat af) { this.format = af.clone(); this.format.setNBits(-1); this.samples = samples; }
/** * Constructor that takes the input and output formats. * @param input The input format * @param output The output format */ public AudioConverter( final AudioFormat input, final AudioFormat output ) { this.inputFormat = input.clone(); this.setFormat( output.clone() ); this.processor = AudioConverter.calculateProcess( input, output ); }
/** * Sets the underlying stream, allowing it to be changed. * * @param stream * The stream */ public void setUnderlyingStream(final AudioStream stream) { this.stream = stream; if (stream != null) this.format = stream.getFormat().clone(); }
/** * {@inheritDoc} * * @see org.openimaj.audio.samples.SampleBuffer#setFormat(org.openimaj.audio.AudioFormat) */ @Override public void setFormat(final AudioFormat af) { this.format = af.clone(); this.format.setNBits(-1); }
/** * @param samples * The samples to use * @param af * The audio format of the samples */ public FloatSampleBuffer(final float[] samples, final AudioFormat af) { this.format = af.clone(); this.format.setNBits(-1); this.samples = samples; }
/** * {@inheritDoc} * * @see org.openimaj.audio.samples.SampleBuffer#setFormat(org.openimaj.audio.AudioFormat) */ @Override public void setFormat(final AudioFormat af) { this.format = af.clone(); this.format.setNBits(-1); }
/** * Sets the underlying stream, allowing it to be changed. * * @param stream * The stream */ public void setUnderlyingStream(final AudioStream stream) { this.stream = stream; if (stream != null) this.format = stream.getFormat().clone(); }
/** * Constructor that takes the input and output formats. * @param input The input format * @param output The output format */ public AudioConverter( final AudioFormat input, final AudioFormat output ) { this.inputFormat = input.clone(); this.setFormat( output.clone() ); this.processor = AudioConverter.calculateProcess( input, output ); }
/** * Construct a new processor based on the given stream. This processor can * then be used as a stream itself in a chain. * * @param a * The audio stream to process. */ public AudioProcessor(final AudioStream a) { this.stream = a; if (a != null) this.format = a.getFormat().clone(); }
/** * Construct a new processor based on the given stream. This processor can * then be used as a stream itself in a chain. * * @param a * The audio stream to process. */ public AudioProcessor(final AudioStream a) { this.stream = a; if (a != null) this.format = a.getFormat().clone(); }
/** * Chainable constructor that takes the stream to chain and the * output format to convert the stream to. * @param stream The stream to chain to * @param output The required output format */ public AudioConverter( final AudioStream stream, final AudioFormat output ) { super( stream ); this.inputFormat = stream.getFormat().clone(); this.setFormat( output.clone() ); this.processor = AudioConverter.calculateProcess( this.inputFormat, output ); }
/** * Chainable constructor that takes the stream to chain and the * output format to convert the stream to. * @param stream The stream to chain to * @param output The required output format */ public AudioConverter( final AudioStream stream, final AudioFormat output ) { super( stream ); this.inputFormat = stream.getFormat().clone(); this.setFormat( output.clone() ); this.processor = AudioConverter.calculateProcess( this.inputFormat, output ); }
/** * Samples represented as a set of doubles. * @param samples The samples. * @param format The format of the samples */ public void setData( final double[] samples, final AudioFormat format ) { final FloatSampleBuffer fsb = new FloatSampleBuffer( samples, format.clone().setNBits( -1 ) ); super.setData( fsb ); }
/** * Create a processor for the given audio stream. The output * of this audio stream will be a mono stream. * * @param a The audio stream to process. */ public MultichannelToMonoProcessor( final AudioStream a ) { super( a ); this.setFormat( this.getFormat().clone().setNumChannels( 1 ) ); }
/** * Create a processor for the given audio stream. The output * of this audio stream will be a mono stream. * * @param a The audio stream to process. */ public MultichannelToMonoProcessor( final AudioStream a ) { super( a ); this.setFormat( this.getFormat().clone().setNumChannels( 1 ) ); }
/** * Updates the number of bits in the source processor's format to match the output format. * * @param ap The source processor * @param output The output format * @return The fixed source format */ private static AudioFormat getFormatBits( final AudioProcessor ap , final AudioFormat output ) { if( ap == null ) return output; final AudioFormat f = ap.getFormat().clone(); f.setNBits( output.getNBits() ); return f; }
/** * Updates the sample rate in the source processor's format to match the output format. * * @param ap The source processor * @param output The output format * @return The fixed source format */ private static AudioFormat getFormatSR( final AudioProcessor ap, final AudioFormat output ) { if( ap == null ) return output; final AudioFormat f = ap.getFormat().clone(); f.setSampleRateKHz( output.getSampleRateKHz() ); return f; }
/** * Updates the number of bits in the source processor's format to match the output format. * * @param ap The source processor * @param output The output format * @return The fixed source format */ private static AudioFormat getFormatBits( final AudioProcessor ap , final AudioFormat output ) { if( ap == null ) return output; final AudioFormat f = ap.getFormat().clone(); f.setNBits( output.getNBits() ); return f; }
/** * {@inheritDoc} */ @Override public SampleChunk clone() { return new SampleChunk(this.samples.clone(), this.format.clone(), this.startTimecode == null ? new AudioTimecode( 0) : this.startTimecode.clone()); }
/** * {@inheritDoc} */ @Override public SampleChunk clone() { return new SampleChunk(this.samples.clone(), this.format.clone(), this.startTimecode == null ? new AudioTimecode( 0) : this.startTimecode.clone()); }