Install @tonaljs/pitch
main@tonaljs/pitch package provides a notation-agnostic representation of pitch. It is primarily intended for developers who need to add support for new pitch notations to the Tonal ecosystem.repository·main·Indexed 26 days ago
https://github.com/tonaljs/tonalA functional music theory library for manipulating tonal elements such as notes, intervals, chords, scales, modes, and keys. It works with data abstractions rather than sound and includes modules for ABC notation conversion, chord detection, chord type management, duration values, and interval calculations.
@tonaljs/pitch package provides a notation-agnostic representation of pitch. It is primarily intended for developers who need to add support for new pitch notations to the Tonal ecosystem.The @tonaljs/pitch-note package provides support for parsing note names into detailed pitch objects.
⚠️ Note: It is recommended to use tonal-note instead of using this package directly unless you have a specific requirement for pitch-based note parsing.
import { note } from "@tonaljs/pitch-note";
note("c4"); // => { name: 'C4', oct: 4, ...}You can use @tonaljs/progression by importing it from the tonal package using ES6 modules or requiring it in Node.js.
// ES6
import { Progression } from "tonal";
// node
const { Progression } = require("tonal");To use the Greek modes dictionary, import the Mode object from tonal using ES6 or CommonJS syntax.
// ES6
import { Mode } from "tonal";
// node (CommonJS)
const { Mode } = require("tonal");You can use @tonaljs/rhythm-pattern either as part of the main tonal package or as a standalone module.
tonal packageIf you have the full tonal package installed, import RhythmPattern directly:
import { RhythmPattern } from "tonal";
// or
const { RhythmPattern } = require("tonal");If you want to reduce bundle size, import specific functions directly from the standalone package:
import { binary, euclid } from "@tonaljs/rhythm-pattern";import { binary, euclid } from "@tonaljs/rhythm-pattern";If you want to minimize your bundle size, you can install and import specific modules individually. Individual modules are prefixed with @tonaljs/. For example, to use note operations, install @tonaljs/note.
npm i @tonaljs/noteimport { transpose } from "@tonaljs/note";
transpose("A4", "P5");You can install the full tonal package via npm to get access to all music theory functions (notes, intervals, chords, scales, etc.).
npm install --save tonalTo install the complete tonal package containing all music theory modules, use npm:
npm install --save tonal@tonaljs/array package is deprecated. Users should migrate to the @tonaljs/collection package for collection-related functionality.You can use @tonaljs/duration-value as a standalone module or via the main tonal package.
Standalone module (ES6):
import DurationValue from "@tonaljs/duration-value";Via tonal package (ES6):
import { DurationValue } from "tonal";Via tonal package (Node.js/CommonJS):
const { DurationValue } = require("tonal");import DurationValue from "@tonaljs/duration-value";empty property of the object returned by note(). To check if two notes are enharmonics (the same pitch), compare their midi numbers or their height properties.To use the key functionality, import the Key object from the tonal package. This package allows you to retrieve scales and chords for major and minor keys.
// ES6
import { Key } from "tonal";
// Node.js
const { Key } = require("tonal");