Package com.tagtraum.audiokern
Class AudiokernSystem
- java.lang.Object
-
- com.tagtraum.audiokern.AudiokernSystem
-
public final class AudiokernSystem extends Object
Wrapper around someAudioSystemmethods in order to influence the order in which SPIs are used.- Author:
- Hendrik Schreiber
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static AudioInputStreamget44_1kHzStereo16BitStream(File file)Deprecated.static AudioInputStreamget44_1kHzStereo16BitStream(URL url)Attempt to open an audio inputstream with certain properties.static AudioInputStreamget44_1kHzStereo16BitStream(URL url, int bufferSize)Attempt to open an audio inputstream with certain properties.static AudioInputStreamget44_1kHzStereo16BitStream(Path file)Attempt to open an audio inputstream with certain properties.static AudioInputStreamget44_1kHzStereo16BitStream(Path file, int bufferSize)Attempt to open an audio inputstream with certain properties.static AudioInputStreamget44_1kHzStereo16BitStream(AudioInputStream in)Attempts to convert the input stream into signed PCM, 44.1kHz, Stereo, 16-bit/sample format.static AudioFileFormatgetAudioFileFormat(File file)Deprecated.static AudioFileFormatgetAudioFileFormat(InputStream stream)Obtains the audio file format of the provided input stream.static AudioFileFormatgetAudioFileFormat(URL url)Obtains the audio file format of the specified URL.static AudioFileFormatgetAudioFileFormat(Path file)Obtains the audio file format of the specifiedFile.static AudioInputStreamgetAudioInputStream(File file)Deprecated.static AudioInputStreamgetAudioInputStream(InputStream stream)Obtains an audio input stream from the provided input stream.static AudioInputStreamgetAudioInputStream(URL url)Obtains an audio input stream from the URL provided.static AudioInputStreamgetAudioInputStream(URL url, int bufferSize)Obtains an audio input stream from the URL provided.static AudioInputStreamgetAudioInputStream(Path file)Obtains an audio input stream from the URL provided.static AudioInputStreamgetAudioInputStream(Path file, int bufferSize)Obtains an audio input stream from the providedFile.static AudioInputStreamgetAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)Obtains an audio input stream of the indicated format, by converting the provided audio input stream.static LonggetDuration(AudioFileFormat audioFileFormat)Returns duration in microseconds.
-
-
-
Method Detail
-
getDuration
public static Long getDuration(AudioFileFormat audioFileFormat)
Returns duration in microseconds.- Parameters:
audioFileFormat- audioFileFormat- Returns:
- duration in microseconds.
- See Also:
AudioFileFormat
-
getAudioFileFormat
public static AudioFileFormat getAudioFileFormat(InputStream stream) throws UnsupportedAudioFileException, IOException
Obtains the audio file format of the provided input stream. The stream must point to valid audio file data. The implementation of this method may require multiple parsers to examine the stream to determine whether they support it. These parsers must be able to mark the stream, read enough data to determine whether they support the stream, and, if not, reset the stream's read pointer to its original position. If the input stream does not support these operations, this method may fail with anIOException.- Parameters:
stream- the input stream from which file format information should be extracted- Returns:
- an
AudioFileFormatobject describing the stream's audio file format - Throws:
UnsupportedAudioFileException- if the stream does not point to valid audio file data recognized by the systemIOException- if an input/output exception occurs- See Also:
InputStream.markSupported(),InputStream.mark(int)
-
getAudioFileFormat
public static AudioFileFormat getAudioFileFormat(URL url) throws UnsupportedAudioFileException, IOException
Obtains the audio file format of the specified URL. The URL must point to valid audio file data.- Parameters:
url- the URL from which file format information should be extracted- Returns:
- an
AudioFileFormatobject describing the audio file format - Throws:
UnsupportedAudioFileException- if the URL does not point to valid audio file data recognized by the systemIOException- if an input/output exception occurs
-
getAudioFileFormat
@Deprecated public static AudioFileFormat getAudioFileFormat(File file) throws UnsupportedAudioFileException, IOException
Deprecated.Obtains the audio file format of the specifiedFile. TheFilemust point to valid audio file data.- Parameters:
file- theFilefrom which file format information should be extracted- Returns:
- an
AudioFileFormatobject describing the audio file format - Throws:
UnsupportedAudioFileException- if theFiledoes not point to valid audio file data recognized by the systemIOException- if an I/O exception occurs
-
getAudioFileFormat
public static AudioFileFormat getAudioFileFormat(Path file) throws UnsupportedAudioFileException, IOException
Obtains the audio file format of the specifiedFile. TheFilemust point to valid audio file data.- Parameters:
file- theFilefrom which file format information should be extracted- Returns:
- an
AudioFileFormatobject describing the audio file format - Throws:
UnsupportedAudioFileException- if theFiledoes not point to valid audio file data recognized by the systemIOException- if an I/O exception occurs
-
getAudioInputStream
public static AudioInputStream getAudioInputStream(InputStream stream) throws UnsupportedAudioFileException, IOException
Obtains an audio input stream from the provided input stream. The stream must point to valid audio file data. The implementation of this method may require multiple parsers to examine the stream to determine whether they support it. These parsers must be able to mark the stream, read enough data to determine whether they support the stream, and, if not, reset the stream's read pointer to its original position. If the input stream does not support these operation, this method may fail with anIOException.- Parameters:
stream- the input stream from which theAudioInputStreamshould be constructed- Returns:
- an
AudioInputStreamobject based on the audio file data contained in the input stream. - Throws:
UnsupportedAudioFileException- if the stream does not point to valid audio file data recognized by the systemIOException- if an I/O exception occurs- See Also:
InputStream.markSupported(),InputStream.mark(int)
-
getAudioInputStream
public static AudioInputStream getAudioInputStream(URL url) throws UnsupportedAudioFileException, IOException
Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.- Parameters:
url- the URL for which theAudioInputStreamshould be constructed- Returns:
- an
AudioInputStreamobject based on the audio file data pointed to by the URL - Throws:
UnsupportedAudioFileException- if the URL does not point to valid audio file data recognized by the systemIOException- if an I/O exception occurs
-
getAudioInputStream
public static AudioInputStream getAudioInputStream(URL url, int bufferSize) throws UnsupportedAudioFileException, IOException
Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.- Parameters:
url- the URL for which theAudioInputStreamshould be constructedbufferSize- buffer size, may be ignored. Use small buffers for low latency.- Returns:
- an
AudioInputStreamobject based on the audio file data pointed to by the URL - Throws:
UnsupportedAudioFileException- if the URL does not point to valid audio file data recognized by the systemIOException- if an I/O exception occurs
-
getAudioInputStream
@Deprecated public static AudioInputStream getAudioInputStream(File file) throws UnsupportedAudioFileException, IOException
Deprecated.Obtains an audio input stream from the providedFile. TheFilemust point to valid audio file data.- Parameters:
file- theFilefor which theAudioInputStreamshould be constructed- Returns:
- an
AudioInputStreamobject based on the audio file data pointed to by theFile - Throws:
UnsupportedAudioFileException- if theFiledoes not point to valid audio file data recognized by the systemIOException- if an I/O exception occurs
-
getAudioInputStream
public static AudioInputStream getAudioInputStream(Path file) throws UnsupportedAudioFileException, IOException
Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.- Parameters:
file- theFilefor which theAudioInputStreamshould be constructed- Returns:
- an
AudioInputStreamobject based on the audio file data pointed to by the URL - Throws:
UnsupportedAudioFileException- if the URL does not point to valid audio file data recognized by the systemIOException- if an I/O exception occurs
-
getAudioInputStream
public static AudioInputStream getAudioInputStream(Path file, int bufferSize) throws UnsupportedAudioFileException, IOException
Obtains an audio input stream from the providedFile. TheFilemust point to valid audio file data.- Parameters:
file- theFilefor which theAudioInputStreamshould be constructedbufferSize- buffer size, may be ignored. Use small buffers for low latency.- Returns:
- an
AudioInputStreamobject based on the audio file data pointed to by theFile - Throws:
UnsupportedAudioFileException- if theFiledoes not point to valid audio file data recognized by the systemIOException- if an I/O exception occurs
-
getAudioInputStream
public static AudioInputStream getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)
Obtains an audio input stream of the indicated format, by converting the provided audio input stream.- Parameters:
targetFormat- the desired audio format after conversionsourceStream- the stream to be converted- Returns:
- an audio input stream of the indicated format
- Throws:
IllegalArgumentException- if the conversion is not supported- See Also:
AudioSystem.getAudioInputStream(AudioFormat, AudioInputStream)
-
get44_1kHzStereo16BitStream
public static AudioInputStream get44_1kHzStereo16BitStream(AudioInputStream in)
Attempts to convert the input stream into signed PCM, 44.1kHz, Stereo, 16-bit/sample format.- Parameters:
in- input stream- Returns:
- specially transformed stream
-
get44_1kHzStereo16BitStream
@Deprecated public static AudioInputStream get44_1kHzStereo16BitStream(File file) throws UnsupportedAudioFileException, IOException
Deprecated.Attempt to open an audio inputstream with certain properties. Default disk buffer size is set to 32k.- Parameters:
file- audio file- Returns:
- audio inputstream
- Throws:
UnsupportedAudioFileExceptionIOException- See Also:
get44_1kHzStereo16BitStream(javax.sound.sampled.AudioInputStream)
-
get44_1kHzStereo16BitStream
public static AudioInputStream get44_1kHzStereo16BitStream(Path file) throws UnsupportedAudioFileException, IOException
Attempt to open an audio inputstream with certain properties. Default disk buffer size is set to 32k.- Parameters:
file- audio file- Returns:
- audio inputstream
- Throws:
UnsupportedAudioFileExceptionIOException- See Also:
get44_1kHzStereo16BitStream(javax.sound.sampled.AudioInputStream)
-
get44_1kHzStereo16BitStream
public static AudioInputStream get44_1kHzStereo16BitStream(Path file, int bufferSize) throws UnsupportedAudioFileException, IOException
Attempt to open an audio inputstream with certain properties.- Parameters:
file- audio filebufferSize- disk/stream access buffer size (may be ignored)- Returns:
- audio inputstream
- Throws:
UnsupportedAudioFileExceptionIOException- See Also:
get44_1kHzStereo16BitStream(javax.sound.sampled.AudioInputStream)
-
get44_1kHzStereo16BitStream
public static AudioInputStream get44_1kHzStereo16BitStream(URL url, int bufferSize) throws UnsupportedAudioFileException, IOException
Attempt to open an audio inputstream with certain properties.- Parameters:
url- audio urlbufferSize- disk/stream access buffer size (may be ignored)- Returns:
- audio inputstream
- Throws:
UnsupportedAudioFileExceptionIOException- See Also:
get44_1kHzStereo16BitStream(javax.sound.sampled.AudioInputStream)
-
get44_1kHzStereo16BitStream
public static AudioInputStream get44_1kHzStereo16BitStream(URL url) throws UnsupportedAudioFileException, IOException
Attempt to open an audio inputstream with certain properties. Default disk buffer size is set to 32k.- Parameters:
url- audio url- Returns:
- audio inputstream
- Throws:
UnsupportedAudioFileExceptionIOException- See Also:
get44_1kHzStereo16BitStream(javax.sound.sampled.AudioInputStream)
-
-