inpro.audio
Class LabelledAudioStream

java.lang.Object
  extended by java.io.InputStream
      extended by javax.sound.sampled.AudioInputStream
          extended by inpro.audio.LabelledAudioStream
All Implemented Interfaces:
java.io.Closeable

public class LabelledAudioStream
extends javax.sound.sampled.AudioInputStream


Nested Class Summary
static interface LabelledAudioStream.Listener
          interface to implement if you're interested in receiving label events
 
Field Summary
private  float bytesPerSecond
           
private  long labelEndPosition
           
private  boolean labelHasStarted
           
(package private)  java.util.Queue<Label> labels
           
private  long labelStartPosition
           
(package private)  java.util.List<LabelledAudioStream.Listener> listeners
           
private  long positionInBytes
           
 
Fields inherited from class javax.sound.sampled.AudioInputStream
format, frameLength, framePos, frameSize
 
Constructor Summary
LabelledAudioStream(java.lang.String fileURL)
          create a new labelled audio object from the two files fileBasename.wav and fileBasename.lab
LabelledAudioStream(java.lang.String fileURL, java.lang.String labelURL)
          create a new labelled audio object from the two files given
 
Method Summary
 void addListener(LabelledAudioStream.Listener l)
          add a label Listener to this stream
 int available()
           
 Label currentLabel()
          return the current label (or null if their is none at the moment)
private  void labelEnd(Label l)
          what to do when a label ends
private  void labelStart(Label l)
          what to do when a label starts
private  void nextLabel()
          advance to the next label and update bookkeeping
 int read(byte[] data)
           
 
Methods inherited from class javax.sound.sampled.AudioInputStream
close, getFormat, getFrameLength, mark, markSupported, read, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

labels

java.util.Queue<Label> labels

positionInBytes

private long positionInBytes

labelStartPosition

private long labelStartPosition

labelEndPosition

private long labelEndPosition

labelHasStarted

private boolean labelHasStarted

bytesPerSecond

private float bytesPerSecond

listeners

java.util.List<LabelledAudioStream.Listener> listeners
Constructor Detail

LabelledAudioStream

public LabelledAudioStream(java.lang.String fileURL)
                    throws java.net.MalformedURLException,
                           javax.sound.sampled.UnsupportedAudioFileException,
                           java.io.IOException
create a new labelled audio object from the two files fileBasename.wav and fileBasename.lab

Throws:
java.net.MalformedURLException
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException

LabelledAudioStream

public LabelledAudioStream(java.lang.String fileURL,
                           java.lang.String labelURL)
                    throws java.net.MalformedURLException,
                           javax.sound.sampled.UnsupportedAudioFileException,
                           java.io.IOException
create a new labelled audio object from the two files given

Throws:
java.net.MalformedURLException
javax.sound.sampled.UnsupportedAudioFileException
java.io.IOException
Method Detail

available

public int available()
              throws java.io.IOException
Overrides:
available in class javax.sound.sampled.AudioInputStream
Throws:
java.io.IOException

read

public int read(byte[] data)
         throws java.io.IOException
Overrides:
read in class javax.sound.sampled.AudioInputStream
Throws:
java.io.IOException

currentLabel

public Label currentLabel()
return the current label (or null if their is none at the moment)


nextLabel

private void nextLabel()
advance to the next label and update bookkeeping


labelStart

private void labelStart(Label l)
what to do when a label starts


labelEnd

private void labelEnd(Label l)
what to do when a label ends


addListener

public void addListener(LabelledAudioStream.Listener l)
add a label Listener to this stream