All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class guinea.player.SoundPlayer

java.lang.Object
   |
   +----guinea.player.SoundPlayer

public class SoundPlayer
extends Object
implements Serializable, PropertyLoader, AudioPlayer, VirtualPlayerSupport, PlayerMessageListener
The SoundPlayer object handles the communication with the external player process.


Variable Index

· currentStamp
· defaultPlayer
Default soundplayer used when no other is specified.
· defLog
· DEVICE_ADAT_OUT
Audio device name for "ADAT Out", the digital 8-chan.
· DEVICE_AES_OUT
Audio device name for "AES Out", the digital stereo port.
· DEVICE_ANALOG_OUT
Audio device name for "Analog Out", the analog stereo port.
· DEVICE_ANALOG_OUT2
Audio device name for "Analog Out 2", the analog stereo port.
· DEVICE_DEFAULT
Audio device name for default output.
· ERRORMONITOR_STDERR_ALWAYS
Always log errors to standard error stream.
· ERRORMONITOR_STDERR_NOLISTENER
Log errors to standard error stream only if there is no player listener.
· ERRORMONITOR_STDERR_NONE
Do not log errors to standard error stream.
· errorMonitorMode
Where to log error messages from the player program.
· log
· playerListeners
· stampThread
· START_CONNECT_SOCKET
· START_LAUNCH_SOCKET
· START_LAUNCH_STDIO

Constructor Index

· SoundPlayer()
Create a new sound player with default parameters: 2 channels, 44.1kHz sample rate, default audio device.
· SoundPlayer(AudioPlayerInfo)
Create a new sound player with default parameters: 2 channels, 44.1kHz sample rate, default audio device.

Method Index

· addPlayerDiagnosticsListener(PlayerDiagnosticsListener)
Adds the specified player listener to receive events from this player.
· addPlayerListener(PlayerListener)
Adds the specified player listener to receive events from this player.
· allocateVirtualPlayer(AudioPlayerInfo)
· createVirtualPlayer(AudioPlayerInfo)
Allocate a virtual player with the master player. Deprecated.
· createVirtualPlayer(int)
· createVirtualPlayer(int, int)
Allocate a virtual player with the master player.
· finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
· freeVirtualPlayer(AudioPlayer)
· getAudioDevice()
Get the audio device name.
· getBufferLength()
· getChannels()
Get number of channels.
· getCorrectionVolume()
Get the correction volume level of the sample. Deprecated.
· getCurrentTimeStamp()
Get the most recent timestamp from the player.
· getDefaultLogger()
· getDevice()
Get the audio device name. Deprecated.
· getFrameStamp(long)
Get a time stamp that corresponds to the given frame number. Deprecated.
· getLogger()
· getOutputVolume()
Get the output volume level of the player.
· getParentPlayer()
Get the parent player of a virtual player.
· getPlayerDirectory()
Get the directory of the player.
· getPlayerID()
The player ID string of this player.
· getRate()
Get sample rate of player. Deprecated.
· getSampleRate()
Get sample rate of player.
· getStartMode()
Get the starting mode.
· getTempMessageID()
Get a temporary ID string for loading samples etc.
· getTimeStampForFrame(long)
Get a time stamp that corresponds to the given frame number.
· getTimeStampForTimeMicros(long)
Get a time stamp that corresponds to the given point of time.
· getTimeStampForTimeMillis(long)
Get a time stamp that corresponds to the given point of time.
· getVirtualPlayerID()
The virtual player ID string of this player.
· hasAudio()
Does this player support audio?.
· hasVideo()
Does this player support video?.
· isPlayerRunning()
Is the player running?
· isVirtualPlayer()
Is the player a 'virtual' player.
· processPlayerMessage(String, String, CommandTokenizer)
This method is invoked when a message is received for this listener.
· propertyLoad(Properties, String)
· registerPlayerObject(String, PlayerMessageListener)
Register a new sample for receiving messages.
· removePlayerDiagnosticsListener(PlayerDiagnosticsListener)
Removes the specified player listener so that it no longer receives events from this player.
· removePlayerListener(PlayerListener)
Removes the specified player listener so that it no longer receives events from this player.
· sendMessage(String)
Send message to the player program.
· setAudioDevice(String)
Set audio device to be used.
· setBufferLength(int)
· setChannels(int)
Set number of channels.
· setCorrectionVolume(double)
Set the output volume level of player. Deprecated.
· setCorrectionVolume(Volume)
Set correction volume of player. Deprecated.
· setDefaultLogger(Logger)
· setDevice(String)
Set audio device to be used. Deprecated.
· setLogger(Logger)
· setOutputVolume(Volume)
Set the output volume level of player.
· setPlayerDirectory(File)
Set the directory for the player.
· setPlayerID(String)
Set player ID.
· setPlayerParameters(AudioPlayerInfo)
· setRate(int)
Set output sample rate. Deprecated.
· setSampleRate(double)
Set output sample rate.
· setStartMode(int)
Set the player starting mode.
· startPlayer()
Start the sound player.
· stopPlayer()
Stop the sound player process.
· unregisterPlayerObject(String)
Remove a sample from sample hash.

Variables

· defaultPlayer
 public static SoundPlayer defaultPlayer
Default soundplayer used when no other is specified.

· START_LAUNCH_STDIO
 public static final int START_LAUNCH_STDIO
· START_LAUNCH_SOCKET
 public static final int START_LAUNCH_SOCKET
· START_CONNECT_SOCKET
 public static final int START_CONNECT_SOCKET
· DEVICE_DEFAULT
 public static final String DEVICE_DEFAULT
Audio device name for default output.

· DEVICE_ANALOG_OUT
 public static final String DEVICE_ANALOG_OUT
Audio device name for "Analog Out", the analog stereo port.

· DEVICE_ANALOG_OUT2
 public static final String DEVICE_ANALOG_OUT2
Audio device name for "Analog Out 2", the analog stereo port.

· DEVICE_ADAT_OUT
 public static final String DEVICE_ADAT_OUT
Audio device name for "ADAT Out", the digital 8-chan. 24-bit port.

· DEVICE_AES_OUT
 public static final String DEVICE_AES_OUT
Audio device name for "AES Out", the digital stereo port.

· currentStamp
 protected transient TimeStamp currentStamp
· stampThread
 protected transient SoundPlayer. StampThread stampThread
· playerListeners
 protected transient PlayerEventQueue playerListeners
· ERRORMONITOR_STDERR_NONE
 public static final int ERRORMONITOR_STDERR_NONE
Do not log errors to standard error stream.

· ERRORMONITOR_STDERR_NOLISTENER
 public static final int ERRORMONITOR_STDERR_NOLISTENER
Log errors to standard error stream only if there is no player listener.

· ERRORMONITOR_STDERR_ALWAYS
 public static final int ERRORMONITOR_STDERR_ALWAYS
Always log errors to standard error stream.

· errorMonitorMode
 protected int errorMonitorMode
Where to log error messages from the player program.

· defLog
 protected static Logger defLog
· log
 protected Logger log

Constructors

· SoundPlayer
 public SoundPlayer()
Create a new sound player with default parameters: 2 channels, 44.1kHz sample rate, default audio device. The player program is not started, it should be done with startPlayer The first soundplayer that is created is also marked to be the default soundplayer.

See Also:
startPlayer
· SoundPlayer
 public SoundPlayer(AudioPlayerInfo info)
Create a new sound player with default parameters: 2 channels, 44.1kHz sample rate, default audio device. The player program is not started, it should be done with startPlayer The first soundplayer that is created is also marked to be the default soundplayer.

Parameters:
info - Parameters of the player.
See Also:
startPlayer

Methods

· setPlayerParameters
 public void setPlayerParameters(AudioPlayerInfo info)
· setPlayerDirectory
 public void setPlayerDirectory(File dir)
Set the directory for the player. Player directory can be used to load files from sample directories with relative names.

Parameters:
dir - A directory.
· getPlayerDirectory
 public File getPlayerDirectory()
Get the directory of the player. Player directory can be used to load files from sample directories with relative names.

Parameters:
return - Player directory.
· hasAudio
 public boolean hasAudio()
Does this player support audio?.

Returns:
true if audio is supported.
· hasVideo
 public boolean hasVideo()
Does this player support video?.

Returns:
true if video is supported.
· isVirtualPlayer
 public boolean isVirtualPlayer()
Is the player a 'virtual' player. A virtual player is a player which uses a parent player and uses only a subset of all output channels for output.

Returns:
this player always returns false.
See Also:
getParentPlayer
· getParentPlayer
 public Player getParentPlayer()
Get the parent player of a virtual player. This player is not a virtual player so it returns itself as the parent.

Returns:
the object itself is returned.
See Also:
isVirtualPlayer
· getVirtualPlayerID
 public String getVirtualPlayerID()
The virtual player ID string of this player. It is used to specify which virtual player the command applies to. Even this is not a virtual player, a virtual player is applicable. The virtual player ID of this player corresponds to the whole player.

Returns:
a virtual player ID string.
· setPlayerID
 public void setPlayerID(String playerID)
Set player ID. Usually, this ID is used to refer to this player or virtual player in the GP test engine.

Parameters:
playerID - A player ID.
· getPlayerID
 public String getPlayerID()
The player ID string of this player.

Returns:
a player ID string.
· isPlayerRunning
 public boolean isPlayerRunning()
Is the player running?

Returns:
true if player is running, false if not running.
· setAudioDevice
 public void setAudioDevice(String devname)
Set audio device to be used. It is generally a good idea to set the device to something else than the default device because all beeps and such go to the default device.

Parameters:
devname - The name of the device.
· getAudioDevice
 public String getAudioDevice()
Get the audio device name.

Returns:
The name of the device or null if no device name has been set (default device).
· setSampleRate
 public void setSampleRate(double rate)
Set output sample rate.

Parameters:
rate - The sample rate in Hz.
· getSampleRate
 public double getSampleRate()
Get sample rate of player.

Returns:
sample rate in Hz.
· setChannels
 public void setChannels(int chan)
Set number of channels. The maximum number is limited by the used.

Parameters:
chan - Number of channels.
· getChannels
 public int getChannels()
Get number of channels.

Returns:
number of channels.
· setBufferLength
 public void setBufferLength(int len)
· getBufferLength
 public int getBufferLength()
· setDevice
 public void setDevice(String devname)
Note: setDevice() is deprecated. use setAudioDevice() instead

Set audio device to be used. It is generally a good idea to set the device to something else than the default device because all beeps and such go to the default device.

Parameters:
devname - The name of the device.
· getDevice
 public String getDevice()
Note: getDevice() is deprecated. use getAudioDevice() instead

Get the audio device name.

Returns:
The name of the device or null if no device name has been set (default device).
· setRate
 public void setRate(int rate)
Note: setRate() is deprecated. use setSampleRate() instead.

Set output sample rate.

Parameters:
rate - The sample rate in Hz.
· getRate
 public int getRate()
Note: getRate() is deprecated. use getSampleRate instead

Get sample rate of player.

Returns:
sample rate in Hz.
· addPlayerDiagnosticsListener
 public void addPlayerDiagnosticsListener(PlayerDiagnosticsListener l)
Adds the specified player listener to receive events from this player.

Parameters:
l - the player listener.
· removePlayerDiagnosticsListener
 public void removePlayerDiagnosticsListener(PlayerDiagnosticsListener l)
Removes the specified player listener so that it no longer receives events from this player.

· addPlayerListener
 public void addPlayerListener(PlayerListener l)
Adds the specified player listener to receive events from this player.

Parameters:
l - the player listener.
· removePlayerListener
 public void removePlayerListener(PlayerListener l)
Removes the specified player listener so that it no longer receives events from this player.

· setOutputVolume
 public void setOutputVolume(Volume vol)
Set the output volume level of player. The volume affects all samples and channels.

Parameters:
vol - the output volume level.
· setCorrectionVolume
 public void setCorrectionVolume(double vol)
Note: setCorrectionVolume() is deprecated. use Volume object instead of double (linear scale)

Set the output volume level of player. The volume affects all samples and channels.

Parameters:
vol - the output volume level in linear scale.
· setCorrectionVolume
 public void setCorrectionVolume(Volume vol)
Note: setCorrectionVolume() is deprecated. use setOutputVolume instead

Set correction volume of player. The correction affects all samples and channels.

Parameters:
vol - the correction volume level. The output level is always multiplied with the correction level.
See Also:
setOutputVolume
· getOutputVolume
 public Volume getOutputVolume()
Get the output volume level of the player.

Returns:
the output volume level of player.
· getCorrectionVolume
 public Volume getCorrectionVolume()
Note: getCorrectionVolume() is deprecated. use getOutputVolume instead

Get the correction volume level of the sample.

Returns:
the correction level as a volume level.
See Also:
getOutputVolume
· registerPlayerObject
 public void registerPlayerObject(String id,
                                  PlayerMessageListener sample)
Register a new sample for receiving messages. The player will then know where to send the message from the player.

Parameters:
id - A string used to identify this listener.
sample - The listener that wants to receive messages
· unregisterPlayerObject
 public Object unregisterPlayerObject(String id)
Remove a sample from sample hash.

Parameters:
id - the id of the object to be removed.
Returns:
the removed object or null if no object was found with the given id.
· getTempMessageID
 public synchronized String getTempMessageID()
Get a temporary ID string for loading samples etc.

Returns:
an unique temporary ID string.
· sendMessage
 public void sendMessage(String msg) throws IOException, PlayerException
Send message to the player program.

Parameters:
msg - The message.
Throws: IOException
an IO exception occured.
Throws: PlayerException
player is not connected to a player process.
· setDefaultLogger
 public static void setDefaultLogger(Logger l)
· getDefaultLogger
 public static Logger getDefaultLogger()
· setLogger
 public synchronized void setLogger(Logger l)
· getLogger
 public synchronized Logger getLogger()
· processPlayerMessage
 public void processPlayerMessage(String targetID,
                                  String command,
                                  CommandTokenizer msg)
This method is invoked when a message is received for this listener.

Parameters:
targetID - the ID of the object this is for.
command - the command string.
msg - rest of the command (tokenizer).
· getCurrentTimeStamp
 public TimeStamp getCurrentTimeStamp()
Get the most recent timestamp from the player.

· getFrameStamp
 public TimeStamp getFrameStamp(long frame)
Note: getFrameStamp() is deprecated. use getTimeStampForFrame() instead.

Get a time stamp that corresponds to the given frame number. The time stamp is expolated based on the most recent current time stamp received from the player.

Parameters:
frame - the audio frame number .
Returns:
a TimeStamp corresponding the given frame number.
· getTimeStampForFrame
 public TimeStamp getTimeStampForFrame(long frame)
Get a time stamp that corresponds to the given frame number. The time stamp is expolated based on the most recent current time stamp received from the player.

Parameters:
frame - the audio frame number .
Returns:
a TimeStamp corresponding the given frame number.
· getTimeStampForTimeMillis
 public TimeStamp getTimeStampForTimeMillis(long currentTime)
Get a time stamp that corresponds to the given point of time. The time stamp is expolated based on the most recent current time stamp received from the player.

Parameters:
currentTime - the time (for example, got from System.currentTimeMillis()) for which to obtain TimeStamp.
Returns:
a TimeStamp corresponding the given time.
· getTimeStampForTimeMicros
 public TimeStamp getTimeStampForTimeMicros(long currentTime)
Get a time stamp that corresponds to the given point of time. The time stamp is expolated based on the most recent current time stamp received from the player.

Parameters:
currentTime - the time (for example, got from System.currentTimeMillis()) for which to obtain TimeStamp.
Returns:
a TimeStamp corresponding the given time.
· setStartMode
 public void setStartMode(int mode)
Set the player starting mode. By default if uses START_LAUNCH_SOCKET.

Parameters:
mode - the staring mode (connect, launch using socket or launch using stdio).
· getStartMode
 public int getStartMode()
Get the starting mode.

· startPlayer
 public void startPlayer() throws Exception
Start the sound player. The parameters of the player must be set before starting the player.

Throws: Exception
if an error occurs when trying to start the player, an exception will be thrown.
· stopPlayer
 public synchronized void stopPlayer()
Stop the sound player process.

· propertyLoad
 public void propertyLoad(Properties p,
                          String name) throws IllegalArgumentException
· finalize
 protected void finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.

Overrides:
finalize in class Object
· allocateVirtualPlayer
 public AudioPlayer allocateVirtualPlayer(AudioPlayerInfo info) throws PlayerException
· freeVirtualPlayer
 public void freeVirtualPlayer(AudioPlayer player)
· createVirtualPlayer
 public AudioPlayer createVirtualPlayer(AudioPlayerInfo info) throws PlayerException
Note: createVirtualPlayer() is deprecated. Use allocateVirtualPlayer() instead.

Allocate a virtual player with the master player.

Parameters:
info - Player information for new virtual player. Only number of channels in currently used.
Returns:
the ID number of the virtual player. The master player's ID is always number zero.
Throws: PlayerException
throws a PlayerException if a player error happened (not connected to player or there are not enough free real channels to allocate.
· createVirtualPlayer
 public synchronized AudioPlayer createVirtualPlayer(int channels) throws PlayerException
· createVirtualPlayer
 public synchronized AudioPlayer createVirtualPlayer(int channels,
                                                     int startChannel) throws PlayerException
Allocate a virtual player with the master player.

Parameters:
channels - the number of channels to allocate for virtual player.
startChannel - The first channel to use for the VP.
Returns:
the ID number of the virtual player. The master player's ID is always number zero.
Throws: PlayerException
throws a PlayerException if a player error happened (not connected to player or there are not enough free real channels to allocate.

All Packages  Class Hierarchy  This Package  Previous  Next  Index