Skip to content

Commit

Permalink
added publishPeakResetDelayMs
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Mar 31, 2024
1 parent 2dd56c2 commit c6c2d74
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/main/java/org/myrobotlab/audio/AudioProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,10 @@ public AudioData play(AudioData data) {
if (audioFile.getConfig().peakDelayMs == null) {
audioFile.invoke("publishPeak", value);
} else {
delayScheduler.schedule(() -> audioFile.invoke("publishPeak", value), audioFile.getConfig().peakDelayMs, TimeUnit.MILLISECONDS);
delayScheduler.schedule(() -> audioFile.invoke("publishPeak", value), audioFile.getConfig().peakDelayMs, TimeUnit.MILLISECONDS);
if (audioFile.getConfig().publishPeakResetDelayMs != null) {
delayScheduler.schedule(() -> audioFile.invoke("publishPeak", 0), audioFile.getConfig().peakDelayMs + audioFile.getConfig().publishPeakResetDelayMs, TimeUnit.MILLISECONDS);
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,9 @@ public class AudioFileConfig extends ServiceConfig {
* delay to synchronize publishing of peak with actual sound in milliseconds
*/
public Long peakDelayMs = null;

/**
* resets the peak to 0 after this many milliseconds
*/
public Long publishPeakResetDelayMs = 30L;
}

0 comments on commit c6c2d74

Please sign in to comment.