#10 Minimal Sound Wave

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.

#dittytoy #tutorial

Log in to post a comment.

// #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.freq = 600; // min=100, max=2000, step=1

synth.def( class {
    
    constructor (options) {
        this.phase = 0;
    }
    
    process(note, env, tick, options) {
        this.phase += ditty.dt * input.freq;
        const wave = Math.sin( this.phase * Math.PI * 2 );
        
        return [wave, wave]; // left, right
    }
    
}).play(0, { env: one} );