From c6c2d746d2e7b09a29e0ffbe70b89fd2c68d3ce2 Mon Sep 17 00:00:00 2001 From: supertick Date: Sun, 31 Mar 2024 09:25:31 -0700 Subject: [PATCH] added publishPeakResetDelayMs --- src/main/java/org/myrobotlab/audio/AudioProcessor.java | 5 ++++- .../java/org/myrobotlab/service/config/AudioFileConfig.java | 5 +++++ 2 files changed, 9 insertions(+), 1 deletion(-) 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; }