/    Sign up×
Community /Pin to ProfileBookmark

Adding / Math with JS (Quartz)

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 chamging from 0 – 1 with 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;
}

Is there a way to ammend this to use the Math object? (I need to use JS, I know I could use a math patch from Quartz but JS is something I need to use within this patch).

Sorry for asking a probably simple question.

to post a comment
JavaScript

3 Comments(s)

Copy linkTweet thisAlerts:
@WebnerdJan 09.2010 — <i>
</i>Math.prototype.addValues = function() {
{
var result = new Object();
result.outputNumber = 0;
for(i=0;i&lt;arguments.length;i++)
{
result.outputNumber += arguments[i];
}
return result;
}


<i>
</i>
alert(Math.addValues(1,2,3,4,5,6).outputNumber)

Copy linkTweet thisAlerts:
@InsaneAcornauthorJan 10.2010 — Thanks, that looks better =D

Although Quartz is telling me 'Incorrect or missing "Main" value'

Ive added a screenshot so you can see whats going on in the first level of my 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!
Copy linkTweet thisAlerts:
@InsaneAcornauthorJan 10.2010 — Ive changed it a little so it looks correct in quartz. but now im stuck again.

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.





Any ideas?
×

Success!

Help @InsaneAcorn spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.10,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...