/** * Sets the playback speed. Calling this method will discard any data buffered within the * processor, and may update the value returned by {@link #isActive()}. * * @param speed The requested new playback speed. * @return The actual new playback speed. */ public float setSpeed(float speed) { speed = Util.constrainValue(speed, MINIMUM_SPEED, MAXIMUM_SPEED); if (this.speed != speed) { this.speed = speed; sonic = null; } flush(); return speed; }
/** * Sets the playback pitch. Calling this method will discard any data buffered within the * processor, and may update the value returned by {@link #isActive()}. * * @param pitch The requested new pitch. * @return The actual new pitch. */ public float setPitch(float pitch) { pitch = Util.constrainValue(pitch, MINIMUM_PITCH, MAXIMUM_PITCH); if (this.pitch != pitch) { this.pitch = pitch; sonic = null; } flush(); return pitch; }
@Test public void testIsActiveWithPitchChange() throws Exception { sonicAudioProcessor.setPitch(1.5f); sonicAudioProcessor.configure(44100, 2, C.ENCODING_PCM_16BIT); sonicAudioProcessor.flush(); assertThat(sonicAudioProcessor.isActive()).isTrue(); }
@Test public void testIsActiveWithSpeedChange() throws Exception { sonicAudioProcessor.setSpeed(1.5f); sonicAudioProcessor.configure(44100, 2, C.ENCODING_PCM_16BIT); sonicAudioProcessor.flush(); assertThat(sonicAudioProcessor.isActive()).isTrue(); }