Class Sound

java.lang.Object
pi.resources.sound.Sound

public final class Sound extends Object
This class implements all required functionality to load sounds from the file system and provide a stream that can later on be used for the sound playback.
  • Constructor Details

    • Sound

      Creates a new Sound instance by the specified file path. Loads the sound data into a byte array and also retrieves information about the format of the sound file.

      Note that the constructor is private. In order to load files use the static Controller.sounds.get(String) method.

      Parameters:
      is - The input stream to load the sound from.
      name - The name of this sound file.
      Throws:
      IOException - If something went wrong loading the file
      UnsupportedAudioFileException - If the audio format is not supported
  • Method Details

    • getFormat

      public AudioFormat getFormat()
      Gets the audio format of this sound instance.
      Returns:
      The audio format of this instance.
    • getName

      public String getName()
      Gets the name of this instance that is used to uniquely identify the resource of this sound.
      Returns:
      The name of this sound.
    • getRawData

      public byte[] getRawData()
      Gets the raw data of this sound as byte array.

      This is used during resource serialization.

      Returns:
      The raw data of this sound as byte array.
    • toString

      public String toString()
      Overrides:
      toString in class Object