/** * {@inheritDoc} * @see org.openimaj.audio.timecode.AudioTimecode#toString() */ @Override public String toString() { return getMeasures()+":"+getBeats()+":"+getTicks(); } }
/** * {@inheritDoc} */ @Override public AudioTimecode clone() { return new AudioTimecode( milliseconds ); } }
/** * Set the tempo of the timekeeper * @param bpm The new beats per minute. */ public void setBPM( final float bpm ) { this.timecode = new MeasuresBeatsTicksTimecode( bpm, this.timecode.getMeasures(), this.timecode.getBeats(), this.timecode.getTicks(), this.timecode.beatsPerMeasure ); }
/** * {@inheritDoc} * * @see org.openimaj.time.TimeKeeper#getTime() */ @Override public AudioTimecode getTime() { // If we've not yet read any samples, just return the timecode // object as it was first given to us. if (this.timecodeReadAt == 0) return this.currentTimecode; // Update the timecode if we're playing (otherwise we'll return the // latest timecode) if (this.mode == Mode.PLAY) this.currentTimecode.setTimecodeInMilliseconds(this.currentTimestamp + (System.currentTimeMillis() - this.timecodeReadAt)); return this.currentTimecode; }
/** * {@inheritDoc} */ @Override public SampleChunk clone() { return new SampleChunk(this.samples.clone(), this.format.clone(), this.startTimecode == null ? new AudioTimecode( 0) : this.startTimecode.clone()); }
/** * {@inheritDoc} * @see org.openimaj.time.TimeKeeper#getTime() */ @Override public MeasuresBeatsTicksTimecode getTime() { if( this.isRunning ) { // Update the current time. this.currentTime = (System.currentTimeMillis() - this.lastStarted - this.timeOffset); this.timecode.setTimecodeInMilliseconds( this.currentTime ); } return this.timecode; }
/** * {@inheritDoc} * * @see org.openimaj.time.TimeKeeper#getTime() */ @Override public AudioTimecode getTime() { // If we've not yet read any samples, just return the timecode // object as it was first given to us. if (this.timecodeReadAt == 0) return this.currentTimecode; // Update the timecode if we're playing (otherwise we'll return the // latest timecode) if (this.mode == Mode.PLAY) this.currentTimecode.setTimecodeInMilliseconds(this.currentTimestamp + (System.currentTimeMillis() - this.timecodeReadAt)); return this.currentTimecode; }
/** * Set the tempo of the timekeeper * @param bpm The new beats per minute. */ public void setBPM( final float bpm ) { this.timecode = new MeasuresBeatsTicksTimecode( bpm, this.timecode.getMeasures(), this.timecode.getBeats(), this.timecode.getTicks(), this.timecode.beatsPerMeasure ); }
/** * {@inheritDoc} */ @Override public AudioTimecode clone() { return new AudioTimecode( milliseconds ); } }
/** * {@inheritDoc} * @see org.openimaj.audio.timecode.AudioTimecode#toString() */ @Override public String toString() { return getMeasures()+":"+getBeats()+":"+getTicks(); } }
/** * {@inheritDoc} */ @Override public SampleChunk clone() { return new SampleChunk(this.samples.clone(), this.format.clone(), this.startTimecode == null ? new AudioTimecode( 0) : this.startTimecode.clone()); }
/** * {@inheritDoc} * @see org.openimaj.time.TimeKeeper#getTime() */ @Override public MeasuresBeatsTicksTimecode getTime() { if( this.isRunning ) { // Update the current time. this.currentTime = (System.currentTimeMillis() - this.lastStarted - this.timeOffset); this.timecode.setTimecodeInMilliseconds( this.currentTime ); } return this.timecode; }
/** * {@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(); }
/** * Play the given stream to a specific device. * * @param a * The audio stream to play. * @param deviceName * The device to play the audio to. */ public AudioPlayer(final AudioStream a, final String deviceName) { this.stream = a; this.deviceName = deviceName; this.setTimecodeObject(new AudioTimecode(0)); }
/** * {@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(); }
/** * Play the given stream to a specific device. * * @param a * The audio stream to play. * @param deviceName * The device to play the audio to. */ public AudioPlayer(final AudioStream a, final String deviceName) { this.stream = a; this.deviceName = deviceName; this.setTimecodeObject(new AudioTimecode(0)); }
/** * {@inheritDoc} * * @see org.openimaj.time.TimeKeeper#pause() */ @Override public void pause() { this.setMode(Mode.PAUSE); // Set the current timecode to the time at which we paused. this.currentTimecode.setTimecodeInMilliseconds(this.currentTimestamp + (System.currentTimeMillis() - this.timecodeReadAt)); } }
/** * Default constructor that takes the format for the samples. All streams * added to this mixer must conform to that sample format. * * @param af * The {@link AudioFormat} */ public AudioMixer(final AudioFormat af) { this.setFormat(af); // Create the current sample chunk that we'll reuse this.currentSample = SampleBufferFactory.createSampleBuffer(af, this.bufferSize); this.timecode = new AudioTimecode(0); }
/** * {@inheritDoc} * * @see org.openimaj.time.TimeKeeper#pause() */ @Override public void pause() { this.setMode(Mode.PAUSE); // Set the current timecode to the time at which we paused. this.currentTimecode.setTimecodeInMilliseconds(this.currentTimestamp + (System.currentTimeMillis() - this.timecodeReadAt)); } }
/** * Default constructor that takes the format for the samples. All streams * added to this mixer must conform to that sample format. * * @param af * The {@link AudioFormat} */ public AudioMixer(final AudioFormat af) { this.setFormat(af); // Create the current sample chunk that we'll reuse this.currentSample = SampleBufferFactory.createSampleBuffer(af, this.bufferSize); this.timecode = new AudioTimecode(0); }