Skip to content

Chord Support

Latest
Compare
Choose a tag to compare
@stevekinney stevekinney released this 23 Jul 18:54
· 16 commits to master since this release

You can create chords with Octavian. Check out the release on npm.

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:

  • major
  • majorSixth
  • 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 major
  • 6 is an alias for majorSixth
  • maj6 is an alias for majorSixth
  • 7 is an alias for majorSeventh
  • maj7 is an alias for majorSeventh
  • maj7b5 is an alias for majorSeventhFlatFive
  • maj7#5 is an alias for majorSeventhSharpFive
  • min is an alias for minor
  • m is an alias for minor
  • min6 is an alias for minorSixth
  • m6 is an alias for minorSixth
  • min7 is an alias for minorSeventh
  • m7 is an alias for minorSeventh
  • m#7 is an alias for minorMajor
  • min#7 is an alias for minorMajor
  • m(maj7) is an alias for minorMajor
  • dom7 is an alias for dominantSeventh
  • dim is an alias for diminished
  • dim7 is an alias for diminishedSeventh
  • m7b5 is an alias for halfDiminshed

Adding Notes to a Chord

You can add notes to a chord manually, if that suits you:

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:

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