1.0.0 • Published 8 years ago

microtonal v1.0.0

Weekly downloads
1
License
MIT
Repository
github
Last release
8 years ago

microtonal

Build Status

The enterprise of “musical set theory” aspires to catalogue all the chords available to contemporary composers. Unfortunately, this project turns out to be more complicated than one might imagine

Microtonal is a micro (3kb) library to create music compositions

npm install microtonal

microtonal.name ⇒ string

Get the note name of a pitch

Kind: static constant of microtonal
Returns: string - the note name if any

ParamType
pitchnumber

microtonal.names ⇒ array.<string>

Get the note names of a musical object.

Kind: static constant of microtonal
Returns: array.<string> - the musical object note names

ParamType
listarray.<number>

Example

names([60, 61, 62]) => // ['C4', 'C#4', 'D4']

microtonal.scaleGen ⇒ function

Creates a scale generator. A scale generator is a function that returns an scale. An scale is a function that, given a degree number, it returns the scale note.

Kind: static constant of microtonal

ParamTypeDescription
intervalsarrthe scale intervals during an octave

Example

const major = scaleGen([0, 2, 4, 5, 7, 9, 11]);
const Cmajor = major(60)
Cmajor(0) // => 60
Cmajor(1) // => 62

microtonal.scales

A collection of named scales. It includes: chromatic, major, minor

Kind: static constant of microtonal

microtonal.pitch(source) ⇒ number

Creates a pitch. A pitch is a float number representing the height of the note. The pitch is the same as the midi number but with float precission.

Basicaly it tries to parse a float

Kind: static method of microtonal
Returns: number - the pitch

ParamType
sourcenumber | string

microtonal.midi(pitch) ⇒ integer

Get the midi value of a pitch. The midi value is the pitch without the float

Kind: static method of microtonal
Returns: integer - the midi number

ParamType
pitchnumber

microtonal.toFreq(pitch, tuning) ⇒ number

Convert a pitch into a frequency

Kind: static method of microtonal
Returns: number - the frequency

ParamTypeDefault
pitchnumber
tuningnumber440

microtonal.fromFreq(freq, tuning) ⇒ number

Convert a frequency into a pitch

Kind: static method of microtonal
Returns: number - the pitch

ParamTypeDefault
freqnumber
tuningnumber440

microtonal.tr(pitch, interval) ⇒ number

Transpose a pitch by an interval

Kind: static method of microtonal
Returns: number - the resulting pitch

ParamType
pitchnumber
intervalnumber

Example

tr(4, 3) => 7

microtonal.trBy(interval) ⇒ function

Creates a function that transposes a pitch by an interval

Kind: static method of microtonal
Returns: function - the transpose function

ParamType
intervalnumber

Example

[60, 61, 82].map(trBy(3));

microtonal.dist(from, to)

Finds the distance between two pitches

Kind: static method of microtonal

ParamType
fromnumber
tonumber

microtonal.distFrom(root) ⇒ function

Creates a function that finds a distance from a root

Kind: static method of microtonal
Returns: function - the distance function

ParamType
rootnumber

microtonal.inv(pitch, center) ⇒ number

Invert a pitch along a center

Kind: static method of microtonal
Returns: number - the inverted pitch

ParamType
pitchnumber
centernumber

microtonal.invFrom(center) ⇒ function

Creates a function that inverts a note from a center

Kind: static method of microtonal
Returns: function - the invert function

ParamType
centerpitch

microtonal.center(from, to) ⇒ number

Find the center between two pitches

Kind: static method of microtonal
Returns: number - center

ParamType
fromnumber
tonumber

microtonal.pc(pitch) ⇒ number

Get the pitch class of a pitch

Kind: static method of microtonal
Returns: number - the pitch class number (0 = C, 1 = D, ... 6 = B with numbers in-between)

ParamType
pitchnumber

microtonal.pctr(pitchClass, interval) ⇒ number

Transpose a pitch class

Kind: static method of microtonal
Returns: number - the pitch class of the transposition

ParamType
pitchClassnumber
intervalnumber

microtonal.pcdist(fromPitchClass, toPitchClass) ⇒ number

Find the distance between pitch classes

Kind: static method of microtonal
Returns: number - the distance (less or equal to 12)

ParamType
fromPitchClassnumber
toPitchClassnumber

microtonal.pcinv(pitchClass, center) ⇒ number

Invert a pitch class from a center

Kind: static method of microtonal
Returns: number - the pitch class

ParamType
pitchClassnumber
centernumber

microtonal.mu(pitches) ⇒ array.<number>

Create a musical object. A musical object is as an ordered series of pitches, uncategorized and uninterpreted.

Kind: static method of microtonal
Returns: array.<number> - the musical object

ParamType
pitchesarray.<number>

Example

mu('C D E') => [0, 2, 4]

microtonal.sort(mu, ascending) ⇒ array.<number>

Sort a musical object

Kind: static method of microtonal
Returns: array.<number> - the sorted musical object

ParamTypeDefault
muarray.<number>
ascendingbooleantrue

microtonal.uniq(mu) ⇒ array.<number>

Sort and remove duplicates from a musical object

Kind: static method of microtonal
Returns: array.<number> - a new musical object without the duplications

ParamType
muarray.<number>

microtonal.pitchset(pitches) ⇒ array.<number>

Create a pitch set: an unordered sets of pitches

Kind: static method of microtonal
Returns: array.<number> - the pitch set
See: Geometry of Music, p. 40

ParamType
pitchesarray.<number>

microtonal.pclist(mu) ⇒ array.<number>

Creates a pclist: an unordered collection of pitch class sets

Kind: static method of microtonal
Returns: array.<number> - a new multiset object with the pitch classes

ParamTypeDescription
muarray.<number>the musical object

microtonal.pcset(mu) ⇒ array.<number>

Creates a pitch class set: an ordered set of pitch classes

Kind: static method of microtonal
Returns: array.<number> - a new pitch set array with the pitch classes

ParamTypeDescription
muarray.<number>the musical object

microtonal.chromatic(tonic) ⇒ function

Creates a chromatic scale.

Kind: static method of microtonal
Returns: function - the scale

ParamType
tonicnumber

microtonal.major(tonic) ⇒ function

Creates a major scale

Kind: static method of microtonal
Returns: function - the scale

ParamType
tonicnumber

microtonal.minor(tonic) ⇒ function

Creates a minor scale

Kind: static method of microtonal
Returns: function - the scale

ParamType
tonicnumber

microtonal.pentatonic(tonic) ⇒ function

Creates a minor scale

Kind: static method of microtonal
Returns: function - the scale

ParamType
tonicnumber

microtonal.degrees(scale, elements)

Generate a number of degrees of a given scale

Kind: static method of microtonal

ParamType
scalefunction
elementsnumber

Example

const scale = degrees(major(60));
scale(8) // => [60, 62, 64, 65, 67, 69, 71, 72]
scale(-8) // =>