diff --git a/src/main/java/org/myrobotlab/audio/AudioProcessor.java b/src/main/java/org/myrobotlab/audio/AudioProcessor.java index 46bc11d136..e7018d664d 100644 --- a/src/main/java/org/myrobotlab/audio/AudioProcessor.java +++ b/src/main/java/org/myrobotlab/audio/AudioProcessor.java @@ -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); + } } } } diff --git a/src/main/java/org/myrobotlab/service/config/AudioFileConfig.java b/src/main/java/org/myrobotlab/service/config/AudioFileConfig.java index 391d175d55..a6faeb07e1 100644 --- a/src/main/java/org/myrobotlab/service/config/AudioFileConfig.java +++ b/src/main/java/org/myrobotlab/service/config/AudioFileConfig.java @@ -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; }