Published
Edited
Oct 9, 2022
6 stars
Insert cell
Insert cell
Insert cell
Insert cell
{
const lightCount = 3
if (synth) {
let lights = []
let noteLights = []
const voiceCount = synth.MAX_VOICES
for (let i = 0; i < lightCount; i++) {
lights = [...lights, 0, 0, 0, 0, 0, 0]
}
for (let i = 0; i < 12; i++) {
const nl = noteLight(i, 0, 0, 0.6, 0.4)
noteLights = [...noteLights, nl[0], nl[1], nl[2]]
}
return renderLightShow(350, 350, lightCount, 7, (t, dt) => {
lights.fill(0)

for (let i = 0; i < voiceCount; i++) {
const v = synth.v[i]
const idx = v.chid * 6
if (idx < lights.length && v.enabled && v.chid !== 9) {
const n = v.note % 12
const o = Math.floor(v.note / 12)
lights[idx] = noteLights[n * 3] * ((2 - v.chid) + 1) / 3
lights[idx + 1] = noteLights[n * 3 + 1] * ((2 - v.chid) + 1) / 3
lights[idx + 2] = noteLights[n * 3 + 2] * ((2 - v.chid) + 1) / 3
lights[idx + 3] = 1
lights[idx + 4] = 175 + Math.cos([23-v.note % 24] / 12 * Math.PI) * (40 + (50 * (2 - v.chid)))
lights[idx + 5] = 175 + Math.sin([23-v.note % 24] / 12 * Math.PI) * (40 + (50 * (2 - v.chid)))
}
}
return lights
})
}
}
Insert cell
Insert cell
import { simplePlayer, synth } from "@maddievision/quick-midi"
Insert cell
import { songSmbGroundTheme, song2MIDI } from '@maddievision/sample-song-data'
Insert cell
import { noteLight, noteDegree, circlePositions } from '@maddievision/tone-circle-lights'
Insert cell
import { renderLightShow } from '@maddievision/light-show'
Insert cell
midi = song2MIDI(songSmbGroundTheme)
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