/** * {@inheritDoc} * * @see org.openimaj.audio.processor.AudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override public SampleChunk process(final SampleChunk sample) throws Exception { // This allows us to retrieve samples that are scaled to 0..1 float // values final SampleBuffer sb = sample.getSampleBuffer(); for (final float s : sb) if (Math.abs(s) * this.scalar > 1) this.scalar = 1 / Math.abs(s); return sample; }
/** * {@inheritDoc} * * @see org.openimaj.audio.processor.AudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override public SampleChunk process(final SampleChunk sample) throws Exception { // This allows us to retrieve samples that are scaled to 0..1 float // values final SampleBuffer sb = sample.getSampleBuffer(); for (final float s : sb) if (Math.abs(s) * this.scalar > 1) this.scalar = 1 / Math.abs(s); return sample; }
/** * {@inheritDoc} * @see org.openimaj.audio.processor.AudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override public SampleChunk process( final SampleChunk sample ) throws Exception { this.process( sample.getSampleBuffer() ); return sample; }
/** * {@inheritDoc} * @see org.openimaj.audio.processor.AudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override public SampleChunk process( final SampleChunk sample ) throws Exception { this.process( sample.getSampleBuffer() ); return sample; }
@Override public void afterPlay( final AudioPlayer ap, final SampleChunk sc ) { aw.setData( sc.getSampleBuffer() ); } } );
@Override public void afterPlay( final AudioPlayer ap, final SampleChunk sc ) { aw.setData( sc.getSampleBuffer() ); } } );
@Override public DoubleFV extractFeature( final SampleChunk object ) { final double[] d = this.mfcc.calculateMFCC( object.getSampleBuffer() )[0]; return new DoubleFV(d); } }
/** * {@inheritDoc} * @see org.openimaj.audio.processor.AudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override public SampleChunk process( final SampleChunk sample ) { // Get a sample buffer object for this data final SampleBuffer sb = sample.getSampleBuffer(); return this.process( sb ).getSampleChunk(); }
/** * {@inheritDoc} * @see org.openimaj.audio.processor.AudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override public SampleChunk process( final SampleChunk sample ) { // Get a sample buffer object for this data final SampleBuffer sb = sample.getSampleBuffer(); return this.process( sb ).getSampleChunk(); }
@Override public DoubleFV extractFeature( final SampleChunk object ) { final double[] d = this.mfcc.calculateMFCC( object.getSampleBuffer() )[0]; return new DoubleFV(d); } }
/** * {@inheritDoc} * @see org.openimaj.audio.AudioStream#nextSampleChunk() */ @Override public SampleChunk nextSampleChunk() { final Oscillator o = this.oscillator; if( !this.noteOn ) return null; // o = Oscillator.NONE; final SampleChunk x = o.getSampleChunk( this.sampleChunkLength, this.currentTime, this.frequency, this.gain, this.format ); this.applyADSREnvelope( x.getSampleBuffer() ); this.currentTime += x.getSampleBuffer().size() / (this.format.getSampleRateKHz()*1000d); this.currentTimeMS = this.currentTime * 1000d; return x; }
/** * {@inheritDoc} * @see org.openimaj.audio.AudioStream#nextSampleChunk() */ @Override public SampleChunk nextSampleChunk() { final Oscillator o = this.oscillator; if( !this.noteOn ) return null; // o = Oscillator.NONE; final SampleChunk x = o.getSampleChunk( this.sampleChunkLength, this.currentTime, this.frequency, this.gain, this.format ); this.applyADSREnvelope( x.getSampleBuffer() ); this.currentTime += x.getSampleBuffer().size() / (this.format.getSampleRateKHz()*1000d); this.currentTimeMS = this.currentTime * 1000d; return x; }
/** * Calculates the feature for each channel, then flattens the channel arrays * into a single {@link DoubleFV}. * * {@inheritDoc} * @see org.openimaj.feature.FeatureExtractor#extractFeature(java.lang.Object) */ @Override public DoubleFV extractFeature( final SampleChunk sc ) { // Calculate the feature vector for this frame. this.process( sc.getSampleBuffer() ); return new DoubleFV( ArrayUtils.reshape( this.lastCalculatedFeature ) ); }
/** * Calculates the feature for each channel, then flattens the channel arrays * into a single {@link DoubleFV}. * * {@inheritDoc} * @see org.openimaj.feature.FeatureExtractor#extractFeature(java.lang.Object) */ @Override public DoubleFV extractFeature( final SampleChunk sc ) { // Calculate the feature vector for this frame. this.process( sc.getSampleBuffer() ); return new DoubleFV( ArrayUtils.reshape( this.lastCalculatedFeature ) ); }
/** * Process the given sample chunk. Note that it is expected that the * sample will be the correct length (as given in the constructor). If it * is not, the window will not be applied correctly. * * {@inheritDoc} * @see org.openimaj.audio.processor.AudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override final public SampleChunk process( final SampleChunk sample ) { if( sample == null ) return null; if( this.weightTable == null ) this.generateWeightTableCache( sample ); // Apply the Hanning weights this.process( sample.getSampleBuffer() ); return this.processSamples( sample ); }
/** * Process the given sample chunk. Note that it is expected that the * sample will be the correct length (as given in the constructor). If it * is not, the window will not be applied correctly. * * {@inheritDoc} * @see org.openimaj.audio.processor.AudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override final public SampleChunk process( final SampleChunk sample ) { if( sample == null ) return null; if( this.weightTable == null ) this.generateWeightTableCache( sample ); // Apply the Hanning weights this.process( sample.getSampleBuffer() ); return this.processSamples( sample ); }
/** * {@inheritDoc} * @see org.openimaj.audio.processor.FixedSizeSampleAudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override public SampleChunk process( final SampleChunk sample ) throws Exception { final SampleBuffer sb = sample.getSampleBuffer(); for( int c = 0; c < sample.getFormat().getNumChannels(); c++ ) { float acc = 0; for( int i = 0; i < this.coefficients.length; i++ ) acc += sb.get(i) * this.coefficients[i]; sb.set( 0, acc ); } return sample; } }
/** * {@inheritDoc} * @see org.openimaj.audio.processor.FixedSizeSampleAudioProcessor#process(org.openimaj.audio.SampleChunk) */ @Override public SampleChunk process( final SampleChunk sample ) throws Exception { final SampleBuffer sb = sample.getSampleBuffer(); for( int c = 0; c < sample.getFormat().getNumChannels(); c++ ) { float acc = 0; for( int i = 0; i < this.coefficients.length; i++ ) acc += sb.get(i) * this.coefficients[i]; sb.set( 0, acc ); } return sample; } }
@Override public SampleChunk process( final SampleChunk s, final AudioFormat output ) { final SampleBuffer sbin = s.getSampleBuffer(); final SampleBuffer sbout = SampleBufferFactory.createSampleBuffer( output, sbin.size() ); sbout.setFormat( output ); // The sample buffer will do the conversion for( int i = 0; i < sbin.size(); i++ ) sbout.set( i, sbin.get(i) ); return sbout.getSampleChunk(); } };
@Override public SampleChunk process( final SampleChunk s, final AudioFormat output ) { final SampleBuffer sbin = s.getSampleBuffer(); final SampleBuffer sbout = SampleBufferFactory.createSampleBuffer( output, sbin.size() ); sbout.setFormat( output ); // The sample buffer will do the conversion for( int i = 0; i < sbin.size(); i++ ) sbout.set( i, sbin.get(i) ); return sbout.getSampleChunk(); } };