diff options
| author | Jules Laplace <julescarbon@gmail.com> | 2018-08-22 17:35:49 +0200 |
|---|---|---|
| committer | Jules Laplace <julescarbon@gmail.com> | 2018-08-22 17:35:49 +0200 |
| commit | acf03a89ea16bfa49db8c1175be8f0cf1e021ab3 (patch) | |
| tree | b0ece3cd3f67e5db7cbeed6d58600835f75e5d59 /client/lib/scales.js | |
civic violence simulator
Diffstat (limited to 'client/lib/scales.js')
| -rw-r--r-- | client/lib/scales.js | 299 |
1 files changed, 299 insertions, 0 deletions
diff --git a/client/lib/scales.js b/client/lib/scales.js new file mode 100644 index 0000000..d85fe08 --- /dev/null +++ b/client/lib/scales.js @@ -0,0 +1,299 @@ +import Intonation from './intonation' + +const meantone = `! meanquar.scl +! +1/4-comma meantone scale. Pietro Aaron's temperament (1523) + 12 +! + 76.04900 + 193.15686 + 310.26471 + 5/4 + 503.42157 + 579.47057 + 696.57843 + 25/16 + 889.73529 + 1006.84314 + 1082.89214 + 2/1 +` + +const shares = `! shares.scl +! +A scale based on shares of wealth +! +1. +5. +15. +32. +52. +78. +116. +182. +521. +1000. +` + +const shares_sum = `! shares_sum.scl +! +A scale based on summing shares of wealth +! +1 +6.0 +21.0 +53.0 +105.0 +183.0 +299.0 +481.0 +1002.0 +2/1 +` + +const mavila = `! mavila12.scl +! +A 12-note mavila scale (for warping meantone-based music), 5-limit TOP + 12 +! +-30.99719 + 163.50770 + 358.01258 + 327.01540 + 521.52028 + 490.52310 + 685.02798 + 654.03080 + 848.53568 + 1043.04057 + 1012.04338 + 1206.54826 +` + +const carlos_alpha = `! carlos_alpha.scl +! +Wendy Carlos' Alpha scale with perfect fifth divided in nine + 18 +! + 78.00000 + 156.00000 + 234.00000 + 312.00000 + 390.00000 + 468.00000 + 546.00000 + 624.00000 + 702.00000 + 780.00000 + 858.00000 + 936.00000 + 1014.00000 + 1092.00000 + 1170.00000 + 1248.00000 + 1326.00000 + 1404.00000 +` + +const lamonte = `! young-lm_piano.scl +! +LaMonte Young's Well-Tempered Piano +12 +! +567/512 +9/8 +147/128 +21/16 +1323/1024 +189/128 +3/2 +49/32 +7/4 +441/256 +63/32 +2/1 +` + +const colundi = `! colundi.scl +! +Colundi scale +10 +! +9/8 +171/140 +137/112 +43/35 +3/2 +421/280 +213/140 +263/150 +66/35 +2/1 +` + +const liu_major = `! liu_major.scl +! +Linus Liu's Major Scale, see his 1978 book, "Intonation Theory" + 7 +! + 10/9 + 100/81 + 4/3 + 3/2 + 5/3 + 50/27 + 2/1 +` +const liu_pentatonic = `! liu_pent.scl +! +Linus Liu's "pentatonic scale" + 7 +! + 9/8 + 81/64 + 27/20 + 3/2 + 27/16 + 243/128 + 81/40 +` + +const liu_minor = `! LIU_MINor.scl +! +Linus Liu's Harmonic Minor + 7 +! + 10/9 + 6/5 + 4/3 + 40/27 + 8/5 + 50/27 + 2/1 +` + +const liu_melodic_minor = `! liu_mel.scl +! +Linus Liu's Melodic Minor, use 5 and 7 descending and 6 and 8 ascending + 9 +! + 10/9 + 6/5 + 4/3 + 3/2 + 81/50 + 5/3 + 9/5 + 50/27 + 2/1 +` + +const scales = [ + { + intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1', + name: "harmonic scale", + }, + { + root: 450, + intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1', + name: "harmonic scale @ 450", + }, + { + tet: 5, + }, + { + tet: 12, + }, + { + tet: 17, + }, + { + intervals: '1/1 81/80 33/32 21/20 16/15 12/11 11/10 10/9 9/8 8/7 7/6 32/27 6/5 11/9 5/4 14/11 9/7 21/16 4/3 27/20 11/8 7/5 10/7 16/11 40/27 3/2 32/21 14/9 11/7 8/5 18/11 5/3 27/16 12/7 7/4 16/9 9/5 20/11 11/6 15/8 40/21 64/33 160/81 2/1', + name: "harry partch scale", + }, + { + scl: lamonte, + }, + { + scl: meantone, + }, + { + scl: mavila, + }, + { + scl: carlos_alpha, + }, + { + scl: colundi, + }, + { + scl: shares, + }, + { + scl: shares_sum, + }, + { + scl: liu_major, + }, + { + scl: liu_minor, + }, + { + scl: liu_melodic_minor, + }, + { + scl: liu_pentatonic, + } +].map( (opt) => new Intonation(opt) ) + +let scale = scales[0] +let handleChange = function(){} + +function build () { + scales.forEach( (scale, i) => { + scale.heading = document.createElement('div') + scale.heading.innerHTML = scale.name + scale.heading.classList.add('heading') + scale.heading.addEventListener('click', function(){ + pick(i) + }) + scale_list.appendChild(scale.heading) + }) + pick(0) +} +function build_options(el) { + scales.forEach( (scale, i) => { + const option = document.createElement('option') + option.innerHTML = scale.name + option.value = i + el.appendChild(option) + }) + el.addEventListener('input', function(e){ + pick(e.target.value) + }) + pick(0) +} + +function pick (i) { + if (scale) { + scale.heading && scale.heading.classList.remove('selected') + } + scale = scales[i] + scale.heading && scale.heading.classList.add('selected') + handleChange(scale) +} + +function current () { + return scale +} + +function onChange (fn) { + handleChange = fn +} + +function names () { + return scales.map( scale => scale.name ) +} + + +export default { scales, current, build, build_options, pick, names, onChange } |
