diff --git a/src/main/java/org/myrobotlab/audio/AudioProcessor.java b/src/main/java/org/myrobotlab/audio/AudioProcessor.java index e7018d664d..bdbcd854a5 100644 --- a/src/main/java/org/myrobotlab/audio/AudioProcessor.java +++ b/src/main/java/org/myrobotlab/audio/AudioProcessor.java @@ -239,14 +239,17 @@ public AudioData play(AudioData data) { } final double value = peak * (double) audioFile.getPeakMultiplier(); - + + // skew publish forwards in time if (audioFile.getConfig().peakDelayMs == null) { audioFile.invoke("publishPeak", value); } else { 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); - } + } + + // reset to 0 after millis + 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 a6faeb07e1..df4a78e446 100644 --- a/src/main/java/org/myrobotlab/service/config/AudioFileConfig.java +++ b/src/main/java/org/myrobotlab/service/config/AudioFileConfig.java @@ -17,20 +17,20 @@ public class AudioFileConfig extends ServiceConfig { /** * a multiplier to scale amplitude of output waveform */ - public double peakMultiplier = 100.0; + public double peakMultiplier = 300.0; /** * sample interval for peak */ - public double peakSampleInterval = 15; + public double peakSampleInterval = 2.0; /** * delay to synchronize publishing of peak with actual sound in milliseconds */ - public Long peakDelayMs = null; + public Long peakDelayMs = 10L; /** * resets the peak to 0 after this many milliseconds */ - public Long publishPeakResetDelayMs = 30L; + public Long publishPeakResetDelayMs = 100L; } diff --git a/src/main/resources/resource/WebGui/app/service/views/AudioFileGui.html b/src/main/resources/resource/WebGui/app/service/views/AudioFileGui.html index 93e1cac98b..49edaff5a9 100644 --- a/src/main/resources/resource/WebGui/app/service/views/AudioFileGui.html +++ b/src/main/resources/resource/WebGui/app/service/views/AudioFileGui.html @@ -49,6 +49,22 @@ volume {{service.volume.toFixed(2) * 100}} + + peak volume multiplier + {{service.config.peakMultiplier }} + + + peak volume sample interval + {{service.config.peakSampleInterval }} + + + peak volume delay + {{service.config.peakDelayMs }} + + + peak reset delay + {{service.config.publishPeakResetDelayMs }} +