Skip to content

🎥 Make videos programmatically with React

fix(studio): keep waveform peaks unscaled with volume curves

Jonny Burger4b4505c8b70c
diff --git a/packages/studio/src/components/AudioWaveform.tsx b/packages/studio/src/components/AudioWaveform.tsx
index 1e7d336166..24ed34d472 100644
--- a/packages/studio/src/components/AudioWaveform.tsx
+++ b/packages/studio/src/components/AudioWaveform.tsx
@@ -100,6 +100,8 @@ const AudioWaveformInner: React.FC<{
volume,
});
}, [displayDurationInFrames, displayOffsetInFrames, muted, volume]);
+ const waveformVolume =
+ shouldRenderVolumeOverlay && !muted ? 1 : visibleVolume;
// Layout effect so that a cache hit sets the peaks synchronously and the
// waveform is painted on the very first frame after mounting.
@@ -166,11 +168,11 @@ const AudioWaveformInner: React.FC<{
WHITE_ALPHA_60,
getComputedStyle(canvasElement),
),
- volume: visibleVolume,
+ volume: waveformVolume,
width: drawingWidth,
horizontalOffset,
});
- }, [height, peakRange, peaks, visibleVolume, visualizationWidth]);
+ }, [height, peakRange, peaks, visualizationWidth, waveformVolume]);
useLayoutEffect(() => {
if (!shouldRenderVolumeOverlay || !peaks) {