@tonaljs/pitch-interval
TypeScript icon, indicating that this package has built-in type declarations

6.0.0 • Public • Published

@tonaljs/pitch-interval tonal npm version

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: "" }

Package Sidebar

Install

npm i @tonaljs/pitch-interval

Weekly Downloads

1,164

Version

6.0.0

License

MIT

Unpacked Size

30.9 kB

Total Files

9

Last publish

Collaborators

  • danigb