time-beat-frame
v0.1.1
Published
Seconds, beats, and frames with optional tempo knots (BPM ramps).
Readme
time-beat-frame
秒・拍・フレーム数を相互変換するTypeScriptライブラリです。
固定BPMのほか、時刻ごとのBPM変化にも対応します。
Installation
npm i time-beat-frameUsage
固定BPM(knotsなし)ではbpmが必須です。既定のフレームレートは30fpsです。
import { TimeBeatFrame } from "time-beat-frame";
const tbf = new TimeBeatFrame({ bpm: 120, frameRate: 30 });
tbf.timeToBeat(2); // 秒 → 拍
tbf.beatToTime(4); // 拍 → 秒
tbf.timeToFrame(2); // 秒 → フレーム時刻ごとにBPMを変える場合はknotsを渡します。
const tbf = new TimeBeatFrame({
knots: [
{ time: 0, bpm: 120, curveToNext: "hold" },
{ time: 4, bpm: 150, curveToNext: "hold" },
],
});
tbf.atTime(4).addBeat(1).toTime(); // 4秒地点から1拍進めた時間