All Packages Class Hierarchy This Package Previous Next Index
Class guinea.player.SoundSample
java.lang.Object
|
+----guinea.player.Sample
|
+----guinea.player.SoundSample
- public class SoundSample
- extends Sample
- implements PlayerMessageListener, Serializable, FileSample, PropertyLoader, Cloneable
The SoundSample objects can be used to play sound samples.
Variable Index
- ·
correctionVolume
- The volume correction level.
- ·
EXP_FADE
- Exponential fade (dB linear).
Deprecated.
- ·
FADE_EXP
- Exponential fade (dB linear).
- ·
FADE_LINEAR
- Linear fade.
- ·
LINEAR_FADE
- Linear fade.
Deprecated.
- ·
loop_frame
- Frame of last loop.
- ·
NOTIFY_LOOP
- Notify about sample loops.
- ·
NOTIFY_POSITION
- Notify about sample position.
- ·
NOTIFY_START
- Notify about sample starts.
- ·
NOTIFY_STOP
- Notify about sample ends and stops.
- ·
start_frame
- Starting frame of last start.
- ·
stop_frame
- Frame of last stop.
Constructor Index
- ·
SoundSample()
- Create a new sample not yet associated with any file using the
default player.
- ·
SoundSample(AudioPlayer)
- Create a new sample not yet associated with any file using the
given player.
- ·
SoundSample(SoundPlayer, String)
- Create a new sample and load sample from designated player.
- ·
SoundSample(String)
- Create a new sample and load sample using default player.
Method Index
- ·
addOptions(int)
- Turn on some sample options.
- ·
addSamplePositionListener(SamplePositionListener)
- Adds the specified sample position listener to receive position
events from this sample.
- ·
clone()
- Clone sample.
- ·
close()
- Close sample.
Deprecated.
- ·
dispose()
- Dispose of sample when not needed anymore.
- ·
fade(String, double, double)
- Do a fade.
Deprecated.
- ·
fade(String, double, Volume)
- Do a fade.
- ·
finalize()
- Finalize sample.
- ·
getChannels()
- Get number of channels in sample.
- ·
getCorrectionVolume()
- Get the correction volume level for this sample.
- ·
getFilename()
- Get file name of sample.
- ·
getOptions()
- Get sample options.
- ·
getParams()
- Return string representation of sample.
- ·
getPositionNotifyInterval()
- Get the position notify interval.
- ·
getSampleID()
- Get the sample ID used in the player.
- ·
isLoaded()
-
- ·
isLoopable()
- Whether sample can be looped.
- ·
length()
- Get length of sample.
Deprecated.
- ·
load()
- Load a sound sample.
- ·
load(String)
- Load a sound sample.
- ·
mapChannel(ChannelMapping)
- Set the mapping of samples channels.
- ·
mapChannel(ChannelMapping[])
- Set the mapping of samples channels.
- ·
mapChannel(int, int)
- Set the mapping of samples channels.
- ·
processPlayerMessage(String, String, CommandTokenizer)
- Process messages from the player for this sample.
- ·
propertyLoad(Properties, String)
-
- ·
removeOptions(int)
- Turn off some sample options.
- ·
removeSamplePositionListener(SamplePositionListener)
- Removes the specified sample position listener so it no longer
receives position events from this sample.
- ·
seek(long)
- Seek to a given sample frame.
Deprecated.
- ·
setCorrectionVolume(double)
- Set correction volume of sample.
Deprecated.
- ·
setCorrectionVolume(Volume)
- Set correction volume of sample.
- ·
setFilename(String)
- Set file name of sample.
- ·
setLooping(boolean)
- Set looping status of sample.
- ·
setOptions(int)
- Set sample options.
- ·
setPlayer(Player)
- Set the player this sample is using.
- ·
setPosition(long)
- Seek to a given sample frame.
- ·
setPositionNotifyInterval(double)
- Set sample position notification interval.
- ·
setPositionNotifyInterval(int)
- Set sample position notification interval.
- ·
setVolume(double, int)
- Set volume of specified channel in sample.
Deprecated.
- ·
setVolume(Volume)
- Set volume of sample.
- ·
setVolume(Volume, int)
- Set volume of specified channel in sample.
- ·
start(long)
- Start playing the sample at given time.
- ·
startWait()
- Start playing the sample and wait for it to
start before returning.
- ·
startWait(long)
- Start playing the sample at a given time and wait for it to
start before returning.
- ·
stop()
- Stop playing.
- ·
unload()
- Unload sample.
- ·
waitForStart()
- Wait for sample to start.
- ·
waitForStop()
- Wait for sample to stop.
Variables
·
FADE_LINEAR
public static final String FADE_LINEAR
- Linear fade.
·
LINEAR_FADE
public static final String LINEAR_FADE
- Note: LINEAR_FADE is deprecated.
use FADE_LINEAR instead.
- Linear fade.
·
FADE_EXP
public static final String FADE_EXP
- Exponential fade (dB linear).
·
EXP_FADE
public static final String EXP_FADE
- Note: EXP_FADE is deprecated.
use FADE_EXP instead.
- Exponential fade (dB linear).
·
NOTIFY_START
protected static final int NOTIFY_START
- Notify about sample starts.
·
NOTIFY_STOP
protected static final int NOTIFY_STOP
- Notify about sample ends and stops.
·
NOTIFY_LOOP
protected static final int NOTIFY_LOOP
- Notify about sample loops.
·
NOTIFY_POSITION
protected static final int NOTIFY_POSITION
- Notify about sample position.
·
start_frame
protected transient long start_frame
- Starting frame of last start.
·
stop_frame
protected transient long stop_frame
- Frame of last stop.
·
loop_frame
protected transient long loop_frame
- Frame of last loop.
·
correctionVolume
protected Volume correctionVolume
- The volume correction level.
Constructors
·
SoundSample
public SoundSample()
- Create a new sample not yet associated with any file using the
default player.
·
SoundSample
public SoundSample(String filename) throws SampleException
- Create a new sample and load sample using default player.
- Parameters:
- name - file name of the sound sample.
- Throws: SampleException
- thrown if sample loading fails.
·
SoundSample
public SoundSample(AudioPlayer player)
- Create a new sample not yet associated with any file using the
given player.
- Parameters:
- player - the sound player this sample is using.
·
SoundSample
public SoundSample(SoundPlayer player,
String filename) throws SampleException
- Create a new sample and load sample from designated player.
- Parameters:
- name - file name of the sound sample.
- player - the sound player this sample is using.
- Throws: SampleException
- thrown if sample loading fails.
Methods
·
setPlayer
public synchronized void setPlayer(Player player)
- Set the player this sample is using.
- Overrides:
- setPlayer in class Sample
·
getSampleID
public String getSampleID()
- Get the sample ID used in the player.
- Returns:
- the player sample ID or
null
if sample is
not loaded.
- Overrides:
- getSampleID in class Sample
·
getChannels
public int getChannels()
- Get number of channels in sample.
- Returns:
- number of channels
·
length
public long length()
- Note: length() is deprecated.
Use getNumFrames() instead.
- Get length of sample.
- Returns:
- length of sample in sample frames
·
getFilename
public String getFilename()
- Get file name of sample.
·
setFilename
public void setFilename(String filename)
- Set file name of sample.
- Parameters:
- filename - of sample.
·
load
public void load() throws SampleException
- Load a sound sample. The sample name must have been set prior to
loading.
- Throws: SampleException
- thrown if load failed or
sample was already loaded.
·
load
public synchronized void load(String name) throws SampleException
- Load a sound sample.
- Parameters:
- name - file name of the sound sample.
- Throws: SampleException
- thrown if load failed or
sample was already loaded.
·
unload
public synchronized void unload()
- Unload sample.
·
close
public void close()
- Note: close() is deprecated.
Use dispose instead.
- Close sample.
- Overrides:
- close in class Sample
·
processPlayerMessage
public synchronized void processPlayerMessage(String targetID,
String command,
CommandTokenizer st)
- Process messages from the player for this sample.
- Parameters:
- targetID - the ID of the object this is for.
- command - the command string as a string.
- msg - the command tokenizer that can be used to get more
tokens from the command.
·
start
public void start(long frame)
- Start playing the sample at given time.
- Parameters:
- frame - output frame number.
- Overrides:
- start in class Sample
·
startWait
public long startWait(long frame) throws InterruptedException
- Start playing the sample at a given time and wait for it to
start before returning.
- Parameters:
- frame - output frame number.
- Returns:
- the timestamp indicating the starting time of sample.
If frame was non-zero, the same value should be returned
unless framedrops occured. Values less that zero indicate errors.
- Throws: InterruptedException
- if the wait was interrupted
·
startWait
public long startWait() throws InterruptedException
- Start playing the sample and wait for it to
start before returning.
- Returns:
- the timestamp indicating the starting time of sample.
Values less that zero indicate errors.
- Throws: InterruptedException
- if the wait was interrupted
·
waitForStart
public synchronized long waitForStart() throws InterruptedException
- Wait for sample to start.
- Returns:
- timestamp of samples start.
- Throws: InterruptedException
- if the wait was interrupted
·
stop
public void stop()
- Stop playing.
- Overrides:
- stop in class Sample
·
waitForStop
public synchronized long waitForStop() throws InterruptedException
- Wait for sample to stop.
- Returns:
- timestamp of samples ending.
- Throws: InterruptedException
- if the wait was interrupted
·
seek
public void seek(long pos) throws SampleException
- Note: seek() is deprecated.
use setPosition(pos) instead.
- Seek to a given sample frame.
- Parameters:
- pos - the sample frame number where to seek
- Throws: SampleException
- thrown if position was out of bounds
·
setPosition
public void setPosition(long pos) throws SampleException
- Seek to a given sample frame.
- Parameters:
- pos - the sample frame number where to seek
- Throws: SampleException
- thrown if position was out of bounds
- Overrides:
- setPosition in class Sample
·
setCorrectionVolume
public void setCorrectionVolume(Volume vol)
- Set correction volume of sample. The correction affects all
channels.
- Parameters:
- vol - the correction volume level. The sample's level is
always multiplied with the correction level.
·
setCorrectionVolume
public void setCorrectionVolume(double vol)
- Note: setCorrectionVolume() is deprecated.
Use Volume objects as parameters.
- Set correction volume of sample. The correction affects all
channels.
- Parameters:
- vol - The correction volume level in linear scale. The
sample's level is always multiplied with the correction level.
·
getCorrectionVolume
public Volume getCorrectionVolume()
- Get the correction volume level for this sample.
- Returns:
- The correction volume level for this sample.
·
setVolume
public void setVolume(Volume v)
- Set volume of sample. Sets volume of all channels.
- Parameters:
- vol - volume ((1.0, 0dB, 100%) is full volume, (0.0, 0%)
is no volume)
- Overrides:
- setVolume in class Sample
·
setVolume
public void setVolume(double vol,
int channel)
- Note: setVolume() is deprecated.
use Volume objects instead of double values.
- Set volume of specified channel in sample.
- Parameters:
- vol - volume (1.0 is full volume, 0.0 is no volume)
- channel - channel number
·
setVolume
public void setVolume(Volume v,
int channel)
- Set volume of specified channel in sample.
- Parameters:
- vol - Volume of channel.
- channel - Channel number of the channel whose volume to
change.
·
fade
public void fade(String type,
double length,
double volume)
- Note: fade() is deprecated.
use Volume objects instead of double values.
- Do a fade.
- Parameters:
- type - type of fade, either LINEAR_FADE or EXP_FADE.
- length - length of fade in seconds.
- volume - volume at end of fade.
·
fade
public void fade(String type,
double length,
Volume v)
- Do a fade.
- Parameters:
- type - type of fade, either LINEAR_FADE or EXP_FADE.
- length - length of fade in seconds.
- volume - volume at end of fade.
·
getParams
public String getParams()
- Return string representation of sample.
- Overrides:
- getParams in class Sample
·
addSamplePositionListener
public void addSamplePositionListener(SamplePositionListener l)
- Adds the specified sample position listener to receive position
events from this sample.
- Parameters:
- l - the sample position listener.
- Overrides:
- addSamplePositionListener in class Sample
·
removeSamplePositionListener
public 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.
- Overrides:
- removeSamplePositionListener in class Sample
·
setLooping
public void setLooping(boolean loop)
- Set looping status of sample.
- Parameters:
- loop - set to true if looping is wanted, false
otherwise.
- Overrides:
- setLooping in class Sample
·
isLoopable
public boolean isLoopable()
- Whether sample can be looped.
- Returns:
- true if sample can loop, false
if not.
- Overrides:
- isLoopable in class Sample
·
setPositionNotifyInterval
public void setPositionNotifyInterval(int numFrames)
- Set sample position notification interval.
- Parameters:
- numFrames - the interval in sample frames.
·
setPositionNotifyInterval
public void setPositionNotifyInterval(double millis)
- Set sample position notification interval.
- Parameters:
- numFrames - the interval in milliseconds.
·
getPositionNotifyInterval
public int getPositionNotifyInterval()
- Get the position notify interval.
·
addOptions
protected void addOptions(int opts)
- Turn on some sample options.
- Parameters:
- opts - a mask of options to turn on.
·
removeOptions
protected void removeOptions(int opts)
- Turn off some sample options.
- Parameters:
- opts - a mask of options to turn off.
·
setOptions
protected void setOptions(int opts)
- Set sample options.
- Parameters:
- opts - a mask of options to turn set.
·
getOptions
protected int getOptions()
- Get sample options.
- Returns:
- a set of sample options.
·
isLoaded
public boolean isLoaded()
·
mapChannel
public void mapChannel(int source,
int dest)
- Set the mapping of samples channels. Maps a source sample from
the sample to a destination channel of the current virtual
player.
- Parameters:
- source - the source channel number.
- dest - the destination channel number.
·
mapChannel
public void mapChannel(ChannelMapping cm)
- Set the mapping of samples channels. Maps a source sample from
the sample to a destination channel of the current virtual
player.
- Parameters:
- cm - the channel mapping object describing the mapping.
·
mapChannel
public void mapChannel(ChannelMapping cm[])
- Set the mapping of samples channels. Maps a source sample from
the sample to a destination channel of the current virtual
player.
- Parameters:
- cm - an array of multiple mappings for the sample.
·
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 Sample
·
finalize
protected void finalize()
- Finalize sample. Calls dispose().
- Overrides:
- finalize in class Sample
- See Also:
- dispose
·
dispose
public void dispose()
- Dispose of sample when not needed anymore. First unloads
sample (if it is loaded) and then deallocates resources used
by the sample.
- Overrides:
- dispose in class Sample
·
propertyLoad
public void propertyLoad(Properties p,
String name) throws IllegalArgumentException
- Overrides:
- propertyLoad in class Sample
All Packages Class Hierarchy This Package Previous Next Index