com.softsynth.jsyn
Class SynthObject

java.lang.Object
  extended by java.util.Observable
      extended by com.softsynth.jsyn.SynthObject
Direct Known Subclasses:
SynthChannelData, SynthSound, SynthTable

public class SynthObject
extends java.util.Observable

Root class for all JSyn units, samples, envelopes, etc. SynthObject deletes its native peers when deleted.
This class used to keep a list of all SynthObjects created to prevent unexpected garbage collection. Now that list is kept in the SynthContext.

Version:
JSyn Version 005
Author:
(C) 1997 Phil Burk, SoftSynth.com, All Rights Reserved
See Also:
Synth, SynthUnit

Constructor Summary
SynthObject(SynthContext context)
           
 
Method Summary
 void delete()
          Delete the native structure that is associated with this object.
static void deleteAll()
          Delete all units, SynthSamples, SynthEnvelopes and other Synth objects created since Synth.startEngine() was called.
static void enableDeletionByGarbageCollector(boolean ifEnabled)
          Note: call this method if you are using a global SynthContext, in other words if you called "Synth.startEngine()".
static void enableTracking(boolean ifTrack)
          Request that all SynthObjects created by the currently executing thread be automatically tracked when created, or not.
 int getPeer()
           
 SynthContext getSynthContext()
           
static boolean isTrackingEnabled()
           
 java.lang.String toString()
           
 void track()
          Keep a reference to this object in a vector in the SynthContext class.
 
Methods inherited from class java.util.Observable
addObserver, countObservers, deleteObserver, deleteObservers, hasChanged, notifyObservers, notifyObservers
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

SynthObject

public SynthObject(SynthContext context)
Method Detail

getSynthContext

public SynthContext getSynthContext()

isTrackingEnabled

public static boolean isTrackingEnabled()

enableTracking

public static void enableTracking(boolean ifTrack)
Request that all SynthObjects created by the currently executing thread be automatically tracked when created, or not. Calls can be nested.

See Also:
track

track

public void track()
Keep a reference to this object in a vector in the SynthContext class. This will prevent the garbage collector from accidentally deleting a JSyn object that is active but not referenced by any other Java objects. It also allows the object to be deleted automatically by stopEngine() or by calling deleteAll().


getPeer

public int getPeer()
            throws SynthException
Throws:
SynthException

deleteAll

public static void deleteAll()
                      throws SynthException
Delete all units, SynthSamples, SynthEnvelopes and other Synth objects created since Synth.startEngine() was called. This will be called automatically by Synth.stopEngine().

Throws:
SynthException

delete

public void delete()
            throws SynthException
Delete the native structure that is associated with this object. Also removes the object from the list kept by the SynthObject class for the deleteAll() method.

Throws:
SynthException - If token already deleted.

enableDeletionByGarbageCollector

public static void enableDeletionByGarbageCollector(boolean ifEnabled)
Note: call this method if you are using a global SynthContext, in other words if you called "Synth.startEngine()". If you are using your own specific SynthContext, in other words if you called "mySynthContext.start()", then use "mySynthContext.enableDeletionByGarbageCollector(f)" instead.

Enable deletion of the native portion of SynthObjects (eg. units and samples) when the Java portion is deleted by the Garbage Collector.
Warning: enabling this can cause unexpected removal of objects that may be making sound but are no longer referenced by Java. The sudden silence can be embarassing.
Warning: disabling this can cause native resources to accumulate unless you explicitly delete them using their delete() method. This can consume memory and cause memory allocation to fail.
The safest thing to do is to disable this and delete() your own objects when you are through using them.

Parameters:
ifEnabled - set true to enable deletion, false to disable, default is true
See Also:
Synth.getObjectCount

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object