diff options
Diffstat (limited to 'bundle.js')
| -rw-r--r-- | bundle.js | 111 |
1 files changed, 74 insertions, 37 deletions
@@ -24575,7 +24575,7 @@ var dataPromises = files.map(function (name) { }); var h = lines.shift(); return { - name: name, + name: name.replace(/-/g, ' '), h: h, lines: lines.filter(function (s) { return !!s; @@ -24728,6 +24728,13 @@ var lamonte = '! young-lm_piano.scl\n!\nLaMonte Young\'s Well-Tempered Piano\n12 var colundi = '! colundi.scl\n!\nColundi scale\n10\n!\n9/8\n171/140\n137/112\n43/35\n3/2\n421/280\n213/140\n263/150\n66/35\n2/1\n'; +var liu_major = '! liu_major.scl\n!\nLinus Liu\'s Major Scale, see his 1978 book, "Intonation Theory" \n 7\n!\n 10/9\n 100/81\n 4/3\n 3/2\n 5/3\n 50/27\n 2/1\n'; +var liu_pentatonic = '! liu_pent.scl\n!\nLinus Liu\'s "pentatonic scale" \n 7\n!\n 9/8\n 81/64\n 27/20\n 3/2\n 27/16\n 243/128\n 81/40\n'; + +var liu_minor = '! LIU_MINor.scl\n!\nLinus Liu\'s Harmonic Minor \n 7\n!\n 10/9\n 6/5\n 4/3\n 40/27\n 8/5\n 50/27\n 2/1\n'; + +var liu_melodic_minor = '! liu_mel.scl\n!\nLinus Liu\'s Melodic Minor, use 5 and 7 descending and 6 and 8 ascending \n 9\n!\n 10/9\n 6/5\n 4/3\n 3/2\n 81/50\n 5/3\n 9/5\n 50/27\n 2/1\n'; + var scales = [{ intervals: '1/1 9/8 5/4 4/3 3/2 5/3 15/8 2/1', name: "harmonic scale" @@ -34542,32 +34549,51 @@ function midi_ready(err) { if (filtered.length) { midi = filtered[0]; } - } else { - midi = _webmidi2.default.outputs[0]; } + midi = midi || _webmidi2.default.outputs[0]; console.log(midi.name); } -var i = 0; +var i = 0, + datasets = {}, + dataset = {}, + bounds = {}, + diff = []; +var play_fn = play_sequence; data.load().then(function (lists) { // nx.dataset.choices = Object.keys(lists) console.log(lists); - var list = lists.weekly_earnings; - document.querySelector('#dataset_name').innerHTML = list.name.replace(/-/g, ' '); - // playSequence(list) - playIntervalSequence(list); + datasets = lists; + (0, _util.requestAudioContext)(ready); + pick_dataset('housing costs and income inequality'); }); +function pick_dataset(key) { + console.log('pick dataset:', key); + i = 0; + dataset = datasets[key]; + bounds = get_bounds(dataset); + diff = get_diff_bounds(bounds.rows); +} +var behaviors = { + sequence: { name: 'Sequence', fn: play_sequence }, + interval: { name: 'Intervals', fn: play_interval_sequence } +}; +function pick_behavior(name) { + behaviors[name].fn(); +} +function play_next() { + var note_time = 120000 / _tone2.default.Transport.bpm.value * note_values[nx.timing.active][0]; + setTimeout(play_next, note_time); + play_fn(note_time); +} +function play_sequence() { + play_fn = function play_fn(note_time) { + var _bounds = bounds, + rows = _bounds.rows, + min = _bounds.min, + max = _bounds.max; -function playSequence(list) { - var _get_bounds = get_bounds(list), - rows = _get_bounds.rows, - min = _get_bounds.min, - max = _get_bounds.max; - - var count = rows.length * rows[0].length; - playNext(); - function playNext() { - var note_time = 120000 / _tone2.default.Transport.bpm.value * note_values[nx.timing.active][0]; - setTimeout(playNext, note_time); + var count = rows.length * rows[0].length; + if (i >= count) i = 0; var y = Math.floor(i / rows[0].length); var x = i % rows[0].length; if (!x) console.log(y); @@ -34575,34 +34601,32 @@ function playSequence(list) { i += 1; if (i >= count) i = 0; play(norm(n, min, max) * nx.multiply.value, note_time * nx.duration.value); - } + }; } +function play_interval_sequence() { + play_fn = function play_fn(note_time) { + var _bounds2 = bounds, + rows = _bounds2.rows, + min = _bounds2.min, + max = _bounds2.max; -function playIntervalSequence(list) { - var _get_bounds2 = get_bounds(list), - rows = _get_bounds2.rows, - min = _get_bounds2.min, - max = _get_bounds2.max; - - var diff = get_diff_bounds(rows); - var count = rows.length; - playNext(); - function playNext() { - var note_time = 120000 / _tone2.default.Transport.bpm.value * note_values[nx.timing.active][0]; - setTimeout(playNext, note_time); + var count = rows.length; + if (i >= count) i = 0; var y = i % count; var row = rows[y]; + if (!row) { + i = 0;return; + } var row_min = Math.min.apply(Math, row); var row_max = Math.max.apply(Math, row); var row_f0 = norm(row_min, min, max); var row_root = row_f0 * nx.multiply.value; - rows[y].forEach(function (n) { + row.forEach(function (n) { var note = row_root + norm(n - row_min, diff.min, diff.max) * nx.interval.value; play(note, note_time * nx.duration.value); }); i += 1; - if (i > count) i = 0; - } + }; } function norm(n, min, max) { @@ -34663,7 +34687,6 @@ function play(index, duration) { _kalimba2.default.play(freq); } } -(0, _util.requestAudioContext)(ready); function update_value_on_change(el, id, is_int, fn) { var label = document.querySelector(id + ' + .val'); @@ -34691,8 +34714,22 @@ function update_radio_value_on_change(el, id, values, fn) { update(el.active); el.update = update; } +function build_options(el, lists, fn) { + Object.keys(lists).forEach(function (key, i) { + var list = lists[key]; + var option = document.createElement('option'); + option.innerHTML = list.name; + option.value = key; + el.appendChild(option); + }); + el.addEventListener('input', function (e) { + fn(e.target.value); + }); +} function ready() { _scales2.default.build_options(document.querySelector('#scale')); + build_options(document.querySelector('#dataset'), datasets, pick_dataset); + build_options(document.querySelector('#behavior'), behaviors, pick_behavior); // nx.colorize('#f4d142') _tone2.default.Transport.bpm.value = DEFAULT_BPM; @@ -34753,8 +34790,8 @@ function ready() { }); update_value_on_change(nx.interval, '#interval', true); - _tone2.default.Transport.start(); document.querySelector('.loading').classList.remove('loading'); + play_next(); } _keys2.default.listen(function (index) { |
