jass.render
Class RTAudioIn

java.lang.Object
  extended by java.lang.Thread
      extended by jass.render.RTAudioIn
All Implemented Interfaces:
java.lang.Runnable

public class RTAudioIn
extends java.lang.Thread

Utility class to read audio in real-time. Use appropriate constructor to use JavaSound or native sound support

Author:
Kees van den Doel (kvdoel@cs.ubc.ca)

Nested Class Summary
 
Nested classes/interfaces inherited from class java.lang.Thread
java.lang.Thread.State, java.lang.Thread.UncaughtExceptionHandler
 
Field Summary
 
Fields inherited from class java.lang.Thread
MAX_PRIORITY, MIN_PRIORITY, NORM_PRIORITY
 
Constructor Summary
RTAudioIn(float srate, int nchannels, int bufferSizeJass)
          Constructor.
RTAudioIn(float srate, int bitsPerFrame, int nchannels, boolean signed)
          Constructor.
RTAudioIn(float srate, int nchannels, int bufferSizeJass, int numRtAudioBuffers)
          Constructor.
RTAudioIn(int buffersize, float srate, int bitsPerFrame, int nchannels, boolean signed)
          Constructor.
RTAudioIn(int buffersize, float srate, int bitsPerFrame, int nchannels, boolean signed, java.lang.String prefMixer)
          Constructor.
 
Method Summary
 void close()
           
 void closeNativeSound(long nativeObjectPointer)
          Close native sound This is a native method and needs librtaudio.so (LINUX) or rtaudio.dll (Windows)
 long initNativeSound(int nchannels, int srate, int bufferSizeJass, int numRtAudioBuffers)
          Initialize native sound for RtAudio This is a native method and needs librtaudio.so (LINUX) or rtaudio.dll (Windows)
 void read(float[] y, int nsamples)
          Read audio buffer from input queue and block if queue is empty.
 void readNativeSoundFloat(long nativeObjectPointer, float[] buf, int buflen)
          Read a buffer of floats using native sound.
 
Methods inherited from class java.lang.Thread
activeCount, checkAccess, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, run, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

RTAudioIn

public RTAudioIn(int buffersize,
                 float srate,
                 int bitsPerFrame,
                 int nchannels,
                 boolean signed)
Constructor. Uses JavaSound with default mixer

Parameters:
bufferSize - Buffer size used by JavaSound.
srate - sampling rate in Hertz.
bitsPerFrame - number of bits per audio frame.
nchannels - number of audio channels.
signed - true if signed format, false otherwise.

RTAudioIn

public RTAudioIn(int buffersize,
                 float srate,
                 int bitsPerFrame,
                 int nchannels,
                 boolean signed,
                 java.lang.String prefMixer)
Constructor. Uses JavaSound and can set mixer to use (e.g. "Esd Mixer")

Parameters:
bufferSize - Buffer size used by JavaSound.
srate - sampling rate in Hertz.
bitsPerFrame - number of bits per audio frame.
nchannels - number of audio channels.
signed - true if signed format, false otherwise.
prefMixer - preferred mixer as name string

RTAudioIn

public RTAudioIn(float srate,
                 int bitsPerFrame,
                 int nchannels,
                 boolean signed)
Constructor. Uses default high latency JavaSound buffersize and default mixer

Parameters:
srate - sampling rate in Hertz.
bitsPerFrame - number of bits per audio frame.
nchannels - number of audio channels.
signed - true if signed format, false otherwise.

RTAudioIn

public RTAudioIn(float srate,
                 int nchannels,
                 int bufferSizeJass,
                 int numRtAudioBuffers)
Constructor. Uses native sound capture. This is a native method and needs librtaudio.so (LINUX) or rtaudio.dll (Windows)

Parameters:
srate - sampling rate in Hertz.
nchannels - number of audio channels.
bufferSizeJass - jass bufsz
numRtAudioBuffers - rtaudio parameter related to latency. 0 lowest

RTAudioIn

public RTAudioIn(float srate,
                 int nchannels,
                 int bufferSizeJass)
Constructor. Uses native sound capture. Uses default (0) for numRtAudioBuffers This is a native method and needs librtaudio.so (LINUX) or rtaudio.dll (Windows)

Parameters:
srate - sampling rate in Hertz.
nchannels - number of audio channels.
bufferSizeJass - jass bufsz
Method Detail

initNativeSound

public long initNativeSound(int nchannels,
                            int srate,
                            int bufferSizeJass,
                            int numRtAudioBuffers)
Initialize native sound for RtAudio This is a native method and needs librtaudio.so (LINUX) or rtaudio.dll (Windows)

Parameters:
nchannels - number of audio channels.
srate - sampling rate in Hertz.
bufferSizeJass - jass buffersize
numRtAudioBuffers - affectiing latency, 0 gives best latency
Returns:
long representing C++ object pointer

readNativeSoundFloat

public void readNativeSoundFloat(long nativeObjectPointer,
                                 float[] buf,
                                 int buflen)
Read a buffer of floats using native sound. This is a native method and needs librtaudio.so (LINUX) or rtaudio.dll (Windows)

Parameters:
nativeObjectPointer - representing C++ object pointer.
buf - array of float with sound buffer.
buflen - length of buffer.

closeNativeSound

public void closeNativeSound(long nativeObjectPointer)
Close native sound This is a native method and needs librtaudio.so (LINUX) or rtaudio.dll (Windows)

Parameters:
nativeObjectPointer - representing C++ object pointer

read

public void read(float[] y,
                 int nsamples)
Read audio buffer from input queue and block if queue is empty.

Parameters:
y - buffer to write to.
nsamples - number of samples required.

close

public void close()