Dittytoy
書式
code:js
ditty.bpm = 120;
loop( () => {
sine.play( c4, { attack: 0.01, release: 0.25, duration: 1.0 } );
sleep( 2.0 );
}, { name: 'my ditty' } );
Synthの定義
code:javascript
// phase: t * freq
// env: the current voltage of the envelope
// tick: the time * bps since the note on
// options: optional parameters it received
const mySynth = synth.def( ( phase, env, tick, options ) => {
const gain = options.gain ?? 1.5;
return Math.tanh( gain * Math.sin( TAU * phase ) );
} );
Debug
code:javascript
// log lines are reused for each labels, easy to debug continuous values
debug.log( label, message );
debug.warn( label, message );
debug.error( label, message );
// debug.probe displays an oscilloscope for each labels
debug.probe( label, value, amp, duration );