com.groovemanager.spi.asio
Class ASIOMixer

java.lang.Object
  extended by com.groovemanager.spi.asio.ASIOMixer
All Implemented Interfaces:
ASIOListener, Line, Mixer

public class ASIOMixer
extends Object
implements Mixer, ASIOListener

An ASIOMixer represents an ASIO driver

Author:
Manu Robledo

Nested Class Summary
 
Nested classes/interfaces inherited from interface javax.sound.sampled.Mixer
Mixer.Info
 
Field Summary
private  ASIODataLine[] activeLines
          Lines that have been opened simultanously and must be started and stopped simultaneously.
private  HashMap<String,ASIODataLine> allLines
          The lines associated to this mixer
private  ASIOBufferInfo[] asioBufferInfos
          ASIOBufferInfo objects used for ASIOPrepare()
private  ArrayList<ASIOListener> asioListeners
          List of ASIOListeners
(package private)  int bufferIndex
          The bufferIndex of the buffer half which should be filled right now and will be copied next to the asio buffers
private  int buffersize
          buffersize
private  ASIODriverInfo driverInfo
          The ASIODriverInfo of the ASIO driver represented by this Mixer
(package private) static int INITIALIZED
          Status constants
private  long initSeq
          Sequence number from ASIOInit()-call
private  long lastSample
          Variable for getMicrosecondPosition() and getSamplePosition()
private  long lastTime
          Variable for getMicrosecondPosition() and getSamplePosition()
private  ArrayList<ASIODataLine> linesToSync
          Lines that have to be opened simultaneously.
private  ArrayList<LineListener> listeners
          List of LineListeners
(package private) static int LOADED
          Status constants
private  ASIOMixerProvider.ASIOMixerInfo mixerInfo
          The Mixer.Info corresponding to this Mixer
private  long nanosSinceOpen
          Variable for getMicrosecondPosition() and getSamplePosition()
(package private) static double[] POSSIBLE_RATES
          Because the ASIO driver can only say if he supports specific rates or not, we have to ask him before we can define the ASIOFormats it supports.
(package private) static int PREPARED
          Status constants
(package private) static int RUNNING
          Status constants
private  long samplesSinceOpen
          Variable for getMicrosecondPosition() and getSamplePosition()
private  ASIOLineInfo[] sourceInfo
          The info objects for getSourceLineInfo()
private  int status
          The current status of this ASIO driver
private  ASIOLineInfo[] targetInfo
          The info objects for getTargetLineInfo()
(package private)  byte[] tempBuffer
          Temporary byte buffer for compy operations
(package private) static int UNLOADED
          Status constants
 
Constructor Summary
ASIOMixer(ASIOMixerProvider.ASIOMixerInfo i)
          Constructs a new ASIOMixer
 
Method Summary
 void addASIOListener(ASIOListener listener)
          Adds an ASIOListener that will be notified of callbacks from this ASIO driver
 void addLineListener(LineListener listener)
           
(package private)  void ASIOExit(long seq)
          Calls ASIOExit(), ASIODisposeBuffers() and ASIOStop() for this Mixer if needed.
(package private)  long ASIOInit()
          Try to initialize the ASIO driver.
private  long ASIOPrepare(ASIOBufferInfo[] infos, int buffersize)
          Calls ASIOCreateBuffers() and ASIO Init() for this Mixer if needed and returns a sequence number for the use with ASIOExit()
private  long ASIOStart(ASIOBufferInfo[] infos, int buffersize)
          Calls ASIOStart(), ASIOCreateBuffers and ASIOInit() for this mixer if needed and returns a sequence number for the use with ASIOExit()
private  boolean ASIOStop()
          Calls ASIOStop() for this Mixer if needed
(package private)  boolean ASIOUnPrepare()
          Calls ASIODisposeBuffers() and ASIOStop() for this Mixer if needed
 boolean bufferSizeChanged(ASIOMixer mixer, int newSize)
          Indicates that the preferred buffer size of the driver has changed.
(package private)  void bufferSwitchTimeInfo(ASIOTime time, int index, boolean processNow, boolean internal)
          ASIOīs bufferSwitchTimeInfo() callback
 void close()
           
(package private)  void close(long seq)
          Closes this Mixer only if the sequence number matches the one which was generated by ASIOInit()
(package private)  void closeLine(ASIODataLine line, long seq)
          Request from an ASIODataLine to be closed
private  void createLines(boolean isInput)
          create the lines that correspond to this Mixer.
private  void freeVM()
          Free all references in the native code
(package private)  AudioFormat[] getAudioFormats(ASIOChannelInfo cInfo)
          Get all AudioFormats supported by an ASIODataLine.
private  int getBufferSizeGranularity()
          Get the granularity of the driverīs buffersize in sample frames
 Control getControl(Control.Type control)
          No Controls are supported by ASIOMixer.
 Control[] getControls()
          No Controls are supported by ASIOMixer.
(package private)  int getDriverVersion()
          Get the version of the ASIO driver
 int getInputLatency()
          Get the current input Latency in sample frames
 ASIODataLine getLine(Line.Info info)
           
 Line.Info getLineInfo()
           
(package private)  int getMaxBufferSize()
          Get the maximum buffersize supported by this driver
(package private) static int getMaxFrameSize(AudioFormat[] formats)
          Get the maximum frame size out of some given AudioFormats.
private  int getMaxInChannels()
          Get the number of input channels on this device
 int getMaxLines(Line.Info info)
           
private  int getMaxOutChannels()
          Get the number of output channels on this device
(package private)  long getMicrosecondPosition()
          Is used for DataLine.getMicrosencondposition()
(package private)  int getMinBufferSize()
          Get the minimum buffersize supported by this driver
(package private) static int getMinFrameSize(AudioFormat[] formats)
          Get the minimum frame size out of some given AudioFormats.
 ASIOMixerProvider.ASIOMixerInfo getMixerInfo()
           
(package private)  String getName()
          Get the name of the ASIO driver
 int getOutputLatency()
          Get the current output Latency in sample frames
(package private)  int getPreferredBufferSize()
          Get the preferreed buffersize of the ASIO driver
(package private)  long getSamplePosition()
          Is used by ASIODataLine.getFramePosition()
(package private)  double getSampleRate()
          Get the current sample rate of this ASIO driver
 ASIOLineInfo[] getSourceLineInfo()
          Returns one ASIOLineInfo object for each mono output channel of this device.
 Line.Info[] getSourceLineInfo(Line.Info info)
           
 ASIODataLine[] getSourceLines()
           
(package private)  int getStatus()
          Get the status of the ASIO driver
 ASIOLineInfo[] getTargetLineInfo()
          Returns one ASIOLineInfo object for each mono input channel of this device.
 Line.Info[] getTargetLineInfo(Line.Info info)
           
 ASIODataLine[] getTargetLines()
           
private  void initVM()
          Initialize some variables in the native code for being able to accept callbacks from native code
 boolean isControlSupported(Control.Type control)
          No Controls are supported by ASIOMixer.
 boolean isLineSupported(Line.Info info)
           
private  boolean isLineSupported(Line l)
          Indicate whether a Line object is belonging to this ASIOMixer instance
 boolean isOpen()
           
 boolean isSynchronizationSupported(Line[] lines, boolean maintainSync)
          Synchronization is supported for all Lines of this Mixer.
(package private)  void jBufferSwitchTimeInfo(long asioTime, int index, boolean directProcess)
          This method is called from the native bufferSwitchTimeInfo callback
 boolean latenciesChanged(ASIOMixer mixer)
          Indicates that the input - and/or output-latencies have changed.
private  void notifyListeners(LineEvent e)
          Notify the LineListeners of a LineEvent
 void open()
           
(package private)  void openLine(ASIODataLine line)
          A request from an ASIOdataLine to be opened with default buffersize
(package private)  void openLine(ASIODataLine line, int buffersize)
          A request from an ASIODataLine to be opened with the given buffersize
private  void prepare(ASIODataLine[] lines, int buffersize)
          Prepare all Lines, buffers etc. for being able to start.
 void removeASIOListener(ASIOListener listener)
          Removes a registeres ASIOListener
 void removeLineListener(LineListener listener)
           
 void resetRequest(ASIOMixer mixer)
          Is called when the driver needs a reset.
 boolean resyncRequest(ASIOMixer mixer)
          Indicates that the driver has lost its sync because of some reason and needs resyncing (usually stop and restart)
 void sampleRateChanged(ASIOMixer mixer, double newRate)
          Indicates that the sample rate has changed.
(package private)  void setDriverInfo(ASIODriverInfo driverInfo)
          Set the driver info of this ASIOMixer instance.
(package private)  void setStatus(int i)
          Set the status of this Mixer.
 void showControlPanel()
          Open the ASIO Control Panel for this driver
(package private)  void startLine(ASIODataLine line)
          A request from an ASIODataLine to be started
(package private)  void stopLine(ASIODataLine line)
          Request from an ASIODataLine to be stopped
 boolean supportsBufferSizeChange()
          Ask if this ASIOListener will react to the bufferSizeChanged() call.
 boolean supportsLatenciesChanged()
          Ask if this ASIOListener will react to the latenciesChanged() call.
 boolean supportsResyncRequest()
          Ask if this ASIOListener will react to the resyncRequest() call.
 void synchronize(Line[] lines, boolean maintainSync)
          ASIO automatically synchronizes all DataLines on one Mixer.
 void unsynchronize(Line[] lines)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

POSSIBLE_RATES

static final double[] POSSIBLE_RATES
Because the ASIO driver can only say if he supports specific rates or not, we have to ask him before we can define the ASIOFormats it supports. These rates will be queried.


sourceInfo

private ASIOLineInfo[] sourceInfo
The info objects for getSourceLineInfo()


targetInfo

private ASIOLineInfo[] targetInfo
The info objects for getTargetLineInfo()


mixerInfo

private ASIOMixerProvider.ASIOMixerInfo mixerInfo
The Mixer.Info corresponding to this Mixer


driverInfo

private ASIODriverInfo driverInfo
The ASIODriverInfo of the ASIO driver represented by this Mixer


listeners

private ArrayList<LineListener> listeners
List of LineListeners


UNLOADED

static final int UNLOADED
Status constants

See Also:
Constant Field Values

LOADED

static final int LOADED
Status constants

See Also:
Constant Field Values

INITIALIZED

static final int INITIALIZED
Status constants

See Also:
Constant Field Values

PREPARED

static final int PREPARED
Status constants

See Also:
Constant Field Values

RUNNING

static final int RUNNING
Status constants

See Also:
Constant Field Values

status

private int status
The current status of this ASIO driver


allLines

private HashMap<String,ASIODataLine> allLines
The lines associated to this mixer


linesToSync

private ArrayList<ASIODataLine> linesToSync
Lines that have to be opened simultaneously. Used with synchronize()


activeLines

private ASIODataLine[] activeLines
Lines that have been opened simultanously and must be started and stopped simultaneously.


asioBufferInfos

private ASIOBufferInfo[] asioBufferInfos
ASIOBufferInfo objects used for ASIOPrepare()


initSeq

private long initSeq
Sequence number from ASIOInit()-call


lastTime

private long lastTime
Variable for getMicrosecondPosition() and getSamplePosition()


lastSample

private long lastSample
Variable for getMicrosecondPosition() and getSamplePosition()


nanosSinceOpen

private long nanosSinceOpen
Variable for getMicrosecondPosition() and getSamplePosition()


samplesSinceOpen

private long samplesSinceOpen
Variable for getMicrosecondPosition() and getSamplePosition()


buffersize

private int buffersize
buffersize


asioListeners

private ArrayList<ASIOListener> asioListeners
List of ASIOListeners


bufferIndex

int bufferIndex
The bufferIndex of the buffer half which should be filled right now and will be copied next to the asio buffers


tempBuffer

byte[] tempBuffer
Temporary byte buffer for compy operations

Constructor Detail

ASIOMixer

ASIOMixer(ASIOMixerProvider.ASIOMixerInfo i)
Constructs a new ASIOMixer

Parameters:
i - The ASIOInfo describing the ASIO driver
Method Detail

initVM

private void initVM()
Initialize some variables in the native code for being able to accept callbacks from native code


freeVM

private void freeVM()
Free all references in the native code


setDriverInfo

void setDriverInfo(ASIODriverInfo driverInfo)
Set the driver info of this ASIOMixer instance. Is called from the ASIOMixerProvider

Parameters:
driverInfo -

getName

String getName()
Get the name of the ASIO driver

Returns:
The name of the ASIO driver

getDriverVersion

int getDriverVersion()
Get the version of the ASIO driver

Returns:
The version of the ASIO driver

getStatus

int getStatus()
Get the status of the ASIO driver

Returns:
One of the status constants

createLines

private void createLines(boolean isInput)
create the lines that correspond to this Mixer. Should be called only once for one Mixer


showControlPanel

public void showControlPanel()
Open the ASIO Control Panel for this driver


getMixerInfo

public ASIOMixerProvider.ASIOMixerInfo getMixerInfo()
Specified by:
getMixerInfo in interface Mixer
See Also:
Mixer.getMixerInfo()

setStatus

void setStatus(int i)
Set the status of this Mixer. Should only be called from ASIOMixerProvider

Parameters:
i - The new status

ASIOInit

long ASIOInit()
        throws ASIOError
Try to initialize the ASIO driver. This is meeded for most inquiry methods. A sequence number is returned that must be passed to ASIOExit() after finishing the request. This sequence number is only valid if the driver was really initialized with this call. If it had been initialized before, the sequence number will be invalid. This mechanism gaurantees that ASIOExit only causes an unload of the driver if the caller is the one that initialized the driver.

Returns:
A sequence number that should be used as an argument to ASIOExit()
Throws:
ASIOError - If neither input nor output is present (ASE_NotPresent), other possible ASIOErrors are ASE_NoMemory and ASE_HWMalfunction

ASIOPrepare

private long ASIOPrepare(ASIOBufferInfo[] infos,
                         int buffersize)
                  throws ASIOError
Calls ASIOCreateBuffers() and ASIO Init() for this Mixer if needed and returns a sequence number for the use with ASIOExit()

Parameters:
infos - Array of ASIOBufferInfos which will be filled in the call
buffersize - The ASIO buffersize in sample frames
Returns:
A sequence number that should be used with ASIOExit()
Throws:
ASIOError - If not enough memory is available for the buffers (ASE_NoMemory), if no input/output is present (ASE_NotPresent), if buffersize is not supported or one or more of the ASIOBufferInfo elements contain invalid settings (ASE_InvalidMode). Other possible value is ASE_HWMalfunction

ASIOStart

private long ASIOStart(ASIOBufferInfo[] infos,
                       int buffersize)
                throws ASIOError
Calls ASIOStart(), ASIOCreateBuffers and ASIOInit() for this mixer if needed and returns a sequence number for the use with ASIOExit()

Parameters:
infos - Array of ASIOBufferInfos which will be filled in the call
buffersize - The ASIO buffersize in sample frames
Returns:
A sequence number that should be used with ASIOExit()
Throws:
ASIOError - If not enough memory is available for the buffers (ASE_NoMemory), if no input/output is present (ASE_NotPresent), if buffersize is not supported or one or more of the ASIOBufferInfo elements contain invalid settings (ASE_InvalidMode). Other possible value is ASE_HWMalfunction

ASIOStop

private boolean ASIOStop()
                  throws ASIOError
Calls ASIOStop() for this Mixer if needed

Returns:
true if the call to ASIOStop() succeeded
Throws:
ASIOError - If neither input nor output is present (ASE_NotPresent)

ASIOUnPrepare

boolean ASIOUnPrepare()
                throws ASIOError
Calls ASIODisposeBuffers() and ASIOStop() for this Mixer if needed

Returns:
true if the calls succeede, false otherwise
Throws:
ASIOError - If neither input nor output is present (ASE_NotPresent), if no buffers were ever created(ASE_InvalidMode)

ASIOExit

void ASIOExit(long seq)
Calls ASIOExit(), ASIODisposeBuffers() and ASIOStop() for this Mixer if needed.

Parameters:
seq - A sequence number which should have been gotten from ASIOInit(). Only if this sequence number is the one of the call that initialized the driver, the driver will be unloaded.

getSourceLineInfo

public ASIOLineInfo[] getSourceLineInfo()
Returns one ASIOLineInfo object for each mono output channel of this device. You can query the returned objects with ASIOLineInfo.getName().

Specified by:
getSourceLineInfo in interface Mixer
See Also:
Mixer.getSourceLineInfo()

getMinFrameSize

static int getMinFrameSize(AudioFormat[] formats)
Get the minimum frame size out of some given AudioFormats. Needed for the conversion between ASIOīs buffersizes (in sample frames) and Java Soundīs buffersizes (in bytes)

Parameters:
formats - The formats to query for their frame size
Returns:
The minimum occuring frame size or AudioSystem.NOT_SPECIFIED

getMaxFrameSize

static int getMaxFrameSize(AudioFormat[] formats)
Get the maximum frame size out of some given AudioFormats. Needed for the conversion between ASIOīs buffersizes (in sample frames) and Java Soundīs buffersizes (in bytes)

Parameters:
formats - The formats to query for their frame size
Returns:
The maximum occuring frame size or AudioSystem.NOT_SPECIFIED

getAudioFormats

AudioFormat[] getAudioFormats(ASIOChannelInfo cInfo)
Get all AudioFormats supported by an ASIODataLine. All supported sample rates will be taken into account as well as all possible numbers of channels. The rest is specified by the ASIOChannelInfo. If a line is the last one on a device (e.g. the 8th channel on an 8 channel device) it will only support mono formats. All other channels will support mono, stereo and all possible numbers of channels from their channel number up to the highest channel.

Parameters:
cInfo - The ASIOChannelInfo describing the channel
Returns:
An Array of AudioFormats supported by this channel

getTargetLineInfo

public ASIOLineInfo[] getTargetLineInfo()
Returns one ASIOLineInfo object for each mono input channel of this device. You can query the returned objects with ASIOLineInfo.getName().

Specified by:
getTargetLineInfo in interface Mixer
See Also:
Mixer.getTargetLineInfo()

getSourceLineInfo

public Line.Info[] getSourceLineInfo(Line.Info info)
Specified by:
getSourceLineInfo in interface Mixer
See Also:
Mixer.getSourceLineInfo(javax.sound.sampled.Line.Info)

getTargetLineInfo

public Line.Info[] getTargetLineInfo(Line.Info info)
Specified by:
getTargetLineInfo in interface Mixer
See Also:
Mixer.getTargetLineInfo(javax.sound.sampled.Line.Info)

getMinBufferSize

int getMinBufferSize()
               throws ASIOError
Get the minimum buffersize supported by this driver

Returns:
The minimum buffer size in sample frames
Throws:
ASIOError - if the driver could not be initialized

getMaxBufferSize

int getMaxBufferSize()
               throws ASIOError
Get the maximum buffersize supported by this driver

Returns:
The maximum buffer size in sample frames
Throws:
ASIOError - if the driver could not be initialized

isLineSupported

private boolean isLineSupported(Line l)
Indicate whether a Line object is belonging to this ASIOMixer instance

Parameters:
l - The Line to test
Returns:
true if this Line belongs to this Mixer, false otherwise

isLineSupported

public boolean isLineSupported(Line.Info info)
Specified by:
isLineSupported in interface Mixer
See Also:
Mixer.isLineSupported(javax.sound.sampled.Line.Info)

getLine

public ASIODataLine getLine(Line.Info info)
                     throws LineUnavailableException
Specified by:
getLine in interface Mixer
Throws:
LineUnavailableException
See Also:
Mixer.getLine(javax.sound.sampled.Line.Info)

getMaxLines

public int getMaxLines(Line.Info info)
Specified by:
getMaxLines in interface Mixer
See Also:
Mixer.getMaxLines(javax.sound.sampled.Line.Info)

getSourceLines

public ASIODataLine[] getSourceLines()
Specified by:
getSourceLines in interface Mixer
See Also:
Mixer.getSourceLines()

getTargetLines

public ASIODataLine[] getTargetLines()
Specified by:
getTargetLines in interface Mixer
See Also:
Mixer.getTargetLines()

synchronize

public void synchronize(Line[] lines,
                        boolean maintainSync)
ASIO automatically synchronizes all DataLines on one Mixer. But if you want to use more than one line simultaneosly on an ASIOMixer, you will have to call this Method before opening a line. Otherwise trying to open a Line when another one is already open on this Mixer would result in a LineUnavailableException

Specified by:
synchronize in interface Mixer
See Also:
Mixer.synchronize(javax.sound.sampled.Line[], boolean)

unsynchronize

public void unsynchronize(Line[] lines)
Specified by:
unsynchronize in interface Mixer
See Also:
Mixer.unsynchronize(javax.sound.sampled.Line[])

getMaxInChannels

private int getMaxInChannels()
Get the number of input channels on this device

Returns:
The number of input channels or 0 if the ASIO driver can not be initialized

getMaxOutChannels

private int getMaxOutChannels()
Get the number of output channels on this device

Returns:
The number of input channels or 0 if the ASIO driver can not be initialized

isSynchronizationSupported

public boolean isSynchronizationSupported(Line[] lines,
                                          boolean maintainSync)
Synchronization is supported for all Lines of this Mixer.

Specified by:
isSynchronizationSupported in interface Mixer
See Also:
Mixer.isSynchronizationSupported(javax.sound.sampled.Line[], boolean)

getLineInfo

public Line.Info getLineInfo()
Specified by:
getLineInfo in interface Line
See Also:
Line.getLineInfo()

open

public void open()
          throws LineUnavailableException
Specified by:
open in interface Line
Throws:
LineUnavailableException
See Also:
Line.open()

close

public void close()
Specified by:
close in interface Line
See Also:
Line.close()

close

void close(long seq)
Closes this Mixer only if the sequence number matches the one which was generated by ASIOInit()

Parameters:
seq - The sequence number

isOpen

public boolean isOpen()
Specified by:
isOpen in interface Line
See Also:
Line.isOpen()

getControls

public Control[] getControls()
No Controls are supported by ASIOMixer.

Specified by:
getControls in interface Line
See Also:
Line.getControls()

isControlSupported

public boolean isControlSupported(Control.Type control)
No Controls are supported by ASIOMixer.

Specified by:
isControlSupported in interface Line
See Also:
Line.isControlSupported(javax.sound.sampled.Control.Type)

getControl

public Control getControl(Control.Type control)
No Controls are supported by ASIOMixer.

Specified by:
getControl in interface Line
See Also:
Line.getControl(javax.sound.sampled.Control.Type)

addLineListener

public void addLineListener(LineListener listener)
Specified by:
addLineListener in interface Line
See Also:
Line.addLineListener(javax.sound.sampled.LineListener)

removeLineListener

public void removeLineListener(LineListener listener)
Specified by:
removeLineListener in interface Line
See Also:
Line.removeLineListener(javax.sound.sampled.LineListener)

notifyListeners

private void notifyListeners(LineEvent e)
Notify the LineListeners of a LineEvent

Parameters:
e - The LineEvent

openLine

void openLine(ASIODataLine line)
        throws LineUnavailableException
A request from an ASIOdataLine to be opened with default buffersize

Parameters:
line - The ASIODataLine the askes to be opened
Throws:
LineUnavailableException

getPreferredBufferSize

int getPreferredBufferSize()
Get the preferreed buffersize of the ASIO driver

Returns:
The preferred buffer size in sample frames or 0 if the driver could not be initialized

openLine

void openLine(ASIODataLine line,
              int buffersize)
        throws LineUnavailableException
A request from an ASIODataLine to be opened with the given buffersize

Parameters:
line - The ASIODataLine which requests to be opened
buffersize - The requested buffersize in sample frames
Throws:
LineUnavailableException - If other lines are already open on this Mixer or if the driver could not be initialized

startLine

void startLine(ASIODataLine line)
A request from an ASIODataLine to be started

Parameters:
line - The ASIODataLine which requests to be started

prepare

private void prepare(ASIODataLine[] lines,
                     int buffersize)
Prepare all Lines, buffers etc. for being able to start.

Parameters:
lines - The ASIODataLines which should be synchronized
buffersize - The buffersize in sample frames

getBufferSizeGranularity

private int getBufferSizeGranularity()
Get the granularity of the driverīs buffersize in sample frames

Returns:
the granularity at which buffer sizes may differ. Usually, the buffer size will be a power of 2; in this case, granularity will hold -1 on return, signaling possible buffer sizes starting from minSize, increased in powers of 2 up to maxSize.

stopLine

void stopLine(ASIODataLine line)
Request from an ASIODataLine to be stopped

Parameters:
line - The ASIODataLine which requested to be stopped

getMicrosecondPosition

long getMicrosecondPosition()
Is used for DataLine.getMicrosencondposition()

Returns:
The number of microseconds that this line has been running since it was opened

jBufferSwitchTimeInfo

void jBufferSwitchTimeInfo(long asioTime,
                           int index,
                           boolean directProcess)
This method is called from the native bufferSwitchTimeInfo callback

Parameters:
asioTime - Pointer to an ASIOTime structure
index - The buffer half index that should be processed
directProcess - Indicates whether this method should return immediately or should process the buffer contents immediately

bufferSwitchTimeInfo

void bufferSwitchTimeInfo(ASIOTime time,
                          int index,
                          boolean processNow,
                          boolean internal)
ASIOīs bufferSwitchTimeInfo() callback

Parameters:
time - ASIOTime object that represents the time and sample position at which this call was launched
index - The buffer half index that should be processed
processNow - Indicates whether this method should return immediately or should process the buffer contents immediately
internal - Indicates if this call has come from the ASIO driver (false) or as an internal call from this Mixer (true)

closeLine

void closeLine(ASIODataLine line,
               long seq)
Request from an ASIODataLine to be closed

Parameters:
line - The ASIODataLine which requests to be closed
seq - The sequence number with which this line was opened

getSampleRate

double getSampleRate()
Get the current sample rate of this ASIO driver

Returns:
The current sample rate of this ASIO driver

getSamplePosition

long getSamplePosition()
Is used by ASIODataLine.getFramePosition()

Returns:
The number of sampleFrames played back or recorded since the Line was opened

addASIOListener

public void addASIOListener(ASIOListener listener)
Adds an ASIOListener that will be notified of callbacks from this ASIO driver

Parameters:
listener - The ASIOlistener to be added

removeASIOListener

public void removeASIOListener(ASIOListener listener)
Removes a registeres ASIOListener

Parameters:
listener - The ASIOListener to be removed

sampleRateChanged

public void sampleRateChanged(ASIOMixer mixer,
                              double newRate)
Description copied from interface: ASIOListener
Indicates that the sample rate has changed. May be because of external sync or because of opening an ASIODataLine with a new AudioFormat

Specified by:
sampleRateChanged in interface ASIOListener
Parameters:
mixer - The ASIOMixer representing the ASIO driver
newRate - The new sample rate
See Also:
ASIOListener.sampleRateChanged(com.groovemanager.spi.asio.ASIOMixer, double)

resetRequest

public void resetRequest(ASIOMixer mixer)
Description copied from interface: ASIOListener
Is called when the driver needs a reset. It will automatically be closed.

Specified by:
resetRequest in interface ASIOListener
Parameters:
mixer - The ASIOMixer representing the ASIO driver
See Also:
ASIOListener.resetRequest(com.groovemanager.spi.asio.ASIOMixer)

supportsBufferSizeChange

public boolean supportsBufferSizeChange()
Description copied from interface: ASIOListener
Ask if this ASIOListener will react to the bufferSizeChanged() call. If it ignores calls to bufferSizeChanged(), false should be returned.

Specified by:
supportsBufferSizeChange in interface ASIOListener
Returns:
true if this listener may react to calls to bufferSizeChanged(), false otherwise
See Also:
ASIOListener.supportsBufferSizeChange()

bufferSizeChanged

public boolean bufferSizeChanged(ASIOMixer mixer,
                                 int newSize)
Description copied from interface: ASIOListener
Indicates that the preferred buffer size of the driver has changed.

Specified by:
bufferSizeChanged in interface ASIOListener
Parameters:
mixer - The ASIOMixer representing the ASIO driver
newSize - The new buffersize in sample frames. Please note that this value means a size in frames, not a number of bytes.
Returns:
true if this listener has accepted the message, false otherwise.
See Also:
ASIOListener.bufferSizeChanged(com.groovemanager.spi.asio.ASIOMixer, int)

supportsResyncRequest

public boolean supportsResyncRequest()
Description copied from interface: ASIOListener
Ask if this ASIOListener will react to the resyncRequest() call. If it ignores calls to resyncRequest(), false should be returned.

Specified by:
supportsResyncRequest in interface ASIOListener
Returns:
true if this listener may react to calls to resyncRequest(), false otherwise
See Also:
ASIOListener.supportsResyncRequest()

resyncRequest

public boolean resyncRequest(ASIOMixer mixer)
Description copied from interface: ASIOListener
Indicates that the driver has lost its sync because of some reason and needs resyncing (usually stop and restart)

Specified by:
resyncRequest in interface ASIOListener
Parameters:
mixer - The ASIOMixer representing the ASIO driver
Returns:
true if this listener has accepted the message, false otherwise.
See Also:
ASIOListener.resyncRequest(com.groovemanager.spi.asio.ASIOMixer)

supportsLatenciesChanged

public boolean supportsLatenciesChanged()
Description copied from interface: ASIOListener
Ask if this ASIOListener will react to the latenciesChanged() call. If it ignores calls to latenciesChanged(), false should be returned.

Specified by:
supportsLatenciesChanged in interface ASIOListener
Returns:
true if this listener may react to calls to latenciesChanged(), false otherwise

latenciesChanged

public boolean latenciesChanged(ASIOMixer mixer)
Description copied from interface: ASIOListener
Indicates that the input - and/or output-latencies have changed. The latency values can be queried by ASIOMixer.getInputLatency() and ASIOMixer.getOutputLatency()

Specified by:
latenciesChanged in interface ASIOListener
Parameters:
mixer - The ASIOMixer representing the ASIO driver
Returns:
true if this listener has accepted the message, false otherwise.
See Also:
ASIOListener.latenciesChanged(com.groovemanager.spi.asio.ASIOMixer)

getInputLatency

public int getInputLatency()
Get the current input Latency in sample frames

Returns:
The current input latency in sample frames

getOutputLatency

public int getOutputLatency()
Get the current output Latency in sample frames

Returns:
The current output latency in sample frames