We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
IndexProgramming Questions & HelpIntegration › Processing + Java
Page Index Toggle Pages: 1
Processing + Java (Read 1547 times)
Processing + Java
Nov 9th, 2006, 2:29am
 
I'm regularly using Java code in Processing without any problems so far. But now I've got an semantic error for the following line of Java code

DataLine.Info info = new DataLine.Info(SourceDataLine.class, format);

It seems that Processing doesn't understand the method "class" here. So I wonder if any restrictions regarding Java code in Processing are known and documented somewhere.


Re: Processing + Java
Reply #1 - Nov 9th, 2006, 11:04am
 
Where does this method come from, and what's the actual error?
Re: Processing + Java
Reply #2 - Nov 9th, 2006, 11:21am
 
The code above is part of a standard Java program reading an audio file.
It works well when compiled with javac on Mac OS X.

I'm trying to use it in Processing after importing
import java.io.File;
import javax.sound.sampled.*;

But I get the following error message:

Semantic Error: No applicable overload was found for a constructor with signature
"Info(??)" in type "javax.sound.sampled.DataLine$Info".
Perhaps you wanted the overloaded version
"Info(java.lang.Class $1, javax.sound.sampled.AudioFormat $2);" instead?

So I'm just guessing that the method name "class" may cause confusion.

Re: Processing + Java
Reply #3 - Nov 9th, 2006, 12:13pm
 
1: to use class as a method it'd need () on the end.
2: What I think you actually want is getClass() not class(), since getClass returns the Class of the object.
2: As far as I can tell "SourceDataLine" is an interface, not a class, so you need to create your own class that implements it and pass that.
Re: Processing + Java
Reply #4 - Nov 9th, 2006, 1:35pm
 
Thanks for your suggestions. But I'm puzzled that my code is understood by the standard Java compiler. And it's also used in some 'official' example code like this

http://www.jsresources.org/examples/SimpleAudioPlayer.java.html

Re: Processing + Java
Reply #5 - Nov 9th, 2006, 7:43pm
 
the preprocessor isn't perfect, unfortunately.
Re: Processing + Java
Reply #6 - Nov 9th, 2006, 8:47pm
 
Thanks fry for clarifying. I was just exploring to combine some of my existing JavaSound programs with the graphics of Processing. I'm really amazed how well it worked so far considering that Java's low level sound processing it quite tricky. But generally I think that using Processing with a library like Sonia (JSyn) is more convenient and powerful anyway.

Page Index Toggle Pages: 1