uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
|
MIDI message transceiver. More...
#include <stddef.h>
#include <avr/interrupt.h>
#include <avr/io.h>
#include "gpio.h"
#include "midi.h"
#include "leds.h"
Functions | |
void | init_midi_module (const struct midi_config *const 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 pnum) |
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... | |
static void | handle_status_byte (midi_value_t data) |
Updates the MIDI state machine according to the supplied data byte. More... | |
ISR (USARTE0_RXC_vect) | |
Main interrupt service routine for incoming MIDI messages. More... | |
Variables | |
static struct midi_event_handlers * | event_handlers |
The MIDI event handlers. More... | |
static enum midi_state | midi_state = MIDI_STATE_IDLE |
Current state of the MIDI state machine. More... | |
static bool | omni_mode |
Omni mode state. More... | |
static enum midi_channel | rx_channel |
The MIDI receive channel. More... | |
static enum midi_channel | tx_channel |
The MIDI transmit channel. More... | |
static bool | signal_rx |
If set to true , the red on-board LED flashes on every received MIDI message. More... | |
MIDI message transceiver.
|
static |
Updates the MIDI state machine according to the supplied data byte.
data | the MIDI data byte to be parsed |
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 |
ISR | ( | USARTE0_RXC_vect | ) |
Main interrupt service routine for incoming MIDI messages.
This routine reads and parses MIDI data arriving on the USART and calls the callback functions registered during module initialization. For the time being, all MIDI packets are handled, regardless of the MIDI channel, so uMIDI devices are effectively in OMNI mode.
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 |
|
static |
The MIDI event handlers.
|
static |
Current state of the MIDI state machine.
|
static |
Omni mode state.
|
static |
The MIDI receive channel.
|
static |
If set to true
, the red on-board LED flashes on every received MIDI message.
|
static |
The MIDI transmit channel.