Repository
Current version released
3 years ago
Dependencies
std
pitch
pitch is a collection of tools for working with musical pitch. It is implemented in TypeScript for Deno.
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");