org.tritonus.lowlevel.esd
Class EsdSample

java.lang.Object
  extended byorg.tritonus.lowlevel.esd.Esd
      extended byorg.tritonus.lowlevel.esd.EsdSample

public class EsdSample
extends Esd


Field Summary
 
Fields inherited from class org.tritonus.lowlevel.esd.Esd
ESD_BITS16, ESD_BITS8, ESD_MONO, ESD_PLAY, ESD_STEREO, ESD_STREAM
 
Constructor Summary
EsdSample()
           
 
Method Summary
 void close()
          Closes the connection to esd.
 void free()
          Uncache a sample from the server.
 void kill()
          Stop a playing sample immediately.
 void loop()
          Play the sample indefinitely.
 void open(int nFormat, int nSampleRate, int nLength)
          Opens the connection to esd and starts uploading the sample data.
 void play()
          Play the sample once.
 void setVolume(int nLeftVolume, int nRightVolume)
          Sets the volume for the sample.
 void stop()
          Stop a looping sample at end.
 int write(byte[] abData, int nOffset, int nLength)
          Uploads a piece of data for the sample.
 
Methods inherited from class org.tritonus.lowlevel.esd.Esd
isLibraryAvailable, loadNativeLibrary
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EsdSample

public EsdSample()
Method Detail

open

public void open(int nFormat,
                 int nSampleRate,
                 int nLength)
Opens the connection to esd and starts uploading the sample data. After this call, you can upload the sample data with calls to write() (multiple calls allowed). Then you can play or loop the sample. To free native resources, call close() if you're done with the sample (not after you've uploaded all data).


write

public int write(byte[] abData,
                 int nOffset,
                 int nLength)
Uploads a piece of data for the sample. You have to open a connection to esd with open() before calling this method. Multiple calls to this (write()) method are allowed. The data uploaded in consequtive calls are simply concatenated.

Returns:
the number of bytes written

close

public void close()
Closes the connection to esd. Use only if you are completely done with this sample.


play

public void play()
Play the sample once.


loop

public void loop()
Play the sample indefinitely.


stop

public void stop()
Stop a looping sample at end.


kill

public void kill()
Stop a playing sample immediately.


free

public void free()
Uncache a sample from the server. This call frees resources in the server associated with the sample and invalidated the internal id. Calls to play() and loop() are no longer allowed after return from this method.


setVolume

public void setVolume(int nLeftVolume,
                      int nRightVolume)
Sets the volume for the sample.