uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
|
MIDI message transceiver. More...
Go to the source code of this file.
Data Structures | |
struct | midi_event_handlers |
Pointers to MIDI message handling callbacks. More... | |
struct | midi_config |
MIDI transceiver module configuration. More... | |
Macros | |
#define | BAUD_RATE 31250 |
MIDI baudrate. More... | |
#define | MIDI_UART USARTE0 |
UART used for MIDI I/O. More... | |
#define | MIDI_CHANNEL_MASK 0x0f |
Bitmask for the channel in the MIDI status byte. More... | |
#define | MIDI_MESSAGE_TYPE_MASK 0xf0 |
Bitmask for the message type in the MIDI status byte. More... | |
#define | MIDI_MAX_VALUE 127 |
Maximum MIDI value. More... | |
Typedefs | |
typedef uint8_t | midi_value_t |
Type for valid MIDI values [0..127]. More... | |
Enumerations | |
enum | midi_channel { MIDI_CHANNEL_01 = 0x00, MIDI_CHANNEL_02 = 0x01, MIDI_CHANNEL_03 = 0x02, MIDI_CHANNEL_04 = 0x03, MIDI_CHANNEL_05 = 0x04, MIDI_CHANNEL_06 = 0x05, MIDI_CHANNEL_07 = 0x06, MIDI_CHANNEL_08 = 0x07, MIDI_CHANNEL_09 = 0x08, MIDI_CHANNEL_10 = 0x09, MIDI_CHANNEL_11 = 0x0a, MIDI_CHANNEL_12 = 0x0b, MIDI_CHANNEL_13 = 0x0c, MIDI_CHANNEL_14 = 0x0d, MIDI_CHANNEL_15 = 0x0e, MIDI_CHANNEL_16 = 0x0f } |
MIDI status byte values (second nibble) More... | |
enum | midi_message_type { MIDI_MSG_TYPE_CONTROL_CHANGE = 0xb0, MIDI_MSG_TYPE_NOTE_OFF = 0x80, MIDI_MSG_TYPE_NOTE_ON = 0x90, MIDI_MSG_TYPE_PROGRAM_CHANGE = 0xc0 } |
MIDI status byte values (first nibble) More... | |
enum | midi_state { MIDI_STATE_IDLE, MIDI_STATE_CONTROL_CHANGE_NUMBER, MIDI_STATE_CONTROL_CHANGE_VALUE, MIDI_STATE_NOTE_OFF_NUMBER, MIDI_STATE_NOTE_OFF_VALUE, MIDI_STATE_NOTE_ON_NUMBER, MIDI_STATE_NOTE_ON_VALUE, MIDI_STATE_PROGRAM_CHANGE } |
States in the MIDI state machine. More... | |
Functions | |
static bool | uart_is_ready (void) |
Checks if the UART is ready to send data. More... | |
static void | uart_write (uint8_t data) |
Sends one byte of date over the UART. More... | |
void | init_midi_module (const struct midi_config *config) |
Initializes the MIDI transceiver module. More... | |
enum midi_channel | read_midi_channel_from_jumpers (const struct jumpers *jumpers) |
Reads the MIDI channel configuration from the solder jumpers. More... | |
void | send_control_change (midi_value_t controller, midi_value_t value) |
Sends a control change message. More... | |
void | send_midi_message (enum midi_channel channel, enum midi_message_type type, midi_value_t data0, midi_value_t data1) |
Sends an arbitrary MIDI message. More... | |
void | send_note_off (midi_value_t note, midi_value_t velocity) |
Sends a note off message. More... | |
void | send_note_on (midi_value_t note, midi_value_t velocity) |
Sends a note on message. More... | |
void | send_program_change (midi_value_t program) |
Sends a program change message. More... | |
void | set_midi_rx_channel (enum midi_channel channel) |
Updates the midi receive channel. More... | |
void | set_midi_tx_channel (enum midi_channel channel) |
Updates the midi transmit channel. More... | |
void | set_omni_mode (bool enable) |
Puts the device into Omni mode. More... | |
MIDI message transceiver.
#define BAUD_RATE 31250 |
MIDI baudrate.
#define MIDI_CHANNEL_MASK 0x0f |
Bitmask for the channel in the MIDI status byte.
#define MIDI_MAX_VALUE 127 |
Maximum MIDI value.
#define MIDI_MESSAGE_TYPE_MASK 0xf0 |
Bitmask for the message type in the MIDI status byte.
#define MIDI_UART USARTE0 |
UART used for MIDI I/O.
typedef uint8_t midi_value_t |
Type for valid MIDI values [0..127].
enum midi_channel |
MIDI status byte values (second nibble)
enum midi_message_type |
enum midi_state |
States in the MIDI state machine.
void init_midi_module | ( | const struct midi_config * | config | ) |
Initializes the MIDI transceiver module.
Configures the UART, enables the RXC interrupt and registers MIDI message handlers.
config | the MIDI module configuration to apply |
enum midi_channel read_midi_channel_from_jumpers | ( | const struct jumpers * | jumpers | ) |
Reads the MIDI channel configuration from the solder jumpers.
jumpers | the the solder jumpers configuration struct |
void send_control_change | ( | midi_value_t | controller, |
midi_value_t | value | ||
) |
Sends a control change message.
controller | the MIDI controller number |
value | the new value for the controller |
void send_midi_message | ( | enum midi_channel | channel, |
enum midi_message_type | type, | ||
midi_value_t | data0, | ||
midi_value_t | data1 | ||
) |
Sends an arbitrary MIDI message.
If the second data byte is not required for the specified message type, the parameter is simply ignored.
channel | the MIDI channel to send on |
type | the type of the MIDI message to send |
data0 | the first data byte (e.g. MIDI controller number for a control change) |
data1 | the second data byte (optional, e.g. value for a control change) |
void send_note_off | ( | midi_value_t | note, |
midi_value_t | velocity | ||
) |
Sends a note off message.
note | the MIDI note number |
velocity | velocity of the key press |
void send_note_on | ( | midi_value_t | note, |
midi_value_t | velocity | ||
) |
Sends a note on message.
note | the MIDI note number |
velocity | velocity of the key press |
void send_program_change | ( | midi_value_t | program | ) |
Sends a program change message.
program | the new MIDI program to load |
void set_midi_rx_channel | ( | enum midi_channel | channel | ) |
Updates the midi receive channel.
channel | the channel to listen on |
void set_midi_tx_channel | ( | enum midi_channel | channel | ) |
Updates the midi transmit channel.
channel | the channel to talk on |
void set_omni_mode | ( | bool | enable | ) |
Puts the device into Omni mode.
In Omni mode the device handles all received MIDI messages regardless of the channel. When not in Omni mode, only messages on the configured receive channel are processed.
enable | if true , Omni mode is enabled; if false , it is disabled |
|
inlinestatic |
Checks if the UART is ready to send data.
true
if the UART is ready; false
otherwise
|
inlinestatic |
Sends one byte of date over the UART.
data | the data byte to send |