All Packages  Class Hierarchy  This Package  Previous  Next  Index

Class guinea.player.ParallelSamples

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

public class ParallelSamples
extends Sample
implements SampleListener, SamplePositionListener, Serializable
The ParallelSamples sample object plays several samples at the same time but only one of them is heard. When switching to another sample, a crossfade is used.


Constructor Index

· ParallelSamples(Sample[])
· ParallelSamples(SoundSample[])

Method Index

· addSamplePositionListener(SamplePositionListener)
Adds the specified sample position listener to receive position events from this sample.
· close()
Close the sample.
· finalize()
Called by the garbage collector on an object when garbage collection determines that there are no more references to the object.
· getChannels()
Get number of channels in sample.
· getFadeLength()
Get the length of crossfade.
· getFadeType()
Get fade type.
· getPlaying()
Get the currently playing sample.
· getPlayingIndex()
Get the index of currently playing sample.
· getPositionNotifyInterval()
· getSampleID()
Get the sample ID used with the player.
· getSamples()
· isLoopable()
Whether sample can be looped.
· removeSamplePositionListener(SamplePositionListener)
Removes the specified sample position listener so it no longer receives position events from this sample.
· sampleLooped(SampleEvent)
Called when sample has looped.
· samplePositionChanged(SamplePositionEvent)
Called when sample position has changed.
· sampleStarted(SampleEvent)
Called when sample has started.
· sampleStopped(SampleEvent)
Called when sample has stopped or was stopped.
· setFadeLength(double)
Set the length of the crossfade from one sample to another.
· setFadeType(String)
Set fade type.
· setLooping(boolean)
Set looping status of sample.
· setPlayer(Player)
Set the player this sample is using.
· setPlaying(int)
Switch to one of the samples contained in this parallel sample.
· setPlaying(SoundSample)
Switch to one of the samples contained in this parallel sample.
· setPosition(long)
Seek to a given sample frame.
· setPositionNotifyInterval(double)
Set sample position notification interval.
· setPositionNotifyInterval(int)
Set sample position notification interval.
· setVolume(Volume)
Set volume of 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.

Constructors

· ParallelSamples
 public ParallelSamples(Sample samples[])
· ParallelSamples
 public ParallelSamples(SoundSample samples[])

Methods

· getSampleID
 public String getSampleID()
Get the sample ID used with the player.

Overrides:
getSampleID in class Sample
· setPlayer
 public void setPlayer(Player player)
Set the player this sample is using.

Overrides:
setPlayer in class Sample
· getSamples
 public Sample[] getSamples()
· getChannels
 public int getChannels()
Get number of channels in sample.

Returns:
number of channels
· setPlaying
 public void setPlaying(SoundSample s)
Switch to one of the samples contained in this parallel sample.

Parameters:
s - the sample to which to switch.
· setPlaying
 public void setPlaying(int index)
Switch to one of the samples contained in this parallel sample.

Parameters:
index - the index of the sample to which to switch. The order is the same as when constructing this sample.
· getPlayingIndex
 public int getPlayingIndex()
Get the index of currently playing sample.

Returns:
number of current sample or -1 if sample is not yet set.
· getPlaying
 public Sample getPlaying()
Get the currently playing sample.

Returns:
current sample or null if sample is not yet set.
· setFadeLength
 public void setFadeLength(double length)
Set the length of the crossfade from one sample to another.

Parameters:
length - the length of fade in seconds.
· getFadeLength
 public double getFadeLength()
Get the length of crossfade.

Returns:
the length of crossfade in seconds.
· setFadeType
 public void setFadeType(String type)
Set fade type.

Parameters:
type - the type of fade, 'linear' or 'exp'.
· getFadeType
 public String getFadeType()
Get fade type.

Returns:
the fade type, 'linear' or 'exp'.
· unload
 public synchronized void unload()
Unload sample.

· close
 public void close()
Close the sample.

Overrides:
close in class Sample
· 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
· 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
· setVolume
 public void setVolume(Volume vol)
Set volume of sample. Sets volume of all channels.

Parameters:
vol - volume of sample.
Overrides:
setVolume 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.

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()
· sampleStarted
 public void sampleStarted(SampleEvent e)
Called when sample has started. Event's timestamp tells when sample started playing.

· sampleStopped
 public void sampleStopped(SampleEvent e)
Called when sample has stopped or was stopped. Event's timestamp tells when sample stopped playing.

· sampleLooped
 public void sampleLooped(SampleEvent e)
Called when sample has looped. Event's timestamp tells when sample looped and started playing from start.

· samplePositionChanged
 public void samplePositionChanged(SamplePositionEvent e)
Called when sample position has changed.

· 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

All Packages  Class Hierarchy  This Package  Previous  Next  Index