Skip to content

Instantly share code, notes, and snippets.

@colinbdclark
Last active January 20, 2021 16:20
Show Gist options
  • Save colinbdclark/3a7c776d6494079d5563b9e894d6575f to your computer and use it in GitHub Desktop.
Save colinbdclark/3a7c776d6494079d5563b9e894d6575f to your computer and use it in GitHub Desktop.
Using Flocking's BufferLoader
fluid.defaults("bncfi.bufferLoader", {
gradeNames: "flock.bufferLoader",
sounds: ['MaxV - Conga Hi.wav', 'MaxV - Conga Lo.wav', 'MaxV - Conga Mi.wav',
'MaxV - Tom Hi.wav', 'MaxV - Tom Lo.wav', 'MaxV - Tom Mi.wav', 'MaxV - Kick2.wav', 'MaxV - Kick1.wav']
bufferDefs: {
expander: {
funcName: "bncfi.bufferLoader.mapSoundFileURLs",
args: ["{that}.options.sounds)"]
}
}
});
bncfi.bufferLoader.mapSoundFileURLs = function mapSoundFileURLs (sounds) {
sounds.map(function (url, idx) {
return {
id: idx,
src: url
};
});
};
fluid.defaults("bncfi.samplePlayerSynth", {
gradeNames: "flock.synth",
synthDef: {
ugen: "flock.ugen.out",
source: {
id: "player",
ugen: "flock.ugen.playBuffer",
buffer: 1,
speed: 1,
loop: 1,
start: 0,
end: 1
}
}
});
fluid.defaults("bncfi.composition", {
gradeNames: "fluid.component",
components: {
enviro: {
type: "flock.enviro"
},
bufferLoader: {
type: "bncfi.bufferLoader"
},
synth: {
type: "bncfi.samplePlayerSynth"
}
},
listeners: {
"afterBuffersLoaded.playSynth": "{synth}.play()"
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment