[flocking] Newbie question

Colin Clark colin at colinclark.org
Mon Apr 4 19:21:09 UTC 2016


Hi Luke,

Totally good question!

Yes, you can set the "target" option of your click unit generator to an arbitrary selector or DOM node. So something like this:

var synth = flock.synth({
    synthDef: {
        ugen: "flock.ugen.sinOsc",
        freq: 440,
        mul: {
            ugen: "flock.ugen.asr",
            attack: 0.25,
            sustain: 0.25,
            release: 0.5,
            gate: {
                ugen: "flock.ugen.mouse.click",
                options: {
                    target: "#gfx"
                }
            }
        }
    }
});

This is a modified version of the example in the Flocking Playground, which will only trigger when the user clicks within the graphics region up at the top right of the page.

I hope this helps,

Colin


> On Apr 4, 2016, at 11:27 AM, Luke Sanger <lukesanger at gmail.com> wrote:
> 
> Hello,
> 
> I'm having some fun experimenting with flocking and have a quick question!
> 
> In my .js file I'm using "flock.ugen.mouse.click" to trigger my asr envelope.
> 
> All is working well, however I was wondering if there was a way to limit the area of the browser window (perhaps in a <div>) in which the "flock.ugen.mouse.click" can be active or not?
> 
> I'd basically like to have my flocking synth be triggered in a specific area of the browser (if that makes sense!), ideally in a specific <div>.
> 
> Apologies if this sounds un-technical, I'm not a web developer really and just messing about!
> 
> Many thanks,
> 
> Luke
> _______________________________________________
> flocking mailing list
> flocking at lists.idrc.ocad.ca
> http://lists.idrc.ocad.ca/mailman/listinfo/flocking



More information about the flocking mailing list