de.gulden.framework.jjack
Class JJackSystem

java.lang.Object
  extended by de.gulden.framework.jjack.JJackSystem
All Implemented Interfaces:
JJackConstants

public class JJackSystem
extends java.lang.Object
implements JJackConstants

JJack system class. This purely static class is the bridge between the native JACK client and the Java classes implementing JJackAudioProcessor.

Version:
0.3
Author:
Jens Gulden

Field Summary
private static JJackAudioProcessor client
           
private static java.lang.String clientName
           
static boolean DEBUG
          Flag for debug mode.
private static java.lang.String DEFAULT_AUTOCONNECT
          Default auto-connect mode.
private static java.lang.String DEFAULT_CLIENT_NAME
          Default name of the native JACK client to register.
private static java.lang.String DEFAULT_PORTS
          Default ports count.
private static java.lang.String DEFAULT_VERBOSE
          Default verbose mode.
private static long infPointer
          Pointer to native handle-structure.
private static JJackException initError
           
private static boolean initialized
           
private static java.lang.Object lock
           
private static int portsInput
           
private static boolean portsInputAutoconnect
           
private static int portsOutput
           
private static boolean portsOutputAutoconnect
           
private static java.lang.String PROPERTY_CLIENT_NAME
          Name of the system property specifying the name of the native JACK client to register.
private static java.lang.String PROPERTY_PORTS
          Name of the system property specifying how many ports to allocate.
private static java.lang.String PROPERTY_VERBOSE
          Name of the system property specifying whether JJack should give more verbose output.
private static boolean running
           
private static java.lang.String SUFFIX_AUTOCONNECT
          Suffix of the system property specifying whether ports should be auto-connected to physical JACK ports.
private static java.lang.String SUFFIX_INPUT
          Additional suffix of the system property specifying how many input ports to allocate.
private static java.lang.String SUFFIX_OUTPUT
          Suffix of the system property specifying how many output ports to allocate.
private static boolean verbose
           
static java.lang.String VERSION
          JJack version number.
 
Fields inherited from interface de.gulden.framework.jjack.JJackConstants
INPUT, LEFT, OUTPUT, RIGHT
 
Constructor Summary
private JJackSystem()
          Private constructor for getting an instance of Runnable.
 
Method Summary
static int calculateSampleCount(int milliseconds)
          Calculates number of samples used for a single channel in the given amount of milliseconds.
static int countPorts(int inout)
          Returns the number of ports available either for input or output mode.
static java.lang.String getInfo()
          Returns a short information text about the JJack system and its current status.
static java.lang.String getJackClientName()
          Returns the name of the native JACK client that has been regstered by the JJack system.
static JJackAudioProcessor getProcessor()
          Returns the audio processor which is responsible for signal processing.
static int getSampleRate()
          Returns the sample rate used by the JACK daemon.
private static void init()
          Initialized the JJack system.
(package private) static void init1()
           
static boolean isInitialized()
           
static void log(java.lang.Object src, java.lang.String msg)
          Logs a message from the specified source object, if verbose mode is enabled.
static void main(java.lang.String[] args)
          Wrapper main()-method, invokes the main()-method of the class specified as arg[0].
private static void nativeDestroy()
          Native client shutdown.
private static void nativeInit()
          Native initialization.
private static void nativeStart()
          Native client start.
static void process(JJackAudioProcessor p, JJackAudioEvent e)
          Process an audio event by a given audio processor.
private static void processBytes(java.nio.ByteBuffer[] in, java.nio.ByteBuffer[] out)
          This method is the actual bridge from JACK to Java.
static void setProcessor(JJackAudioProcessor cl)
          Sets the audio processor which is responsible for signal processing.
static void shutdown()
           
private static void start()
          Start background processing on the Java side.
private static void stop()
          Stops background processing on the Java side.
private static void usage()
          Output usage description, then exit with error code.
static boolean verbose()
          Returns whether the JJack sytem runs in verbose mode.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

VERSION

public static final java.lang.String VERSION
JJack version number.

See Also:
Constant Field Values

DEBUG

public static final boolean DEBUG
Flag for debug mode.

See Also:
Constant Field Values

PROPERTY_CLIENT_NAME

private static final java.lang.String PROPERTY_CLIENT_NAME
Name of the system property specifying the name of the native JACK client to register.

See Also:
Constant Field Values

DEFAULT_CLIENT_NAME

private static final java.lang.String DEFAULT_CLIENT_NAME
Default name of the native JACK client to register.

See Also:
Constant Field Values

PROPERTY_VERBOSE

private static final java.lang.String PROPERTY_VERBOSE
Name of the system property specifying whether JJack should give more verbose output.

See Also:
Constant Field Values

DEFAULT_VERBOSE

private static final java.lang.String DEFAULT_VERBOSE
Default verbose mode.

See Also:
Constant Field Values

PROPERTY_PORTS

private static final java.lang.String PROPERTY_PORTS
Name of the system property specifying how many ports to allocate.

See Also:
Constant Field Values

SUFFIX_INPUT

private static final java.lang.String SUFFIX_INPUT
Additional suffix of the system property specifying how many input ports to allocate.

See Also:
Constant Field Values

SUFFIX_OUTPUT

private static final java.lang.String SUFFIX_OUTPUT
Suffix of the system property specifying how many output ports to allocate.

See Also:
Constant Field Values

DEFAULT_PORTS

private static final java.lang.String DEFAULT_PORTS
Default ports count.

See Also:
Constant Field Values

SUFFIX_AUTOCONNECT

private static final java.lang.String SUFFIX_AUTOCONNECT
Suffix of the system property specifying whether ports should be auto-connected to physical JACK ports.

See Also:
Constant Field Values

DEFAULT_AUTOCONNECT

private static final java.lang.String DEFAULT_AUTOCONNECT
Default auto-connect mode.

See Also:
Constant Field Values

clientName

private static java.lang.String clientName

portsInput

private static int portsInput

portsOutput

private static int portsOutput

portsInputAutoconnect

private static boolean portsInputAutoconnect

portsOutputAutoconnect

private static boolean portsOutputAutoconnect

client

private static JJackAudioProcessor client

initError

private static JJackException initError

initialized

private static boolean initialized

running

private static boolean running

verbose

private static boolean verbose

lock

private static java.lang.Object lock

infPointer

private static long infPointer
Pointer to native handle-structure. Yes, this carries a real physical memory address. See the native implementation of libjjack.so in file libjjack.c.

Constructor Detail

JJackSystem

private JJackSystem()
Private constructor for getting an instance of Runnable.

Method Detail

getSampleRate

public static int getSampleRate()
Returns the sample rate used by the JACK daemon.

Returns:
the sample rate

setProcessor

public static void setProcessor(JJackAudioProcessor cl)
Sets the audio processor which is responsible for signal processing. The process()-method of this audio processor will then regularly be called.


getProcessor

public static JJackAudioProcessor getProcessor()
Returns the audio processor which is responsible for signal processing.

Returns:
the audio processor

main

public static void main(java.lang.String[] args)
                 throws java.lang.Throwable
Wrapper main()-method, invokes the main()-method of the class specified as arg[0]. By this time, the Jack connection has already been established by the static initializer.

Parameters:
args - command line parameters
Throws:
java.lang.Throwable - if an unhandled exception occurs inside the wrapped application, or a JJackException if initializing the Jack client was not successful.

shutdown

public static void shutdown()
                     throws JJackException
Throws:
JJackException

getJackClientName

public static java.lang.String getJackClientName()
Returns the name of the native JACK client that has been regstered by the JJack system.

Returns:
the client name

countPorts

public static int countPorts(int inout)
Returns the number of ports available either for input or output mode.

Parameters:
inout - either constant INPUT or OUTPUT
Returns:
the number of ports

verbose

public static boolean verbose()
Returns whether the JJack sytem runs in verbose mode.

Returns:
true if verbose mode

log

public static void log(java.lang.Object src,
                       java.lang.String msg)
Logs a message from the specified source object, if verbose mode is enabled.

Parameters:
src - the source object, usually the originator of the log message
msg - the message text

calculateSampleCount

public static int calculateSampleCount(int milliseconds)
Calculates number of samples used for a single channel in the given amount of milliseconds. The current system sample rate is being taken into account.

Returns:
number of sample values

process

public static void process(JJackAudioProcessor p,
                           JJackAudioEvent e)
Process an audio event by a given audio processor.

Parameters:
p - the audio processor that is to process the event
e - the audio event

getInfo

public static java.lang.String getInfo()
Returns a short information text about the JJack system and its current status.

Returns:
information text

isInitialized

public static boolean isInitialized()

init1

static void init1()

usage

private static void usage()
Output usage description, then exit with error code.


nativeInit

private static void nativeInit()
                        throws JJackException
Native initialization.

Throws:
JJackException

nativeStart

private static void nativeStart()
                         throws JJackException
Native client start.

Throws:
JJackException

nativeDestroy

private static void nativeDestroy()
                           throws JJackException
Native client shutdown.

Throws:
JJackException

init

private static void init()
                  throws JJackException
Initialized the JJack system.

Throws:
JJackException

start

private static void start()
                   throws JJackException
Start background processing on the Java side.

Throws:
JJackException - if an error occurs

stop

private static void stop()
Stops background processing on the Java side. (Not implemented.)


processBytes

private static void processBytes(java.nio.ByteBuffer[] in,
                                 java.nio.ByteBuffer[] out)
This method is the actual bridge from JACK to Java. It is directly called from native code, and only from there.

Parameters:
in - the direct memory access input buffer
out - the direct memory access output buffer