Added limiter to peak meter

This commit is contained in:
Pax1601
2024-10-09 18:41:40 +02:00
parent b282e5d676
commit 12b9337026
2 changed files with 6 additions and 4 deletions

View File

@@ -15,7 +15,7 @@ export function AudioSourcePanel(props: { source: AudioSource }) {
useEffect(() => {
setInterval(() => {
setMeterLevel(props.source.getMeter().getPeaks().current[0]);
setMeterLevel(Math.min(100, props.source.getMeter().getPeaks().current[0]));
}, 50);
}, []);
@@ -92,14 +92,16 @@ export function AudioSourcePanel(props: { source: AudioSource }) {
</div>
<OlRangeSlider
value={props.source.getVolume() * 100}
min={0}
max={200}
onChange={(ev) => {
props.source.setVolume(parseFloat(ev.currentTarget.value) / 100);
}}
className="absolute top-[18px]"
/>
</div>
<div className="h-[40px] min-w-[40px] p-2">
<span>{Math.round(props.source.getVolume() * 100)}</span>
<div className="h-[40px] min-w-[60px] p-2 text-md">
<span>{Math.round(props.source.getVolume() * 100)}%</span>
</div>
</div>
</div>