[flocking-users] envelope loop with different durations

Colin Clark colin at colinclark.org
Sat Jan 10 13:28:54 EST 2015


Hi again Antonio,

Good question! There are a couple of ways to achieve what you want. Probably the easiest is to use something like a square wave to control the gate to your envelope. The frequency of your square wave will determine the duration of the envelope. Here's an example I whipped up:

https://gist.github.com/colinbdclark/e9dfd34f7f9cf8f9c0f4

If you look at the "source" input of the Moog filter you'll see I've got a sawtooth oscillator that has its amplitude connected to an ADSR envelope. The gate of the ADSR envelope is triggered by a square wave. I'm reading the durations of the envelope from a "sequence" unit generator, which just pulls values out of a list and loops. Here's a simplified version, just so it's clear what's going on:

flock.synth({
    synthDef: {
        ugen: "flock.ugen.lfSaw",
        freq: 120,
        mul: {
            ugen: "flock.ugen.envGen",
            envelope: "flock.envelope.adsr",
            gate: {
                ugen: "flock.ugen.lfPulse",
                width: 1.0,
                freq: {
                    ugen: "flock.ugen.sequence",
                    freq: 1,
                    list: [1, 2, 3, 4, 2, 1, 3],
                    loop: 1.0
                }
            },
            mul: 0.25
        }
    } 
});

You can also, if you need to do some very complex processing, use the triggerCallback unit generator along with the impulse unit generator (which acts as a metronome) to call a function at a certain time. It's fairly well-documented here:

https://github.com/colinbdclark/Flocking/blob/master/docs/ugens/triggers.md
http://flockingjs.org/demos/interactive/html/playground.html#triggerCallback

In terms of documentation of the unit generators, it's still quite rudimentary. I'm going to make a push to write at least basic documentation for all the built-in unit generators for the 0.1.0 release, which is coming soon. In the meantime, I know it's a terrible inconvenience. You will probably find it helpful to flip through the unit generator source code and look at comments as well as the various "defaults blocks," which list all the inputs and options that a unit generator has. Here's an example:

https://github.com/colinbdclark/Flocking/blob/master/flocking/flocking-ugens.js#L3876-L3906

I will definitely be improving the documentation soon, and if anyone wants to help contribute to the effort, let me know.

I hope this helps,

Colin


> On Jan 10, 2015, at 9:37 AM, Antonio Della Marina <antonio.dellamarina at gmail.com> wrote:
> 
> Hello :)
> 
> I am trying my first flocking synth, after several unsuccessful tries I need a clue from you.
> I want to have a looped envelope, passing each repetition a different envelope duration. The loop should be infinite.
> I am looking at the way to call a function when an envelope ends, but maybe that's not the right direction.
> 
> Also, maybe I am not looking in the right place, but is there any reference guide? How can I know the possible functions available for a ugen or object?
> I hope I explained myself, I am not a programmer and so I apologize for any silly question I might ask and I thank you for your time and patience.
> 
> A.
> 
> _______________________________________________
> users mailing list
> users at lists.flockingjs.org
> http://lists.flockingjs.org/listinfo.cgi/users-flockingjs.org




More information about the flocking mailing list