A set of utilities for working with musical notes, frequencies, and chords
npm install octavianOctavian is a little utility library for working with musical notes and their frequencies. Super cool, right?
First things, first: how do I install this thing?
``js`
npm install octavian
Maybe you even throw a --save in there if you feel like keeping it around.
So, we've got Octavian installed, how do we use it?
`js
var Octavian = require('octavian');
var note = new Octavian.Note('A4');
`
Or, if you're some kind of hipster…
`js
var Note = require('octavian').Note;
var note = new Note('A4');
`
A Note has a few properties that we can play around with.
`js
var note = new Note('A#4');
note.letter; // 'A'
note.modifier; // '#'
note.octave; // 4
note.signature; // 'A#4'
note.pianoKey; // 50
note.frequency; // 466.164
`
But, what if we toss in some bogus note? Something like E#, maybe? There is no E#, right?
`js
var note = new Note('E#5');
note.signature; // 'F5'
`
Music is all about intervals. We can move up by a semitone or some other interval.
`js
var note = new Note('C3');
note.majorThird(); // returns a new Note('E3');
note.perfectFifth(); // returns a new Note('G3');
note.perfectOctave(); // returns a new Note('C4');
`
You can do any of the following:
* downOctave()minorSecond()
* majorSecond()
* minorThird()
* majorThird()
* perfectFourth()
* diminishedFifth()
* perfectFifth()
* minorSixth()
* majorSixth()
* minorSeventh()
* majorSeventh()
* perfectOctave()
*
There are also some extra methods that are aliased, if you'd prefer:
* augmentedFourth()third()
* fifth()
*
You can create chords with Octavian.
`js
const cMajorChord = new Octavian.Chord('C4', 'major');
cMajorChord.notes; // returns [ { letter: 'C', modifier: null, octave: 4 },
// { letter: 'E', modifier: null, octave: 4 },
// { letter: 'G', modifier: null, octave: 4 } ]
cMajorChord.signatures; // returns [ 'C4', 'E4', 'G4' ]
cMajorChord.frequencies; // returns [ 261.626, 329.628, 391.995 ]
cMajorChord.pianoKeys; // returns [ 40, 44, 47 ]
`
You can create the following chords:
* majormajorSixth
* majorSeventh
* majorSeventhFlatFive
* majorSeventhSharpFive
* minor
* minorSixth
* minorSeventh
* minorMajor
* dominantSeventh
* diminished
* diminishedSeventh
* halfDimished
*
You're also more than welcome to use the following aliases for any of the above:
* maj is an alias for major6
* is an alias for majorSixthmaj6
* is an alias for majorSixth7
* is an alias for majorSeventhmaj7
* is an alias for majorSeventhmaj7b5
* is an alias for majorSeventhFlatFivemaj7#5
* is an alias for majorSeventhSharpFivemin
* is an alias for minorm
* is an alias for minormin6
* is an alias for minorSixthm6
* is an alias for minorSixthmin7
* is an alias for minorSeventhm7
* is an alias for minorSeventhm#7
* is an alias for minorMajormin#7
* is an alias for minorMajorm(maj7)
* is an alias for minorMajordom7
* is an alias for dominantSeventhdim
* is an alias for diminisheddim7
* is an alias for diminishedSeventhm7b5
* is an alias for halfDiminshed
#### Adding Notes to a Chord
You can add notes to a chord manually, if that suits you:
`js
const chord = new Octavian.Chord('C4');
chord.signatures; // returns ['C4']
chord.addInterval('majorThird');
chord.signatures; // returns ['C4', 'E4']
chord.addInterval(7);
chord.signatures; // returns ['C4', 'E4', 'G4']
`
#### Turning a Note into a Chord
You can turn any note into the basis for a chord:
`js``
const note = new Octavian.Note('C4');
note.toChord(); // returns a new chord with only C4 in it.
note.toChord('major'); // returns a new chord with C4, E4, and G4 in it