Class SwingSound

java.lang.Object
ch.epfl.cs107.play.window.swing.SwingSound
All Implemented Interfaces:
Sound

public final class SwingSound extends Object implements Sound
  • Constructor Summary

    Constructors
    Constructor
    Description
    Default SwingSound Constructor - store the input stream into an audio byte array - keep also format, info and size in memory
  • Method Summary

    Modifier and Type
    Method
    Description
    openedClip(int offset)
    Create and open a new audio Clip containing the swing sound
    int
    Compute a random integer in the range defined by the sound size

    Methods inherited from class java.lang.Object

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

    • SwingSound

      public SwingSound(InputStream input) throws IOException, UnsupportedAudioFileException
      Default SwingSound Constructor - store the input stream into an audio byte array - keep also format, info and size in memory
      Parameters:
      input - (InputStream): corresponding to the sound file. Not null
      Throws:
      IOException - : if the AudioInputStream cannot be read
      UnsupportedAudioFileException - : if the URL does not point to valid audio file data recognized by the system
  • Method Details

    • openedClip

      public Clip openedClip(int offset)
      Create and open a new audio Clip containing the swing sound
      Parameters:
      offset - (int): the point at which to start copying, expressed in bytes from the beginning of the array
      Returns:
      (Clip): the opened swing sound ready to start or null on error
    • randomOffSet

      public int randomOffSet()
      Compute a random integer in the range defined by the sound size
      Returns:
      (int): a random int between 0 (inclusive) and size (exclusive)