Skip to content

Commit

Permalink
Only reconfigure TarsosDSPPlayer if tempo actually changed
Browse files Browse the repository at this point in the history
  • Loading branch information
centic9 committed Sep 10, 2024
1 parent 6e5d53d commit 1ddc9b3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/main/java/org/dstadler/audio/player/TarsosDSPPlayer.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,14 @@ public TarsosDSPPlayer(InputStream stream) {
@Override
public void setOptions(String options) {
if(StringUtils.isNotEmpty(options)) {
float prevTempo = tempo;
tempo = Float.parseFloat(options);
Preconditions.checkState(tempo > 0,
"Cannot play at speed zero or less, but had: %s",
tempo);

// if already playing, pass on the new parameters to allow to change tempo at runtime
if (wsola != null) {
if (wsola != null && prevTempo != tempo) {
wsola.setDispatcher(dispatcher);
wsola.setParameters(WaveformSimilarityBasedOverlapAdd.Parameters.musicDefaults(tempo, sampleRate));
}
Expand Down

0 comments on commit 1ddc9b3

Please sign in to comment.