All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class guinea.player.Sample

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

public abstract class Sample
extends Object
implements Cloneable, PropertyLoader
The Sample class is an abstract base class for various types of samples.


Variable Index

· length
Length of sample in frames.
· looping
Whether sample is looping or not (one shot play).
· name
Name of this sample for use as a label.
· player
The player this sample uses.
· PositionListeners
Sample position listeners.
· rate
Frame rate of this sample.
· SampleListeners
Sample listeners.
· sampleProperties
Extra properties that can be defined for sample.
· type
Type of sample, "audio", "video", or something else.

Constructor Index

· Sample()

Method Index

· addSampleListener(SampleListener)
Adds the specified sample listener to receive sample event from this sample.
· addSamplePositionListener(SamplePositionListener)
Adds the specified sample position listener to receive position events from this sample.
· clone()
Clone sample.
· close()
Close the sample. Deprecated.
· dispose()
Deallocate resources used by the sample.
· finalize()
Finalize a sample.
· formatPosition(long)
Returns a string representation of given position in sample.
· getDuration()
Get duration of sample in seconds.
· getLooping()
Get looping status of sample.
· getName()
Get name (or label) of sample.
· getNumFrames()
Get number of audio or video frames in this sample.
· getParams()
Get a string describing the values of this sample.
· getPlayer()
Get the player this sample is using.
· getProperty(String)
Get a property of the sample.
· getPropertyNames()
Get an enumeration of sample's property names.
· getRate()
Get frame rate of this sample.
· getSampleID()
Get the sample ID used with the player.
· getType()
Get type of sample.
· isLoopable()
Whether sample can be looped.
· main(String[])
A simple test for testing sample's features.
· processSampleEvent(SampleEvent)
Send sample event to interested listeners.
· processSamplePositionEvent(SamplePositionEvent)
Send sample position event to interested listeners.
· propertyLoad(Properties, String)
· removeSampleListener(SampleListener)
Removes the specified sample listener so it no longer receives sample events from this sample.
· removeSamplePositionListener(SamplePositionListener)
Removes the specified sample position listener so it no longer receives position events from this sample.
· setLooping(boolean)
Set looping status of sample.
· setName(String)
Set name of sample.
· setPlayer(Player)
Set the player this sample is using.
· setPosition(long)
Seek to a position in sample.
· setVolume(double)
Set volume of sample. Deprecated.
· setVolume(Volume)
Set volume of sample.
· start()
Start playing the sample.
· start(long)
Start playing the sample at given time.
· stop()
Stop playing sample and rewind sample to beginning.
· toString()
Return string representation of sample.

Variables

· rate
 protected double rate
Frame rate of this sample. For audio it is the sampling rate of the sample. For video, it is the number of video frames per second.

· length
 protected long length
Length of sample in frames.

· SampleListeners
 protected transient Vector SampleListeners
Sample listeners.

· PositionListeners
 protected transient Vector PositionListeners
Sample position listeners.

· player
 protected transient Player player
The player this sample uses.

· name
 protected String name
Name of this sample for use as a label. Do not confuse with file name.

· looping
 protected boolean looping
Whether sample is looping or not (one shot play).

· type
 protected String type
Type of sample, "audio", "video", or something else.

· sampleProperties
 protected Properties sampleProperties
Extra properties that can be defined for sample.

Constructors

· Sample
 public Sample()

Methods

· getRate
 public double getRate()
Get frame rate of this sample. For audio it is the sampling rate of the sample. For video, it is the number of video frames per second.

· getNumFrames
 public long getNumFrames()
Get number of audio or video frames in this sample.

Returns:
number of audio sample frames or video frames in sample.
· getDuration
 public double getDuration()
Get duration of sample in seconds.

Returns:
duration of sample in seconds.
· getSampleID
 public String getSampleID()
Get the sample ID used with the player.

Returns:
the player sample ID or null if sample is not loaded.
· getName
 public String getName()
Get name (or label) of sample.

Returns:
the name or label for sample.
· setName
 public void setName(String name)
Set name of sample. Name of this sample is for use as a label. Do not confuse with file name.

Parameters:
name - the label for sample.
· getType
 public String getType()
Get type of sample.

Returns:
type of sample as a string.
· setVolume
 public void setVolume(double volume)
Note: setVolume() is deprecated. use Volume object instead

Set volume of sample.

Parameters:
volume - the volume level.
· setVolume
 public void setVolume(Volume volume)
Set volume of sample.

Parameters:
volume - the volume level.
· start
 public abstract void start(long frame)
Start playing the sample at given time.

Parameters:
frame - the timestamp (audio frame number) of when sample should start coming out of the machine's output jacks. Zero means start immediately (as soon as is possible).
· start
 public void start()
Start playing the sample. Equivalent to start(0).

· stop
 public abstract void stop()
Stop playing sample and rewind sample to beginning.

· setPosition
 public abstract void setPosition(long frame) throws SampleException
Seek to a position in sample.

Parameters:
frame - the sample frame offset from start of sample. For audio it is in audio frames (for example, position 44100 is one second from the start of a 44.1KHz sample) and for video it is in video frames (25/s for PAL, 30/s for NTSC).
Throws: SampleException
throws an exception if seeking past the end of sample is tried.
· addSampleListener
 public synchronized void addSampleListener(SampleListener l)
Adds the specified sample listener to receive sample event from this sample.

Parameters:
l - the sample listener.
· removeSampleListener
 public synchronized void removeSampleListener(SampleListener l)
Removes the specified sample listener so it no longer receives sample events from this sample.

Parameters:
l - the sample listener.
· processSampleEvent
 protected void processSampleEvent(SampleEvent event)
Send sample event to interested listeners.

Parameters:
event - an event to send.
· addSamplePositionListener
 public synchronized void addSamplePositionListener(SamplePositionListener l)
Adds the specified sample position listener to receive position events from this sample.

Parameters:
l - the sample position listener.
· removeSamplePositionListener
 public synchronized void removeSamplePositionListener(SamplePositionListener l)
Removes the specified sample position listener so it no longer receives position events from this sample.

Parameters:
l - the sample position listener.
· processSamplePositionEvent
 protected void processSamplePositionEvent(SamplePositionEvent event)
Send sample position event to interested listeners.

Parameters:
event - an event to send.
· close
 public void close()
Note: close() is deprecated. Use dispose() instead.

Close the sample.

See Also:
dispose
· formatPosition
 public String formatPosition(long position)
Returns a string representation of given position in sample. The default is to show a position with like '1:23:50' where first are minutes, then seconds and finally 1/100s of secods.

Parameters:
position - a position to be represented with a string.
· setLooping
 public void setLooping(boolean loop)
Set looping status of sample.

Parameters:
loop - set to true if looping is wanted, false otherwise.
· getLooping
 public boolean getLooping()
Get looping status of sample.

Returns:
true if sample is set to loop, false if not.
· isLoopable
 public boolean isLoopable()
Whether sample can be looped.

Returns:
true if sample can loop, false if not.
· getPlayer
 public Player getPlayer()
Get the player this sample is using.

Returns:
the player this sample is using.
· setPlayer
 public void setPlayer(Player player)
Set the player this sample is using.

Parameters:
player - the player to use.
· getProperty
 public String getProperty(String name)
Get a property of the sample.

Parameters:
name - Name of property to get.
Returns:
Value of parameter or null if such parameter was not found.
· getPropertyNames
 public Enumeration getPropertyNames()
Get an enumeration of sample's property names.

Returns:
An enumeration of parameter names.
· clone
 public Object clone()
Clone sample. A new sample object is created that has the same properties as the original. If original sample was loaded when cloned, the clone will be loaded also.

Returns:
A copy of the object.
Overrides:
clone in class Object
· dispose
 public void dispose()
Deallocate resources used by the sample.

· finalize
 protected void finalize() throws Throwable
Finalize a sample. This calls dispose() to de-allocate any resources used by this sample.

Throws: Throwable
If an exception is thrown for some reason. Shouldn't really happen.
Overrides:
finalize in class Object
See Also:
dispose
· propertyLoad
 public void propertyLoad(Properties p,
                          String name) throws IllegalArgumentException
· getParams
 public String getParams()
Get a string describing the values of this sample. It is used by toString() to create a string presentation of the sample.

Returns:
A string.
· toString
 public String toString()
Return string representation of sample.

Returns:
A string.
Overrides:
toString in class Object
· main
 public static void main(String args[]) throws Exception
A simple test for testing sample's features. Give a samples-filelist name as argument. The sample objects described in the list are created and infromation about the samples are printed.


All Packages  Class Hierarchy  This Package  Previous  Next  Index