Class JDK13AppletAudioClip

java.lang.Object
org.monte.media.eightsvx.JDK13AppletAudioClip
All Implemented Interfaces:
Runnable, AudioClip, LoopableAudioClip

public class JDK13AppletAudioClip extends Object implements LoopableAudioClip, Runnable
JDK13AppletAudioClip. Supports playback of JDK13_SAMPLE_RATE Hz linear 8 encoded PCM data. This class is designed and tuned for use in applets. It is not recommended to use this class in Java applications.
Author:
Werner Randelshofer, Hausmatt 10, CH-6405 Goldau, Switzerland
  • Field Summary

    Fields inherited from interface org.monte.media.eightsvx.LoopableAudioClip

    LOOP_CONTINUOUSLY
  • Constructor Summary

    Constructors
    Constructor
    Description
    JDK13AppletAudioClip(byte[] samples, int sampleRate, int volume, float pan)
    Creates a new instance.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Starts playing this audio clip in a loop.
    void
    loop(int count)
    Starts looping playback from the current position.
    void
    Starts playing this audio clip.
    void
    run()
    When an object implementing interface Runnable is used to create a workerThread, starting the workerThread causes the object's run method to be called in that separately executing workerThread.
    void
    setLoopPoints(int start, int end)
    Sets the first and last sample frames that will be played in the loop.
    void
    Stops playing this audio clip.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • JDK13AppletAudioClip

      public JDK13AppletAudioClip(byte[] samples, int sampleRate, int volume, float pan) throws IOException
      Creates a new instance.
      Parameters:
      samples - Array of signed linear 8-bit encoded audio samples.
      volume - The volume setting controls the loudness of the sound. range 0 (mute) to 64 (maximal volume).
      pan - The relative pan of a stereo signal between two stereo speakers. The valid range of values is -1.0 (left channel only) to 1.0 (right channel only). The default is 0.0 (centered).
      Throws:
      IOException
  • Method Details

    • setLoopPoints

      public void setLoopPoints(int start, int end)
      Sets the first and last sample frames that will be played in the loop. The ending point must be greater than or equal to the starting point, and both must fall within the the size of the loaded media. A value of 0 for the starting point means the beginning of the loaded media. Similarly, a value of -1 for the ending point indicates the last frame of the media.
      Parameters:
      start - the loop's starting position, in sample frames (zero-based)
      end - the loop's ending position, in sample frames (zero-based), or -1 to indicate the final frame
      Throws:
      IllegalArgumentException - if the requested loop points cannot be set, usually because one or both falls outside the media's duration or because the ending point is before the starting point
    • loop

      public void loop()
      Description copied from interface: AudioClip
      Starts playing this audio clip in a loop.
      Specified by:
      loop in interface AudioClip
    • loop

      public void loop(int count)
      Starts looping playback from the current position. Playback will continue to the loop's end point, then loop back to the loop start point count times, and finally continue playback to the end of the clip.

      If the current position when this method is invoked is greater than the loop end point, playback simply continues to the end of the clip without looping.

      A count value of 0 indicates that any current looping should cease and playback should continue to the end of the clip. The behavior is undefined when this method is invoked with any other value during a loop operation.

      If playback is stopped during looping, the current loop status is cleared; the behavior of subsequent loop and start requests is not affected by an interrupted loop operation.

      Specified by:
      loop in interface LoopableAudioClip
      Parameters:
      count - the number of times playback should loop back from the loop's end position to the loop's start position, or LoopableAudioClip.LOOP_CONTINUOUSLY to indicate that looping should continue until interrupted
    • play

      public void play()
      Description copied from interface: AudioClip
      Starts playing this audio clip. Each time this method is called, the clip is restarted from the beginning.
      Specified by:
      play in interface AudioClip
    • stop

      public void stop()
      Description copied from interface: AudioClip
      Stops playing this audio clip.
      Specified by:
      stop in interface AudioClip
    • run

      public void run()
      When an object implementing interface Runnable is used to create a workerThread, starting the workerThread causes the object's run method to be called in that separately executing workerThread.

      The general contract of the method run is that it may take any action whatsoever.

      Specified by:
      run in interface Runnable
      See Also: