Files
units-ui/lib/tempo.ts
Sebastian Krüger f1fc803b0e style: clarify tempo unit labels to show millisecond durations
Update musical note unit labels to include "(ms)" suffix to make it
clear that values represent durations in milliseconds, not counts.

Before: "120 BPM = 2,000 Whole Notes" (confusing - sounds like a count)
After: "120 BPM = 2,000 Whole Note (ms)" (clear - it's a duration)

Changes:
- All note units now show "(ms)" in both singular and plural forms
- Triplet labels shortened for brevity (e.g., "Quarter Triplet (ms)")
- Makes the conversion meaning immediately clear to users

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

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-08 13:50:14 +01:00

118 lines
3.6 KiB
TypeScript

/**
* Custom tempo/BPM measure for convert-units
*
* Converts between BPM and note durations in milliseconds.
* Uses a reciprocal relationship where BPM (beats per minute) is the base unit.
*
* Formula: milliseconds per beat = 60000 / BPM
*
* The to_anchor value represents the conversion factor:
* - For BPM → time units: multiply by to_anchor to get milliseconds
* - For time units → BPM: divide by to_anchor to get BPM
*/
export const tempoMeasure = {
tempo: {
systems: {
metric: {
// BPM as the base unit (1 BPM = 60000 ms per beat)
'BPM': {
name: { singular: 'Beat per Minute', plural: 'Beats per Minute' },
to_anchor: 1
},
// Whole note (4 beats) = 240000 / BPM
'whole': {
name: { singular: 'Whole Note (ms)', plural: 'Whole Note (ms)' },
to_anchor: 240000
},
// Half note (2 beats) = 120000 / BPM
'half': {
name: { singular: 'Half Note (ms)', plural: 'Half Note (ms)' },
to_anchor: 120000
},
// Quarter note (1 beat) = 60000 / BPM
'quarter': {
name: { singular: 'Quarter Note (ms)', plural: 'Quarter Note (ms)' },
to_anchor: 60000
},
// Eighth note (0.5 beats) = 30000 / BPM
'eighth': {
name: { singular: 'Eighth Note (ms)', plural: 'Eighth Note (ms)' },
to_anchor: 30000
},
// Sixteenth note (0.25 beats) = 15000 / BPM
'sixteenth': {
name: { singular: 'Sixteenth Note (ms)', plural: 'Sixteenth Note (ms)' },
to_anchor: 15000
},
// Thirty-second note (0.125 beats) = 7500 / BPM
'thirty-second': {
name: { singular: 'Thirty-Second Note (ms)', plural: 'Thirty-Second Note (ms)' },
to_anchor: 7500
},
// Dotted notes (1.5x the duration)
'dotted-half': {
name: { singular: 'Dotted Half Note (ms)', plural: 'Dotted Half Note (ms)' },
to_anchor: 180000 // 3 beats
},
'dotted-quarter': {
name: { singular: 'Dotted Quarter Note (ms)', plural: 'Dotted Quarter Note (ms)' },
to_anchor: 90000 // 1.5 beats
},
'dotted-eighth': {
name: { singular: 'Dotted Eighth Note (ms)', plural: 'Dotted Eighth Note (ms)' },
to_anchor: 45000 // 0.75 beats
},
'dotted-sixteenth': {
name: { singular: 'Dotted Sixteenth Note (ms)', plural: 'Dotted Sixteenth Note (ms)' },
to_anchor: 22500 // 0.375 beats
},
// Triplet notes (2/3 of the duration)
'quarter-triplet': {
name: { singular: 'Quarter Triplet (ms)', plural: 'Quarter Triplet (ms)' },
to_anchor: 40000 // 2/3 beat
},
'eighth-triplet': {
name: { singular: 'Eighth Triplet (ms)', plural: 'Eighth Triplet (ms)' },
to_anchor: 20000 // 1/3 beat
},
'sixteenth-triplet': {
name: { singular: 'Sixteenth Triplet (ms)', plural: 'Sixteenth Triplet (ms)' },
to_anchor: 10000 // 1/6 beat
},
// Milliseconds as direct time unit
'ms': {
name: { singular: 'Millisecond', plural: 'Milliseconds' },
to_anchor: 60000 // Same as quarter note
},
// Seconds
's': {
name: { singular: 'Second', plural: 'Seconds' },
to_anchor: 60 // 60 seconds per beat at 1 BPM
},
// Hertz (beats per second)
'Hz': {
name: { singular: 'Hertz', plural: 'Hertz' },
to_anchor: 1 / 60 // 1 BPM = 1/60 Hz
}
}
}
}
};