...

View Full Version : I need help writing some java code



Aaron h
07-24-2011, 10:04 PM
Ok, so i need help writing a java script that will look at a bunch of numbers and output the highest one so what i need is for it to do something like this.

(A is my input value)
(B is my output value)
the (A) value will be constantly changing and with the script has to do is look at all of those values and output them to (b)


if anyone knows how to do this i would be so grateful if they could write the code for me because i'm new to coding and i really need this to work.
thanks.

BluePanther
07-25-2011, 12:45 AM
sounds very much like a piece of school homework haha. What variable type is (A)? Array?

Aaron h
07-25-2011, 03:25 AM
sounds very much like a piece of school homework haha. What variable type is (A)? Array?
well it's not homework, it's for a audio interactive motion graphic.
and i don't know what type variable (A)
(A) will be the audio level input ranging from 0 to 1 so (A) will be any # between 0 and 1
and i need it to tell me the highest audio level

Old Pedant
07-25-2011, 03:36 AM
Ummmm...you are asking for JAVA help. This is the JavaSCRIPT forum. About the only thing the two languages have in common are the first 4 letters of their names.

So which is it you really need? If it's really Java, then try the Java forum.

Aaron h
07-25-2011, 03:47 AM
this is the Java form

DanInMa
07-25-2011, 04:15 AM
nope.

Aaron h
07-25-2011, 04:16 AM
oh well can you guys help me out anyways?

Old Pedant
07-25-2011, 04:30 AM
Well, the code (in any language) is trivial. But the means of *displaying* the results will be completely different in the different languages.

And you don't say where/how your stream of "A" values is coming from. Is it some port that the code needs to sample (a) as fast as possible, (b) once a millisecond, (c) once an hour, (d) or what?

But the basic code is surely something like

double maxA = 0;
while ( true )
{
double a = readNewA( );
if ( a > maxA ) maxA = a;
}

But now you need to figure out how to display maxA. You need to code readNewA. And...

The devil is in the details.

Aaron h
07-25-2011, 04:59 AM
well, the value of (A) is coming from a live audio feed (audio input on the computer) witch is being piped into this Java script. and i just want it to be display it as a number. like a simple equation # goes in on (A) max # comes out on (B)

sorry i'm new to java and i really need this to work.

Old Pedant
07-25-2011, 05:19 AM
I have NO IDEA how you can read the (volume?) of an audio feed. I would assume you need an A-to-D converter. But for the rest of it...if you don't know the details (e.g., how often you will sample the value), how can you expect us to know.

And you haven't given an inkling of how you intend to display the B value.

Aaron h
07-25-2011, 05:27 AM
yes i do have an A to D converter, it need to sample it as fast as possible, and i just need it too look at the level and find the max level and output it as a # thats it

Aaron h
07-25-2011, 05:48 AM
Never mind i got it to work thank you so much you saved my butt like no joke



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum