public class Metro extends java.lang.Object implements MetroLock, org.jaudiolibs.jnajack.JackProcessCallback, org.jaudiolibs.jnajack.JackShutdownCallback, org.jaudiolibs.jnajack.JackTimebaseCallback, java.lang.Runnable, ThreadInitializerContainer<Metro>, ThreadInitializerCollectionContainer
Modifier and Type | Field and Description |
---|---|
protected org.jaudiolibs.jnajack.JackClient |
client |
protected java.util.ArrayList<MetroPort> |
inputPortList |
protected org.jaudiolibs.jnajack.Jack |
jack |
static java.lang.Object |
mainTrackId |
protected java.util.ArrayList<MetroPort> |
outputPortList |
protected java.lang.Thread |
thread |
Constructor and Description |
---|
Metro() |
Modifier and Type | Method and Description |
---|---|
static int |
calcOneBarLengthInFrames(Metro metro,
org.jaudiolibs.jnajack.JackClient client,
org.jaudiolibs.jnajack.JackPosition position) |
void |
clearAllPorts() |
void |
clearTracks() |
void |
clientShutdown(org.jaudiolibs.jnajack.JackClient client) |
void |
close() |
void |
connectPort(java.util.Map<java.lang.String,java.lang.String> map) |
void |
connectPort(java.lang.String from,
java.lang.String to) |
MetroPort |
createInputPort(java.lang.Object portName) |
MetroPort |
createOutputPort(java.lang.Object portName) |
MetroTrack |
createTrack(java.lang.Object name,
java.util.Collection<java.lang.Object> tags,
MetroSequence sequence) |
boolean |
destroyInputPort(MetroPort port) |
boolean |
destroyOutputPort(MetroPort port) |
void |
disconnectPort(java.lang.String from,
java.lang.String to) |
void |
dumpTracks()
For debug-purpose only.
|
void |
enterTrackChangeBlock() |
java.util.List<java.lang.String> |
getAvailableInputPorts() |
java.util.List<java.lang.String> |
getAvailableOutputPorts() |
long |
getBeatsPerBar() |
double |
getBeatsPerMinute() |
static Metro |
getCurrent() |
java.util.List<MetroPort> |
getInputPorts() |
MetroTrack |
getMainTrack()
A field which tracks a reference to the main track by best effort.
|
java.lang.Object |
getMetroLock()
The every routines which access to the `tracks` field must synchronize
to the object which can be retrieved by this getMetroLock() method.
|
int |
getOneBarLengthInFrames() |
java.util.List<MetroPort> |
getOutputPorts() |
boolean |
getPlaying() |
ThreadInitializer<Metro> |
getThreadInitializer() |
ThreadInitializerCollection |
getThreadInitializerCollection() |
java.util.Collection<MetroTrack> |
getTrackByTag(java.lang.String tag) |
double |
getUpdateSequenceThreshold() |
MetroPort |
inputPortNumberToPort(int i) |
boolean |
isOpened() |
static boolean |
isPresent() |
void |
leaveTrackChangeBlock() |
void |
notifyTrackChange()
Any caller of the methods
registerTrack(MetroTrack) and
unregisterTrack(MetroTrack) has responsibility to call
notifyTrackChange() method after calling. |
protected void |
onCreateThread() |
void |
open(java.lang.String clientName) |
MetroPort |
outputPortNumberToPort(int i) |
void |
postMessage(java.lang.Runnable runnable)
Post a new message which is denoted by a runnable objects.
|
boolean |
process(org.jaudiolibs.jnajack.JackClient client,
int nframes)
This method handles JACK's
process event. |
void |
putTrack(java.util.Collection<MetroTrack> trackList,
MetroSyncType syncType,
MetroTrack syncTrack,
double syncOffset) |
void |
putTrack(MetroTrack track,
MetroSyncType syncType,
MetroTrack syncTrack,
double syncOffset) |
void |
registerTrack(java.util.Collection<MetroTrack> trackList) |
void |
registerTrack(MetroTrack track)
This registers the specified track.
|
void |
removeTrack(java.util.Collection<MetroTrack> trackList,
MetroSyncType syncType,
MetroTrack syncTrack,
double syncOffset) |
void |
removeTrack(MetroTrack track,
MetroSyncType syncType,
MetroTrack syncTrack,
double syncOffset) |
java.util.List<MetroTrack> |
replicateAllTracks() |
void |
run()
Note that this method is called by another thread.
|
java.util.List<MetroPort> |
searchInputPort(Invokable condition) |
java.util.List<MetroPort> |
searchInputPort(java.lang.Object name) |
java.util.List<MetroPort> |
searchOutputPort(Invokable condition) |
java.util.List<MetroPort> |
searchOutputPort(java.lang.Object name) |
java.util.List<MetroTrack> |
searchTrack(Invokable invokable) |
java.util.List<MetroTrack> |
searchTrack(java.lang.Object name) |
java.util.Collection<MetroTrack> |
searchTracksByTag(java.lang.String tag) |
java.util.Collection<MetroTrack> |
searchTracksByTagSet(java.util.Collection<java.lang.String> tagSet) |
void |
setBeatsPerBar(long beatsPerBar) |
void |
setBeatsPerMinute(double beatsPerMinute) |
static void |
setMainTrackId(java.lang.Object id) |
void |
setPlaying(boolean playing) |
void |
setUpdateSequenceThreshold(double value) |
static Metro |
startClient(java.lang.String clientName,
MetroSequence sequence)
This is a utility method to create a Metro instance with a single sequence.
|
boolean |
togglePlaying() |
void |
unregisterTrack(java.util.Collection<MetroTrack> trackList) |
void |
unregisterTrack(MetroTrack track)
This method unregister the specified track.
|
void |
updatePosition(org.jaudiolibs.jnajack.JackClient invokingClient,
org.jaudiolibs.jnajack.JackTransportState state,
int nframes,
org.jaudiolibs.jnajack.JackPosition position,
boolean newPosition) |
public static java.lang.Object mainTrackId
protected org.jaudiolibs.jnajack.Jack jack
protected org.jaudiolibs.jnajack.JackClient client
protected java.lang.Thread thread
protected final java.util.ArrayList<MetroPort> inputPortList
protected final java.util.ArrayList<MetroPort> outputPortList
public static void setMainTrackId(java.lang.Object id)
public final java.lang.Object getMetroLock()
getMetroLock
in interface MetroLock
public ThreadInitializer<Metro> getThreadInitializer()
getThreadInitializer
in interface ThreadInitializerContainer<Metro>
public static Metro getCurrent()
public static boolean isPresent()
public ThreadInitializerCollection getThreadInitializerCollection()
getThreadInitializerCollection
in interface ThreadInitializerCollectionContainer
public MetroTrack getMainTrack()
public double getBeatsPerMinute()
public void setBeatsPerMinute(double beatsPerMinute) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public long getBeatsPerBar()
public void setBeatsPerBar(long beatsPerBar) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public void setUpdateSequenceThreshold(double value)
public double getUpdateSequenceThreshold()
public boolean getPlaying()
public void setPlaying(boolean playing)
public boolean togglePlaying()
public static Metro startClient(java.lang.String clientName, MetroSequence sequence) throws org.jaudiolibs.jnajack.JackException
clientName
- sequence
- org.jaudiolibs.jnajack.JackException
public MetroPort createInputPort(java.lang.Object portName) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public MetroPort createOutputPort(java.lang.Object portName) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public boolean destroyOutputPort(MetroPort port) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public boolean destroyInputPort(MetroPort port) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public java.util.List<MetroPort> getInputPorts()
public java.util.List<MetroPort> getOutputPorts()
public java.util.List<MetroPort> searchInputPort(java.lang.Object name)
public java.util.List<MetroPort> searchOutputPort(java.lang.Object name)
public void dumpTracks()
public java.util.Collection<MetroTrack> getTrackByTag(java.lang.String tag)
public MetroTrack createTrack(java.lang.Object name, java.util.Collection<java.lang.Object> tags, MetroSequence sequence)
public java.util.List<MetroTrack> replicateAllTracks()
public java.util.List<MetroTrack> searchTrack(Invokable invokable)
public java.util.List<MetroTrack> searchTrack(java.lang.Object name)
public java.util.Collection<MetroTrack> searchTracksByTag(java.lang.String tag)
public java.util.Collection<MetroTrack> searchTracksByTagSet(java.util.Collection<java.lang.String> tagSet)
public void open(java.lang.String clientName) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public boolean isOpened()
protected void onCreateThread()
public void close()
public void clearTracks()
public void run()
run
in interface java.lang.Runnable
public java.util.List<java.lang.String> getAvailableOutputPorts() throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public java.util.List<java.lang.String> getAvailableInputPorts() throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public void connectPort(java.util.Map<java.lang.String,java.lang.String> map)
public void connectPort(java.lang.String from, java.lang.String to) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public void disconnectPort(java.lang.String from, java.lang.String to) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public void clearAllPorts() throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public boolean process(org.jaudiolibs.jnajack.JackClient client, int nframes)
process
event.
This is possibly called by JACK's thread.process
in interface org.jaudiolibs.jnajack.JackProcessCallback
public MetroPort outputPortNumberToPort(int i)
public MetroPort inputPortNumberToPort(int i)
public void notifyTrackChange()
Any caller of the methods registerTrack(MetroTrack)
and
unregisterTrack(MetroTrack)
has responsibility to call
notifyTrackChange()
method after calling. When multiple tracks are
registered/unregistered at once, the caller must call
notifyTrackChange()
at least once a session and not necessarily call
every time registering a track.
It is preferable that a user who performs any bulk-registering calls
notifyTrackChange()
method only once after the registering a set of
track and they should avoid to redundantly call notifyTrackChange()
multiple times.
Any caller of this method should place the calling inside a synchronized
block of an object which you can retrieve by getMetroLock()
method;
otherwise you will get an unexpected result.
synchronized (getMetroLock()) { MetroTrack track = createTrack(...); registerTrack(track); notifyCheckBuffer(); }
track
- public void enterTrackChangeBlock()
public void leaveTrackChangeBlock()
public void registerTrack(MetroTrack track)
registerTrack(MetroTrack)
method.track
- #registerTrack(MetroTrack)}
public void registerTrack(java.util.Collection<MetroTrack> trackList)
public void unregisterTrack(MetroTrack track)
registerTrack(MetroTrack)
method.track
- #registerTrack(MetroTrack)}
public void unregisterTrack(java.util.Collection<MetroTrack> trackList)
public void postMessage(java.lang.Runnable runnable)
runnable
- the procedure to run at a later time.public void putTrack(MetroTrack track, MetroSyncType syncType, MetroTrack syncTrack, double syncOffset)
public void putTrack(java.util.Collection<MetroTrack> trackList, MetroSyncType syncType, MetroTrack syncTrack, double syncOffset)
public void removeTrack(MetroTrack track, MetroSyncType syncType, MetroTrack syncTrack, double syncOffset)
public void removeTrack(java.util.Collection<MetroTrack> trackList, MetroSyncType syncType, MetroTrack syncTrack, double syncOffset)
public void clientShutdown(org.jaudiolibs.jnajack.JackClient client)
clientShutdown
in interface org.jaudiolibs.jnajack.JackShutdownCallback
public void updatePosition(org.jaudiolibs.jnajack.JackClient invokingClient, org.jaudiolibs.jnajack.JackTransportState state, int nframes, org.jaudiolibs.jnajack.JackPosition position, boolean newPosition)
updatePosition
in interface org.jaudiolibs.jnajack.JackTimebaseCallback
public int getOneBarLengthInFrames() throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException
public static int calcOneBarLengthInFrames(Metro metro, org.jaudiolibs.jnajack.JackClient client, org.jaudiolibs.jnajack.JackPosition position) throws org.jaudiolibs.jnajack.JackException
org.jaudiolibs.jnajack.JackException