Music Theory Toolkit
This is a toolkit for note/chord/set parsing, transposition, and enumeration.
Consider interfaces to be unstable - I'm not strictly following semver until this library hits v1.0.0, but the following might help guide adoption/usage until then:
Stable interfaces:
- Note (Class)
- Chord (Class)
Not yet implemented interfaces:
- Set (Class)
- Scale (Class)
Installation and Setup
In your node or JavaScript project using NPM ( run npm init
in a new directory, and follow the prompts ):
npm i music-theory-toolkit
Usage
Note
Object Usage
; // Generates a random note if not passed an arg,// calculates numeric, absolute numeric, and frequency values as properties; // Parses note, calculates all properties; // Transpose a number of half-steps (re-calculates all relevant values)parsedNote.transpose-12; // This class uses the builder pattern, so you can do some pretty crazy things; // => 130.8127826502993 (Hz)
Static Helpers
; // Generate an alpha note filtered to only the # value if there is an enharmonic// For example, if 'C#/Db' (or numeric 1) would have been the output, it will filter to 'C#'; // => 'C#' // Generate a numeric note between 0 and 11; // => 5 // Transpose a note to the 0-11 range, and adjust octave accordingly// If no octave is passed, it assumes octave 4 is the baseline; // => { numeric: 0, octave: 6 }
Chord
Object Usage
; ; // Not yet implemented - this throws an error
Static Helpers
; // Generate a random chord; // => 'C#Maj7'; // => 'C#/DbMaj'; // => 'C#/Dbø7' // Get a random chord quality object; // => { difficulty: 1, name: 'Major', symbol: 'Maj', structure: [0, 4, 7] }; // => { difficulty: 2, name: 'Augmented', symbol: '+', structure: [0, 4, 8] }
Testing and Development
Testing libraries: Mocha & Chai
npm test