Published
Edited
Oct 30, 2019
5 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// Translate {a:b} into [[a, b]]
noteIncidence = [
allNotes.map(note => ({
// Translate MIDI note into note name, and remove the octave
note: Tone.Frequency(note.midi, 'midi').toNote().replace(/\d/, ''),
time: note.time,
duration: note.duration,
midi: note.midi
}))
.reduce((memo, {note, duration}) => {
// count notes by duration
memo[note] = (memo[note] || 0) + duration;
return memo;
}, {})]
.map(Object.entries)
.map(entries => entries.sort((a, b) => b[1] - a[1]))
.map(entries => entries.map(([note, duration]) => ({note,duration})))[0]
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
midiconvert = require('midiconvert')
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more