Re: Wrapper for combination of nodes

Thanks for that Chris! Matt's right though sadly, we'd lose "this".

Looks like there's going to be a lot of sad kids on Christmas day when they
try to send each other the Web Audio patches they made on their new
computers. Chromebooks in the bin by Boxing Day. All because there's no
GraphNode. :)


On 18 December 2012 18:21, Matt Diamond <
matt.diamond@environmentalaesthetics.com> wrote:

> Not sure if that solution would work... as I understand it, returning a
> non-primitive from a constructor function will essentially discard the
> initial object referred to by "this", so the result of "new MyCustomNode"
> would be a gain node without "this.input" or "this.connect."
>
> Matt
> On Dec 18, 2012 3:11 AM, "Chris Lowis" <chris.lowis@bbc.co.uk> wrote:
>
>>
>> > I'm struggling to find a decent solution to packaging a group of nodes
>> > together in a way that can be used similarly to native nodes. For
>> example,
>> > the recent Jam with Chrome article on html5rocks does this :
>> >
>> > var MyCustomNode = function(){
>> >     this.input = audioContext.createGainNode();
>> >     var output = audioContext.createGainNode();
>> >
>> >     this.connect = function(target){
>> >        output.connect(target);
>> >     };
>> > };
>>
>> Hi Stuart!
>>
>> Could you return output from your MyCustomNode function?
>>
>>   var MyCustomNode = function(){
>>       this.input = audioContext.createGainNode();
>>       var output = audioContext.createGainNode();
>>
>>       this.connect = function(target){
>>          output.connect(target);
>>       };
>>
>>       return output;
>>   };
>>
>> I think this would let you do:
>>
>>  gain.connect(customNode);
>>
>> If I understand correctly what you mean.
>>
>> Cheers,
>>
>> Chris
>>
>> http://www.bbc.co.uk/
>> This e-mail (and any attachments) is confidential and may contain
>> personal views which are not the views of the BBC unless specifically
>> stated.
>> If you have received it in error, please delete it from your system.
>> Do not use, copy or disclose the information in any way nor act in
>> reliance on it and notify the sender immediately.
>> Please note that the BBC monitors e-mails sent or received.
>> Further communication will signify your consent to this.
>>
>>
>>

Received on Tuesday, 18 December 2012 23:15:31 UTC