[flocking] changing synth def, smoothing clicks and midi key input

Adam Tindale adamrtindale at gmail.com
Wed Jul 8 13:33:44 EDT 2015

Hi Elliot,

I have a few repos that use the .set method to change the .mul of a UGEN.

Here is one where in synth.js I create a NoteOn and NoteOff function that
set the .mul.


This is probably going to be the more useful example. It creates a chrome
app that takes the keyboard and assigns a sinOsc to each one and then has a
simpleASR envelope triggered with each keypress.


This repo does something similar to the first, but gives another example of
a way of getting there.


Hopefully some of this is useful.


On Tue, 7 Jul 2015 at 06:09 Colin Clark <colin at colinclark.org> wrote:

> Hi Elliott,
> On Jul 7, 2015, at 7:01 AM, Elliott Fienberg <mrtunes at GMAIL.COM> wrote:
> is it possible to change the synth def while it's playing?
> Yes, you can call the set() method to change a synth's unit generator
> graph on the fly. Here's an example:
> var synth = flock.synth({
>     synthDef: {
>         id: "carrier",
>         ugen: "flock.ugen.sinOsc",
>         mul: 180,
>         freq: 440,
>         mul: 0.25
>     },
>     addToEnvironment: false // This tells Flocking not to start playing
> this synth right away.
> });
> // Change the synth from a regular sine tone to AM synthesis
> // by inserting a new sinOsc ugen as the "mul" input to the carrier
> synth.set("carrier.mul", {
>     id: "modulator",
>     ugen: "flock.ugen.sinOsc",
>     freq: 60,
>     mul: 0.25
> });
> also in this example, i have the synth play and pause on drag. there is
> clicking - so i'm wondering if it's better practise to have the synth
> always playing, and the clicking initiates volume (with a smoothed
> envelope). this would likely be how things work if you had a midi keyboard
> plugged in, correct?
> It sounds like you want an envelope on your synth's amplitude. There are
> examples and documentation here:
> *https://github.com/colinbdclark/Flocking/issues/8#issuecomment-108712105
> <https://github.com/colinbdclark/Flocking/issues/8#issuecomment-108712105>*
> In short, envelopes are controlled by a gate signal. When the gate's value
> is > 0.0, the envelope will start its attack phase. When the gate drops
> below 0.0, it will release.
> You can control a gate manually by calls to set(), or you can modulate it
> with something like an lfPulse wave or other unit generator.
> speaking of which, are there any examples of midi input playing a flocking
> synth?
> Right now, this Gist is probably the simplest example:
> https://gist.github.com/colinbdclark/a96e4a8a6c54ce6abf0d
> I think Adam Tindale has some examples of MIDI in his repository as well.
> A lot of work is going on to improve MIDI in version 2.0, and I'll hugely
> improve the demos and documentation when it is close to release. In the
> meantime, I can answer questions or whip up examples on the fly for you.
> Colin
> _______________________________________________
> flocking mailing list
> flocking at lists.idrc.ocad.ca
> http://lists.idrc.ocad.ca/cgi-bin/mailman/listinfo/flocking
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idrc.ocad.ca/pipermail/flocking/attachments/20150708/51ff1190/attachment.html>

More information about the flocking mailing list