com.groovemanager.spi.rex
Class REXHandle

java.lang.Object
  extended by com.groovemanager.spi.rex.NativeClass
      extended by com.groovemanager.spi.rex.REXHandle

final class REXHandle
extends NativeClass

This class is kind of a wrapper class vor the native REXHandle. All functions of the REX API that require a reference to a REXHandle instance are found in this wrapper class as member methods.

Author:
Manu Robledo

Field Summary
private  REXInfo info
          An REXInfo object is stored with each REXHAndle so that only one call to the native function REXGetInfo() is needed per handle.
 
Constructor Summary
private REXHandle()
          Private constructor will only be called from REXCreate()
(package private) REXHandle(long pointer)
          Create a new REXHandle that should be connected to an existing native instance specified by the given pointer.
 
Method Summary
protected  void cleanUp()
          Delete the corresponding native instance to this class
protected  long createClass()
          Create a new native instance and return its address
(package private)  javax.sound.sampled.AudioInputStream getAudioInputStream()
          Creates an AudioInputStream from this REXHandle
(package private) static boolean isBigEndian()
           
private  int jREXCreate(java.nio.ByteBuffer buffer)
           
private  void jREXDelete()
           
private  int jREXGetCreatorInfo(long infoPointer)
           
private  int jREXGetInfo(long infoPointer)
           
private static int jREXGetInfoFromBuffer(java.nio.ByteBuffer buffer, long infoPointer)
           
private  int jREXGetSliceInfo(int sliceIndex, long infoPointer)
           
private  int jREXRenderPreviewBatch(int framesToRender, java.nio.ByteBuffer left, java.nio.ByteBuffer right)
           
private  int jREXRenderSlice(int sliceIndex, int bufferFrameLength, java.nio.ByteBuffer left, java.nio.ByteBuffer right, boolean stereo)
           
private  int jREXSetOutputSampleRate(int rate)
           
private  int jREXSetPreviewTempo(int tempo)
           
private  int jREXStartPreview()
           
private  int jREXStopPreview()
           
(package private) static REXHandle REXCreate(java.io.File file)
          Create a new REXHandle out of a REX file
(package private)  REXCreatorInfo REXGetCreatorInfo()
          Get info about the author and copyright of the REX file represented by this handle
(package private)  REXInfo REXGetInfo()
          Get general information about the REX file represented by this handle
(package private) static REXInfo REXGetInfoFromBuffer(java.nio.ByteBuffer b)
          The REX API provides this function for getting information about a REX file without creating a REXHandle from it
(package private)  REXSliceInfo REXGetSliceInfo(int index)
          Get information about a specific slice inside this file
(package private) static int REXPercentFinished()
           
(package private)  void REXRenderPreviewBatch(int frames, java.nio.ByteBuffer[] buffers)
          Render one buffer of preview audio data. startPreview() must have been called before.
(package private)  void REXRenderSlice(int index, int bufferFrameLength, java.nio.ByteBuffer[] buffers)
          Render the audio data of one slice to the specified buffer
(package private)  void REXSetOutputSampleRate(int rate)
          Set the output sample rate at which the audio data should be rendered
(package private)  void REXSetPreviewTempo(int tempo)
          Set the tempo in which the audio data should be rendered
(package private)  void REXStartPreview()
          The REX API provides a preview mechanism for previewing REX files without rendering the different slices.
(package private)  void REXStopPreview()
          Stop a previously started preview.
 
Methods inherited from class com.groovemanager.spi.rex.NativeClass
finalize, getPointer
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

info

private REXInfo info
An REXInfo object is stored with each REXHAndle so that only one call to the native function REXGetInfo() is needed per handle.

Constructor Detail

REXHandle

private REXHandle()
Private constructor will only be called from REXCreate()


REXHandle

REXHandle(long pointer)
Create a new REXHandle that should be connected to an existing native instance specified by the given pointer.

Parameters:
pointer -
Method Detail

cleanUp

protected void cleanUp()
Description copied from class: NativeClass
Delete the corresponding native instance to this class

Specified by:
cleanUp in class NativeClass

createClass

protected long createClass()
Description copied from class: NativeClass
Create a new native instance and return its address

Specified by:
createClass in class NativeClass
Returns:
The address of the new created native instance

getAudioInputStream

javax.sound.sampled.AudioInputStream getAudioInputStream()
                                                   throws REXError
Creates an AudioInputStream from this REXHandle

Returns:
A new AudioInputStream for the file represented by this handle
Throws:
REXError

isBigEndian

static boolean isBigEndian()

jREXCreate

private int jREXCreate(java.nio.ByteBuffer buffer)

jREXDelete

private void jREXDelete()

jREXGetCreatorInfo

private int jREXGetCreatorInfo(long infoPointer)

jREXGetInfo

private int jREXGetInfo(long infoPointer)

jREXGetInfoFromBuffer

private static int jREXGetInfoFromBuffer(java.nio.ByteBuffer buffer,
                                         long infoPointer)

jREXGetSliceInfo

private int jREXGetSliceInfo(int sliceIndex,
                             long infoPointer)

jREXRenderPreviewBatch

private int jREXRenderPreviewBatch(int framesToRender,
                                   java.nio.ByteBuffer left,
                                   java.nio.ByteBuffer right)

jREXRenderSlice

private int jREXRenderSlice(int sliceIndex,
                            int bufferFrameLength,
                            java.nio.ByteBuffer left,
                            java.nio.ByteBuffer right,
                            boolean stereo)

jREXSetOutputSampleRate

private int jREXSetOutputSampleRate(int rate)

jREXSetPreviewTempo

private int jREXSetPreviewTempo(int tempo)

jREXStartPreview

private int jREXStartPreview()

jREXStopPreview

private int jREXStopPreview()

REXCreate

static REXHandle REXCreate(java.io.File file)
                    throws REXError,
                           java.io.IOException
Create a new REXHandle out of a REX file

Parameters:
file - The REX file to create the handle for
Returns:
A new REXHandle related to the given file
Throws:
REXError
java.io.IOException

REXGetCreatorInfo

REXCreatorInfo REXGetCreatorInfo()
                           throws REXError
Get info about the author and copyright of the REX file represented by this handle

Returns:
A REXCreatorInfo instance containing information about author and copyright
Throws:
REXError

REXGetInfo

REXInfo REXGetInfo()
Get general information about the REX file represented by this handle

Returns:
A REXinfo instance containing general information about the file represented by this handle

REXGetInfoFromBuffer

static REXInfo REXGetInfoFromBuffer(java.nio.ByteBuffer b)
                             throws REXError
The REX API provides this function for getting information about a REX file without creating a REXHandle from it

Parameters:
b - A direct ByteBuffer containing the whole REX file data
Returns:
A REXinfo instance containing general information about the file
Throws:
REXError

REXGetSliceInfo

REXSliceInfo REXGetSliceInfo(int index)
                       throws REXError
Get information about a specific slice inside this file

Parameters:
index - The zero-based index of the slice in question
Returns:
A REXSliceInfo instance containing information about the desired slice
Throws:
REXError

REXPercentFinished

static int REXPercentFinished()

REXRenderPreviewBatch

void REXRenderPreviewBatch(int frames,
                           java.nio.ByteBuffer[] buffers)
                     throws REXError
Render one buffer of preview audio data. startPreview() must have been called before.

Parameters:
frames - The number of sample frames to render
buffers - An Array of two direct ByteBuffers into which the data should be rendered
Throws:
REXError

REXRenderSlice

void REXRenderSlice(int index,
                    int bufferFrameLength,
                    java.nio.ByteBuffer[] buffers)
              throws REXError
Render the audio data of one slice to the specified buffer

Parameters:
index - The zero-based index of the slice which should be rendered
bufferFrameLength - The length of the buffer in sample frames
buffers - An Array of two direct ByteBuffers into which the audio data should be rendered
Throws:
REXError

REXSetOutputSampleRate

void REXSetOutputSampleRate(int rate)
                      throws REXError
Set the output sample rate at which the audio data should be rendered

Parameters:
rate - The new output sample rate
Throws:
REXError

REXSetPreviewTempo

void REXSetPreviewTempo(int tempo)
                  throws REXError
Set the tempo in which the audio data should be rendered

Parameters:
tempo - The bpm multiplied with 1000. 123.456 is given as 123456
Throws:
REXError

REXStartPreview

void REXStartPreview()
               throws REXError
The REX API provides a preview mechanism for previewing REX files without rendering the different slices. This method starts a preview.

Throws:
REXError

REXStopPreview

void REXStopPreview()
              throws REXError
Stop a previously started preview.

Throws:
REXError