11 lines
273 B
TypeScript
11 lines
273 B
TypeScript
import { TPQ } from "./types.ts";
|
|
|
|
// One quarter note = TPQ ticks.
|
|
export function ticksToSeconds(tick: number, bpm: number): number {
|
|
return (tick / TPQ) * (60 / bpm);
|
|
}
|
|
|
|
export function secondsToTicks(s: number, bpm: number): number {
|
|
return s * (bpm / 60) * TPQ;
|
|
}
|