Skip to content

Latest commit

 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

time-beat-frame

秒・拍・フレーム数を相互変換するTypeScriptライブラリです。

固定 tempo のほか、時刻ごとの tempo 変化(automation)にも対応します。

Installation

npm i time-beat-frame

Usage

固定 tempo(tempoAutomation なし)では tempo が必須です。

import { TimeBeatFrame } from "time-beat-frame";

const tbf = new TimeBeatFrame({ tempo: 120, frameRate: 30 });

tbf.timeToBeat(2); // 秒 → 拍
tbf.beatToTime(4); // 拍 → 秒
tbf.timeToFrame(2); // 秒 → フレーム

// 時間式を秒に変換(m: 分、s: 秒、b: 拍、f: フレーム)
tbf.parse("1m30s"); // 90
tbf.parse("2s+1b"); // 2.5(tempo: 120 の場合)
tbf.parse("1s+15f"); // 1.5(frameRate: 30 の場合)

時刻ごとに tempo を変える場合は tempoAutomation が必須です。timeUnit"seconds" または "beats" を渡します。

import { TimeBeatFrame } from "time-beat-frame";

const tbf = new TimeBeatFrame({
  tempoAutomation: {
    timeUnit: "beats",
    points: [
      { time: 0, value: 120, interpolation: "hold" },
      { time: 4, value: 150, interpolation: "hold" },
    ],
  },
});

tbf.atTime(4).addBeat(1).toTime(); // 4秒地点から1拍進めた時間

About

秒・拍・フレーム数を相互変換するTypeScriptライブラリ

Resources

Stars

4 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages