Package samer.audio
Class MultiFileAudioStream
- java.lang.Object
-
- java.io.InputStream
-
- samer.audio.MultiFileAudioStream
-
public abstract class MultiFileAudioStream extends java.io.InputStream
-
-
Constructor Summary
Constructors Constructor and Description MultiFileAudioStream(javax.sound.sampled.AudioFormat target, java.util.List<java.io.File> files)
Construct a FileSource 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 streamjava.util.List<java.io.File>
directory(java.io.File dir, java.lang.String ext)
Set playlist to all WAV files in given directoryjavax.sound.sampled.AudioFormat
getFormat()
java.util.List<java.io.File>
getPlaylist()
boolean
isOpen()
void
next()
Move to head of next file in playlistvoid
open()
Opens the playlist starting with the first file.void
prev()
Move to head of previous file in playlistint
read(byte[] buf, int off, int len)
Returns a Task which copies samples as doubles into the given buffer between the given positions.void
rewind()
Go back to start of playlist.
-
-
-
Constructor Detail
-
MultiFileAudioStream
public MultiFileAudioStream(javax.sound.sampled.AudioFormat target, java.util.List<java.io.File> files)
Construct a FileSource initialised with current file and loop initialised from the current Environment. No exception is thrown if the current file cannot be opened, however, you must be sure to set it to a valid file (or to set a playlist) before trying to read any samples.
-
-
Method Detail
-
getFormat
public javax.sound.sampled.AudioFormat getFormat()
-
directory
public java.util.List<java.io.File> directory(java.io.File dir, java.lang.String ext)
Set playlist to all WAV files in given directory
-
getPlaylist
public java.util.List<java.io.File> getPlaylist()
-
rewind
public void rewind() throws java.io.IOException
Go back to start of playlist. Next block of samples will be from head of first file in playlist. Will throw an exception if there is no playlist- Throws:
java.io.IOException
-
next
public void next() throws java.io.IOException
Move to head of next file in playlist- Throws:
java.io.IOException
-
prev
public void prev() throws java.lang.Exception
Move to head of previous file in playlist- Throws:
java.lang.Exception
-
isOpen
public boolean isOpen()
-
close
public void close()
Closes current input stream- Overrides:
close
in classjava.io.InputStream
-
open
public void open() throws java.lang.Exception
Opens the playlist starting with the first file.- Throws:
java.lang.Exception
-
available
public int available()
Returns number of bytes available in current file- Overrides:
available
in classjava.io.InputStream
-
read
public int read(byte[] buf, int off, int len) throws java.io.IOException
Returns a Task which copies samples as doubles into the given buffer between the given positions.- Overrides:
read
in classjava.io.InputStream
- Throws:
java.io.IOException
-
-