Harmonie is a typescript library that solves music theory questions such as adding & subtracting intervals from a given note, calculating scales, chords and more... Harmonie is written without any third party libraries for minimal bundle size.
@davidfloegel/harmonie is serverd as an npm package.
Add Harmonie to your project by running
// with npm
npm add @davidfloegel/harmonie
// with yarn
yarn add @davidfloegel/harmonie
- Clean up & restructure test suite
- Add commitlint
- Publish to NPM
- Add JSDOC
- Add chords
- Add more scales
- Add key signatures
- Add transpose function
- Add compound intervals
// by name with default octave
const noteEb = new Note('Eb')
// change octave
const noteD5 = new Note('D', 5)const noteEb = new Note('Eb')
noteEb.letter // E
noteEb.accidentals // b
noteEb.octave // 4
noteEb.midiValue // 63Sometimes (mostly in classical music) you will come across notations such as Fb, B#. While this is technically correct, in most modern music an Fb would be written as E, B# as C etc. This is called the enharmonic equivalent. To get the enharmonic equivalent of a note you can use the easyNotation property.
const note = new Note(B#)
note.easyNotation // C// by quality and quantity
const P4 = new Interval('P', 4)
// from string
const M3 = Interval.fromString('M3')const interval = new Interval('m', 6)
interval.name // m6
interval.fullName // minor 6
interval.quality // m
interval.quantity // 6
interval.semitones // 8const interval = new Interval('M', 3)
const inversion = interval.invert()
inversion.name // 'm6'const root = new Note('E')
const interval = Interval.fromString('P5')
const target = root.addInterval(interval)
target.name // Bconst root = new Note('E')
const interval = Interval.fromString('P5')
const target = root.addInterval(interval)
target.name // Aconst noteA = new Note('D')
const noteB = new Note('B')
const interval = noteA.minusNote(noteB)
interval.name // M6