@tonaljs/pitch-interval
v6.0.0
Published
Parse intervals in shorthand notation
Downloads
14,527
Maintainers
Readme
@tonaljs/pitch-interval
Pitch interval support
Usage
⚠️ It's probably you don't need to use this package directly. Use tonal-interval instead.
import { parse, toName } from "@tonaljs/pitch-interval";
parse("4P").semitones; // => 5
API
interval(name: string) => Interval
Given an interval name, ite returns an object with the following properties:
- name: the interval name
- type: perfectable | majorable
- dir: direction: 1 | -1
- num: the interval number
- q: quality (...| 'dd' | 'd' | 'm' | 'M' | 'A' | ...)
- alt: the quality number as a number
- oct: the number of octaves it spans
- semitones: the number of semitones it spans
- simple: the simplified number
Example:
interval("4d");
// =>
// {
// name: "4d",
// type: "perfectable",
// dir: 1,
// num: 4,
// q: "d",
// alt: -1,
// chroma: 4,
// oct: 0,
// semitones: 4,
// simple: 4,
// }
This function always returns an object:
interval("hello"); // => { empty: true, name: "" }