mirror of
https://github.com/arduino/Arduino.git
synced 2024-11-30 11:24:12 +01:00
49 lines
1.1 KiB
C
Executable File
49 lines
1.1 KiB
C
Executable File
// Midi.c
|
|
//
|
|
// Midi output routines for the atmel atmega163 (and others)
|
|
//
|
|
// depends on avrlib for buffer
|
|
//
|
|
|
|
#include "uart.h"
|
|
#include "midi.h"
|
|
#include "debug.h"
|
|
|
|
|
|
void midiInit() {
|
|
uartInit();
|
|
uartSetBaudRate(MIDI_BAUD_RATE);
|
|
}
|
|
|
|
u08 midiNoteOnOut(u08 note, u08 vel, u08 channel) {
|
|
uartSendByte(MIDI_NOTE_ON | (channel & MIDI_CHANNEL_MASK));
|
|
uartSendByte(MIDI_DATA_MASK & note);
|
|
uartSendByte(MIDI_DATA_MASK & vel);
|
|
|
|
return 0;
|
|
}
|
|
|
|
u08 midiNoteOffOut(u08 note, u08 vel, u08 channel) {
|
|
uartSendByte(MIDI_NOTE_OFF | (channel & MIDI_CHANNEL_MASK));
|
|
uartSendByte(MIDI_DATA_MASK & note);
|
|
uartSendByte(MIDI_DATA_MASK & vel);
|
|
|
|
return 0;
|
|
}
|
|
|
|
u08 midiControlChangeOut(u08 controller, u08 value, u08 channel) {
|
|
uartSendByte(MIDI_CONTROL_CHANGE | (channel & MIDI_CHANNEL_MASK));
|
|
uartSendByte(MIDI_DATA_MASK & controller);
|
|
uartSendByte(MIDI_DATA_MASK & value);
|
|
|
|
return 0;
|
|
}
|
|
|
|
u08 midiProgramChangeOut(u08 program, u08 channel) {
|
|
uartSendByte(MIDI_PROGRAM_CHANGE | (channel & MIDI_CHANNEL_MASK));
|
|
uartSendByte(MIDI_DATA_MASK & program);
|
|
|
|
return 0;
|
|
}
|
|
|