let bass, snare, kick, hat, backing, backing2
window.getAudioContext = undefined
createCanvas(windowWidth, windowHeight);
bass = new Voice(new Oscillator(440, 'sine'))
{ time: '0:0:0', note: 'C2', duration: '0:0:3' },
{ time: '0:1:0', note: 'C2', duration: '0:0:3' },
{ time: '0:2:0', note: 'C3', duration: '0:0:3' },
{ time: '1:2:0', note: 'A#3', duration: '0:0:2' },
{ time: '1:2:2', note: 'F#2', duration: '0:0:2' },
{ time: '1:3:0', note: 'F2', duration: '0:0:2' },
{ time: '1:3:2', note: 'D#2', duration: '0:0:2' },
], { by: '2:0:0', times: 50 }))
const snareVoice = new Noise('pink')
snareVoice.connect(new Biquad(800, 'highpass'))
snare = new Voice(snareVoice)
{ time: '0:2:0', duration: '0:0:0.8' },
], { by: '1:0:0', times: 100 }))
const kickVoice = new Noise('brown')
kickVoice.connect(new Biquad(100, 'lowpass'))
kickVoice.noise.volume.value = -5
kick = new Voice(kickVoice)
{ time: '0:0:0', duration: '0:0:0.6' },
], { by: '1:0:0', times: 100 }))
const hatVoice = new Noise('white')
hatVoice.connect(new Biquad(1600, 'highpass'))
hatVoice.noise.volume.value = -20
hat = new Voice(hatVoice)
hat.push(offsetNotes(loopNotes([
{ time: '0:0:0', duration: '0:0:0.4' },
{ time: '0:0:2', duration: '0:0:0.2' },
{ time: '0:1:0', duration: '0:0:0.2' },
{ time: '0:1:2', duration: '0:0:0.2' },
{ time: '0:2:0', duration: '0:0:0.4' },
{ time: '0:2:2', duration: '0:0:0.2' },
{ time: '0:3:0', duration: '0:0:0.2' },
{ time: '0:3:2', duration: '0:0:0.2' },
], { by: '1:0:0', times: 96 }), { by: '4:0:0'}))
backing = new Voice(new Oscillator(440, 'triangle'))
backing.osc.osc.volume.value = -20
backing.push(offsetNotes(loopNotes([
{ time: '0:0:0', note: 'D#4', duration: '0:1:3' },
{ time: '0:2:0', note: 'D#4', duration: '0:1:3' },
], { by: '4:0:0', times: 25 }), { by: '6:0:0' }))
backing2 = new Voice(new Oscillator(440, 'triangle'))
backing2.osc.osc.volume.value = -20
backing2.push(offsetNotes(loopNotes([
{ time: '0:0:0', note: 'C4', duration: '0:1:3' },
{ time: '0:2:0', note: 'C4', duration: '0:1:3' },
], { by: '4:0:0', times: 25 }), { by: '6:0:0' }))
let delta = millis() - startTime
const quarter = 60*1000 / bpm
const bars = Math.floor(delta / (4 * quarter))
delta -= bars * 4 * quarter
const quarters = Math.floor(delta / quarter)
delta -= quarters * quarter
const sixteenths = delta / (quarter / 4)
const t = { bars, quarters, sixteenths }
textAlign(CENTER, CENTER)
text(`${bars}:${quarters}:${floor(sixteenths)}`, width/2, height/2)
function mousePressed() {