pitch
pitch is a collection of tools for working with musical pitch. It is implemented in TypeScript for Deno.
cent.ts
A Cent is a musical unit that equals 1/1200th of an octave.
centitone.ts
A centitone is a musical unit that equals 1/600th of an octave, which is equal to 2 cent.
diatonic.ts
A diatonic scale consists of seven of the twelve tones of the chromatic scale.
midi.ts
The MIDI standard associates numbers with the notes of the chromatic scale, for
example 69
for the pitch A4
.
mts.ts
The MIDI Tuning Standard (MTS) defines how MIDI numbers get converted to absolute frequencies. For example, A4 at 440 hz corresponds to MIDI number 69.
spn.ts
In Scientific Pitch Notation (SPN) a musical pitch is specified by combining a
musical note name (with accidental if needed) and a number identifying the
pitch’s octave. For example, A4
, C#4
, and Eb2
are valid pitches in SPN.
Such strings can be parsed with the parse
function:
import { parse } from "https://deno.land/x/pitch/spn.ts";
const { letter, accidental, octave } = parse("C#4");
console.assert(letter === "C");
console.assert(accidental === "#");
console.assert(octave === 4);
Given a Letter
, Accidental
, and octave number
, the stringify
function
generates an SPN string:
import { stringify } from "https://deno.land/x/pitch/spn.ts";
const spn = stringify({
letter: "C",
accidental: "#",
octave: 4,
});
console.assert(spn === "C#4");