lichen-community-systems / Flocking

Flocking - Creative audio synthesis for the Web
GNU General Public License v2.0
695 stars 60 forks source link

flock.ugen.envGen does not retrigger its envelope if it only has two breakpoints #166

Open colinbdclark opened 8 years ago

colinbdclark commented 8 years ago

This issue was originally reported by a user on the Flocking mailing list. Thanks to Matt Diamond for discovering it.

It appears that flock.ugen.envGen fails to retrigger its envelope when only two breakpoints have been assigned. Here's a simple example, where you'll note that the pitch sweeps up only once, never retriggering when its gate passes back into the positive.

{
    "synthDef": {
        "ugen": "flock.ugen.sin",
        "freq": {
            "ugen": "flock.ugen.envGen",
            "envelope": {
                "levels": [60, 240],
                "times": [0.2]
            },
            "gate": {
                "ugen": "flock.ugen.lfPulse",
                "freq": 0.5
            }
        },
        "mul": 0.5
    }
}

This example with three breakpoints works correctly. You'll note that I've included a "dummy" breakpoint at the beginning with a duration of 0 in order to coerce the envGen into working correctly:

{
    "synthDef": {
        "ugen": "flock.ugen.sin",
        "freq": {
            "ugen": "flock.ugen.envGen",
            "envelope": {
                "levels": [0, 60, 240],
                "times": [0, 0.2]
            },
            "gate": {
                "ugen": "flock.ugen.lfPulse",
                "freq": 0.5
            }
        },
        "mul": 0.5
    }
}