summaryrefslogtreecommitdiff
path: root/client/index.js
diff options
context:
space:
mode:
Diffstat (limited to 'client/index.js')
-rw-r--r--client/index.js18
1 files changed, 16 insertions, 2 deletions
diff --git a/client/index.js b/client/index.js
index 81cb34c..00729e4 100644
--- a/client/index.js
+++ b/client/index.js
@@ -51,6 +51,13 @@ let datasets = {}, dataset = {}, bounds = {}, diff = []
let play_fn = play_sequence
data.load().then(lists => {
console.log(lists)
+ const fm = lists.firearms_manufactured
+ datasets['Firearms Manufactured'] = {}
+ datasets['Firearms Manufactured'].name = 'Firearms Manufactured'
+ datasets['Firearms Manufactured'].play_fn = play_sequence
+ datasets['Firearms Manufactured'].h = fm.h.slice(1, 5)
+ datasets['Firearms Manufactured'].labels = fm.lines.map(l => l.slice(0, 1))
+ datasets['Firearms Manufactured'].lines = fm.lines.map(l => l.slice(1, 5))
transpose(lists.gun_violence_by_month.lines).forEach((row, i) => {
const name = lists.gun_violence_by_month.h[i]
if (name === 'Date') return
@@ -64,6 +71,7 @@ data.load().then(lists => {
})
datasets["Mass Shootings"] = lists.mass_shootings_from_columbine
datasets["Mass Shootings"].name = "Mass Shootings"
+ datasets["Mass Shootings"].pedal = true
datasets["Mass Shootings"].play_fn = play_mass_shootings
const lines = datasets["Mass Shootings"].lines.reverse()
const [min_y, ...rest_a] = lines[0][mass_fields.date].split('/')
@@ -73,7 +81,7 @@ data.load().then(lists => {
const [y, m, d] = row[mass_fields.date].split('/')
return (parseInt(y) - parseInt(min_y)) * 12 + parseInt(m)
})
- max_i = (parseInt(max_y) - parseInt(min_y)) * 12 + parseInt(12)
+ datasets["Mass Shootings"].max_i = (parseInt(max_y) - parseInt(min_y)) * 12 + parseInt(12)
// console.log('max i', max_i)
datasets["Mass Shootings"].data = lines
datasets["Mass Shootings"].lines = [lines.map(row => row[mass_fields.total_victims])]
@@ -186,6 +194,11 @@ function play_next(){
clearTimeout(playTimeout)
playTimeout = setTimeout(play_next, note_time)
let [new_i, notes, timings] = play_fn(i, bounds, diff, note_time)
+ if (dataset.labels) {
+ const j = Math.floor(i / bounds.rows[0].length)
+ document.querySelector('#cases').innerHTML = dataset.labels[j]
+ }
+
i = new_i
if (recording) {
let timing = note_values[nx.timing.active][2]
@@ -214,6 +227,7 @@ function pick_dataset(key){
bounds = get_bounds(dataset)
diff = get_diff_bounds(bounds.rows)
play_fn = dataset.play_fn
+ max_i = dataset.max_i || (bounds.rows.length * bounds.rows[0].length)
}
/* build and bind the UI */
@@ -307,7 +321,7 @@ function ready() {
const export_midi_button = document.querySelector('#export_midi')
export_midi_button.addEventListener('click', () => {
- export_pattern_as_midi(dataset.name, bounds, diff, nx.tempo.value, nx.timing.active, play_fn, max_i)
+ export_pattern_as_midi(dataset, bounds, diff, nx.tempo.value, nx.timing.active, play_fn, max_i)
})
const record_midi_button = document.querySelector('#record_midi')