[flocking-users] Multiple buffers

roger pibernat rogerpibernat at gmail.com
Wed Jan 29 12:50:51 EST 2014


Just tested it and works wonders.  Thanks!


Roger

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


On Wed, Jan 29, 2014 at 6:39 PM, roger pibernat <rogerpibernat at gmail.com>wrote:

> Ah!  I see.  Makes total sense.  It sure does help!  It's just like in
> Supercollider.  I should've guessed it, sorry.
>
> I'll give it a go.  Thanks a lot again!
>
>
> Roger
>
> (+34) 639 81 26 71
> http://www.rogerpibernat.com
> http:// <http://doodledeedoo.wordpress.com/>www.wucollective.com
>
>
> On Wed, Jan 29, 2014 at 6:33 PM, Colin Clark <colin at colinclark.org> wrote:
>
>> Hi Roger,
>>
>> I should definitely improve that error message, sorry.
>>
>> As a convenience to users (assuming it is indeed convenient, I'm worried
>> it's a bit confusing), Flocking will automatically insert an "out" unit
>> generator if one is omitted. If you specify a single unit generator tree,
>> this will be interpreted as a single channel and the "out" unit generator
>> will be expanded to both the left and right channels. If, however, you
>> specify an array at the top level of your synthDef, the system interprets
>> these as multiple channels.
>>
>> If you notice, your synthDef starts with an array. The framework
>> interprets this as a shorthand form of this:
>>
>> {
>>   ugen: "flock.ugen.out",
>>   sources: [
>>     { ... } , // Unit generators to output on channel 0 (i.e. the left
>> channel)
>>
>>     { ... }  // Unit generators to output on channel 1 (i.e. the right
>> channel)
>>   ]
>> }
>>
>> In your case, you've got three unit generators being output to three
>> different channels. I don't know if you're using a multichannel audio
>> device and intending to output 3 distinct channels or not. If you are,
>> Flocking is by default configured for only 2 channel stereo output, which
>> is why you're getting the error. I need to improve the error messages so
>> that it explains what's going on--I apologize for the confusion.
>>
>> If you want more than two channels of output, you'll have to initialize
>> Flocking with more output buses like this:
>>
>> flock.init({
>>   numBuses: 4 // For four-channel output. If the device supports less
>> than four channels, the topmost buses will be available for inter-synth
>> communication.
>> });
>>
>> If, however, you've only got a stereo device and just want to mix three
>> different unit generators together on one channel, you'll need to use the
>> "sum" unit generator like this:
>>
>> synthDef: {
>>   id: "sum",
>>   ugen: "flock.ugen.sum",
>>   sources: [
>>     { id: "c1", ... },
>>     { id: "c2", ... },
>>     { id: "c3", ... }
>>   ]
>> }
>>
>> I hope this helps,
>>
>> Colin
>>
>> On Jan 29, 2014, at 11:48 AM, roger pibernat <rogerpibernat at gmail.com>
>> wrote:
>>
>> > 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:
>> >       * Uncaught TypeError: Cannot read property '0' of undefined
>> flocking-ugens.js:1929
>> >               * that.genflocking-ugens.js:1929
>> >               * that.genflocking-core.js:903
>> >               * that.genflocking-core.js:748
>> >               * that.writeSamplesflocking-webaudio.js:64
>> >
>> >
>> > 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://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://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/b26fbef2/attachment.html>


More information about the flocking mailing list