Programming Problems with JSyn
Please check the
List of Known Bugs
For sound quality issues, pops, clicks, distortion, etc., click
here.
Troubleshooting
If you get a "Null Pointer Exception", it might
be because:
-
you are using an object before it is created using "new",
-
or a method that returns an object has failed and returned a null but you
didn't check,
-
or you are attempting to use an Applet method like getParameter() in an
application run from main(),
-
or you forgot to EMBED
the plugin for Netscape browsers when running an Applet,
-
or the program aborted because of another problem and your objects
didn't get created.
If the sound continues after you leave
the Applet, it might be because:
-
you forgot to stop the units and call Synth.stopEngine() in your Applet's
stop() method.
If the scope or other windows stay open after
you leave the Applet, it might be because:
-
you forgot to call hide() on the scope dialog in your Applet's stop() method.
If you get an error "startEngine() not called"
or "invalid token"...
-
Either you forgot to call Synth.startEngine() before using JSyn,
-
or you are using a unit, sample, table or other SynthObject after it has
been got delete()d,
sineOsc.delete(); // deletes native component
associated with token
sineOsc.start(); // "invalid token" error
occurs
-
or when using Netscape Navigator, if you move from one page with a JSyn
Applet to another page with a JSyn Applet, the stop() function of the first
Applet and the start() method of the second Applet may run concurrently.
This could cause Synth.stopEngine() to get called right after
Synth.startEngine()
which will delete the native parts of the units. Try putting a couple calls
to Thread.yield() right before
Synth.startEngine(), or
use a unique SynthContext for your Applet so that you will be isolated
from other Applets..
If units suddenly stop making sound ...
Have you ever been playing a JSyn piece for 5 or 10 minutes and have the
sound suddenly stop? Here is a possible explanation.
In 'C', you allocate memory using malloc() and free it using free().
Java allocates memory for you when you use "new" to create an object or
an array. You do not explicitly free the memory in Java. Java detects when
there is no code that references the object and makes the object available
for garbage collection. There is a problem with JSyn objects in that they
have a native component that may be in use even when the Java level is
no longer referenced.
Consider the following piece of code:
class MyThang
{
LineOut lineOut;
void makeIt()
{
lineOut = new LineOut();
/* Note sineOsc not referenced outside this method! */
SineOScillator sineOsc = new SineOScillator();
sineOsc.output.connect( 0, lineOut.input, 0 );
sineOsc.start();
}
}
As long as you keep a reference to the MyThang then the lineOut will have
a reference and not be garbage collected. But the sineOsc is up for grabs
as soon as you exit makeIt(). There are no references even though the oscillator
is making sound. When Java decides to, which might be several minutes after
calling makeIt(), the SineOscillator will be deleted. This will cause the
native component to also be deleted and the sound will stop. This generally
not happen during testing if you run a short test. But as soon as you are
up on stage and playing for 5 or 10 minutes then the sound will sudenly
stop and you will be left staring at your laptop in puzzlement.
To prevent this, either declare all SynthObjects at the class level
instead of the method level, like "lineOut" versus "sineOsc" above. Or
call:
Synth.startEngine(0);
SynthObject.enableTracking(true);
which will cause a reference to all JSyn SynthObjects to be stored in
a vector to prevent any unexpected garbage collection. The delete() method
will delete the object and remove the reference from the vector. All tracked
objects that are left will be deleted automatically when you call Synth.stopEngine().
Or you can disable the ability of the garbage collector to delete the
native portion of SynthObjects. Try calling:
SynthObject.enableDeletionByGarbageCollector( false );
If your Applet works for Internet Explorer but fails, or gives a NullPointerException,
under Netscape...
You may be using an older obsolete version of Netscape,
or you forgot to EMBED
the plugin for Netscape browsers,
If you get a java.lang.OutOfMemoryError
Java objects and arrays that live inside the Java virtual machine are allocated
from a special Java heap. When you run out of memory, it is automatically
expanded. But you may eventually run out of physical or virtual memory.
Then you will get a "java.lang.OutOfMemoryError". If so then make sure
you are not saving references to objects that you no longer need. A typical
mistake is saving references to objects in Vectors while you use them but
forgetting to remove them when you are done. See also
"SynthException:
MemoryAllocationFailed".
If you cannot find an answer to your question on this website, then
please ask on the
JSyn
list.
© 2001 SoftSynth.com