File syn_usb_midi.h¶
FileList > drivers > syn_usb_midi.h
Go to the source code of this file
Zero-Heap USB 2.0 MIDI Class Device Driver. More...
#include "syntropic/common/syn_defs.h"#include "syntropic/drivers/syn_usb.h"#include <stdbool.h>#include <stddef.h>#include <stdint.h>
Classes¶
| Type | Name |
|---|---|
| struct | SYN_USB_MIDI |
| struct | SYN_USB_MIDI_Packet |
Public Functions¶
| Type | Name |
|---|---|
| SYN_Status | syn_usb_midi_init (SYN_USB_MIDI * midi) Initialize USB MIDI Class Instance. |
| SYN_Status | syn_usb_midi_parse_packet (const uint8_t raw_bytes, SYN_USB_MIDI_Packet * packet) Parse a 4-byte raw USB MIDI packet into structured event packet. |
| SYN_Status | syn_usb_midi_register (SYN_USB_Device * dev, SYN_USB_MIDI * midi) Register USB MIDI class driver with USB device core. |
| SYN_Status | syn_usb_midi_send_cc (SYN_USB_MIDI * midi, uint8_t channel, uint8_t controller, uint8_t value) Encode and queue a Control Change (CC) MIDI message. |
| SYN_Status | syn_usb_midi_send_note_off (SYN_USB_MIDI * midi, uint8_t channel, uint8_t note, uint8_t velocity) Encode and queue a Note Off MIDI message. |
| SYN_Status | syn_usb_midi_send_note_on (SYN_USB_MIDI * midi, uint8_t channel, uint8_t note, uint8_t velocity) Encode and queue a Note On MIDI message. |
| SYN_Status | syn_usb_midi_send_pitch_bend (SYN_USB_MIDI * midi, uint8_t channel, int16_t value) Encode and queue a Pitch Bend MIDI message. |
Macros¶
| Type | Name |
|---|---|
| define | SYN_USB_MIDI_CIN_CABLE_EVENT 0x1U |
| define | SYN_USB_MIDI_CIN_CHANNEL_PRESSURE 0xDU |
| define | SYN_USB_MIDI_CIN_CONTROL_CHANGE 0xBU |
| define | SYN_USB_MIDI_CIN_MISC 0x0U |
| define | SYN_USB_MIDI_CIN_NOTE_OFF 0x8U |
| define | SYN_USB_MIDI_CIN_NOTE_ON 0x9U |
| define | SYN_USB_MIDI_CIN_PITCH_BEND 0xEU |
| define | SYN_USB_MIDI_CIN_POLY_KEYPRESS 0xAU |
| define | SYN_USB_MIDI_CIN_PROGRAM_CHANGE 0xCU |
| define | SYN_USB_MIDI_CIN_SINGLE_BYTE 0xFU |
| define | SYN_USB_MIDI_CIN_SYSEX_ENDS_1 0x5U |
| define | SYN_USB_MIDI_CIN_SYSEX_ENDS_2 0x6U |
| define | SYN_USB_MIDI_CIN_SYSEX_ENDS_3 0x7U |
| define | SYN_USB_MIDI_CIN_SYSEX_START 0x4U |
| define | SYN_USB_MIDI_CIN_SYSTEM_COMMON_2 0x2U |
| define | SYN_USB_MIDI_CIN_SYSTEM_COMMON_3 0x3U |
| define | SYN_USB_MIDI_MAX_PACKET_SIZE 64U |
Detailed Description¶
Implements USB Class Definition for MIDI Devices v1.0 (Audio Streaming subclass). Provides 4-byte USB MIDI Event Packet encoding and decoding for Note On/Off, Control Change, Pitch Bend, and Program Change messages.
Public Functions Documentation¶
function syn_usb_midi_init¶
Initialize USB MIDI Class Instance.
Parameters:
midiPointer to USB MIDI instance.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if NULL.
function syn_usb_midi_parse_packet¶
Parse a 4-byte raw USB MIDI packet into structured event packet.
Parameters:
raw_bytes4-byte raw buffer.packetOutput structured packet pointer.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if NULL.
function syn_usb_midi_register¶
Register USB MIDI class driver with USB device core.
Parameters:
devPointer to USB device core context.midiPointer to USB MIDI instance.
Returns:
SYN_OK on success, SYN_INVALID_PARAM if NULL.
function syn_usb_midi_send_cc¶
Encode and queue a Control Change (CC) MIDI message.
SYN_Status syn_usb_midi_send_cc (
SYN_USB_MIDI * midi,
uint8_t channel,
uint8_t controller,
uint8_t value
)
Parameters:
midiPointer to USB MIDI instance.channelMIDI Channel (0..15).controllerController Number (0..127).valueController Value (0..127).
Returns:
SYN_OK on success, SYN_INVALID_PARAM if invalid.
function syn_usb_midi_send_note_off¶
Encode and queue a Note Off MIDI message.
SYN_Status syn_usb_midi_send_note_off (
SYN_USB_MIDI * midi,
uint8_t channel,
uint8_t note,
uint8_t velocity
)
Parameters:
midiPointer to USB MIDI instance.channelMIDI Channel (0..15).noteMIDI Note Number (0..127).velocityRelease Velocity (0..127).
Returns:
SYN_OK on success, SYN_INVALID_PARAM if invalid.
function syn_usb_midi_send_note_on¶
Encode and queue a Note On MIDI message.
SYN_Status syn_usb_midi_send_note_on (
SYN_USB_MIDI * midi,
uint8_t channel,
uint8_t note,
uint8_t velocity
)
Parameters:
midiPointer to USB MIDI instance.channelMIDI Channel (0..15).noteMIDI Note Number (0..127).velocityNote Velocity (0..127).
Returns:
SYN_OK on success, SYN_INVALID_PARAM if invalid.
function syn_usb_midi_send_pitch_bend¶
Encode and queue a Pitch Bend MIDI message.
Parameters:
midiPointer to USB MIDI instance.channelMIDI Channel (0..15).valuePitch Bend value (-8192..+8191, center 0).
Returns:
SYN_OK on success, SYN_INVALID_PARAM if invalid.
Macro Definition Documentation¶
define SYN_USB_MIDI_CIN_CABLE_EVENT¶
Cable events
define SYN_USB_MIDI_CIN_CHANNEL_PRESSURE¶
Channel Pressure message (0xD0)
define SYN_USB_MIDI_CIN_CONTROL_CHANGE¶
Control Change message (0xB0)
define SYN_USB_MIDI_CIN_MISC¶
USB MIDI Code Index Number (CIN) definitions per USB MIDI Spec Table 4-1 Miscellaneous function codes
define SYN_USB_MIDI_CIN_NOTE_OFF¶
Note Off message (0x80)
define SYN_USB_MIDI_CIN_NOTE_ON¶
Note On message (0x90)
define SYN_USB_MIDI_CIN_PITCH_BEND¶
Pitch Bend message (0xE0)
define SYN_USB_MIDI_CIN_POLY_KEYPRESS¶
Poly KeyPress message (0xA0)
define SYN_USB_MIDI_CIN_PROGRAM_CHANGE¶
Program Change message (0xC0)
define SYN_USB_MIDI_CIN_SINGLE_BYTE¶
Single Byte message
define SYN_USB_MIDI_CIN_SYSEX_ENDS_1¶
Single-byte SysEx ends
define SYN_USB_MIDI_CIN_SYSEX_ENDS_2¶
2-byte SysEx ends
define SYN_USB_MIDI_CIN_SYSEX_ENDS_3¶
3-byte SysEx ends
define SYN_USB_MIDI_CIN_SYSEX_START¶
SysEx starts or continues
define SYN_USB_MIDI_CIN_SYSTEM_COMMON_2¶
2-byte System Common messages
define SYN_USB_MIDI_CIN_SYSTEM_COMMON_3¶
3-byte System Common messages
define SYN_USB_MIDI_MAX_PACKET_SIZE¶
Maximum USB MIDI packet size in bytes
The documentation for this class was generated from the following file src/syntropic/drivers/syn_usb_midi.h