Skip to content

Instantly share code, notes, and snippets.

@colinbdclark
Last active November 6, 2017 01:03
Show Gist options
  • Save colinbdclark/ff036ffb9b79a5ddb27c199aec09f8ff to your computer and use it in GitHub Desktop.
Save colinbdclark/ff036ffb9b79a5ddb27c199aec09f8ff to your computer and use it in GitHub Desktop.
Dynamically creating synths based on a source array
fluid.defaults("adam.noiseSynth", {
gradeNames: "flock.synth",
freq: 300,
synthDef: {
ugen: "flock.ugen.sum",
sources: {
ugen: "flock.ugen.filter.biquad.bp",
freq: "{that}.options.freq",
q: 1,
source: {
ugen: "flock.ugen.whiteNoise"
}
}
}
});
fluid.defaults("adam.noiseBand", {
gradeNames: "flock.band",
numFreqBands: 10,
bandFreqMul: 100,
baseFreq: 300,
noiseFrequencies: {
expander: {
funcName: "adam.noiseBand.generateFrequencies",
args: [
"{that}.options.numFreqBands",
"{that}.options.bandFreqMul",
"{that}.options.baseFreq"
]
}
},
dynamicComponents: {
noiseSynth: {
sources: "{that}.options.noiseFrequencies",
type: "adam.noiseSynth",
options: {
freq: "{source}"
}
}
}
});
adam.noiseBand.generateFrequencies = function (numFreqBands, bandFreqMul, baseFreq) {
return fluid.generate(numFreqBands, function (i) {
return (bandFreqMul * i) + baseFreq;
}, true);
};
window.band = adam.noiseBand();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment