Public
Edited
Feb 8, 2024
1 star
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
// toggleSounds = {
// let i = 0;
// while (true) {
// await Promises.delay(5000);
// ++i;
// yield i % 2 === 0 ? 'NoiseSynth' : 'AMSynth';
// }
// }
Insert cell
Insert cell
Insert cell
callback = (time) => {
if (randFromArr([0, 1])) mutable note = randFromArr(scale.notes);
if (randFromArr([0, 1])) mutable octave = randFromArr(octaves);
noteIndex < 11 ? mutable noteIndex++ : (mutable noteIndex = 0);
mutable noteWillBePlayed = randFromArr([0, 1]);

if (noteWillBePlayed) {
synth.triggerAttackRelease(
`${note}${octave}`,
"64n",
time,
d3.randomUniform(0.1, 1)()
);
} else {
if (altSynthToggle) {
altSynth.triggerAttackRelease(
`${note}${octave}`,
// `${noteLength}n`,
"32n",
time,
d3.randomUniform(0.5, 1)()
);
}
}

membraneSynth.triggerAttackRelease(
`${chromaticScale[noteIndex]}${randFromArr([0, 1])}`,
"16n",
time,
d3.randomUniform(0.4, 0.8)()
);

bassSynth.triggerAttackRelease(
`${bassNote}${randFromArr([1, 2])}`,
"12n",
time + bassOffset,
d3.randomUniform(0.4, 1)()
);
}
Insert cell
// callback = (time) => {
// noteIndex < 11 ? mutable noteIndex++ : (mutable noteIndex = 0);

// if (randFromArr([0, 1])) {
// mutable note = randFromArr(scale.notes);
// // membraneSynth.triggerAttackRelease(
// // `${chromaticScale[noteIndex]}${randFromArr([0, 1])}`,
// // '16n',
// // time,
// // d3.randomUniform(0.4, 0.8)()
// // );
// }

// if (randFromArr([0, 1])) {
// synth.triggerAttackRelease(
// `${note}${randFromArr([3, 4, 5])}`,
// "32n",
// time,
// d3.randomUniform(0.1, 1)()
// );
// }

// // else {
// // altSynth.triggerAttackRelease(
// // `${note}${randFromArr([2, 3, 4, 5, 6])}`,
// // '16n',
// // time,
// // d3.randomUniform(0.5, 1)()
// // );
// // }

// // synth.triggerAttackRelease(
// // `${bassNote}${randFromArr([1, 2])}`,
// // '12n',
// // time + bassOffset,
// // d3.randomUniform(0.4, 1)()
// // );
// }
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
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