Time and Rhythm
Time duration
Functions to parse and manipulate time duration values
import { DurationValue } from "tonal";
DurationValue.get("quarter").value; // => 0.25Properties
DurationValue.get
get(name: string) => DurationValue
Get a duration value object from name:
DurationValue.get("quarter"); // =>
// {
// empty: false,
// name: 'quarter',
// value: 0.25,
// fraction: [ 1, 4 ],
// shorthand: 'q',
// dots: '',
// names: [ 'quarter', 'crotchet' ]
// }The name accepts an arbitrary number of dots:
DurationValue.get("quarter.."); // =>
// {
// empty: false,
// name: 'quarter..',
// value: 0.4375,
// fraction: [ 7, 16 ],
// shorthand: 'q',
// dots: '..',
// names: [ 'quarter', 'crotchet' ]
// }Short names are accepted:
DurationValue.get("q").value; // => 0.25
DurationValue.get("q.").value; // => 0.375
DurationValue.get("q..").value; // => 0.4375Some aliases (value and fraction) are provided:
DurationValue.value("q.."); // => 0.4375
DurationValue.fraction("q.."); // => [ 7, 16 ]List durations
DurationValue.names
names() => string[]
Return all duration names
DurationValue.names(); // => ["large", "duplex longa", ...]DurationValue.shorthands
shorthands() => string[]
Return all duration value shorthands
DurationValue.shorthands(); // => ["dl", "l", "d", "w", "h", "q", "e", "s", "t", "sf", "h", "th"]