Midi

#include <AMidi.h>

Summary

Enumerations

Anonymous Enum 12{
  AMIDI_OPCODE_DATA = 1,
  AMIDI_OPCODE_FLUSH = 2
}
enum
Anonymous Enum 13{
  AMIDI_DEVICE_TYPE_USB = 1,
  AMIDI_DEVICE_TYPE_VIRTUAL = 2,
  AMIDI_DEVICE_TYPE_BLUETOOTH = 3
}
enum

Typedefs

AMidiDevice typedef
struct AMidiDevice
AMidiInputPort typedef
struct AMidiInputPort
AMidiOutputPort typedef
struct AMidiOutputPort

Functions

AMidiDevice_fromJava(JNIEnv *env, jobject midiDeviceObj, AMidiDevice **outDevicePtrPtr)
media_status_t AMIDI_API
Connects a native Midi Device object to the associated Java MidiDevice object.
AMidiDevice_getNumInputPorts(const AMidiDevice *device)
ssize_t AMIDI_API
Gets the number of input (sending) ports available on the specified MIDI device.
AMidiDevice_getNumOutputPorts(const AMidiDevice *device)
ssize_t AMIDI_API
Gets the number of output (receiving) ports available on the specified MIDI device.
AMidiDevice_getType(const AMidiDevice *device)
int32_t AMIDI_API
Gets the MIDI device type.
AMidiDevice_release(const AMidiDevice *midiDevice)
media_status_t AMIDI_API
Disconnects the native Midi Device Object from the associated Java MidiDevice object.
AMidiInputPort_close(const AMidiInputPort *inputPort)
void AMIDI_API
Closes the input port.
AMidiInputPort_open(const AMidiDevice *device, int32_t portNumber, AMidiInputPort **outInputPortPtr)
media_status_t AMIDI_API
Opens the input port so that the client can send data to it.
AMidiInputPort_send(const AMidiInputPort *inputPort, const uint8_t *buffer, size_t numBytes)
ssize_t AMIDI_API
Sends data to the specified input port.
AMidiInputPort_sendFlush(const AMidiInputPort *inputPort)
media_status_t AMIDI_API
Sends a message with a 'MIDI flush command code' to the specified port.
AMidiInputPort_sendWithTimestamp(const AMidiInputPort *inputPort, const uint8_t *buffer, size_t numBytes, int64_t timestamp)
ssize_t AMIDI_API
Sends data to the specified input port with a timestamp.
AMidiOutputPort_close(const AMidiOutputPort *outputPort)
void AMIDI_API
Closes the output port.
AMidiOutputPort_open(const AMidiDevice *device, int32_t portNumber, AMidiOutputPort **outOutputPortPtr)
media_status_t AMIDI_API
Opens the output port so that the client can receive data from it.
AMidiOutputPort_receive(const AMidiOutputPort *outputPort, int32_t *opcodePtr, uint8_t *buffer, size_t maxBytes, size_t *numBytesReceivedPtr, int64_t *outTimestampPtr)
ssize_t AMIDI_API
Receives the next pending MIDI message.

Enumerations

Anonymous Enum 12

 Anonymous Enum 12

Typedefs

AMidiDevice

struct AMidiDevice AMidiDevice

AMidiInputPort

struct AMidiInputPort AMidiInputPort

AMidiOutputPort

struct AMidiOutputPort AMidiOutputPort

Functions

AMidiDevice_fromJava

media_status_t AMIDI_API AMidiDevice_fromJava(
  JNIEnv *env,
  jobject midiDeviceObj,
  AMidiDevice **outDevicePtrPtr
)

Connects a native Midi Device object to the associated Java MidiDevice object.

Use this AMidiDevice to access the rest of the native MIDI API. Use AMidiDevice_release() to disconnect from the Java object when not being used any more.

See also:AMEDIA_ERROR_INVALID_OBJECT - the midiDeviceObj is null or already connected to a native AMidiDevice See also:AMEDIA_ERROR_UNKNOWN - an unknown error occurred.

Details
Parameters
env
Points to the Java Environment.
midiDeviceObj
The Java MidiDevice Object.
outDevicePtrPtr
Points to the pointer to receive the AMidiDevice
Returns
AMEDIA_OK on success, or a negative error value:

AMidiDevice_getNumInputPorts

ssize_t AMIDI_API AMidiDevice_getNumInputPorts(
  const AMidiDevice *device
)

Gets the number of input (sending) ports available on the specified MIDI device.

See also:AMEDIA_ERROR_INVALID_PARAMETER - the device parameter is NULL. See also:AMEDIA_ERROR_UNKNOWN - couldn't retrieve the device info.

Details
Parameters
device
Specifies the MIDI device.
Returns
If successful, returns the number of MIDI input (sending) ports available on the device. If an error occurs, returns a negative value indicating the error:

AMidiDevice_getNumOutputPorts

ssize_t AMIDI_API AMidiDevice_getNumOutputPorts(
  const AMidiDevice *device
)

Gets the number of output (receiving) ports available on the specified MIDI device.

See also:AMEDIA_ERROR_INVALID_PARAMETER - the device parameter is NULL. See also:AMEDIA_ERROR_UNKNOWN - couldn't retrieve the device info.

Details
Parameters
device
Specifies the MIDI device.
Returns
If successful, returns the number of MIDI output (receiving) ports available on the device. If an error occurs, returns a negative value indicating the error:

AMidiDevice_getType

int32_t AMIDI_API AMidiDevice_getType(
  const AMidiDevice *device
)

Gets the MIDI device type.

See also:AMEDIA_ERROR_INVALID_PARAMETER - the device parameter is NULL. See also:AMEDIA_ERROR_UNKNOWN - Unknown error.

Details
Parameters
device
Specifies the MIDI device.
Returns
The identifier of the MIDI device type: AMIDI_DEVICE_TYPE_USB AMIDI_DEVICE_TYPE_VIRTUAL AMIDI_DEVICE_TYPE_BLUETOOTH or a negative error value:

AMidiDevice_release

media_status_t AMIDI_API AMidiDevice_release(
  const AMidiDevice *midiDevice
)

Disconnects the native Midi Device Object from the associated Java MidiDevice object.

See also:AMEDIA_ERROR_INVALID_PARAMETER - the device parameter is NULL. See also:AMEDIA_ERROR_INVALID_OBJECT - the device is not consistent with the associated Java MidiDevice. See also:AMEDIA_ERROR_INVALID_OBJECT - the JNI interface initialization to the associated java MidiDevice failed. See also:AMEDIA_ERROR_UNKNOWN - couldn't retrieve the device info.

Details
Parameters
midiDevice
Points to the native AMIDI_MidiDevice.
Returns
AMEDIA_OK on success, or a negative error value:

AMidiInputPort_close

void AMIDI_API AMidiInputPort_close(
  const AMidiInputPort *inputPort
)

Closes the input port.

Details
Parameters
inputPort
Identifies the input (sending) port to close.

AMidiInputPort_open

media_status_t AMIDI_API AMidiInputPort_open(
  const AMidiDevice *device,
  int32_t portNumber,
  AMidiInputPort **outInputPortPtr
)

Opens the input port so that the client can send data to it.

The port remains open and valid until AMidiInputPort_close() is called for the returned AMidiInputPort.

See also:AMEDIA_ERROR_UNKNOWN - Unknown Error.

Details
Parameters
device
Specifies the MIDI device.
portNumber
Specifies the zero-based port index on the device to open. This value ranges between 0 and one less than the number of input ports reported by the AMidiDevice_getNumInputPorts() function..
outInputPortPtr
Receives the native API port identifier of the opened port.
Returns
AMEDIA_OK, or a negative error code:

AMidiInputPort_send

ssize_t AMIDI_API AMidiInputPort_send(
  const AMidiInputPort *inputPort,
  const uint8_t *buffer,
  size_t numBytes
)

Sends data to the specified input port.

See also:AMEDIA_ERROR_INVALID_PARAMETER - The specified port was NULL, the specified buffer was NULL.

Details
Parameters
inputPort
The identifier of the port to send data to.
buffer
Points to the array of bytes containing the data to send.
numBytes
Specifies the number of bytes to write.
Returns
The number of bytes sent, which could be less than specified or a negative error code:

AMidiInputPort_sendFlush

media_status_t AMIDI_API AMidiInputPort_sendFlush(
  const AMidiInputPort *inputPort
)

Sends a message with a 'MIDI flush command code' to the specified port.

This should cause a receiver to discard any pending MIDI data it may have accumulated and not processed.

See also:AMEDIA_OK if successful, otherwise a negative error code: See also:AMEDIA_ERROR_INVALID_PARAMETER - The specified port was NULL See also:AMEDIA_ERROR_UNSUPPORTED - The FLUSH command couldn't be sent.

Details
Parameters
inputPort
The identifier of the port to send the flush command to.
Returns

AMidiInputPort_sendWithTimestamp

ssize_t AMIDI_API AMidiInputPort_sendWithTimestamp(
  const AMidiInputPort *inputPort,
  const uint8_t *buffer,
  size_t numBytes,
  int64_t timestamp
)

Sends data to the specified input port with a timestamp.

See also:AMEDIA_ERROR_INVALID_PARAMETER - The specified port was NULL, the specified buffer was NULL.

Details
Parameters
inputPort
The identifier of the port to send data to.
buffer
Points to the array of bytes containing the data to send.
numBytes
Specifies the number of bytes to write.
timestamp
The CLOCK_MONOTONIC time in nanoseconds to associate with the sent data.
Returns
The number of bytes sent, which could be less than specified or a negative error code:

AMidiOutputPort_close

void AMIDI_API AMidiOutputPort_close(
  const AMidiOutputPort *outputPort
)

Closes the output port.

Details
Parameters
outputPort
The native API port identifier of the port.

AMidiOutputPort_open

media_status_t AMIDI_API AMidiOutputPort_open(
  const AMidiDevice *device,
  int32_t portNumber,
  AMidiOutputPort **outOutputPortPtr
)

Opens the output port so that the client can receive data from it.

The port remains open and valid until AMidiOutputPort_close() is called for the returned AMidiOutputPort.

See also:AMEDIA_ERROR_UNKNOWN - Unknown Error.

Details
Parameters
device
Specifies the MIDI device.
portNumber
Specifies the zero-based port index on the device to open. This value ranges between 0 and one less than the number of output ports reported by the AMidiDevice_getNumOutputPorts function.
outOutputPortPtr
Receives the native API port identifier of the opened port.
Returns
AMEDIA_OK, or a negative error code:

AMidiOutputPort_receive

ssize_t AMIDI_API AMidiOutputPort_receive(
  const AMidiOutputPort *outputPort,
  int32_t *opcodePtr,
  uint8_t *buffer,
  size_t maxBytes,
  size_t *numBytesReceivedPtr,
  int64_t *outTimestampPtr
)

Receives the next pending MIDI message.

To retrieve all pending messages, the client should repeatedly call this method until it returns 0.

Note that this is a non-blocking call. If there are no Midi messages are available, the function returns 0 immediately (for 0 messages received).

See also:AMEDIA_ERROR_UNKNOWN - Unknown Error.

Details
Parameters
outputPort
Identifies the port to receive messages from.
opcodePtr
Receives the message Op Code.
buffer
Points to the buffer to receive the message data bytes.
maxBytes
Specifies the size of the buffer pointed to by the buffer parameter.
numBytesReceivedPtr
On exit, receives the actual number of bytes stored in buffer.
outTimestampPtr
If non-NULL, receives the timestamp associated with the message. (the current value of the running Java Virtual Machine's high-resolution time source, in nanoseconds)
Returns
the number of messages received (either 0 or 1), or a negative error code: