xxxxxxxxxx
43
let lp = null;
// smoothing
const smoother = {
y: 0.0,
smooth: function(x, c = 0.99) {
return (this.y = (1.0-c)*x + c*this.y);
}
}
// sequencer setup
function startSequencer(sequencer) {
// eventLists for sequencer
let seq = [[lp.lowPitch, lp.midLevel, lp.soon, lp.longDuration], O];
sequencer.add(lp.cello, seq);
lp.cello.reverb(2.5);
// set the BPM
lp.setBpm(200);
// run sequencer
sequencer.play();
// pan/filter modulation
let s1 = smoother;
let s2 = smoother;
const modulator = (t) => {
lp.cello.pan(s1.smooth(random()));
lp.cello.cutoff(0.4+0.6*s2.smooth(random()));
sequencer.addCallback(modulator);
}
// prime it
sequencer.addCallback(modulator);
}
async function setup() {
lp = await lpLoad();
startSequencer(lp.sequencer);
}