count

Scale# count

A collection of functions that return an amount

Methods

# (static) chord_quality(intervals) → {Number}

Returns the number of times a certain chord (or interval) quality (specified in intervallic units above the root) exists in the scale.

E.g. scale.count.chord_quality([4, 7, 11]) counts the number of times a major 7th (if in 12 EDO) appears in a scale

Remark: "intervallic units" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.

Parameters:
Name Type Description
intervals Array.<(Number|Array.<Number>)>

intervallic units above 0

Source:
Returns:
Type
Number
Examples
let edo = new EDO(12) //Create a tuning context
let scale = edo.scale([0,2,4,5,7,9,11]) //define new scale (Major)
//Major 7th
scale.count.chord_quality([4, 7, 11]) //returns 2

let scale = edo.scale([0,2,3,5,6,8,9,11]) //define new scale (Octatonic)
//diminished triad
scale.count.chord_quality([3, 6]) //returns 8
//(in 12-EDO) count how many major OR minor triads are in the diatonic scale
let scale = edo.scale([0,2,4,5,7,9,11]) //define new scale (Major)
//count how many times in the diatonic scale, the 1st interval is a pitch-class of 3 OR PC4, and the 2nd interval a PC7
scale.count.chord_quality([[3,4], 7]) //returns 6

# (static) consecutive_steps(size) → {Number}

Returns the maximal number of consecutive steps of size 'size' in the scale (and its rotations).

Parameters:
Name Type Description
size Number

the size of the step

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //Create a tuning context
let scale = edo.scale([0,2,4,5,7,9,11]) //define new scale (Major)
scale.count.consecutive_steps(2) //returns 3

# (static) imperfections(toleranceopt, cacheopt) → {Number}

Returns the number of imperfections (notes that do not have a P5 above them) in the scale.

Parameters:
Name Type Attributes Default Description
tolerance Number <optional>
10

allowed tolerance in cents (away from pure P5)

cache Boolean <optional>

when true, the result will be cached for faster retrieval.

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //Create a tuning context
let scale = edo.scale([0,2,4,5,7,9,11]) //define new scale (Major)
scale.count.imperfections() //returns 1
scale.count.imperfections(0) //returns 7

# (static) interval(interval) → {Number}

Returns the number of intervals of a specified size in the scale.

When an array is passed, the function returns total amount of intervals found from the array.

Remark: "intervallic units" conform to the current tuning system used. E.g., 0-11 occupy 1 octave in 12EDO, 0-16 in 17EDO, etc.

Parameters:
Name Type Description
interval Number | Array.<Number>

some interval class.

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //Create a tuning context
let scale = edo.scale([0,2,4,5,7,9,11]) //define new scale (Major)
scale.count.interval([3,4]) //returns 7 (the amount of IC3 in the scale + the amount of IC4 in the scale)

# (static) M3s() → {Number}

Returns the number of Major Thirds (approximations of 5:4 with a tolerance of 20 cents) in the scale.

(To count other intervals or set a different tolerance use Scale.count.ratio())

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,5,7,9,11]) //new Scale object
scale.count.M3s() //returns 3 (C-E, F-A, G-B)

# (static) m3s() → {Number}

Returns the number of Minor Thirds (with a tolerance of 20 cents) in the scale.

(To count other intervals or set a different tolerance use Scale.count.ratio())

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,5,7,9,11]) //new Scale object
scale.count.m3s() //returns 4

# (static) major_minor_triads() → {Number}

Returns the number of major and minor (sounding) triads in the scale.

For other chord qualities use a combination of Scale.count.chord_quality() and EDO.convert.ratio_to_interval()

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,5,7,9,11]) //Major
scale.count.major_minor_triads() //returns 6

# (static) min_max_n_chords_in_necklace() → {Number}

Returns the min/max number of unique combinations that can be made from the set of this necklace family.

Source:
Returns:
Type
Number

# (static) modes() → {Number}

Returns the number of unique modes in the scale.

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,5,7,9,11]) //Major
scale.count.modes() //returns 7

scale = edo.scale([0,2,4,6,8,10]) //Whole-tone
scale.count.modes() //returns 1

# (static) n_chords(options) → {Number}

Returns the number of unique combinations that can be made from the set or subsets of it.

Parameters:
Name Type Description
options Object
Properties
Name Type Attributes Default Description
prime_form Boolean <optional>
false

Whether the count should consider n_chords that have the same prime form as similar

n Array.<Number> <optional>
[2, # of pitches]

[minimum n for n_chord, maximum n for n_chord]

cache Boolean <optional>
set at Class level

whether to cache the results

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,7,9]) //pentatonic
scale.count.n_chords() //returns 15

# (static) n_chords_diatonic() → {Number}

Returns the number of unique (with regards to diatonicity) n_chords that can be made from the set or subsets of it.

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,7,9]) //pentatonic
scale.count.n_chords_diatonic() //returns 15

# (static) P5s() → {Number}

Returns the number of Perfect Fifths (with a tolerance of 5 cents) in the scale.

(To count other intervals or set a different tolerance use @Scale.count.ratio())

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,5,7,9,11]) //new Scale object
scale.count.P5s() //returns 6 (C-G, D-A, E-B, F-C, G-D, A-E)

# (static) pitches() → {Number}

Returns the number of pitches in the scale (its cardinality).

Source:
Returns:
Type
Number
Example
let scale = edo.scale([0,2,4,5,7,9,11]) //new Scale object
scale.count.pitches() //returns 7

# (static) rahn_ambiguities() → {Number}

Returns the number of (Rahn's) ambiguities in the scale.

Source:
See:
  • Rahn, J. (1991). "Coordination of interval sizes in seven-tone collections." Journal of Music Theory 35(1/2): 33-60.
  • Scale#get.specific_intervals
Returns:
Type
Number
Example
let scale = edo.scale([0,2,4,5,7,9,11]) //The diatonic scale
scale.count.rahn_ambiguities() //returns 1

# (static) rahn_contradictions() → {Number}

Returns the number of (Rahn's) contradictions in the scale.

Source:
See:
  • Rahn, J. (1991). "Coordination of interval sizes in seven-tone collections." Journal of Music Theory 35(1/2): 33-60.
Returns:
Type
Number
Example
let scale = edo.scale([0,2,4,5,7,9,11]) //The diatonic scale
scale.count.rahn_contradictions() //returns 0

# (static) rahn_differences() → {Number}

Returns the number of (Rahn's) differences in the scale.

Source:
See:
  • Rahn, J. (1991). "Coordination of interval sizes in seven-tone collections." Journal of Music Theory 35(1/2): 33-60.
  • Scale#get.generic_intervals
Returns:
Type
Number
Example
let scale = edo.scale([0,2,4,5,7,9,11]) //The diatonic scale
scale.count.rahn_differences() //returns 56

# (static) ratio(ratio, toleranceopt) → {Number}

Counts how many times some ratio appears in the scale within a given tolerance.

Parameters:
Name Type Attributes Default Description
ratio Number
tolerance Number <optional>
10

a tolerance in cents

Source:
Returns:
Type
Number

# (static) rotational_symmetries() → {Number}

Returns the number of rotational symmetries in the scale.

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,3,5,6,8,9,11]) //Octatonic
scale.count.rotational_symmetries() //returns 4

# (static) simple_ratios(limitopt, toleranceopt)

Counts how many simple ratios appear in the scale.

Parameters:
Name Type Attributes Default Description
limit Number <optional>
17

some harmonic limit

tolerance Number <optional>
15

a tolerance in cents

Source:
Returns:

simple_ratio

# (static) tetrachords() → {Number}

Returns the number of unique tetrachords available in the scale.

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,5,7,9,11]) //major
scale.count.tetrachords() //returns 20

# (static) thirds() → {Number}

Returns the number of Major and Minor (sounding) Thirds (with a tolerance of 20 cents) in the scale

.

(To count other intervals or set a different tolerance use Scale.count.ratio())

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,5,7,9,11]) //new Scale object
scale.count.thirds() //returns 7

# (static) transpositions(cacheopt) → {Number}

Returns number of unique transpositions available for the scale.

Parameters:
Name Type Attributes Description
cache Boolean <optional>

when true, the result will be cached for faster retrieval.

Source:
Returns:
Type
Number

# (static) trichords() → {Number}

Returns the number of unique trichords available in the scale.

Source:
Returns:
Type
Number
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,5,7,9,11]) //major
scale.count.trichords() //returns 15

# (static) unique_elements(arr) → {Array.<Number>}

Returns the number of elements in the scale that are not in the provided arr.

Remark: "pitch-classes" conform to the current tuning system used. E.g., 0-11 in 12EDO, 0-16 in 17EDO, etc.

Parameters:
Name Type Description
arr Array.<Number>

a collection of pitch classes

Source:
Returns:
Type
Array.<Number>
Example
let edo = new EDO(12) //define context
let scale = edo.scale([0,2,4,5,7,9,11]) //major
scale.count.unique_elements([2]) //6