fix: remove double dB conversion from track levels for consistent metering

Track levels were being converted to dB scale twice:
1. First in useMultiTrackPlayer via linearToDbScale()
2. Again in TrackFader via linearToDb()

This caused tracks to show incorrect meter levels compared to master.
Now both track and master levels store raw linear values (0-1) and
let the fader components handle the single dB conversion for display.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-19 00:55:46 +01:00
parent 7a45a985c7
commit 34452862ca

View File

@@ -112,8 +112,8 @@ export function useMultiTrackPlayer(
}
}
// Convert linear peak to logarithmic dB scale
levels[track.id] = linearToDbScale(peak);
// Store raw linear peak (will be converted to dB in the fader component)
levels[track.id] = peak;
});
setTrackLevels(levels);
@@ -152,15 +152,14 @@ export function useMultiTrackPlayer(
// Detect clipping (signal >= 1.0)
const isClipping = peak >= 1.0;
// Convert to dB scale (same as track levels) for consistent metering
setMasterPeakLevel(linearToDbScale(peak));
setMasterRmsLevel(linearToDbScale(rms));
setMasterPeakLevel(peak);
setMasterRmsLevel(rms);
if (isClipping) {
setMasterIsClipping(true);
}
masterLevelMonitorFrameRef.current = requestAnimationFrame(monitorMasterLevels);
}, [linearToDbScale]);
}, []);
// Apply automation values during playback
const applyAutomation = useCallback(() => {