Package net.mtrop.doom.util
Class SoundUtils
java.lang.Object
net.mtrop.doom.util.SoundUtils
Sound utility methods for sound types.
- Author:
- Matthew Tropiano
-
Method Summary
Modifier and TypeMethodDescriptionstatic DMXSound
createSound
(File file) Imports a file as a DMXSound.static AudioInputStream
getAudioInputStream
(DMXSound sound) Creates an AudioInputStream for a DMX Sound.static void
writeSoundToFile
(DMXSound sound, AudioFileFormat.Type fileType, File outFile) Writes a DMXSound out to an audio file.static void
writeSoundToOutputStream
(DMXSound sound, AudioFileFormat.Type fileType, OutputStream out) Writes a DMXSound out to an output stream.
-
Method Details
-
createSound
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
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.
-