fix: handle same-unit conversions in tempo converter

Fix issue where converting BPM to BPM (or any tempo unit to itself)
was incorrectly applying the conversion formula instead of returning
the same value.

Example bug: 120 BPM → BPM was returning 0.008333 instead of 120

Added check: if fromUnit === toUnit, return value unchanged.

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

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-11-08 11:59:15 +01:00
parent 75f895284f
commit fa1b82bbd6

View File

@@ -104,6 +104,11 @@ export function convertUnit(
const isToTempo = toUnit in tempoUnits;
if (isFromTempo && isToTempo) {
// Same unit - no conversion needed
if (fromUnit === toUnit) {
return value;
}
const fromAnchor = tempoUnits[fromUnit as keyof typeof tempoUnits].to_anchor;
const toAnchor = tempoUnits[toUnit as keyof typeof tempoUnits].to_anchor;