summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--client/index.js39
-rw-r--r--client/lib/kalimba.js9
2 files changed, 28 insertions, 20 deletions
diff --git a/client/index.js b/client/index.js
index f5853b9..4740db0 100644
--- a/client/index.js
+++ b/client/index.js
@@ -71,7 +71,7 @@ data.load().then(lists => {
return (parseInt(y) - parseInt(min_y)) * 12 + parseInt(m)
})
datasets["Mass Shootings"].data = lines
- datasets["Mass Shootings"].lines = [lines.map(row => Math.log(row[mass_fields.total_victims]))]
+ datasets["Mass Shootings"].lines = [lines.map(row => row[mass_fields.total_victims])]
requestAudioContext(ready)
})
@@ -105,8 +105,9 @@ function play_mass_shootings(i, bounds, diff, note_time, channel="all", exportin
let notes = [], midi_notes = [], cases = []
console.log(i, mass_i, dataset.dates[mass_i])
while (i >= dataset.dates[mass_i] && mass_i < total) {
- notes.push(dataset.lines[mass_i])
- cases.push(dataset.data[mass_i][mass_fields.date] + ' ' + dataset.data[mass_i][mass_fields.case])
+ notes.push(dataset.lines[0][mass_i])
+ cases.push(dataset.data[mass_i][mass_fields.date] + ' ' + dataset.data[mass_i][mass_fields.case] +
+ ", " + dataset.data[mass_i][mass_fields.fatalities] + ' dead, ' + dataset.data[mass_i][mass_fields.injured] + ' injured')
console.log('push case', dataset.data[mass_i][mass_fields.date] + ' ' + dataset.data[mass_i][mass_fields.case])
mass_i += 1
}
@@ -116,22 +117,22 @@ function play_mass_shootings(i, bounds, diff, note_time, channel="all", exportin
mass_rest += 1
break
case 1:
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 128, channel, exporting, mass_rest, 0))
+ midi_notes.push(play_note( norm(notes[0], min, max) * nx.multiply.value, 128, channel, exporting, mass_rest, 0))
break
case 2:
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 64, channel, exporting, mass_rest, 0))
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 64, channel, exporting, 0, 64))
+ midi_notes.push(play_note( norm(notes[0], min, max) * nx.multiply.value, 64, channel, exporting, mass_rest, 0))
+ midi_notes.push(play_note( norm(notes[1], min, max) * nx.multiply.value, 64, channel, exporting, 0, 64))
break
case 3:
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 43, channel, exporting, mass_rest))
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 43, channel, exporting, 0, 43))
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 42, channel, exporting, 0, 85))
+ midi_notes.push(play_note( norm(notes[0], min, max) * nx.multiply.value, 43, channel, exporting, mass_rest))
+ midi_notes.push(play_note( norm(notes[1], min, max) * nx.multiply.value, 43, channel, exporting, 0, 43))
+ midi_notes.push(play_note( norm(notes[2], min, max) * nx.multiply.value, 42, channel, exporting, 0, 85))
break
case 4:
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 32, channel, exporting, mass_rest))
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 32, channel, exporting, 0, 32))
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 32, channel, exporting, 0, 64))
- midi_notes.push(play_note( norm(n, min, max) * nx.multiply.value, 32, channel, exporting, 0, 96))
+ midi_notes.push(play_note( norm(notes[0], min, max) * nx.multiply.value, 32, channel, exporting, mass_rest))
+ midi_notes.push(play_note( norm(notes[1], min, max) * nx.multiply.value, 32, channel, exporting, 0, 32))
+ midi_notes.push(play_note( norm(notes[2], min, max) * nx.multiply.value, 32, channel, exporting, 0, 64))
+ midi_notes.push(play_note( norm(notes[3], min, max) * nx.multiply.value, 32, channel, exporting, 0, 96))
break
}
if (cases.length) {
@@ -144,7 +145,7 @@ function play_mass_shootings(i, bounds, diff, note_time, channel="all", exportin
} else {
i += 1
}
- kalimba.play(220)
+ kalimba.play(220, -12)
if (notes.length) {
mass_rest = 0
return [i, midi_notes]
@@ -219,7 +220,7 @@ function ready() {
min: -24,
max: 24,
step: 1,
- value: 0,
+ value: -5,
})
update_value_on_change(nx.offset, '#offset', true)
@@ -237,7 +238,7 @@ function ready() {
min: -64,
max: 64,
step: 1,
- value: 7,
+ value: 17,
})
update_value_on_change(nx.multiply, '#multiply', true)
@@ -275,8 +276,12 @@ function ready() {
document.querySelector('.loading').classList.remove('loading')
- document.querySelector('#dataset').value = 'Surrenders'
+ document.querySelector('#dataset').value = 'Mass Shootings'
pick_dataset('Mass Shootings')
+
+ document.querySelector('#scale').value = '14'
+ scales.pick(14)
+
play_next()
}
diff --git a/client/lib/kalimba.js b/client/lib/kalimba.js
index 0354f69..1401dc4 100644
--- a/client/lib/kalimba.js
+++ b/client/lib/kalimba.js
@@ -2,6 +2,7 @@ import Tone from 'tone'
import { choice } from './util'
const player_count = 2
+let sample_index = 0
const compressor = new Tone.Compressor(-30, 3).toMaster()
@@ -33,14 +34,16 @@ samples.forEach((sample) => {
}
})
-function play (freq) {
- const best = { sample: choice(samples) }
+function play (freq, volume = 0.0) {
+ const best = { sample: samples[sample_index] }
+ sample_index = (sample_index + 1) % samples.length
best.sample.index = (best.sample.index + 1) % player_count
const player = best.sample.players[ best.sample.index ]
player.playbackRate = freq / best.sample.root
// console.log(player)
- player.start()
+ player.volume.value = volume
+ setTimeout(() => { player.start() }, 0)
}
export default { play }