PDA

View Full Version : Adding values with JS (In Quartz Composer)



insaneacorn
01-10-2010, 01:12 PM
Hi guys im having a world of trouble doing simple JS in Quartz. I'm very new to this. All I need is a patch that will add two values and then output them. one value is an input which is constantly being changed from 0 - 1 by an audio peek and the other is just a number that I can set myself. this is a patch but it seems far too basic.


function (__number outputNumber) main (__number inputNumber[2])
{
var result = new Object();
result.outputNumber = inputNumber[0] + inputNumber[1];
return result;
}

And then its been changed a little to involve the math object:

function (__number outputNumber) main (__number inputNumber)

Math.prototype.addValues = function() {
{
var result = new Object();
result.outputNumber = 0;
for(i=0;i<arguments.length;i++)
{
result.outputNumber += arguments[i];
}
return result;
}

but this gives a syntax parse error.
So you can see whats going on and what context its in here is a screenshot of the parent level patch.
http://yfrog.com/1rpicture7op

I basically want to add a value of 0.2555 to the audio peek number (which changed from 0 to 1) so that there is always some alpha visibility on the next patch down.
JS is not my strong point, as you can tell (Im ace at acoustics though)

Sorry if im being an idiot and doing things wrong.
but thankyou!