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

Colin Clark colin at colinclark.org
Tue Jul 7 09:08:53 EDT 2015


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 <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

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idrc.ocad.ca/pipermail/flocking/attachments/20150707/85ec5652/attachment.html>


More information about the flocking mailing list