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

6.0.0 • Public • Published

@tonaljs/pitch-note tonal npm version

Pitch note support

Usage

⚠️ It's probably you don't need to use this package directly. Use tonal-note instead.

import { note } from "@tonaljs/pitch-note";

note("c4"); // => { name: 'C4', oct: 4, ...}

API

note(name: string) => Note

Given a note name, it returns an object with the following properties:

  • name: the note name
  • pc: the pitch class name
  • letter: the note letter
  • step: the letter number (0..6)
  • acc: the note accidentals
  • alt: the accidental number (..., -1 = 'b', 0 = '', 1 = '#', ...)
  • oct: the octave (or null if not present)
  • chroma: the note chroma (0..11)
  • midi: the note midi or null if octave is not present
  • freq: the note frequency in Hertzes, or null if the octave is note present

Example:

note("ab4");
// =>
// {
//   name: "Ab4",
//   pc: "Ab",
//   letter: "A",
//   acc: "b",
//   step: 5,
//   alt: -1,
//   oct: 4,
//   chroma: 8,
//   midi: 68,
//   freq: 415.3046975799451,
// }

This function always returns an object:

note("hello"); // => { empty: true, name: "" }

Package Sidebar

Install

npm i @tonaljs/pitch-note

Weekly Downloads

938

Version

6.0.0

License

MIT

Unpacked Size

24.1 kB

Total Files

9

Last publish

Collaborators

  • danigb