Package com.tagtraum.audiokern
Class AudiokernSystem
- java.lang.Object
-
- com.tagtraum.audiokern.AudiokernSystem
-
public final class AudiokernSystem extends Object
Wrapper around someAudioSystem
methods 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 AudioInputStream
get44_1kHzStereo16BitStream(File file)
Deprecated.static AudioInputStream
get44_1kHzStereo16BitStream(URL url)
Attempt to open an audio inputstream with certain properties.static AudioInputStream
get44_1kHzStereo16BitStream(URL url, int bufferSize)
Attempt to open an audio inputstream with certain properties.static AudioInputStream
get44_1kHzStereo16BitStream(Path file)
Attempt to open an audio inputstream with certain properties.static AudioInputStream
get44_1kHzStereo16BitStream(Path file, int bufferSize)
Attempt to open an audio inputstream with certain properties.static AudioInputStream
get44_1kHzStereo16BitStream(AudioInputStream in)
Attempts to convert the input stream into signed PCM, 44.1kHz, Stereo, 16-bit/sample format.static AudioFileFormat
getAudioFileFormat(File file)
Deprecated.static AudioFileFormat
getAudioFileFormat(InputStream stream)
Obtains the audio file format of the provided input stream.static AudioFileFormat
getAudioFileFormat(URL url)
Obtains the audio file format of the specified URL.static AudioFileFormat
getAudioFileFormat(Path file)
Obtains the audio file format of the specifiedFile
.static AudioInputStream
getAudioInputStream(File file)
Deprecated.static AudioInputStream
getAudioInputStream(InputStream stream)
Obtains an audio input stream from the provided input stream.static AudioInputStream
getAudioInputStream(URL url)
Obtains an audio input stream from the URL provided.static AudioInputStream
getAudioInputStream(URL url, int bufferSize)
Obtains an audio input stream from the URL provided.static AudioInputStream
getAudioInputStream(Path file)
Obtains an audio input stream from the URL provided.static AudioInputStream
getAudioInputStream(Path file, int bufferSize)
Obtains an audio input stream from the providedFile
.static AudioInputStream
getAudioInputStream(AudioFormat targetFormat, AudioInputStream sourceStream)
Obtains an audio input stream of the indicated format, by converting the provided audio input stream.static Long
getDuration(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
AudioFileFormat
object 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
AudioFileFormat
object 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
. TheFile
must point to valid audio file data.- Parameters:
file
- theFile
from which file format information should be extracted- Returns:
- an
AudioFileFormat
object describing the audio file format - Throws:
UnsupportedAudioFileException
- if theFile
does 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
. TheFile
must point to valid audio file data.- Parameters:
file
- theFile
from which file format information should be extracted- Returns:
- an
AudioFileFormat
object describing the audio file format - Throws:
UnsupportedAudioFileException
- if theFile
does 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 theAudioInputStream
should be constructed- Returns:
- an
AudioInputStream
object 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 theAudioInputStream
should be constructed- Returns:
- an
AudioInputStream
object 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 theAudioInputStream
should be constructedbufferSize
- buffer size, may be ignored. Use small buffers for low latency.- Returns:
- an
AudioInputStream
object 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
. TheFile
must point to valid audio file data.- Parameters:
file
- theFile
for which theAudioInputStream
should be constructed- Returns:
- an
AudioInputStream
object based on the audio file data pointed to by theFile
- Throws:
UnsupportedAudioFileException
- if theFile
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) throws UnsupportedAudioFileException, IOException
Obtains an audio input stream from the URL provided. The URL must point to valid audio file data.- Parameters:
file
- theFile
for which theAudioInputStream
should be constructed- Returns:
- an
AudioInputStream
object 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
. TheFile
must point to valid audio file data.- Parameters:
file
- theFile
for which theAudioInputStream
should be constructedbufferSize
- buffer size, may be ignored. Use small buffers for low latency.- Returns:
- an
AudioInputStream
object based on the audio file data pointed to by theFile
- Throws:
UnsupportedAudioFileException
- if theFile
does 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:
UnsupportedAudioFileException
IOException
- 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:
UnsupportedAudioFileException
IOException
- 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:
UnsupportedAudioFileException
IOException
- 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:
UnsupportedAudioFileException
IOException
- 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:
UnsupportedAudioFileException
IOException
- See Also:
get44_1kHzStereo16BitStream(javax.sound.sampled.AudioInputStream)
-
-