net.sf.jack4j.examples
Class Metronome

java.lang.Object
  extended by net.sf.jack4j.JackClient
      extended by net.sf.jack4j.JackTransportClient
          extended by net.sf.jack4j.AbstractJackTransportClient
              extended by net.sf.jack4j.examples.Metronome

public class Metronome
extends AbstractJackTransportClient

Metronome that can cooperate with Jack transport infrastructure.

The metronome can run in one of three modes:

For transport-aware and transport-BBT-aware mode, you need a tool that can control Jack transport (qjackctl, for example). For transport-BBT-aware mode, you also need a Timebase master that controls bar/beat/tick and BBT-offset information (you can use TimebaseMaster example from Jack4j package).

See comments in the code that describe the usage of Jack4j library.

To run the examples, you need to have the native Jack4j library in your system load path (LD_LIBRARY_PATH under Linux).

This example client expects single command line parameter - client name.

Author:
repa

Constructor Summary
Metronome(java.lang.String clientName, boolean useExactName, boolean canStartServer, java.lang.String serverName)
           
 
Method Summary
static void main(java.lang.String[] args)
           
 int process(int bufferSize)
          This is callback method, invoked by Jack client thread during each process cycle.
 void run()
          Activation and main event loop.
 
Methods inherited from class net.sf.jack4j.AbstractJackTransportClient
bufferSizeCallback, clientRegistrationCallback, freewheelCallback, graphOrderCallback, portConnectCallback, portRegistrationCallback, sampleRateCallback, syncCallback, threadInitCallback, timebaseCallback, xRunCallback
 
Methods inherited from class net.sf.jack4j.JackTransportClient
getCurrentTransportFrame, locateTransport, queryTransport, releaseTimebase, repositionTransport, setDefaultSyncCallback, setDefaultTimebaseCallback, setSyncCallback, setSyncTimeout, setTimebaseCallback, startTransport, stopTransport, unsetSyncCallback
 
Methods inherited from class net.sf.jack4j.JackClient
activate, addAudioPort, addMidiPort, addPort, close, connect, cpuLoad, deactivate, disconnect, finalize, framesSinceCycleStart, framesToTime, frameTime, getAllPortConnections, getBufferSize, getCallbackStruct, getClientHandle, getClientName, getClientThread, getPorts, getPorts, getSampleRate, getStatistics, getTotalPortLatency, internalClientByName, isActive, isMine, isOpen, isProcessMethodSynchronized, isRealtime, isShutdown, lastFrameTime, loadInternalClient, localPort, localPortNames, portById, portByName, recomputeTotalLatencies, recomputeTotalPortLatency, removePort, requestPortMonitorByName, setAllDefaultCallbacks, setBufferSize, setBufferSizeCallback, setClientRegistrationCallback, setDefaultBufferSizeCallback, setDefaultClientRegistrationCallback, setDefaultFreewheelCallback, setDefaultGraphOrderCallback, setDefaultPortConnectCallback, setDefaultPortRegistrationCallback, setDefaultProcessCallback, setDefaultSampleRateCallback, setDefaultShutdownCallback, setDefaultThreadInitCallback, setDefaultXRunCallback, setFreewheel, setFreewheelCallback, setGraphOrderCallback, setPortConnectCallback, setPortRegistrationCallback, setProcessCallback, setProcessMethodSynchronized, setSampleRateCallback, setShutdownCallback, setThreadInitCallback, setXRunCallback, threadWait, time, timeToFrames
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Metronome

public Metronome(java.lang.String clientName,
                 boolean useExactName,
                 boolean canStartServer,
                 java.lang.String serverName)
          throws JackException
Throws:
JackException
Method Detail

process

public int process(int bufferSize)
            throws java.lang.Exception
This is callback method, invoked by Jack client thread during each process cycle.

This method produces the sound.

The method is expected to put bufferSize samples into buffer associated with the output audio port.

Port was created earlier, during client initialization.

Note that this method is not synchronized, but the native code that invokes this method always obtains a lock on this JackClient instance, so it actually behaves as a synchronized method.

Overrides:
process in class AbstractJackTransportClient
Throws:
java.lang.Exception
See Also:
JackClient.process(int)

run

public void run()
         throws JackException,
                java.io.IOException
Activation and main event loop.

Throws:
JackException
java.io.IOException

main

public static void main(java.lang.String[] args)
                 throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 2008 Ondrej Par. All Rights Reserved.