Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
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);
00049
00058 void midi_device_process(MidiDevice * device);
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);
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
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
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
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
00455
00456 #define MIDI_STATUSMASK 0x80
00457
00458
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
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
00484 #define SYSEX_EDUMANUFID 0x7D
00485
00488 #endif
00489