#16 Segmented envelope

The segmented envelope is the most flexible built-in envelope available in Dittytoy. You can set the number and levels of segments yourself and independently set the curvature value for each segment. This envelope is similar to the segmented envelope used in Super Collider.

doc.sccode.org/classes/env.html
dittytoy.net/syntax#envelopes

#dittytoy #tutorial

Log in to post a comment.

// #16 Segmented envelope (segenv). DittyToy 2022.
// The MIT License.
//
// https://dittytoy.net/ditty/ce63852ccf
//
// The segmented envelope is the most flexible built-in envelope available in Dittytoy. 
// You can set the number and levels of segments yourself and independently set the curvature 
// value for each segment. This envelope is similar to the segmented envelope used in 
// Super Collider.
//
// adsr      envelope: https://dittytoy.net/ditty/34e1600f63
// adsr2     envelope: https://dittytoy.net/ditty/0f2e4c2cdd
// segmented envelope: https://dittytoy.net/ditty/ce63852ccf
//
// https://doc.sccode.org/Classes/Env.html
// https://dittytoy.net/syntax#envelopes
//
 
input.duration      = 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, { 
        levels:         [0, 1, 0.5, 0],
        times:          [0.1, 0.1, 0.25],      // in seconds
        curves:         [0, -2, -2],           // you can also pass one number
        releaseNode:    2,                     // set to -1 if you don't want a releaseNode
        duration:       input.duration,        // in ticks 
        env:            segenv
    });
    sleep( input.duration + 1);
}, { name: 'Segmented enveloppe' }).connect( signalProbe.create() );