/** * Chainable constructor * @param as The audio stream to process */ public BeatDetector( final AudioStream as ) { this( as, as.getFormat() ); }
@Override public boolean hasNext() { if (next != null) return true; next = nextSampleChunk(); return next != null; }
/** * {@inheritDoc} * @see org.openimaj.audio.AudioStream#getLength() */ @Override public long getLength() { return this.stream.getLength() * nLoops; } }
final double sampleRate = audioStream.getFormat().getSampleRateKHz() * 1000; final SampleChunk sc = audioStream.nextSampleChunk();
SampleChunk sc = stream.nextSampleChunk(); stream.reset(); return stream.nextSampleChunk();
/** * {@inheritDoc} * * The implementation in this class just calls reset on the wrapped stream * (if it's set). * * @see org.openimaj.audio.AudioStream#reset() */ @Override public void reset() { if (this.stream != null) { stream.reset(); } }
/** * {@inheritDoc} * * @see org.openimaj.time.TimeKeeper#seek(long) */ @Override public void seek(final long timestamp) { this.stream.seek(timestamp); }
final double sampleRate = audioStream.getFormat().getSampleRateKHz() * 1000; final SampleChunk sc = audioStream.nextSampleChunk();
SampleChunk sc = stream.nextSampleChunk(); stream.reset(); return stream.nextSampleChunk();
/** * {@inheritDoc} * * The implementation in this class just calls reset on the wrapped stream * (if it's set). * * @see org.openimaj.audio.AudioStream#reset() */ @Override public void reset() { if (this.stream != null) { stream.reset(); } }
/** * {@inheritDoc} * * @see org.openimaj.time.TimeKeeper#seek(long) */ @Override public void seek(final long timestamp) { this.stream.seek(timestamp); }
@Override public boolean hasNext() { if (next != null) return true; next = nextSampleChunk(); return next != null; }
/** * Chainable constructor * @param as The audio stream to process */ public BeatDetector( final AudioStream as ) { this( as, as.getFormat() ); }
/** * {@inheritDoc} * * @see org.openimaj.audio.AudioStream#getLength() */ @Override public long getLength() { return this.stream.getLength(); } }
/** * {@inheritDoc} * * @see org.openimaj.time.TimeKeeper#reset() */ @Override public void reset() { this.timecodeReadAt = 0; this.currentTimestamp = 0; this.started = false; this.currentTimecode.setTimecodeInMilliseconds(0); this.stream.reset(); }
@Override public SampleChunk next() { if (next == null) next = nextSampleChunk(); final SampleChunk ret = next; next = null; if (ret == null) throw new NoSuchElementException(); return ret; }
/** * Create a new looper that will loop the given stream the given number * of times. Whether the stream is cached or not is able to be specified. * * @param stream The stream to loop * @param nLoops The number of loops to do * @param cacheStream Whether to cache the stream or not */ public AudioLooper( AudioStream stream, int nLoops, boolean cacheStream ) { this.stream = stream; this.nLoops = nLoops; this.cacheStream = cacheStream; this.format = stream.getFormat(); if( cacheStream ) streamCache = new ArrayList<SampleChunk>(); }
/** * {@inheritDoc} * * @see org.openimaj.audio.AudioStream#getLength() */ @Override public long getLength() { return this.stream.getLength(); } }
/** * {@inheritDoc} * * @see org.openimaj.time.TimeKeeper#reset() */ @Override public void reset() { this.timecodeReadAt = 0; this.currentTimestamp = 0; this.started = false; this.currentTimecode.setTimecodeInMilliseconds(0); this.stream.reset(); }