Class SoundUtils

java.lang.Object
net.mtrop.doom.util.SoundUtils

public final class SoundUtils extends Object
Sound utility methods for sound types.
Author:
Matthew Tropiano
  • Method Details

    • createSound

      public static DMXSound createSound(File file) throws IOException, UnsupportedAudioFileException
      Imports a file as a DMXSound. This is dependent on the drivers in the Java SPI to read supported files. If the input has multiple channels, they are lazily muxed into a single channel.

      NOTE: DMX Sounds are stored as mono, 8-bit PCM waveforms. Some sound information will be lost on conversion!

      Parameters:
      file - the input audio stream.
      Returns:
      the resultant DMX Sound object.
      Throws:
      IOException - if an error occurs on write.
      UnsupportedAudioFileException - if the file is an unrecognized audio type.
    • writeSoundToFile

      public static void writeSoundToFile(DMXSound sound, AudioFileFormat.Type fileType, File outFile) throws IOException, UnsupportedAudioFileException
      Writes a DMXSound out to an audio file. The destination file will be overwritten!
      Parameters:
      sound - the input DMX Sound.
      fileType - the file format type.
      outFile - the output file.
      Throws:
      IOException - if an error occurred during the write.
      UnsupportedAudioFileException - if the output type is unsupported.
    • writeSoundToOutputStream

      public static void writeSoundToOutputStream(DMXSound sound, AudioFileFormat.Type fileType, OutputStream out) throws IOException, UnsupportedAudioFileException
      Writes a DMXSound out to an output stream.
      Parameters:
      sound - the input DMX Sound.
      fileType - the file format type.
      out - the output stream.
      Throws:
      IOException - if an error occurred during the write.
      UnsupportedAudioFileException - if the output type is unsupported.
    • getAudioInputStream

      public static AudioInputStream getAudioInputStream(DMXSound sound)
      Creates an AudioInputStream for a DMX Sound.
      Parameters:
      sound - the DMX Sound to get an audio stream for.
      Returns:
      an AudioInputStream for reading audio data from this sound.