The ADSR2 envelope is added to Dittytoy to have an envelope compatible with the default envelope used in Sonic Pi. The ADSR2 envelope works similarly to the ADSR envelope, but the most significant difference is that all durations are in ticks.
sonic-pi.net/tutorial.html#section-2-4
dittytoy.net/syntax#envelopes
#dittytoy #tutorial
Log in to post a comment.
// #15 ADSR2 enveloppe. DittyToy 2022. // The MIT License. // // https://dittytoy.net/ditty/0f2e4c2cdd // // The ADSR2 envelope is added to Dittytoy to have an envelope compatible with the default envelope // used in Sonic Pi. The ADSR2 envelope works similarly to the ADSR envelope, but the most // significant difference is that all durations are in ticks. // // adsr envelope: https://dittytoy.net/ditty/34e1600f63 // adsr2 envelope: https://dittytoy.net/ditty/0f2e4c2cdd // segmented envelope: https://dittytoy.net/ditty/ce63852ccf // // https://sonic-pi.net/tutorial.html#section-2-4 // https://dittytoy.net/syntax#envelopes // input.attack_time = 0.1; // min=0, max=0.2, step=0.001 input.attack_level = 1; // min=0, max=1, step=0.001 input.decay_time = 0.2; // min=0, max=2, step=0.001 input.decay_level = 0.75; // min=0, max=1, step=0.001 input.sustain_time = 0; // min=0, max=2, step=0.001 input.sustain_level = 0.5; // min=0, max=1, step=0.001 input.release = 0.5; // min=0, max=2, step=0.001 // signalProbe - by athibaul const signalProbe = filter.def( class { process(input) { debug.probe('signal', input[0]+input[1], 2, 1); return input; } }); loop( () => { sine.play(c, { attack: input.attack_time, // in ticks attack_level: input.attack_level, decay: input.decay_time, // in ticks decay_level: input.decay_level, sustain: input.sustain_time, // in ticks sustain_level: input.sustain_level, release: input.release, // in ticks env: adsr2 }); sleep( input.attack_time + input.decay_time + input.sustain_time + input.release + 1); }, { name: 'ADSR2 envelope' }).connect( signalProbe.create() );