summaryrefslogtreecommitdiff
path: root/client/lib
diff options
context:
space:
mode:
authorJules Laplace <julescarbon@gmail.com>2018-10-10 14:58:24 +0200
committerJules Laplace <julescarbon@gmail.com>2018-10-10 14:58:24 +0200
commit31117e3b786e4d24a7dc43163362ab4a4d3050fd (patch)
treef11f19a71c0d4b40f31c4bd8d5dab9efbbfa8294 /client/lib
parentec4db2e8a67ca063737c696716e64496470ebbb3 (diff)
exporting all midi notes... add pedal tone option
Diffstat (limited to 'client/lib')
-rw-r--r--client/lib/midi.js15
1 files changed, 9 insertions, 6 deletions
diff --git a/client/lib/midi.js b/client/lib/midi.js
index d51aeff..449abc0 100644
--- a/client/lib/midi.js
+++ b/client/lib/midi.js
@@ -142,31 +142,34 @@ export function play_interval_sequence(i, bounds, diff, note_time, channel="all"
/* generate a 1-track midi file by calling the play function repeatedly */
-export function export_pattern_as_midi(datasetName, bounds, diff, tempo, timingIndex, play_fn) {
+export function export_pattern_as_midi(datasetName, bounds, diff, tempo, timingIndex, play_fn, max_i) {
// const behavior = document.querySelector('#behavior').value
const { rows } = bounds
// let count = behavior === 'sequence' ? rows[0].length * rows.length : rows.length
- let count = rows[0].length
+ max_i = max_i || rows[0].length
let notes, timings, wait
let note_time
// let timing = note_values[timingIndex][2]
let midi_track = new MidiWriter.Track()
+ let next_i
midi_track.setTempo(tempo)
- for (let i = 0, len = count; i < len; i++) {
- [i, notes, timings, wait] = play_fn(i, bounds, note_time, "all", true)
+ for (let i = 0, len = max_i; i < len; i++) {
+ [next_i, notes, timings, wait] = play_fn(i, bounds, diff, note_time, "all", true)
// if (timing.length) {
// note_time = timing[i % timing.length]
// } else {
// note_time = timing
// }
// midi_track.addEvent(new MidiWriter.NoteEvent({ pitch: notes, duration: 't' + note_time }))
- console.log(i, notes, timings, wait)
+ // console.log(i, notes, timings, wait)
for (let j = 0; j < notes.length; j++) {
+ console.log(i, j, notes[j], timings[j], wait)
midi_track.addEvent(new MidiWriter.NoteEvent({
pitch: notes[j],
duration: 't' + timings[j],
- wait: (j === 0) ? wait : 0,
+ wait,
}))
+ wait = 0
}
}
const writer = new MidiWriter.Writer([midi_track])