// Forked from "#10 Minimal Sound Wave" by Dittytoy
// https://dittytoy.net/ditty/80910da4d2
// #10 Minimal Sound Wave. DittyToy 2022.
// The MIT License.
//
// https://dittytoy.net/ditty/80910da4d2
//
// If you want to write a function that generates the entire sound wave of your ditty, you can.
// In that case, use this boilerplate and get started.
//
input.freq1 = 600; // min=100, max=2000, step=1
input.freq2 = 600; // min=100, max=2000, step=1
input.freq3 = 600; // min=100, max=2000, step=1
synth.def( class {
constructor (options) {
this.phase1 = 0;
this.phase2 = 0;
this.phase3 = 0;
}
process(note, env, tick, options) {
this.phase1 += ditty.dt * input.freq1;
const wave1 = Math.sin( this.phase1 * Math.PI * 2 );
this.phase2 += ditty.dt * input.freq2;
const wave2 = Math.sin( this.phase2 * Math.PI * 2 );
this.phase3 += ditty.dt * input.freq3;
const wave3 = Math.sin( this.phase3 * Math.PI * 2 );
const waveTotal = wave1 + wave2 + wave3;
return [waveTotal, waveTotal]; // left, right
}
}).play(0, { env: one} );