Skip to content

Instantly share code, notes, and snippets.

@colinbdclark
Last active June 20, 2016 17:44
Show Gist options
  • Save colinbdclark/0bd443589eec51d0756bff736e6c346d to your computer and use it in GitHub Desktop.
Save colinbdclark/0bd443589eec51d0756bff736e6c346d to your computer and use it in GitHub Desktop.
Example of how to use buses in Flocking
/**********************
* For Flocking 0.1.x:
**********************/
var interconnectBus = flock.enviro.shared.acquireNextBus("interconnect");
var snare = flock.synth({
synthDef: {
ugen: "flock.ugen.out",
bus: interconnectBus,
expand: 1,
sources: {
ugen: "flock.ugen.impulse",
freq: {
ugen: "flock.ugen.lfNoise",
freq: 1/3,
mul: 0.5,
add: 0.5
},
mul: 1.5
}
}
});
var lead = flock.synth({
synthDef: {
ugen: "flock.ugen.out",
bus: interconnectBus,
expand: 1,
sources: {
ugen: "flock.ugen.square",
freq: {
ugen: "flock.ugen.sequence",
freq: 1.2,
loop: 1,
list: [90, 165, 110]
},
mul: {
ugen: "flock.ugen.asr",
attack: 0.01,
sustain: 0.1,
decay: 0.01,
gate: {
ugen: "flock.ugen.lfPulse",
freq: {
ugen: "flock.ugen.lfNoise",
freq: 1/2,
mul: 0.5,
add: 0.5
},
width: 0.15
},
mul: 1
}
}
}
});
var effectsSynth = flock.synth({
synthDef: {
ugen: "flock.ugen.freeverb",
mix: 1,
room: 0.75,
damp: 1,
source: {
// Read from the interconnect bus.
ugen: "flock.ugen.in",
bus: interconnectBus
}
}
});
/*************************************************************************************************
* If you're using the master branch, which will be Flocking 0.2.x, the API has changed slightly:
*************************************************************************************************/
var interconnectBus = flock.environment.busManager.acquireNextBus("interconnect");
var snare = flock.synth({
synthDef: {
ugen: "flock.ugen.out",
bus: interconnectBus,
expand: 1,
sources: {
ugen: "flock.ugen.impulse",
freq: {
ugen: "flock.ugen.lfNoise",
freq: 1/3,
mul: 0.5,
add: 0.5
},
mul: 1.5
}
}
});
var lead = flock.synth({
synthDef: {
ugen: "flock.ugen.out",
bus: interconnectBus,
expand: 1,
sources: {
ugen: "flock.ugen.square",
freq: {
ugen: "flock.ugen.sequence",
freq: 1.2,
loop: 1,
values: [90, 165, 110]
},
mul: {
ugen: "flock.ugen.asr",
attack: 0.01,
sustain: 0.1,
decay: 0.01,
gate: {
ugen: "flock.ugen.lfPulse",
freq: {
ugen: "flock.ugen.lfNoise",
freq: 1/2,
mul: 0.5,
add: 0.5
},
width: 0.15
},
mul: 1
}
}
}
});
var effectsSynth = flock.synth({
addToEnvironment: "tail",
synthDef: {
ugen: "flock.ugen.freeverb",
mix: 1,
room: 0.75,
damp: 1,
source: {
// Read from the interconnect bus.
ugen: "flock.ugen.in",
bus: interconnectBus
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment