A collection of functions manipulating an input
Methods
# (static) angle(triplet) → {Number}
Returns the angle created on the necklace for a given trichord.
If a
, b
, and c
, are vertices of a triangle (trichord) on a necklace. This function returns the angle abc
. That is, the angle node b has with a and c.
Name | Type | Description |
---|---|---|
triplet |
Array.<Number> | a triplet/trichord of 3 numbers (intervallic units) |
the angle in degrees
- Type
- Number
let edo = new EDO(12) // define a tuning system
edo.get.angle([0,3,6]) //returns 90
# (static) best_edo_from_cents(scale_in_cents, begin_edo, end_edo) → {Scale}
Given an array of scale degrees in cents, returns a Scale Object in the edo that best describes the pitches.
If a
, b
, and c
, are vertices of a triangle (trichord) on a necklace. This function returns the angle abc
. That is, the angle node b has with a and c.
Name | Type | Description |
---|---|---|
scale_in_cents |
Array.<Number> | The scale in question represented in cents |
begin_edo |
Number | The smallest EDO to consider |
end_edo |
Number | The largest EDO to consider |
A scale in the best fitting EDO
- Type
- Scale
let edo = new EDO() // define a tuning system
edo.get.best_edo_from_cents([0,200,350,500,700,900,1100])
//returns the Scale Object [0,4,7,10,14,18,22] in a 24EDO context
# (static) combinations(set, k) → {Array.<Array.<Number>>}
From a given set of pitches, returns every combination (order specific) of size k
(For a similar function where the order doesn't matter use EDO.get.n_choose_k())
Name | Type | Description |
---|---|---|
set |
Array.<Number> | The array from which to extract combinations |
k |
Number | The number of elements per set returned |
- Type
- Array.<Array.<Number>>
edo.get.combinations([1,3,5,7],2)
//returns
[[1,3],[3,1],[1,5],[5,1],[1,7],[7,1],[3,5],[5,3],[3,7],[7,3],[5,7],[7,5]]
# (static) complementary_interval(interval) → {Number}
Returns the complementary interval (needed to complete the octave) for a given an interval class.
Name | Type | Description |
---|---|---|
interval |
Number | Some interval class |
- Type
- Number
let edo = new EDO(12) // define a tuning system
edo.get.complementary_interval(3) //returns 9
# (static) complementary_set(from_0opt) → {Array.<Number>}
Returns all the pitch-classes of the EDO that the scale does not use.
Remark: "pitch-classes" conform to the current tuning system used. E.g., 0-11 in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
from_0 |
boolean |
<optional> |
false | when true, the output will be normalized to 0. |
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.complementary_set([0,2,4,5,7,9,11])
//returns [1, 3, 6, 8, 10]
edo.get.complementary_set([0,2,4,5,7,9,11],true)
//returns [0, 2, 5, 7, 9]
# (static) contour(pitches, localopt) → {Array.<Number>}
Returns a vector describing the contour of the given pitches.
If local is set to true, every cell in the vector will be
either 1 if note n is higher than n-1, 0 if note n is the same as n-1, and -1 if note n is lower than n-1
For instance [0,0,4,7,4,7,4,0]
will in local mode will return [0,1,1,-1,1,-1,-1]
If local is set to false (default), the contour of the line is expressed such that the actual pitch-class of the
note is removed but its relative position in regards to the entire line is kept.
[0,4,7,12,16,7,12,16]
(Bach prelude in C) has 5 distinct note heights, so it will return
[0,1,2,3, 4, 2,3, 4]
indicating the relative height of each note in the entire phrase
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pitches |
Array.<Number> | a given array of pitches |
||
local |
Boolean |
<optional> |
false | if set to false, function will only return subsets that have consecutive members |
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.contour([0,4,7,12,16,7,12,16])
//returns [0, 1, 2, 3, 4, 2, 3, 4]
let edo = new EDO(12) // define a tuning system
edo.get.contour([0,4,7,12,16,7,12,16],true)
//returns [1, 1, 1, 1,-1, 1, 1]
# (static) contour_motives(melody, allow_skipsopt, maximal_lengthopt) → {Array.<motives>}
Extracts every possible contour motive from a given melody.
The function extracts every contour subset appearing in the given melody. The function also keeps track of the number of times each motive appeared.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
melody |
Array.<Number> | a collection of pitches to find (in order) |
||
allow_skips |
Boolean |
<optional> |
false | if false, the search will only be done on consecutive items |
maximal_length |
Number |
<optional> |
8 | Do not look for motives longer than this value. |
- Type
- Array.<motives>
let edo = new EDO(12) // define a tuning system
edo.get.contour_motives([7,6,7,6,7,2,5,3,0]).slice(0,4) //get first 3 motives
//returns
[
{ motive: [ -1, 1 ], incidence: 2 }, //going a half-step down, then up appears twice
{ motive: [ -1 ], incidence: 2 }, //going a half-step down appears twice
{ motive: [ 1 ], incidence: 2 } //going a half-step up appears twice
]
# (static) coordinates(pitch, circle_centeropt, ropt) → {Array.<Array.<Number, Number>>}
Returns the [x,y] coordinates of the nodes of the given pitches. pitch
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pitch |
Array.<Number> | Number | A pitch, or an array of pitches |
||
circle_center |
Array.<Number> |
<optional> |
[0,0] | The center of the circle |
r |
Number |
<optional> |
0.56418958354776 | The radius of the circle. By default the radius is of a circle with area=1 |
An array with tuples each corresponding to the x,y position of every pitch
- Type
- Array.<Array.<Number, Number>>
let edo = new EDO(12) //define context
edo.get.coordinates([0,3,7]) //minor triad
//returns
[
[0,0.56418958354776],
[0.56418958354776,3.454664838020213e-17],
[-0.2820947917738801,-0.48860251190292314]
]
# (static) evenly_split(n) → {Array.<Number>}
Returns N step constituents such that they minimize the size between the smallest and largest constituents
Name | Type | Description |
---|---|---|
n |
Number | The numbers of desired steps |
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.evenly_split(5) //returns [ 2, 2, 2, 3, 3 ]
edo.get.evenly_split(6) //returns [ 2, 2, 2, 2, 2, 2 ]
edo.get.evenly_split(7) //returns [ 1, 1, 2, 2, 2, 2, 2 ]
edo.get.evenly_split(8) //returns [ 1, 1, 1, 1, 2, 2, 2, 2 ]
# (static) fill_partial_harp_pedaling(qualities, harp_defaultopt, scordaturaopt) → {Array.<Number>}
Fills in the missing pedals to the output of EDO.get.harp_position_of_quality().
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
qualities |
Array.<Object> | The output of @link EDO#get.harp_position_of_quality |
||
harp_default |
Array.<Number> |
<optional> |
[-1,-1,-1,-1,-1,-1,-1] | The default configuration of the pedals |
scordatura |
Array.<Number> |
<optional> |
[0,2,4,5,7,9,11] | The tuning of the strings when all pedals are not flattened nor sharpened. |
- Type
- Array.<Number>
# (static) generated_scale(generatoropt, cardinalityopt) → {Array.<Number>}
Returns a generated scale generated by a given generator, with a given cardinality.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
generator |
Number |
<optional> |
7 | The generator |
cardinality |
Number |
<optional> |
7 | The cardinality (number of pitches) |
- See:
-
- Balzano, G. J. (1980). "The group-theoretic description of 12-fold and microtonal pitch systems." Computer music journal 4(4): 66-84.
- Carey, N. (2007). "Coherence and sameness in well-formed and pairwise well-formed scales." Journal of Mathematics and Music 1(2): 79-98.
- Carey, N. and D. Clampitt (1989). "Aspects of well-formed scales." Music Theory Spectrum 11(2): 187-206.
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.generated_scale(7,5) // returns [0,2,4,7,9]
# (static) generators(with_complement_intervalopt) → {Array.<Number>}
Returns every IC that by iteratively adding it to 0, produces all of the pitches of the tuning space.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
with_complement_interval |
Boolean |
<optional> |
false | When true the complementary intervals will be included (e.g. in 12EDO IC>6) |
- See:
-
- Balzano, G. J. (1980). "The group-theoretic description of 12-fold and microtonal pitch systems." Computer music journal 4(4): 66-84.
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.generators()
//returns [1,5]
edo.get.generators(true)
//returns [[1,11],[5,7]]
# (static) harmonic_progression(allowed_qualities, starting_chord, num_of_chordsopt, common_notes_minopt) → {Array.<Array.<Number>>}
Returns a chord progression of length num_of_chords
using only allowed_qualities
, with at least common_notes_min
notes in common between every chord.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
allowed_qualities |
Array.<Array.<Number>> | A list of allowed chord qualities (regardless of transposition) |
||
starting_chord |
Array.<Number> | The first chord in the progression (using exact pitches and voicing) |
||
num_of_chords |
Number |
<optional> |
4 | The number of chords the final progression shuold include. |
common_notes_min |
Number |
<optional> |
2 | The minimal number of notes in common between every two succeeding chords in the progression. |
- Type
- Array.<Array.<Number>>
let edo = new EDO(12) // define a tuning system
edo.get.harmonic_progression([[0,3,7],[0,4,7]],[1,4,7])
//returns e.g. [ [ 1, 4, 7 ], [ 11, 4, 7 ], [ 11, 2, 7 ], [ 10, 2, 7 ] ]
# (static) harmonized_melody(melody, allowed_qualities, starting_chord, common_notes_minopt) → {Array.<Array.<Number>>}
Returns a chord progression to harmonize a given melodies with given possible chord qualities.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
melody |
Array.<Number> | The melody |
||
allowed_qualities |
Array.<Array.<Number>> | A list of allowed chord qualities (regardless of transposition) |
||
starting_chord |
Array.<Number> | The first chord in the progression (using exact pitches and voicing) |
||
common_notes_min |
Number |
<optional> |
1 | The minimal number of notes in common between every two succeeding chords in the progression. |
- Type
- Array.<Array.<Number>>
let edo = new EDO(12) // define a tuning system
edo.get.harmonized_melody([7,4,5,2,4,0,2],[[0,4,7],[0,3,7]])
//returns e.g.
[
[ 4, 7, 11 ],
[ 4, 9, 0 ],
[ 5, 9, 2 ],
[ 7, 11, 2 ],
[ 7, 0, 4 ],
[ 9, 0, 4 ],
[ 9, 2, 5 ]
]
# (static) harp_pedals_to_pitches(pedals, scordaturaopt) → {Array.<Number>}
Returns the pitches produced given a list of harp pedal transpositions (in ascending order, not harp pedal order).
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pedals |
Array.<Number> | The configuration / transposition set be each pedal (e.g. [-1,0,0,0,1,0,0]) for Cb and G# in 12EDO |
||
scordatura |
Array.<Number> |
<optional> |
[0,2,4,5,7,9,11] | The tuning of the strings |
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.harp_pedals_to_pitches([0,0,0,0,0,1,-1]) 6th string sharpened, 7th string flattened
//returns
[0, 2, 4, 5, 7, 10, 10]
# (static) harp_position_of_quality(quality, scordaturaopt, pedal_shiftopt) → {Array.<Object>}
Returns all of the possible ways to achieve a certain chord quality on a harp.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
quality |
Array.<Number> | The desired chord quality |
||
scordatura |
Array.<Number> |
<optional> |
[0,2,4,5,7,9,11] | The tuning of the strings |
pedal_shift |
Array.<Number> |
<optional> |
[-1,0,1] | The possible configurations of every pedal (how much does a configuration raise/lower the pitch) |
- Type
- Array.<Object>
let edo = new EDO(12) // define a tuning system
edo.get.harp_position_of_quality([0,1,2,3]) //find all possible chromatic tetrachord on a harp
//returns
[
{
strings: [ 6, 1, 7, 2 ], //the strings to be plucked
pedals: [ 1, -1, 1, -1 ], //the pedals corresponding to the aforementioned strings
pitches: [ 10, 11, 0, 1 ] //the resultant pitches
},
{
strings: [ 5, 6, 7, 1 ],
pedals: [ 1, 0, -1, -1 ],
pitches: [ 8, 9, 10, 11 ]
},
{
strings: [ 3, 4, 5, 6 ],
pedals: [ 1, 1, 0, -1 ],
pitches: [ 5, 6, 7, 8 ]
},
{
strings: [ 2, 3, 4, 5 ],
pedals: [ 1, 0, 0, -1 ],
pitches: [ 3, 4, 5, 6 ]
},
{
strings: [ 2, 4, 3, 5 ],
pedals: [ 1, -1, 1, -1 ],
pitches: [ 3, 4, 5, 6 ]
},
{
strings: [ 6, 7, 1, 2 ],
pedals: [ 1, 0, 0, -1 ],
pitches: [ 10, 11, 0, 1 ]
},
{
strings: [ 1, 2, 3, 4 ],
pedals: [ 1, 0, -1, -1 ],
pitches: [ 1, 2, 3, 4 ]
},
{
strings: [ 7, 1, 2, 3 ],
pedals: [ 1, 1, 0, -1 ],
pitches: [ 0, 1, 2, 3 ]
}
]
# (static) intersection(…collections) → {Array.<Number>}
Returns the elements that are found in all given sets
Name | Type | Attributes | Description |
---|---|---|---|
collections |
Array.<Number> |
<repeatable> |
Any number of arrays containing pitches |
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.intersection([1,2,3,4],[3,4,5,6])
//returns [3,4]
edo.get.intersection([1,2,3,4],[3,4,5,6],[2,4])
//returns [4]
# (static) interval_stack(intervals, stack_sizeopt, as_pitchesopt) → {Array.<Number>}
Makes every stacking combination of intervals from 'intervals' up to 'height' stack_size.
For instance, given the intervals = [2,3]
and stack_size = 3
, the function will return a list of lists
such that every list will be of length = 3
(stack_size
) containing an exhaustive list of every
combination using the intervals 2 and 3 (in this case).
As such, it will return [[2, 2, 2], [2, 2, 3], [2, 3, 2], [3, 2, 2], [2, 3, 3], [3, 2, 3],
[3, 3, 2], [3, 3, 3]]
which represents every combination or 2s and 3s in any order of length 3.
if as_pitches = true
, instead of returning the list of intervals classes of length 3, it
will return a list of pitches starting from 0 (which can go above 11). If set to true the function
will return [[0, 2, 4, 6], [0, 2, 4, 7], [0, 2, 5, 7], [0, 3, 5, 7], [0, 2, 5, 8], [0, 3, 5, 8],
[0, 3, 6, 8], [0, 3, 6, 9]]
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
intervals |
Array.<Number> | the intervals be used |
||
stack_size |
Number |
<optional> |
3 | the size of the stack of pitches. |
as_pitches |
Boolean |
<optional> |
false | Indicates whether the returned result represents interval classes or pitches |
a list of interval classes or pitches
- Type
- Array.<Number>
let edo = new EDO(12) // create a tuning context
edo.get.interval_stack([3,2],3)
//returns
[
[ 2, 2, 2 ],
[ 3, 2, 2 ],
[ 2, 3, 2 ],
[ 2, 2, 3 ],
[ 3, 3, 2 ],
[ 3, 2, 3 ],
[ 2, 3, 3 ],
[ 3, 3, 3 ]
]
edo.get.interval_stack([3,2],3,true)
//returns
[
[ 0, 2, 4, 6 ],
[ 0, 3, 5, 7 ],
[ 0, 2, 5, 7 ],
[ 0, 2, 4, 7 ],
[ 0, 3, 6, 8 ],
[ 0, 3, 5, 8 ],
[ 0, 2, 5, 8 ],
[ 0, 3, 6, 9 ]
]
# (static) interval_traversed(intervals) → {Number}
Gets a melody represented as intervals, and returns the interval traversed by the end.
Name | Type | Description |
---|---|---|
intervals |
Array.<Number> | Melody represented in intervals |
the interval traversed by the melody
- Type
- Number
let edo = new EDO(12) // define a tuning system
edo.get.interval_traversed([2,-3,4,-1])
//returns 2 (moving up 2, then down 3, then up 4, then down 1 will get you +2 above where you started)
# (static) inversion(scale, cache) → {Array.<Number>}
Returns the inversion of a given set of pitches
Name | Type | Description |
---|---|---|
scale |
Array.<Number> | a collection of pitches (not necessarily pitch-classes) |
cache |
Boolean | if true, the result will be cached for faster retrieval |
The inverted input
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.inversion([0,2,4,5,7,9,11]) //univertable collection
//returns [0, 2, 4, 6, 7, 9, 11]
# (static) lattice(horopt, veropt, as_notesopt)
Returns a lattice from the pitches in the scale
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
hor |
Number |
<optional> |
3 | the gap between numbers horizontally |
ver |
Number |
<optional> |
4 | the gap between numbers vertically |
as_notes |
Boolean |
<optional> |
false |
let edo = new EDO(12) //define tuning
edo.get.lattice()
//returns
//0 3 6 9 0 3 6 9 0 3 6 9
//
//8 11 2 5 8 11 2 5 8 11 2 5
//
//4 7 10 1 4 7 10 1 4 7 10 1
//
//0 3 6 9 0 3 6 9 0 3 6 9
//
//8 11 2 5 8 11 2 5 8 11 2 5
//
//4 7 10 1 4 7 10 1 4 7 10 1
//
//0 3 6 9 0 3 6 9 0 3 6 9
# (static) levenshtein(collection1, collection1, ratio_calcopt) → {Number}
Returns the Levenshtein distance from one collection of pitches to another
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
collection1 |
Array.<Number> | A collection of pitches |
||
collection1 |
Array.<Number> | Another collection of pitches |
||
ratio_calc |
Boolean |
<optional> |
false | When true, the function computes the levenshtein distance ratio of similarity between two collections |
- Type
- Number
let edo = new EDO(12) //define tuning
edo.get.levenshtein([0,2,4,7,9],[0,2,4,5,7,9,11]) //returns 2
edo.get.levenshtein([0,2,4,7,9],[0,2,4,5,7,9,11],true) //returns 0.9230769230769231
# (static) maximal_carey_coherence_failures(N) → {Number}
Returns the Maximal number of coherence failures as described in the paper by Carey (see citation) This agrees with Balzano coherency and Rothenberg Propriety, but provides a continues measure rather than a discrete one.
Name | Type | Description |
---|---|---|
N |
Number | The cardinality of the scale (how many pitches it has) |
- See:
-
- Carey, N. (2007). "Coherence and sameness in well-formed and pairwise well-formed scales." Journal of Mathematics and Music 1(2): 79-98.
- Rahn, J. (1991). "Coordination of interval sizes in seven-tone collections." Journal of Music Theory 35(1/2): 33-60.
- Type
- Number
let edo = new EDO() // create a tuning context
edo.get.maximal_carey_coherence_failures(7) * //returns 140
# (static) maximal_rahn_difference(N) → {Number}
Returns the Maximal number of differences for a a scale of cardinality N
Name | Type | Description |
---|---|---|
N |
Number | The cardinality of the scale (how many pitches it has) |
- See:
-
- Rahn, J. (1991). "Coordination of interval sizes in seven-tone collections." Journal of Music Theory 35(1/2): 33-60.
- Carey, N. (2007). "Coherence and sameness in well-formed and pairwise well-formed scales." Journal of Mathematics and Music 1(2): 79-98.
- Type
- Number
let edo = new EDO() // create a tuning context
edo.get.maximal_rahn_difference(7) //maximal rahn difference for a scale of length 7
//returns 126
# (static) minimal_voice_leading(chord1, chord2) → {Array.<Number>}
Returns the disposition of chord2
that minimizes movement from chord1
.
Note: chord1
and chord2
must have the same number of pitches
Name | Type | Description |
---|---|---|
chord1 |
Array.<Number> | an origin chord in some disposition |
chord2 |
Array.<Number> | an destination chord |
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.minimal_voice_leading([7,0,3],[4,8,11])
//returns [8,11,4]
# (static) mixture_in_cardinality(cardinality) → {Array.<Array.<Number>>}
Returns all the possible scale combinations within a certain cardinality where each scale-degree option has no gaps.
Name | Type | Description |
---|---|---|
cardinality |
Number | The cardinality of the desired mixture |
- See:
- Type
- Array.<Array.<Number>>
# (static) modes(scale, cache) → {Array.<Array.<Number>>}
Returns the normal order of a given set of pitches
Remark: "intervallic units" conform to the current tuning system used. E.g., 0-11 in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Description |
---|---|---|
scale |
Array.<Number> | a collection of pitch-classes |
cache |
Boolean | if true, the result will be cached for faster retrieval |
- Type
- Array.<Array.<Number>>
let edo = new EDO(12) // create a tuning context
edo.get.modes([0,2,4,5,7,9,11]) //Major scale
//returns
[
[0,2,4,5,7,9,11], //Ionian
[0,2,3,5,7,9,10], //Dorian
[0,1,3,5,7,8,10], //Phrigian
[0,2,4,6,7,9,11], //Lydian
[0,2,4,5,7,9,10], //Mixolydian
[0,2,3,5,7,8,10], //Aeolian
[0,1,3,5,6,8,10] //Locrian
]
# (static) motives(melody, intervallicopt, allow_skipsopt, maximal_lengthopt) → {Array.<motives>}
Extracts every possible "motive" from a given melody.
A motive can be intervalic (default) such that it looks at the intervallic units rather than the pitch classes. The function also keeps track of the number of times each motive appeared.
Remark: "intervals" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
melody |
Array.<Number> | a collection of pitches to find (in order) |
||
intervallic |
Boolean |
<optional> |
true | looks at the intervals rather than the pitch classes. |
allow_skips |
Boolean |
<optional> |
true | if false, the search will only be done on consecutive items |
maximal_length |
Number |
<optional> |
8 | Do not look for motives longer than this value |
- Type
- Array.<motives>
let edo = new EDO(12) // define a tuning system
edo.get.motives([7,6,7,6,7,2,5,3,0]).slice(0,4) //get first 3 motives
//returns
[
{ motive: [ -1, 1 ], incidence: 2 }, //going a half-step down, then up appears twice
{ motive: [ -1 ], incidence: 2 }, //going a half-step down appears twice
{ motive: [ 1 ], incidence: 2 } //going a half-step up appears twice
]
# (static) n_choose_k(arr, k) → {Array.<Number>}
Returns all combinations of size k from an array.
Name | Type | Default | Description |
---|---|---|---|
arr |
Array | An array with elements |
|
k |
Number | 2 | The number of elements in each returned permutation |
- Type
- Array.<Number>
edo.get.n_choose_k([1,3,5,7],k=3)
//returns [ [ 1, 3, 5 ], [ 1, 3, 7 ], [ 1, 5, 7 ], [ 3, 5, 7 ] ]
# (static) necklace(lst) → {Array.<Array.<Number>>}
Returns all necklaces from a given set of steps
Remark: "intervals" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Description |
---|---|---|
lst |
Array.<Number> | a set of intervals |
Necklaces
- Type
- Array.<Array.<Number>>
let edo = new EDO(12)
edo.get.necklace([2,2,1,2,2,2,1])
//returns
[ //These are the 3 unique orderings of the intervals in the input
[2, 2, 2, 1, 2, 2, 1], //any other combination would be some rotation of
[2, 2, 2, 2, 1, 2, 1], //one of these
[2, 2, 2, 2, 2, 1, 1]
]
# (static) new_pitches(melody, as_PC) → {Array.<Array.<Number>>}
Returns the pitch and its position where it first appeared in a melody
Name | Type | Description |
---|---|---|
melody |
Array.<Number> | a melody to be analyzed |
as_PC |
Boolean | when true, the algorithm views all notes as similar if they belong to the same PC |
a "tuple" of [pitch,position]
- Type
- Array.<Array.<Number>>
let edo = new EDO(12)
edo.get.new_pitches([2,1,0,5,4,3,0,2,8,4,1,0,9,1])
//returns
[
[2, 0],
[1, 1],
[0, 2],
[5, 3],
[4, 4],
[3, 5],
[8, 8],
[9, 12],
]
# (static) ngrams(melody, nopt) → {Array.<Object>}
Returns all the ngrams up to a given n from a given melody.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
melody |
Array.<Number> | a melody to be analyzed |
||
n |
Number |
<optional> |
3 | The maximal length ngram to be generated |
A dictionary that given an ngram key, returns the prediction.
- Type
- Array.<Object>
let edo = new EDO(12) //Create a tuning context
edo.get.ngrams([4,4,5,7,7,5,4,2,0,0,2,4,4,2,2])
//returns
{
'0': [ 0, 2 ],
'2': [ 0, 4, 2 ],
'4': [ 4, 5, 2, 4, 2 ],
'5': [ 7, 4 ],
'7': [ 7, 5 ],
'4 4': [ 5, 2 ],
'4 5': [ 7 ],
'5 7': [ 7 ],
'7 7': [ 5 ],
'7 5': [ 4 ],
'5 4': [ 2 ],
'4 2': [ 0, 2 ],
'2 0': [ 0 ],
'0 0': [ 2 ],
'0 2': [ 4 ],
'2 4': [ 4 ]
}
# (static) normal_order(lst, cache) → {Array.<Number>}
Returns the normal order of a given set of pitches
Remark: "pitch classes" conform to the current tuning system used. E.g., 0-11 in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Description |
---|---|---|
lst |
Array.<Number> | a collection of pitch-classes |
cache |
Boolean | if true, the result will be cached for faster retrival |
The normal order of the input
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
edo.get.normal_order([0,2,4,5,7,9,11])
//returns [ 0, 1, 3, 5, 6, 8, 10 ]
# (static) notes_from_cents(cents) → {Array.<Object>}
Returns the closest approximation within the current EDO from a list of pitches in cents and the difference between the EDO version to the original in cents.
Name | Type | Description |
---|---|---|
cents |
Array.<Number> | A list of pitches as cents |
- Type
- Array.<Object>
edo.get.notes_from_cents([0,157,325,498,655,834,1027])
//returns
[
{ note: 0, diff: 0 },
{ note: 2, diff: 43 },
{ note: 3, diff: -25 },
{ note: 5, diff: 2 },
{ note: 7, diff: 45 },
{ note: 8, diff: -34 },
{ note: 10, diff: -27 }
]
# (static) partitioned_subsets(arr) → {Array.<Array.<Number>>}
Gets an array with element-wise possibilities, and returns every subset given these possibilities
For instance, given [4,[7,8],[9,10,11]]
the function will return every set starting with 4, with EITHER 7 or 8 in the 2nd position, and EITHER 9, 10, or 11 in the 3rd.
Name | Type | Description |
---|---|---|
arr |
Array.<Number> | element-wise possibilities |
- Type
- Array.<Array.<Number>>
edo.get.partitioned_subsets([4,[7,8],[10,11]])
//returns
[ [ 4, 7, 10 ], [ 4, 7, 11 ], [ 4, 8, 10 ], [ 4, 8, 11 ] ]
# (static) path_n_steps(destination, motives, n_steps) → {Array.<Array.<Number>>}
Returns all the ways to reach a destination pitch by providing a set of motives and a number of steps
Name | Type | Description |
---|---|---|
destination |
Number | the destination note. This is an int that represents some interval away from 0. |
motives |
Array.<Array.<Number>> | a list of motives to be used |
n_steps |
Number | The exact number of pitches needed |
An array of all the ways possible.
- Type
- Array.<Array.<Number>>
// returns [3,3,-3]
get.path_n_steps(3,[[3],[-3]],3)
# (static) path_on_tree(intervals, path, starting_pitchopt) → {Array.<Number>}
Returns the path taken (as pitches) after climbing up a interval "fractal" tree.
In an interval tree where each branch adds (or subtracts) an interval recursively.
For instance, such a tree could have 2 interval branches. One "on the left" adding -3 to the current
pitch, and the one "on the right" adding +2 to the current pitch.
If you climbed this tree using some path, for instance "left, left, right, left, right, right", you
will in essence move [-3, -3, +2, -3, +2, +2]
such that if you start with pitch class 0 you get:
[0, -3, -6, -4, -7, -5, -3]
which if we ignore octave (i.e. indicate pitch classes) we get: [0, 9, 6, 8, 5, 7, 9]
.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
intervals |
Array.<Number> | the "branches" coming out of each node on the tree. For instance, |
||
path |
Array.<Number> | the indication of how to traverse the tree. The list contains the indexes of
the branch to be climbed at each iteration. so |
||
starting_pitch |
Number |
<optional> |
0 | Indicates the starting pitch of the tree (the pitch to be added to rather than starting at 0). |
the path
- Type
- Array.<Number>
# (static) permutations(pitches) → {Array.<Array.<Number>>}
Gets an array and returns every possible ordering of that array.
Name | Type | Description |
---|---|---|
pitches |
Array.<Number> | (usually) a collection of pitches, but could be used with any type of array |
- Type
- Array.<Array.<Number>>
edo.get.permutations([0, 2, 3])
// [[ 0, 2, 3 ],[ 0, 3, 2 ],[ 2, 0, 3 ],[ 2, 3, 0 ],[ 3, 0, 2 ],[ 3, 2, 0 ]]
# (static) pitch_distribution(pitches, as_PC) → {Array.<distribution>}
Returns the distribution (as fractions adding up to 1) of the pitches in a set of pitches
Name | Type | Description |
---|---|---|
pitches |
Array.<Number> | a given array of pitches |
as_PC |
Boolean | When true, the distribution tallies notes based on their pitch-class rather than their absolute pitch. |
- Type
- Array.<distribution>
let edo = new EDO(12) // create a tuning context
edo.get.pitch_distribution([8,7,7,8,7,7,8,7,7,15,15,14,12,12,10,8,8,7,5,5]) //Mozart Sym. 40
//returns
[
{ note: 7, rate: 0.35 },
{ note: 8, rate: 0.25 },
{ note: 15, rate: 0.1 },
{ note: 12, rate: 0.1 },
{ note: 5, rate: 0.1 },
{ note: 14, rate: 0.05 },
{ note: 10, rate: 0.05 }
]
edo.get.pitch_distribution([0,12,0,12,7,0])
//returns
[
{"note": 0,"rate": 0.5},
{"note": 12,"rate": 0.3333333333333333},
{"note": 7,"rate": 0.16666666666666666}
]
# (static) pitch_fields(pitches, sizeopt, as_PCopt, uniqueopt, avoid_duplicate_windowsopt) → {Array.<Array.<Number>>}
Returns all the pitches available in windows of size size
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pitches |
Array.<Number> | a given array of pitches |
||
size |
Number |
<optional> |
8 | The size of the window. |
as_PC |
Boolean |
<optional> |
true | When true, notes that belong to the same pitch-class will be counted as the same. |
unique |
Boolean |
<optional> |
false | When true, the function does not count pitches if they are already in the window. |
avoid_duplicate_windows |
Boolean |
<optional> |
false | When true, if two or more succeeding windows have the same content, the function will only return one of them. |
- Type
- Array.<Array.<Number>>
let edo = new EDO(12) // create a tuning context
edo.get.pitch_fields([8,7,7,8,7,7,8,7,7,15,15,14,12,12,10,8,8,7,5,5]) //Mozart Sym. 40
[
[ 7, 8 ],
[ 7, 8 ],
[ 3, 7, 8 ],
[ 3, 7, 8 ],
[ 2, 3, 7, 8 ],
[ 0, 2, 3, 7, 8 ],
[ 0, 2, 3, 7, 8 ],
[ 0, 2, 3, 7, 10 ],
[ 0, 2, 3, 7, 8, 10 ],
[ 0, 2, 3, 8, 10 ],
[ 0, 2, 3, 7, 8, 10 ],
[ 0, 2, 5, 7, 8, 10 ],
[ 0, 5, 7, 8, 10 ]
]
edo.get.pitch_fields([8,7,7,8,7,7,8,7,7,15,15,14,12,12,10,8,8,7,5,5],5,false,true,true) //as_PC=false, unique=true,avoid_duplicate_windows=true
[
[ 7, 8, 12, 14, 15 ],
[ 7, 10, 12, 14, 15 ],
[ 8, 10, 12, 14, 15 ],
[ 7, 8, 10, 12, 14 ],
[ 5, 7, 8, 10, 12 ],
[ 5, 7, 8, 10 ]
]
# (static) random_melody(lengthopt, rangeopt, repetition_minimal_gapopt, modeopt, avoid_leaps_overopt) → {Array.<Number>}
Returns an array of (length) (pseudo)random pitches, with lowest note not lower than range[0], and highest note not higher than range[1].
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
length |
Number |
<optional> |
8 | The number of pitches in the melody |
range |
Array.<number> |
<optional> |
[0, 12] | the lower and upper limits (inclusive) for the melody |
repetition_minimal_gap |
Number |
<optional> |
0 | number of intervening notes before a note can repeat (the same pitch-class across different octave is not considered the same note) |
mode |
Array.<number> |
<optional> |
If mode is provided, the pitches returned will be only ones that appear in the mode provided. |
|
avoid_leaps_over |
Number |
<optional> |
5 | The generator will attempt to avoid returning melodies that leap beyond the this IC. |
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
edo.get.random_melody(4,[-3,2]) //returns e.g. [ -3, 0, 2, -2 ]
edo.get.random_melody(4, [-3, 2],1) //returns e.g. [ 1, -3, 2, -3 ]
edo.get.random_melody(6, [0, 17], 6,[0, 2, 4, 5, 7, 9, 11]) // returns e.g. [ 16, 12, 14, 7, 11, 5 ]
edo.get.random_melody(6, [0, 17], 3,[0, 2, 4, 5, 7, 9, 11],3) // returns e.g. [ 14, 16, 12, 9, 11, 14 ]
# (static) random_melody_from_contour(contour, rangeopt, modeopt) → {Array.<Number>}
Returns an array of (length) (pseudo)random pitches, with lowest note not lower than range[0], and highest note not higher than range[1].
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
contour |
Array.<Number> | The contour. For instance [0,2,1,2,0] = [low high mid high low] but you can have as many "heights" as you'd like. |
||
range |
Array.<number> |
<optional> |
[0, 12] | the lower and upper limits (inclusive) for the melody |
mode |
Array.<number> |
<optional> |
If mode is provided, the pitches returned will be only ones that appear in the mode provided. |
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
edo.get.random_melody_from_contour([0,3,1,3,2],[0,12],[0,2,4,5,7,9,11]); //returns e.g. [ 2, 11, 7, 11, 9 ]
# (static) random_melody_from_distribution(dist, lengthopt) → {Array.<Number>}
Returns a random melody of length based on a distribution (as generated by EDO.get.pitch_distribution()).
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
dist |
Array.<Object> | A stratistical distribution of pitches (as returned from EDO.get.pitch_distribution()) |
||
length |
Array.<number> |
<optional> |
8 | The length of the output melody |
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
let dist = edo.get.pitch_distribution([4,4,5,7,7,5,4,2,0,0,2,4,4,2,2])
edo.get.random_melody_from_distribution(dist);
//returns
[4, 4, 2, 2, 0, 2, 2, 7]
# (static) random_melody_from_ngram(ngrams, startopt, lengthopt) → {Array.<Number>}
Returns an array of (length) based on an ngram analysis of a given input.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
ngrams |
Array.<Object> | A list of ngrams (as returned from EDO.get.ngrams()) |
||
start |
Array.<number> |
<optional> |
[0] | The starting pitch / phrase (multiple pitches) of the melody |
length |
Array.<number> |
<optional> |
16 | The length of the output melody |
- See:
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
let ngrams = edo.get.ngrams([4,4,5,7,7,5,4,2,0,0,2,4,4,2,2],4)
edo.get.random_melody_from_ngram(ngrams);
//returns
[0, 2, 4, 4, 2, 2, 4, 4, 2, 2, 0, 0, 2, 4, 4, 2]
# (static) ratio_approximation(interval, limitopt, cache) → {Object|approximation}
Returns the closest ratio (within a given limit) for any interval class.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
interval |
Number | An interval class |
||
limit |
Number |
<optional> |
17 | The harmonic limit |
cache |
Boolean | if true, the result will be cached for faster retrival |
-
- Type
- Object
-
- Type
- approximation
let edo = new EDO(12) // create a tuning context
edo.get.ratio_approximation(7)
//returns {
"cents_offset": -1.955000865387433
"decimal": 1.5
"log_position": 0.5849625007211562
"octave": 1
"ratio": "3:2"
}
# (static) retrograde(scale) → {Array.<Number>}
Returns the retrograde of a given set of pitches (their reversed order)
Remark: "pitches" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Description |
---|---|---|
scale |
Array.<Number> | a collection of pitches (not necessarily pitch-classes) |
The reversed input
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.retrograde([0,2,4,5,7,9,11])
//returns [11,9,7,5,4,2,0]
# (static) rotated(pitches, n) → {Array.<Number>}
Returns a given collection of pitches, rotated n times.
Name | Type | Description |
---|---|---|
pitches |
Array.<Number> | a collection of numbers (not necessarily pitch-classes, not necessarily unique) |
n |
Number | Number of rotations |
- Type
- Array.<Number>
let edo = new EDO(12) // define a tuning system
edo.get.rotated([0,2,4,5,7],2) //returns [4,5,7,0,2]
edo.get.rotated([0,2,4,5,7],-1) //returns [7,0,2,4,5]
# (static) rotations(pitches) → {Array.<Array.<Number>>}
Returns all the rotations (inversions) of an array of pitches
Name | Type | Description |
---|---|---|
pitches |
Array.<Number> | a collection of numbers (not necessarily pitch-classes, not necessarily unique) |
- Type
- Array.<Array.<Number>>
let edo = new EDO(12) // define a tuning system
edo.get.rotations([0,4,7,4])
//returns [ [ 0, 4, 7, 4 ], [ 4, 7, 4, 0 ], [ 7, 4, 0, 4 ], [ 4, 0, 4, 7 ] ]
# (static) scalar_melodies(melody, stepsopt, look_backopt) → {Array.<Object>}
Returns all the melodies that can be constructed without any leaps (regardless of how many notes in the melody need to be skipped until next scalar note is found)
Remark: "intervallic units" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
melody |
Array.<Number> | a collection of pitches (not necessarily pitch-classes, not necessarily unique) |
||
steps |
Array.<Number> |
<optional> |
[1,2] | which intervallic units to consider as steps |
look_back |
Boolean |
<optional> |
true | When true, the algorithm creates alternate paths to already resolves melodies. When false, resolved melodies will not be considered and a new path will begin. |
object with property pitch
indicating the pitch, and property index
representing its original position in the melody.
- Type
- Array.<Object>
let edo = new EDO(12) // define a tuning system
let melody = [2,2,4,2,7,6,2,2,4,2,9,7] //happy birthday song
edo.get.scalar_melodies(melody)
//returns
[
[
{ pitch: 2, index: 0 },
{ pitch: 2, index: 1 },
{ pitch: 4, index: 2 },
{ pitch: 2, index: 3 },
{ pitch: 2, index: 6 },
{ pitch: 2, index: 7 },
{ pitch: 4, index: 8 },
{ pitch: 2, index: 9 }
],
[
{ pitch: 7, index: 4 },
{ pitch: 6, index: 5 },
{ pitch: 4, index: 8 },
{ pitch: 2, index: 9 }
],
[
{ pitch: 7, index: 4 },
{ pitch: 9, index: 10 },
{ pitch: 7, index: 11 }
],
]
# (static) scale_fragments(options, cacheopt) → {Array.<Object>}
Returns the full list of {frag_max_length} steps that span a given {span}.
Name | Type | Attributes | Default | Description | ||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
options |
Object |
Properties
|
||||||||||||||||||||||||||||||||
cache |
Boolean |
<optional> |
true | Whether to cache the result for faster retrieval. |
- Returns an array of object, with each specifying a fragment, and its "virtual cardinality". The virtual cardinality in this case refers to how many notes are needed to fill an octave by repeatly filling it with the fragment. So in 12-EDO, the fragment [1,1,1,1] will have a cardinality of 12, because you need 12 notes ([1,1,1,1][1,1,1,1][1,1,1,1]) to span an octave. The fragment [2,1,2,1] will have a cardinality of 8, because you need 8 notes ([2,1,2,1][2,1,2,1]) to span an octave. Importantly, the fragment [2,1,2] will have a cardinality of 7.2, because more than 2Xfragment is needed, and less than 3Xfragment ([2,1,2][2,1,2][2...) The actual calculation is: (EDO/span)*fragment_length
- Type
- Array.<Object>
let edo = new EDO(12) // define a tuning system
edo.get.scale_fragments({span:5,max_length:3,min_length:3}) //All of the fragments that span a perfect 4th (5) with 3 members (i.e., 4 notes). This returns all of the possible scalar tetrachords in 12-EDO
//returns
[
{ fragment: [ 1, 1, 3 ], cardinality: 7.199999999999999 },
{ fragment: [ 1, 2, 2 ], cardinality: 7.199999999999999 },
{ fragment: [ 1, 3, 1 ], cardinality: 7.199999999999999 },
{ fragment: [ 2, 1, 2 ], cardinality: 7.199999999999999 },
{ fragment: [ 2, 2, 1 ], cardinality: 7.199999999999999 },
{ fragment: [ 3, 1, 1 ], cardinality: 7.199999999999999 },
{ fragment: [ 1, 1, 2 ], cardinality: 9 },
{ fragment: [ 1, 2, 1 ], cardinality: 9 },
{ fragment: [ 2, 1, 1 ], cardinality: 9 },
{ fragment: [ 1, 1, 1 ], cardinality: 12 }
]
# (static) scales(min_step, max_step, min_sizes) → {Array.<Scale>}
Generates all possible necklaces (unique scales without their modes) based on input parameters.
Remark: "intervallic units" / "step sizes" conform to the current tuning system used. E.g., 0-11 in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Description |
---|---|---|
min_step |
Number | The smallest step size that can be used to form scales. If min_step=3, no scale will contain intervallic units smaller than 3 (so no intervals of size 2, or 1 will be found in any scale) |
max_step |
Number | The largest step that can be used to form scales. If max_step=3, no scale will contain intervallic units larger than 3 (so no intervals of size >3 will be found in any scale) |
min_sizes |
Number | The minimal amount of variety in step size needed to make a scale. if min_sizes=2, then scales with step sizes that belong to fewer than 2 intervallic units will not be included. In the case of min_sizes=2, the following scales will be excluded: [0,1,2,3,4,5,6,7,8,9,10,11], [0,2,4,6,8,10], [0,3,6,9], etc.
In the case of max_sizes=2, the following scale will be excluded: [0,1,4,5,7,10,11], because it has >2 (3) step sizes. step size=1 between 0 and 1, step size=2 between 5 and 7, and step size = 3 between 1 and 4. |
all the scales that abide by the criteria given
- Type
- Array.<Scale>
# (static) sets_from_mixture(mixture) → {Array.<Array.<Number>>}
Returns every scale that can be constructed, given some mixture (as returned by Scale#get.mixture, for instance)
Name | Type | Description |
---|---|---|
mixture |
Array.<Array.<Number>> | [[possibilities for step 1], [possibilities for step 2],...,[possibilities for step n]] in a scale with n steps. |
- Returns all of the sets that can be constructed with the mixture provided
- Type
- Array.<Array.<Number>>
let edo = new EDO(12) // define a tuning system
edo.get.sets_from_mixture([ [0], [3,4], [7,8] ])
//returns [ [ 0, 3, 7 ], [ 0, 3, 8 ], [ 0, 4, 7 ], [ 0, 4, 8 ] ]
# (static) shortest_path(destination, intervals) → {Array.<Array.<Number>>}
Finds the required operation to get to a destination note using given intervals
Finds the shortest path towards a given note (destination) by starting on note 0 and moving using the
intervals provided.
For instance, for destination = -4
and intervals = [-7,3]
(reaching -4, by only moving up by minor 3rds (3) and down by perfect
5ths (-7)), the function will return [3,3,3,3,3,3,-7,-7]
which is the shortest way to get from 0
to -4 using only these intervals.
Note: the order of the intervals is mutable and can be jumbled up at will without harming the result. In the example given, as long as there are six 3s and two -7s. the sum will be -4. So there is potential for permutations.
Remark: "intervallic units" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Description |
---|---|---|
destination |
Number | the destination note. This is an int that represents some interval away from 0. |
intervals |
Array.<Number> | Number | the intervallic units to be used (usually at least one positive interval to move up and one negative to move down) |
an sorted array of the intervals needed to reach the destination starting from 0.
- Type
- Array.<Array.<Number>>
//The quickest way to get to E (from 0) moving up with P5s and down with m3s
let path = edo.get.shortest_path(7,[5,-3]) // returns [ -3, 5, 5 ]
# (static) simple_ratios(limitopt, cache) → {Object}
Returns simple ratios in fraction form, decimal form, and their representation in cents with a given limit.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
limit |
Number |
<optional> |
17 | the limit |
cache |
Boolean | if true, the result will be cached for faster retrival |
- Type
- Object
# (static) stacked(pitches, intervals, transposed_to_0) → {Array.<Array.<Number>>}
Returns the given pitches, stacked using the given intervals
Name | Type | Description |
---|---|---|
pitches |
Array.<Number> | a collection of pitches |
intervals |
Array.<Number> | The intervals with which to stack |
transposed_to_0 |
Boolean | When true, the returned sets will be transposed to start from 0 |
All the stacks that can be created with the given pitches using the given intervals
- Type
- Array.<Array.<Number>>
let edo = new EDO(12) //Create a tuning context
edo.get.stacked([0,2,4,6,9],[3,4])
//returns [ [ 2, 6, 9, 12, 16 ] ]
edo.get.stacked([0,2,4,6,9],[3,4,5],true)
//returns [ [ 0, 4, 9, 14, 18 ], [ 0, 4, 7, 10, 14 ] ]
# (static) starting_at(pitches, start_at, as_PCsopt) → {Array.<Number>}
Returns the given pitches, such that they are shifted to start from start_at
.
Remark: "pitches" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pitches |
Array.<Number> | an array of pitches (or pitch-classes) |
||
start_at |
Number | The number to which everything will be shifted |
||
as_PCs |
Boolean |
<optional> |
true | when false the shift will respect the octave, when true, the array will be returned containing only Pitch Classes |
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
edo.get.starting_at([1,5,8],0)
//returns [0,4,7] //Everything shifted such that the starting pitch is 0
edo.get.starting_at([5,1,8],2,false)
//returns [2,-2,5] //Everything shifted such that the starting pitch is 2, and octave is respected
# (static) step_maximal_mean_error_in_cardinality(cardinality) → {Number}
Returns the maximal sum of step difference from the mean in a scale of that cardinality
Name | Type | Description |
---|---|---|
cardinality |
Number | the number of notes in a scale |
The maximal sum of step error from the mean a scale in that cardinality can have
- Type
- Number
let edo = new EDO(12) //Create a tuning context
edo.get.step_maximal_mean_error_in_cardinality(7) //returns 8.571428571428571
# (static) step_min_max_error_in_EDO(cacheopt) → {Object}
Returns the maximal and minimal sums of step difference possible in that tuning system
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cache |
Boolean |
<optional> |
true | option caching for faster retrival |
- See:
-
- EDO#get.step_minimal_mean_error_in_cardinality()
- EDO#get.step_maximal_mean_error_in_cardinality()
- EDO#get.step_min_max_mean_error_in_cardinality()
The minimal and maximal sum of step error from the mean a scale in that tuning system
- Type
- Object
let edo = new EDO(12) //Create a tuning context
edo.get.step_min_max_error_in_EDO()
//returns { min: 0, max: 12 }
# (static) step_min_max_mean_error_in_cardinality(cardinality) → {Object}
Returns the maximal and minimal sums of step difference from the mean in a scale of that cardinality
Name | Type | Description |
---|---|---|
cardinality |
Number | the number of notes in a scale |
- See:
-
- EDO#get.step_minimal_mean_error_in_cardinality()
- EDO#get.step_maximal_mean_error_in_cardinality()
The minimal and maximal sum of step error from the mean a scale in that cardinality can have
- Type
- Object
let edo = new EDO(12) //Create a tuning context
edo.get.step_min_max_mean_error_in_cardinality(7)
//returns { min: 2.8571428571428568, max: 8.571428571428571 }
# (static) step_minimal_mean_error_in_cardinality(cardinality) → {Number}
Returns the minimal sum of step difference from the mean in a scale of that cardinality
Name | Type | Description |
---|---|---|
cardinality |
Number | the number of notes in a scale |
The minimal sum of step error from the mean a scale in that cardinality can have
- Type
- Number
let edo = new EDO(12) //Create a tuning context
edo.get.step_minimal_mean_error_in_cardinality(7) //returns 2.8571428571428568
# (static) subset_indices(find, arr, allow_skipsopt) → {Array.<Array.<Number>>}
Gets a subset to find and returns the indices from a given array (arr) that form that subset
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
find |
Array.<Number> | a collection of pitches to find (in order) |
||
arr |
Array.<Number> | a bigger collection where we search |
||
allow_skips |
Boolean |
<optional> |
true | if false, the search will only be done on consecutive items |
- Type
- Array.<Array.<Number>>
get.subset_indices([0, 2, 3], [0, 0, 2, 0, 2, 3, 3])
// returns [[ 0, 2, 5 ], [ 0, 2, 6 ],[ 0, 4, 5 ], [ 0, 4, 6 ],[ 1, 2, 5 ], [ 1, 2, 6 ],[ 1, 4, 5 ], [ 1, 4, 6 ],[ 3, 4, 5 ], [ 3, 4, 6 ]]
# (static) subsets(pitches, allow_skipsopt, normalopt) → {Array.<Array.<Number>>}
Returns all the subsets (in order) from a given array of pitches.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pitches |
Array.<Number> | a given array of pitches |
||
allow_skips |
Boolean |
<optional> |
true | if set to false, function will only return subsets that have consecutive members |
normal |
Boolean |
<optional> |
true | When true, the returned subsets are converted to normal order |
- Type
- Array.<Array.<Number>>
//returns [[0], [2], [3], [0, 2], [0, 3], [2, 3], [0, 2, 3]]
get.subsets([0,2,3],true)
//returns [[0], [2], [3], [0, 2], [2, 3], [0, 2, 3]]
edo.get.subsets([0,2,3],false)
# (static) transposition(pitches, amountopt, as_PCopt) → {Array.<Number>}
Transposes the input by a given amount
Remark: "a single octave" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
pitches |
Array.<Number> | a given array of pitches |
||
amount |
Number |
<optional> |
0 | the interval by which to transpose |
as_PC |
Boolean |
<optional> |
true | if true, the intervals returns will conform to a single octave |
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
edo.get.transposition([0,2,4,5,7,9,11],7)
//returns [7, 9, 11, 0, 2, 4, 6]
# (static) union(…collections) → {Array.<Number>}
Returns the union of two sets
Name | Type | Attributes | Description |
---|---|---|---|
collections |
Array.<Number> |
<repeatable> |
Any number of arrays of pitches. |
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
edo.get.union([0,1,2],[3,4,5],[6])
//returns [0,1,2,3,4,5,6]
# (static) unique_elements(list) → {Array.<Number>}
Gets an array that may have duplications and returns the array without duplications This should only be used for Arrays with nested Arrays or nested Objects. 1-dimensional arrays should use unique_in_array
Name | Type | Description |
---|---|---|
list |
Array.<(number|Array.<Number>)> | an array with duplications |
an array without duplications
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
edo.get.unique_elements([1,[2,3],2,[2,3],2]) //notice that it accepts nested elements as well
//returns [ 1, [ 2, 3 ], 2 ]
# (static) well_formed_scale(cardinalityopt) → {Array.<Number>}
Generates a well-formed scale in the current EDO with a given cardinality.
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
cardinality |
Number |
<optional> |
7 | The number of pitches in the scale |
- See:
-
- Clough, J. and J. Douthett (1991). "Maximally even sets." Journal of Music Theory 35(1/2): 93-173.
A well formed scale
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
edo.get.well_formed_scale(5) //returns [0,2,4,7,9]
# (static) without(array1, array2, normalopt) → {Array.<Number>}
Returns the elements of array1, but not if they are found in array 2
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
array1 |
Array.<Number> | a collection of numbers (pitch-classes, or anything for that matter) |
||
array2 |
Array.<Number> | a collection of numbers (PCs or any) |
||
normal |
Boolean |
<optional> |
false | when true, the returned set will be in normal order |
All of the elements of array1 that are not in array2
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
edo.get.without([0,1,3,4,6,7,9,10],[0,4,9])
//returns [1,3,6,7,10]
edo.get.without([0,1,3,4,6,7,9,10],[0,4,9],true)
//returns [0,2,5,6,9]
# (static) without_chromatic_notes(melody) → {Array.<Number>}
Gets a melody, and attempts to remove chromatic passing tones
Name | Type | Description |
---|---|---|
melody |
Array.<number> | an array representing a melody |
The array without the chromatic passing tones
- Type
- Array.<Number>
let edo = new EDO(12) //Create a tuning context
let melody = [12,10,9,8,7,6,8,10,11,12,10,9,8,7,6,8,10,11,12,14,19,15] //syrinx
edo.get.without_chromatic_notes(melody)
//returns [12, 6, 8, 12, 6, 8, 12, 14, 19, 15]