com.groovemanager.spi.rex
Class REXInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by com.groovemanager.spi.rex.REXInputStream
All Implemented Interfaces:
java.io.Closeable

class REXInputStream
extends java.io.InputStream

This class is used when constructing an AudioInputStream for REX files. It makes use of the REX API´s preview functionality.

Author:
Manu Robledo

Field Summary
private  java.nio.ByteBuffer[] buffers
          The buffers (one for each channel) into which the audio data will be rendered
private  int channels
          The number of channels in the file
private  int currentSlice
          The number of frames rendered so far.
private  REXHandle handle
          The REX handle representing the file to be streamed
private  int length
          The length of the file in sample frames
private  int sliceCount
          The number of slices
private  REXSliceInfo[] sliceInfos
          The REXSliceInfo objects for all slices
 
Constructor Summary
REXInputStream(REXHandle handle)
          Constrcuts a new REXInputStream
 
Method Summary
 int available()
           
 boolean markSupported()
           
 int read()
          because of the frame size granularity of 4 or 8 bytes, this method should never be called.
 int read(byte[] b)
           
 int read(byte[] b, int off, int len)
           
private  boolean renderNext()
          Render the next part of audio data
 long skip(long s)
           
 
Methods inherited from class java.io.InputStream
close, mark, reset
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

buffers

private java.nio.ByteBuffer[] buffers
The buffers (one for each channel) into which the audio data will be rendered


channels

private int channels
The number of channels in the file


currentSlice

private int currentSlice
The number of frames rendered so far.


handle

private REXHandle handle
The REX handle representing the file to be streamed


length

private int length
The length of the file in sample frames


sliceCount

private int sliceCount
The number of slices


sliceInfos

private REXSliceInfo[] sliceInfos
The REXSliceInfo objects for all slices

Constructor Detail

REXInputStream

REXInputStream(REXHandle handle)
         throws REXError
Constrcuts a new REXInputStream

Parameters:
handle - A REXHandle object referring to the audio data that should be streamed
Throws:
REXError
Method Detail

available

public int available()
              throws java.io.IOException
Overrides:
available in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.available()

markSupported

public boolean markSupported()
Overrides:
markSupported in class java.io.InputStream
See Also:
InputStream.markSupported()

read

public int read()
         throws java.io.IOException
because of the frame size granularity of 4 or 8 bytes, this method should never be called. Will always return 0.

Specified by:
read in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.read()

read

public int read(byte[] b)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.read(byte[])

read

public int read(byte[] b,
                int off,
                int len)
         throws java.io.IOException
Overrides:
read in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.read(byte[], int, int)

renderNext

private boolean renderNext()
Render the next part of audio data

Returns:
true if there was still data left to render, false otherwise

skip

public long skip(long s)
          throws java.io.IOException
Overrides:
skip in class java.io.InputStream
Throws:
java.io.IOException
See Also:
InputStream.skip(long)