ptolemy.actor.lib.javasound
Class LiveSoundActor

java.lang.Object
  extended byptolemy.kernel.util.NamedObj
      extended byptolemy.kernel.InstantiableNamedObj
          extended byptolemy.kernel.Entity
              extended byptolemy.kernel.ComponentEntity
                  extended byptolemy.actor.AtomicActor
                      extended byptolemy.actor.TypedAtomicActor
                          extended byptolemy.actor.lib.javasound.LiveSoundActor
All Implemented Interfaces:
ptolemy.actor.Actor, ptolemy.kernel.util.Changeable, java.lang.Cloneable, ptolemy.kernel.util.Debuggable, ptolemy.kernel.util.DebugListener, ptolemy.kernel.util.Derivable, ptolemy.actor.Executable, ptolemy.kernel.util.Instantiable, LiveSoundListener, ptolemy.kernel.util.ModelErrorHandler, ptolemy.kernel.util.MoMLExportable, ptolemy.kernel.util.Nameable, java.io.Serializable, ptolemy.actor.TypedActor
Direct Known Subclasses:
AudioCapture, AudioPlayer

public class LiveSoundActor
extends ptolemy.actor.TypedAtomicActor
implements LiveSoundListener

This actor forms a base class for actors that interact with real-time sound through the ptolemy.media.LiveSound class. This class manages the parameters for live sound.

Note: Requires Java 2 v1.3.0 or later.

Since:
Ptolemy II 4.0
Version:
$Id: LiveSoundActor.java,v 1.11 2004/04/13 03:21:39 cxh Exp $
Author:
Steve Neuendorffer
See Also:
LiveSound, AudioPlayer, AudioCapture, Serialized Form
Accepted Rating:
Yellow (chf)
Proposed Rating:
Green (neuendor)

Nested Class Summary
 
Nested classes inherited from class ptolemy.kernel.Entity
ptolemy.kernel.Entity.ContainedObjectsIterator
 
Field Summary
protected  int _channels
           
protected  boolean _isExecuting
           
protected  int _transferSize
           
 ptolemy.data.expr.Parameter bitsPerSample
          The number desired number of bits per sample.
 ptolemy.data.expr.Parameter channels
          The number of audio channels to use.
 ptolemy.data.expr.Parameter sampleRate
          The desired sample rate to use, in Hz.
 ptolemy.data.expr.Parameter transferSize
          The number of samples that will be transferred to the audio driver together.
 
Fields inherited from class ptolemy.actor.AtomicActor
_stopRequested
 
Fields inherited from class ptolemy.kernel.util.NamedObj
_changeListeners, _changeLock, _changeRequests, _debugging, _debugListeners, _elementName, _isPersistent, _workspace, ATTRIBUTES, CLASSNAME, COMPLETE, CONTENTS, DEEP, FULLNAME, LINKS
 
Fields inherited from interface ptolemy.actor.Executable
COMPLETED, NOT_READY, STOP_ITERATING
 
Constructor Summary
LiveSoundActor(ptolemy.kernel.CompositeEntity container, java.lang.String name)
          Construct an actor with the given container and name.
 
Method Summary
protected  void _initializeAudio()
          Initialize the audio system.
 void attributeChanged(ptolemy.kernel.util.Attribute attribute)
          Handle change requests for all parameters.
 void initialize()
          Initialize this actor.
 void liveSoundChanged(LiveSoundEvent event)
          Notify this actor that the an audio parameter of LiveSound has changed.
 void wrapup()
          Wrapup execution.
 
Methods inherited from class ptolemy.actor.TypedAtomicActor
_addPort, attributeTypeChanged, clone, newPort, typeConstraintList
 
Methods inherited from class ptolemy.actor.AtomicActor
_createReceivers, clone, connectionsChanged, fire, getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, iterate, newReceiver, outputPortList, postfire, prefire, preinitialize, pruneDependencies, removeDependency, setContainer, stop, stopFire, terminate
 
Methods inherited from class ptolemy.kernel.ComponentEntity
_adjustDeferrals, _checkContainer, _getContainedObject, _propagateExistence, getContainer, instantiate, isAtomic, isOpaque, propagateExistence, setName
 
Methods inherited from class ptolemy.kernel.Entity
_description, _exportMoMLContents, _removePort, connectedPortList, connectedPorts, containedObjectsIterator, getAttribute, getPort, getPorts, linkedRelationList, linkedRelations, portList, removeAllPorts, setClassDefinition, uniqueName, validateSettables
 
Methods inherited from class ptolemy.kernel.InstantiableNamedObj
_setParent, exportMoML, getChildren, getElementName, getParent, getPrototypeList, isClassDefinition
 
Methods inherited from class ptolemy.kernel.util.NamedObj
_addAttribute, _attachText, _cloneFixAttributeFields, _debug, _debug, _debug, _debug, _debug, _getIndentPrefix, _isMoMLSuppressed, _markContentsDerived, _propagateValue, _removeAttribute, _splitName, _stripNumericSuffix, addChangeListener, addDebugListener, attributeList, attributeList, deepContains, depthInHierarchy, description, description, event, executeChangeRequests, exportMoML, exportMoML, exportMoML, exportMoML, getAttribute, getAttributes, getChangeListeners, getClassName, getDerivedLevel, getDerivedList, getFullName, getModelErrorHandler, getName, getName, getSource, handleModelError, isDeferringChangeRequests, isOverridden, isPersistent, message, propagateValue, propagateValues, removeChangeListener, removeDebugListener, requestChange, setClassName, setDeferringChangeRequests, setDerivedLevel, setModelErrorHandler, setPersistent, setSource, toplevel, toString, workspace
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface ptolemy.actor.Actor
getDirector, getExecutiveDirector, getFunctionDependency, getManager, inputPortList, newReceiver, outputPortList
 
Methods inherited from interface ptolemy.actor.Executable
fire, iterate, postfire, prefire, preinitialize, stop, stopFire, terminate
 
Methods inherited from interface ptolemy.kernel.util.Derivable
getDerivedLevel, getDerivedList, propagateValue
 
Methods inherited from interface ptolemy.kernel.util.Nameable
description, getFullName, getName, getName
 

Field Detail

sampleRate

public ptolemy.data.expr.Parameter sampleRate
The desired sample rate to use, in Hz. The default value is an IntToken equal to 8000.

An exception will be occur if this parameter is set to an unsupported sample rate.


bitsPerSample

public ptolemy.data.expr.Parameter bitsPerSample
The number desired number of bits per sample. The default value is an IntToken equal to 16.

An exception will occur if this parameter is set to an unsupported bit resolution.


channels

public ptolemy.data.expr.Parameter channels
The number of audio channels to use. The default value is an IntToken equal to 1.

An exception will occur if this parameter is set to an an unsupported channel number.


transferSize

public ptolemy.data.expr.Parameter transferSize
The number of samples that will be transferred to the audio driver together. The default is 128.


_channels

protected int _channels

_transferSize

protected int _transferSize

_isExecuting

protected boolean _isExecuting
Constructor Detail

LiveSoundActor

public LiveSoundActor(ptolemy.kernel.CompositeEntity container,
                      java.lang.String name)
               throws ptolemy.kernel.util.IllegalActionException,
                      ptolemy.kernel.util.NameDuplicationException
Construct an actor with the given container and name.

Parameters:
container - The container.
name - The name of this actor.
Throws:
ptolemy.kernel.util.IllegalActionException - If the actor cannot be contained by the proposed container.
ptolemy.kernel.util.NameDuplicationException - If the container already has an actor with this name.
Method Detail

attributeChanged

public void attributeChanged(ptolemy.kernel.util.Attribute attribute)
                      throws ptolemy.kernel.util.IllegalActionException
Handle change requests for all parameters. An exception is thrown if the requested change is not allowed.

Throws:
ptolemy.kernel.util.IllegalActionException - If the change is not allowed.

initialize

public void initialize()
                throws ptolemy.kernel.util.IllegalActionException
Initialize this actor. Derived classes should extend this method to initialize the appropriate audio resource.

Specified by:
initialize in interface ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - If there is a problem beginning audio playback.

liveSoundChanged

public void liveSoundChanged(LiveSoundEvent event)
Notify this actor that the an audio parameter of LiveSound has changed.

Specified by:
liveSoundChanged in interface LiveSoundListener
Parameters:
event - The live sound change event.

wrapup

public void wrapup()
            throws ptolemy.kernel.util.IllegalActionException
Wrapup execution. Derived classes should override this method to release access to the audio resources.

Specified by:
wrapup in interface ptolemy.actor.Executable
Throws:
ptolemy.kernel.util.IllegalActionException - May be thrown by derived classes.

_initializeAudio

protected void _initializeAudio()
                         throws ptolemy.kernel.util.IllegalActionException,
                                java.io.IOException
Initialize the audio system. Set parameters in the audio system according to the parameters of this actor. Derived classes should call this method during initialize().

Throws:
ptolemy.kernel.util.IllegalActionException
java.io.IOException