//
// You can find the Dittytoy API Reference here: https://Dittytoy.net/syntax
// Example ditties can be found here: https://dittytoy.net/user/Dittytoy
//
// Most of your ditty will run 44100 times per second using javascript in the browser.
// Make sure you optimize your ditty to work well on as many devices as possible. To do that, try to limit
// the number of simultaneously active synths: make sure they don't last longer than necessary, or you can
// hear them, and spread them over different loops (each loop runs in a separate worker).
//
ditty.bpm = 120;
loop( () => {
for (let i=0; i<4; i++) {
sine.play(c4, { attack: 0.01, release: 0.25, duration: 0.125, pan: Math.random() * 2 - 1, amp: 1.0 });
sleep( 0.25 );
}
sine.play(d4, { attack: 0.01, release: 0.25, duration: 0.25 }); // attack and release in seconds, duration in ticks
sleep(0.5); // sleep in ticks
sine.play(f4, { attack: 0.01, release: 0.75, duration: 0.25 });
sleep(0.5);
}, {name: 'my first loop' });
loop( () => {
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 break1 = Math.sin( this.phase1 * Math.PI * 2 );
this.phase2 += ditty.dt * input.freq2;
const break2 = Math.sin( this.phase2 * Math.PI * 2 );
this.phase3 += ditty.dt * input.freq3;
const break3 = Math.sin( this.phase3 * Math.PI * 2 );
const breakTotal = break1 + break2 + break3;
return [breakTotal, breakTotal]; // left, right
}
}).play(0, { env: one} );
}
);loop( () => {
var pattern = [
c3,1,0,0,g5,1,1,0,c3,1,0,0,c3,1,1,1,c3,1,0,0,g5,1,0,0,c3,1,1,1,c5,1,0,0,
c3,1,0,0,g5,1,1,0,c3,1,0,0,c3,1,1,1,c3,1,0,0,g5,1,0,0,c3,1,1,1,c5,1,0,0,
c3,1,0,0,g5,1,1,0,c3,1,0,0,c3,1,1,1,c3,1,0,0,g5,1,0,0,c3,1,1,1,c5,1,0,0,
c3,1,0,0,a5,1,1,0,c3,1,0,0,c3,1,1,1,c3,1,0,0,f5,1,0,0,c3,1,1,1,c5,1,0,0,
c3,1,0,0,f5,1,1,0,c3,1,0,0,c3,1,1,1,c3,1,0,0,f5,1,0,0,c3,1,1,1,c5,1,0,0,
c3,1,0,0,f5,1,1,0,c3,1,0,0,c3,1,1,1,c3,1,0,0,f5,1,0,0,c3,1,1,1,c5,1,0,0,
c3,1,0,0,f5,1,1,0,c3,1,0,0,c3,1,1,1,c3,1,0,0,f5,1,0,0,c3,1,1,1,c5,1,0,0,
c3,1,0,0,c5,1,1,0,c3,1,0,0,c3,1,1,1,c3,1,0,0,g5,1,0,0,c3,1,1,1,c5,1,0,0,
];
const pblep = (t, dt) => {
if(t < dt) {
t /= dt;
return t + t - t * t - 1;
}
else if (t > 1 - dt) {
t = (t - 1) / dt;
return t * t + t + t + 1;
}
return 0;
}
})
input.gate=.58; // min=.1,max=1,step=.02
input.tune=-18; // min=-24,max=24,step=.01
input.waveform=0.43;
input.cutoff=0.40;
input.resonance=0.69;
input.envmod=0.01;
input.decay=0.05;
input.overdrive=0.45;
input.echo = .8; // value=.8
ditty.bpm = 138;
class SVFilter {
constructor() {
this.lastLp = 0;
this.lastHp = 0;
this.lastBp = 0;
this.kf = 0.1;
this.kq = .1;
}
}