Published
Edited
Dec 31, 2020
1 fork
Importers
28 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
viewof type = DOM.select(['sine', 'triangle', 'sawtooth', 'square'])
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Volume = new Tone.Volume(volume)
Insert cell
Insert cell
synth = {
//create a synth and connect it to the master output (your speakers)
var synth = new Tone.PolySynth(Tone.Synth).chain(Volume, Tone.Master);
synth.set({
oscillator: {
type
},
envelope: {
decay: 1,
release: 1
}
});
try {
yield synth;
yield invalidation;
} finally {
synth.dispose();
}
}
Insert cell
Insert cell
beat = {
let i = 0;
while (true) {
yield Promises.delay(delay, i++);
}
}
Insert cell
Insert cell
note = {
let noteName = String.fromCharCode(65 + (beat % 7));
if (noteName == 'B') noteName = 'D';
return `${noteName}${2 + Math.floor((beat / 7) % 4)}`;
}
Insert cell
Insert cell
{
synth.triggerAttackRelease(note, '4n'); // quarter note from upward scale on every beat
if (beat % 7 == 0) synth.triggerAttackRelease('E5', '8n'); //
if (beat % 14 == 0) synth.triggerAttackRelease(['G3', 'E4', 'C5'], '1n');
if (Math.floor(beat % (7 * 4)) == 16)
synth.triggerAttackRelease(['G4', 'C6', 'B5'], '4n');
if (Math.floor(beat % (7 * 4)) == 18)
synth.triggerAttackRelease(['G4', 'C6', 'A6'], '4n');
if (Math.floor(beat % (7 * 4)) == 20)
synth.triggerAttackRelease(['A4', 'C6', 'E5'], '16n');
}
Insert cell

One platform to build and deploy the best data apps

Experiment and prototype by building visualizations in live JavaScript notebooks. Collaborate with your team and decide which concepts to build out.
Use Observable Framework to build data apps locally. Use data loaders to build in any language or library, including Python, SQL, and R.
Seamlessly deploy to Observable. Test before you ship, use automatic deploy-on-commit, and ensure your projects are always up-to-date.
Learn more