Package samer.audio
Class StreamSource
- java.lang.Object
-
- samer.audio.StreamSource
-
- All Implemented Interfaces:
- AudioSource
public class StreamSource extends java.lang.Object implements AudioSource
An AudioSource that read from an input stream. Can read any format for which the appropriate JavaSound plug-in is installed on your system, eg WAV, AU, MP3, OGG. The implementation of AudioSource.reader() returns a Task which gets samples from the audio files, going through the play list one by one. If the loop flag is true, then samples are returned indefinitely by looping through the playlist; otherwise, an EOFException is thrown if an attempt is made to read beyond the end of the last file. Properties read from current environment:- current
- Current file (String)
- loop
- Loop playlist? (Boolean) [true]
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface samer.audio.AudioSource
AudioSource.Util
-
-
Constructor Summary
Constructors Constructor and Description StreamSource(java.io.File file)
StreamSource(java.io.InputStream s)
StreamSource(java.net.URL url)
StreamSource(javax.sound.sampled.AudioInputStream s)
Construct a StreamSource initialised with current file and loop initialised from the current Environment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method and Description int
available()
Returns number of bytes available in current filevoid
close()
Closes current input streamvoid
dispose()
int
getChannels()
javax.sound.sampled.AudioFormat
getFormat()
float
getRate()
boolean
isOpen()
void
open()
Opens the playlist starting with the first file.Task
reader(double[] dbuf, int off, int len)
Returns a Task which copies samples as doubles into the given buffer between the given positions.Task
reader(float[] dbuf, int off, int len)
Returns a Task which copies samples as floats into the given buffer between the given positions.void
setTargetFormat(javax.sound.sampled.AudioFormat f)
Returns current file
-
-
-
Constructor Detail
-
StreamSource
public StreamSource(java.io.File file) throws java.lang.Exception
- Throws:
java.lang.Exception
-
StreamSource
public StreamSource(java.io.InputStream s) throws java.lang.Exception
- Throws:
java.lang.Exception
-
StreamSource
public StreamSource(java.net.URL url) throws java.lang.Exception
- Throws:
java.lang.Exception
-
StreamSource
public StreamSource(javax.sound.sampled.AudioInputStream s) throws java.lang.Exception
Construct a StreamSource initialised with current file and loop initialised from the current Environment. No exception is thrown if the current file- Throws:
java.lang.Exception
-
-
Method Detail
-
dispose
public void dispose()
- Specified by:
dispose
in interfaceAudioSource
-
setTargetFormat
public void setTargetFormat(javax.sound.sampled.AudioFormat f)
Returns current file
-
getFormat
public javax.sound.sampled.AudioFormat getFormat()
-
isOpen
public boolean isOpen()
- Specified by:
isOpen
in interfaceAudioSource
-
close
public void close()
Closes current input stream- Specified by:
close
in interfaceAudioSource
-
open
public void open() throws java.lang.Exception
Opens the playlist starting with the first file.- Specified by:
open
in interfaceAudioSource
- Throws:
java.lang.Exception
-
available
public int available() throws java.lang.Exception
Returns number of bytes available in current file- Throws:
java.lang.Exception
-
getRate
public float getRate()
- Specified by:
getRate
in interfaceAudioSource
-
getChannels
public int getChannels()
- Specified by:
getChannels
in interfaceAudioSource
-
reader
public Task reader(double[] dbuf, int off, int len)
Returns a Task which copies samples as doubles into the given buffer between the given positions.- Specified by:
reader
in interfaceAudioSource
-
reader
public Task reader(float[] dbuf, int off, int len)
Returns a Task which copies samples as floats into the given buffer between the given positions.- Specified by:
reader
in interfaceAudioSource
-
-