[flocking-users] Multiple buffers

roger pibernat rogerpibernat at gmail.com
Wed Jan 29 11:48:40 EST 2014


Hi Colin,

I still have issues with the multiple buffers thing...  I tested your
solution and works great with 2 buffs, but when I add a third one, it gives
me this error:

   1. Uncaught TypeError: Cannot read property '0' of undefined
   flocking-ugens.js:1929<http://rogerpibernat.com/dev/pianoTeacher/src/libs/flocking/flocking/flocking-ugens.js>
      1. that.genflocking-ugens.js:1929<http://rogerpibernat.com/dev/pianoTeacher/src/libs/flocking/flocking/flocking-ugens.js>
      2. that.genflocking-core.js:903<http://rogerpibernat.com/dev/pianoTeacher/src/libs/flocking/flocking/flocking-core.js>
      3. that.genflocking-core.js:748<http://rogerpibernat.com/dev/pianoTeacher/src/libs/flocking/flocking/flocking-core.js>
      4. that.writeSamplesflocking-webaudio.js:64<http://rogerpibernat.com/dev/pianoTeacher/src/libs/flocking/flocking/flocking-webaudio.js>



This is my code:

var bufs = flock.synth({
    synthDef: [{
            id: "c1",
            ugen: "flock.ugen.playBuffer",
            buffer: {
                id: "buf-c1",
                url: "data/audio/piano-c1.wav"
            },
            trigger: {
                id: "trig-c1",
                ugen: "flock.ugen.valueChangeTrigger",
                source: 0.0
            }
        }
        , {
            id: "c2",
            ugen: "flock.ugen.playBuffer",
            buffer: {
                id: "buf-c2",
                url: "data/audio/piano-c2.wav"
            },
            trigger: {
                id: "trig-c2",
                ugen: "flock.ugen.valueChangeTrigger",
                source: 0.0
            }
        }
        , {
            id: "c3",
            ugen: "flock.ugen.playBuffer",
            buffer: {
                id: "buf-c3",
                url: "data/audio/piano-c3.wav"
            },
            trigger: {
                id: "trig-c3",
                ugen: "flock.ugen.valueChangeTrigger",
                source: 0.0
            }
        }]
});

function playSynth() {
    var rate = Math.pow(2, 3 / 12);
    console.log("playing synth at rates: " + rate);
    bufs.input("c1.speed", rate);
    bufs.set("trig-c1.source", 1.0);

    rate = Math.pow(2, 1 / 12);
    bufs.input("c2.speed", rate);
    bufs.set("trig-c2.source", 1.0);

    rate = Math.pow(2, 5 / 12);
    bufs.input("c3.speed", rate);
    bufs.set("trig-c3.source", 1.0);

    bufs.play();
}

Any hints?


Roger

(+34) 639 81 26 71
http://www.rogerpibernat.com
http:// <http://doodledeedoo.wordpress.com/>www.wucollective.com


On Thu, Jan 23, 2014 at 8:02 PM, roger pibernat <rogerpibernat at gmail.com>wrote:

> That did it!  Thanks again for your invaluable help.  I was putting them
> in different synthDefs (and variables) and it didn't work, althought they
> had different IDs.  Now it works wonders!
>
> Cheers
>
>
> Roger
>
> (+34) 639 81 26 71
> http://www.rogerpibernat.com
> http:// <http://doodledeedoo.wordpress.com/>www.wucollective.com
>
>
> On Thu, Jan 23, 2014 at 4:50 PM, Colin Clark <colin at colinclark.org> wrote:
>
>> Hi Roger,
>>
>> There are no limitations in terms of the number of audio buffers that can
>> be loaded simultaneously. One thing you might want to check is that you're
>> using the same "id" for two different buffers. If you use ids , they need
>> to be unique. Otherwise, the buffer will be overwritten. So check if your
>> buffer ids are unique, or remove them.
>>
>> Here's an example of a synth that plays a different audio buffers in the
>> left and right speakers:
>>
>> https://gist.github.com/colinbdclark/8580936
>>
>> If this doesn't solve your problem, can you send the along code you're
>> having trouble with?
>>
>> Colin
>>
>> On Jan 23, 2014, at 6:39 AM, roger pibernat <rogerpibernat at gmail.com>
>> wrote:
>>
>> > I've been trying to create 2 playBuffer synths with different sizes.
>>  But when playing them I can only hear the first one.  Is there some kind
>> of restriction that only allows one audio file to be loaded?
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.idrc.ocad.ca/pipermail/flocking/attachments/20140129/d68e899a/attachment.html>


More information about the flocking mailing list