Skip to content

Commit

Permalink
ui show peak values
Browse files Browse the repository at this point in the history
  • Loading branch information
supertick committed Mar 31, 2024
1 parent c6c2d74 commit 5900262
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
11 changes: 7 additions & 4 deletions src/main/java/org/myrobotlab/audio/AudioProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,22 @@
<td>volume</td>
<td>{{service.volume.toFixed(2) * 100}}</td>
</tr>
<tr>
<td>peak volume multiplier</td>
<td>{{service.config.peakMultiplier }}</td>
</tr>
<tr>
<td>peak volume sample interval</td>
<td>{{service.config.peakSampleInterval }}</td>
</tr>
<tr>
<td>peak volume delay</td>
<td>{{service.config.peakDelayMs }}</td>
</tr>
<tr>
<td>peak reset delay</td>
<td>{{service.config.publishPeakResetDelayMs }}</td>
</tr>
</table>
<br/>
<!--Selected playlist: {{service.currentPlaylist}}<br/>-->
Expand Down

0 comments on commit 5900262

Please sign in to comment.