qmk-firmware/docs/internals/midi_device.md

13 KiB

group midi_device

You use the functions when you are implementing your own midi device.

You set a send function to actually send bytes via your device, this method is called when you call a send function with this device, for instance midi_send_cc

You use the midi_device_input to process input data from the device and pass it through the device's associated callbacks.

You use the midi_device_set_pre_input_process_func if you want to have a function called at the beginning of the device's process function, generally to poll for input and pass that into midi_device_input

Summary

Members Descriptions
define MIDI_INPUT_QUEUE_LENGTH
enum input_state_t
public void midi_device_input(MidiDevice * device,uint8_t cnt,uint8_t * input) Process input bytes. This function parses bytes and calls the appropriate callbacks associated with the given device. You use this function if you are creating a custom device and you want to have midi input.
public void midi_device_set_send_func(MidiDevice * device,midi_var_byte_func_t send_func) Set the callback function that will be used for sending output data bytes. This is only used if you're creating a custom device. You'll most likely want the callback function to disable interrupts so that you can call the various midi send functions without worrying about locking.
public void midi_device_set_pre_input_process_func(MidiDevice * device,midi_no_byte_func_t pre_process_func) Set a callback which is called at the beginning of the midi_device_process call. This can be used to poll for input data and send the data through the midi_device_input function. You'll probably only use this if you're creating a custom device.
struct _midi_device This structure represents the input and output functions and processing data for a midi device.

Members

define MIDI_INPUT_QUEUE_LENGTH

enum input_state_t

Values Descriptions
IDLE
ONE_BYTE_MESSAGE
TWO_BYTE_MESSAGE
THREE_BYTE_MESSAGE
SYSEX_MESSAGE

public void midi_device_input(MidiDevice * device,uint8_t cnt,uint8_t * input)

Process input bytes. This function parses bytes and calls the appropriate callbacks associated with the given device. You use this function if you are creating a custom device and you want to have midi input.

Parameters

  • device the midi device to associate the input with

  • cnt the number of bytes you are processing

  • input the bytes to process

public void midi_device_set_send_func(MidiDevice * device,midi_var_byte_func_t send_func)

Set the callback function that will be used for sending output data bytes. This is only used if you're creating a custom device. You'll most likely want the callback function to disable interrupts so that you can call the various midi send functions without worrying about locking.

Parameters

  • device the midi device to associate this callback with

  • send_func the callback function that will do the sending

public void midi_device_set_pre_input_process_func(MidiDevice * device,midi_no_byte_func_t pre_process_func)

Set a callback which is called at the beginning of the midi_device_process call. This can be used to poll for input data and send the data through the midi_device_input function. You'll probably only use this if you're creating a custom device.

Parameters

  • device the midi device to associate this callback with

  • midi_no_byte_func_t the actual callback function

struct _midi_device

This structure represents the input and output functions and processing data for a midi device.

A device can represent an actual physical device [serial port, usb port] or something virtual. You should not need to modify this structure directly.

Summary

Members Descriptions
public midi_var_byte_func_t send_func
public midi_three_byte_func_t input_cc_callback
public midi_three_byte_func_t input_noteon_callback
public midi_three_byte_func_t input_noteoff_callback
public midi_three_byte_func_t input_aftertouch_callback
public midi_three_byte_func_t input_pitchbend_callback
public midi_three_byte_func_t input_songposition_callback
public midi_two_byte_func_t input_progchange_callback
public midi_two_byte_func_t input_chanpressure_callback
public midi_two_byte_func_t input_songselect_callback
public midi_two_byte_func_t input_tc_quarterframe_callback
public midi_one_byte_func_t input_realtime_callback
public midi_one_byte_func_t input_tunerequest_callback
public midi_sysex_func_t input_sysex_callback
public midi_var_byte_func_t input_fallthrough_callback
public midi_var_byte_func_t input_catchall_callback
public midi_no_byte_func_t pre_input_process_callback
public uint8_t input_buffer
public input_state_t input_state
public uint16_t input_count
public uint8_t input_queue_data
public byteQueue_t input_queue

Members

public midi_var_byte_func_t send_func

public midi_three_byte_func_t input_cc_callback

public midi_three_byte_func_t input_noteon_callback

public midi_three_byte_func_t input_noteoff_callback

public midi_three_byte_func_t input_aftertouch_callback

public midi_three_byte_func_t input_pitchbend_callback

public midi_three_byte_func_t input_songposition_callback

public midi_two_byte_func_t input_progchange_callback

public midi_two_byte_func_t input_chanpressure_callback

public midi_two_byte_func_t input_songselect_callback

public midi_two_byte_func_t input_tc_quarterframe_callback

public midi_one_byte_func_t input_realtime_callback

public midi_one_byte_func_t input_tunerequest_callback

public midi_sysex_func_t input_sysex_callback

public midi_var_byte_func_t input_fallthrough_callback

public midi_var_byte_func_t input_catchall_callback

public midi_no_byte_func_t pre_input_process_callback

public uint8_t input_buffer

public input_state_t input_state

public uint16_t input_count

public uint8_t input_queue_data

public byteQueue_t input_queue