• Main Page
  • Modules
  • Classes
  • Files
  • File List
  • File Members

midi.h

Go to the documentation of this file.
00001 //midi for embedded chips,
00002 //Copyright 2010 Alex Norman
00003 //
00004 //This file is part of avr-midi.
00005 //
00006 //avr-midi is free software: you can redistribute it and/or modify
00007 //it under the terms of the GNU General Public License as published by
00008 //the Free Software Foundation, either version 3 of the License, or
00009 //(at your option) any later version.
00010 //
00011 //avr-midi is distributed in the hope that it will be useful,
00012 //but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 //MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 //GNU General Public License for more details.
00015 //
00016 //You should have received a copy of the GNU General Public License
00017 //along with avr-midi.  If not, see <http://www.gnu.org/licenses/>.
00018 
00028 #ifndef AVR_MIDI_H
00029 #define AVR_MIDI_H
00030 
00031 #include "midi_device.h"
00032 #include "midi_function_types.h"
00033 
00048 void midi_device_init(MidiDevice * device); // [implementation in midi_device.c]
00049 
00058 void midi_device_process(MidiDevice * device); // [implementation in midi_device.c]
00059 
00076 void midi_send_cc(MidiDevice * device, uint8_t chan, uint8_t num, uint8_t val);
00077 
00086 void midi_send_noteon(MidiDevice * device, uint8_t chan, uint8_t num, uint8_t vel);
00087 
00096 void midi_send_noteoff(MidiDevice * device, uint8_t chan, uint8_t num, uint8_t vel);
00097 
00106 void midi_send_aftertouch(MidiDevice * device, uint8_t chan, uint8_t note_num, uint8_t amt);
00107 
00115 void midi_send_pitchbend(MidiDevice * device, uint8_t chan, int16_t amt); //range -8192, 8191
00116 
00124 void midi_send_programchange(MidiDevice * device, uint8_t chan, uint8_t num);
00125 
00133 void midi_send_channelpressure(MidiDevice * device, uint8_t chan, uint8_t amt);
00134 
00140 void midi_send_clock(MidiDevice * device);
00141 
00147 void midi_send_tick(MidiDevice * device);
00148 
00154 void midi_send_start(MidiDevice * device);
00155 
00161 void midi_send_continue(MidiDevice * device);
00162 
00168 void midi_send_stop(MidiDevice * device);
00169 
00175 void midi_send_activesense(MidiDevice * device);
00176 
00182 void midi_send_reset(MidiDevice * device);
00183 
00184 
00191 void midi_send_tcquaterframe(MidiDevice * device, uint8_t time);
00192 
00199 void midi_send_songposition(MidiDevice * device, uint16_t pos);
00200 
00207 void midi_send_songselect(MidiDevice * device, uint8_t song);
00208 
00214 void midi_send_tunerequest(MidiDevice * device);
00215 
00227 void midi_send_byte(MidiDevice * device, uint8_t b);
00228 
00240 void midi_send_data(MidiDevice * device, uint16_t count, uint8_t byte0, uint8_t byte1, uint8_t byte2);
00241 
00256 //three byte funcs
00257 
00264 void midi_register_cc_callback(MidiDevice * device, midi_three_byte_func_t func);
00265 
00272 void midi_register_noteon_callback(MidiDevice * device, midi_three_byte_func_t func);
00273 
00280 void midi_register_noteoff_callback(MidiDevice * device, midi_three_byte_func_t func);
00281 
00289 void midi_register_aftertouch_callback(MidiDevice * device, midi_three_byte_func_t func);
00290 
00297 void midi_register_pitchbend_callback(MidiDevice * device, midi_three_byte_func_t func);
00298 
00305 void midi_register_songposition_callback(MidiDevice * device, midi_three_byte_func_t func);
00306 
00307 //two byte funcs
00308 
00315 void midi_register_progchange_callback(MidiDevice * device, midi_two_byte_func_t func);
00316 
00323 void midi_register_chanpressure_callback(MidiDevice * device, midi_two_byte_func_t func);
00324 
00331 void midi_register_songselect_callback(MidiDevice * device, midi_two_byte_func_t func);
00332 
00339 void midi_register_tc_quarterframe_callback(MidiDevice * device, midi_two_byte_func_t func);
00340 
00341 //one byte funcs
00342 
00351 void midi_register_realtime_callback(MidiDevice * device, midi_one_byte_func_t func);
00352 
00359 void midi_register_tunerequest_callback(MidiDevice * device, midi_one_byte_func_t func);
00360 
00377 void midi_register_sysex_callback(MidiDevice * device, midi_var_byte_func_t func);
00378 
00389 void midi_register_fallthrough_callback(MidiDevice * device, midi_var_byte_func_t func);
00390 
00391 
00401 void midi_register_catchall_callback(MidiDevice * device, midi_var_byte_func_t func);
00402 
00415 typedef enum {
00416    UNDEFINED = 0,
00417    ONE = 1,
00418    TWO = 2,
00419    THREE = 3} midi_packet_length_t;
00420 
00426 bool midi_is_statusbyte(uint8_t theByte);
00427 
00433 bool midi_is_realtime(uint8_t theByte);
00434 
00441 midi_packet_length_t midi_packet_length(uint8_t status);
00442 
00451 #define SYSEX_BEGIN 0xF0
00452 #define SYSEX_END 0xF7
00453 
00454 //if you and this with a byte and you get anything non-zero
00455 //it is a status message
00456 #define MIDI_STATUSMASK 0x80
00457 //if you and this with a status message that contains channel info,
00458 //you'll get the channel
00459 #define MIDI_CHANMASK 0x0F
00460 
00461 #define MIDI_CC 0xB0
00462 #define MIDI_NOTEON 0x90
00463 #define MIDI_NOTEOFF 0x80
00464 #define MIDI_AFTERTOUCH 0xA0
00465 #define MIDI_PITCHBEND 0xE0
00466 #define MIDI_PROGCHANGE 0xC0
00467 #define MIDI_CHANPRESSURE 0xD0
00468 
00469 //midi realtime
00470 #define MIDI_CLOCK 0xF8
00471 #define MIDI_TICK 0xF9
00472 #define MIDI_START 0xFA
00473 #define MIDI_CONTINUE 0xFB
00474 #define MIDI_STOP 0xFC
00475 #define MIDI_ACTIVESENSE 0xFE
00476 #define MIDI_RESET 0xFF
00477 
00478 #define MIDI_TC_QUATERFRAME 0xF1
00479 #define MIDI_SONGPOSITION 0xF2
00480 #define MIDI_SONGSELECT 0xF3
00481 #define MIDI_TUNEREQUEST 0xF6
00482 
00483 //This ID is for educational or development use only
00484 #define SYSEX_EDUMANUFID 0x7D
00485 
00488 #endif
00489 

Generated on Thu Apr 21 2011 11:27:02 for xnor_midi by  doxygen 1.7.1