00001 // Midi.c 00002 // 00003 // Midi output routines for the atmel atmega163 (and others) 00004 // 00005 // depends on avrlib for buffer 00006 // 00007 00008 #include "uart.h" 00009 #include "midi.h" 00010 #include "debug.h" 00011 00012 00013 void midiInit() { 00014 uartInit(); 00015 uartSetBaudRate(MIDI_BAUD_RATE); 00016 } 00017 00018 u08 midiNoteOnOut(u08 note, u08 vel, u08 channel) { 00019 uartSendByte(MIDI_NOTE_ON | (channel & MIDI_CHANNEL_MASK)); 00020 uartSendByte(MIDI_DATA_MASK & note); 00021 uartSendByte(MIDI_DATA_MASK & vel); 00022 00023 return 0; 00024 } 00025 00026 u08 midiNoteOffOut(u08 note, u08 vel, u08 channel) { 00027 uartSendByte(MIDI_NOTE_OFF | (channel & MIDI_CHANNEL_MASK)); 00028 uartSendByte(MIDI_DATA_MASK & note); 00029 uartSendByte(MIDI_DATA_MASK & vel); 00030 00031 return 0; 00032 } 00033 00034 u08 midiControlChangeOut(u08 controller, u08 value, u08 channel) { 00035 uartSendByte(MIDI_CONTROL_CHANGE | (channel & MIDI_CHANNEL_MASK)); 00036 uartSendByte(MIDI_DATA_MASK & controller); 00037 uartSendByte(MIDI_DATA_MASK & value); 00038 00039 return 0; 00040 } 00041 00042 u08 midiProgramChangeOut(u08 program, u08 channel) { 00043 uartSendByte(MIDI_PROGRAM_CHANGE | (channel & MIDI_CHANNEL_MASK)); 00044 uartSendByte(MIDI_DATA_MASK & program); 00045 00046 return 0; 00047 } 00048