1.0.29 • Published 5 years ago

@torbimusic/core v1.0.29

Weekly downloads
-
License
ISC
Repository
-
Last release
5 years ago

Torbimusic Core

Mision

Provide a set of classes to solve many common needs for music theory programming.

Quick Start

Install

npm install -s @torbimusic/core

Use

import { Chord, Interval, Note, MajorScale, MinorScale } from '@torbimusic/core'

let note = Note.parse('C')
let chord = Chord.parse('Eb')
let interval = Interval.parse('2M')

let intervalFromCtoEb = note.intervalOf(chord.base.note) // 3m

intervalFromCtoEb.traspose(note) // Eb
interval.traspose(note) // F

chord.traspose(interval.add(intervalFromCtoEb))

let scaleC = MajorScale.from(note) // C Major

scaleC.triads // [C, Dm, Em, F, G, A, B°]

scaleC.traspose(interval) // D Major

Core Objects in the Library

As a summary, the most important objects to use are:

  • Interval.
  • Note.
  • Chord.
  • Scale.

Intervals

Represents the distance between two notes.

You can read this table as a summary of what an Interval is.

IntervalAliasesQualityGradesSemitonesNotes
1TPERFECT100
2mMINOR211
22MMAJOR221
2augAUGMENTED231
3m3mMINOR332
33MMAJOR342
4J4PERFECT453
4aug4+ 4#AUGMENTED463
5J5PERFECT574
5aug5+ 5#AUGMENTED584
6mMINOR685
6M6MAJOR695
6aug6+ 6#AUGMENTED6105
7dimDIMINISHED796
7mMINOR7106
7M7MAJOR7116
8PERFECT8127
9mMINOR9138
99MMAJOR9148
1111JPERFECT111710
11aug11+ 11#AUGMENTED111810
13mMINOR132012
1313MMAJOR132112

How to create an Interval

Use of for create an Interval from the distance between two notes.

let a = Note.parse('A')
let c = Note.parse('C')

Interval.of(a, c) // 3M

The intervals can be represented as a difference of grades and semitones.

To obtain an Interval from this two things, you must use fromGradesAndSemitones method.

let grades = 3
let semitones = 4
Interval.fromGradesAndSemitones(grades, semitones) // 3M

Another way to obtain an Interval is using parse and providing a string representation of the Interval, using the table writed above.

Interval.parse('3M') // 3M

Another utility methods for Intervals

Use the traspose just for traspose a note as the Interval value.

let note = Note.parse('C')
let interval = Interval.parse('3M')

interval.traspose(note) // 'E'

Use the add method to compose two Intervals.

let _2M = Interval.parse('2M')
let _2m = Interval.parse('2m')

_2M.add(_2m) // 3m

Note

Represent a musical Note.

How to create an Note

Use fromNote for create a Note from an American or SouthernEuropean note and a NoteAlteration.

Note.fromNote(AmericanNote.C, NoteAlteration.SHARP) // C#
Note.fromNote(SouthernEuropean.DO, NoteAlteration.SHARP) // C#

Use parse to create a Note from a string. Can be an American or SouthernEuropean notation.

Note.parse('C') // C
Note.parse('DO') // C

Utility methods in Note

Use enharmonicToNoteAbove and enharmonicToNoteBelow to get the enharmonics of a note:

Note.parse('C#').enharmonicToNoteAbove() // Db

Note.parse('Eb').enharmonicToNoteBelow() // D#

Use intervalOf to get the interval between the current note and the provided one:

let c = Note.parse('C')
let eb = Note.parse('Eb')

c.intervalOf(eb) // 3m
1.0.29

5 years ago

1.0.28

5 years ago

1.0.27

5 years ago

1.0.26

6 years ago

1.0.25

6 years ago

1.0.24

6 years ago

1.0.23

6 years ago

1.0.22

6 years ago

1.0.21

6 years ago