net.sf.jack4j
Class JackMidiPortBuffer

java.lang.Object
  extended by net.sf.jack4j.JackMidiPortBuffer

public class JackMidiPortBuffer
extends java.lang.Object

MIDI buffer for JackLocalMidiPort.

The instance may be obtained with JackLocalMidiPort.initializeMidiBuffer(int), and is only valid during the current process cycle.


Constructor Summary
JackMidiPortBuffer(long bufferPointer)
           
 
Method Summary
 void clearBuffer()
          Clears an event buffer.
 long eventReserve(int time, int dataSize)
          Allocate space for an event to be written to an event port buffer.
 void eventWrite(int time, byte[] data)
          Write an event into an event port buffer.
 long getBufferPointer()
          Native pointer to buffer data.
 JackMidiEvent getEvent(int index)
          Returns MIDI event from the (input) buffer.
 int getEventCount()
          Returns current number of MIDI events in the buffer.
 int getLostEventsCount()
          Returns the number of events that could not be written to port.
 int getMaxEventSize()
          Returns the size of the largest event that can be stored by the port.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JackMidiPortBuffer

public JackMidiPortBuffer(long bufferPointer)
Method Detail

getBufferPointer

public long getBufferPointer()
Native pointer to buffer data.

The pointer is packed as long value.


getEventCount

public int getEventCount()
Returns current number of MIDI events in the buffer.


getEvent

public JackMidiEvent getEvent(int index)
                       throws JackException
Returns MIDI event from the (input) buffer.

Parameters:
index - event number, must be non-negative and lower than getEventCount()
Returns:
the event
Throws:
JackException - if native Jack API fails

clearBuffer

public void clearBuffer()
Clears an event buffer.

May be called only during client's process callback.

This should be called at the beginning of each process cycle before calling eventReserve(int, int) or eventWrite(int, byte[]). This function may not be called on an input port.


eventReserve

public long eventReserve(int time,
                         int dataSize)
                  throws JackException
Allocate space for an event to be written to an event port buffer.

May be called only during client's process callback.

There's probably no good reason to use this method in Java; use eventWrite(int, byte[]) instead.

The returned value is a native pointer of type jack_midi_data_t*. packed as long.

Clients are to write the actual event data to be written starting at the pointer returned by this function. Clients must not write more than dataSize bytes into this buffer. Clients must write normalized MIDI data to the port - no running status and no (1-byte) realtime messages interspersed with other messages (realtime messages are fine when they occur on their own, like other messages).

Parameters:
time - sample offset of the event (number of frames since cycle start)
dataSize - length of event's raw data in bytes
Returns:
jack_midi_data_t* packed as long
Throws:
JackException - if the error occurrs (native function jack_midi_event_reserve returns NULL)

eventWrite

public void eventWrite(int time,
                       byte[] data)
                throws JackException
Write an event into an event port buffer.

May be called only during client's process callback.

The data must be normalized MIDI data - no running status and no (1-byte) realtime messages interspersed with other messages (realtime messages are fine when they occur on their own, like other messages).

Parameters:
time - sample offset of the event (number of frames since cycle start)
data - raw MIDI data
Throws:
JackException - if error occurrs

getMaxEventSize

public int getMaxEventSize()
Returns the size of the largest event that can be stored by the port.

May be called only during client's process callback.


getLostEventsCount

public int getLostEventsCount()
Returns the number of events that could not be written to port.



Copyright © 2008 Ondrej Par. All Rights Reserved.