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

midi_device.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 
00024 #ifndef MIDI_DEVICE_H
00025 #define MIDI_DEVICE_H
00026 
00046 #include "midi_function_types.h"
00047 #include "bytequeue/bytequeue.h"
00048 #define MIDI_INPUT_QUEUE_LENGTH 192
00049 
00050 typedef enum {
00051    IDLE, 
00052    ONE_BYTE_MESSAGE = 1,
00053    TWO_BYTE_MESSAGE = 2, 
00054    THREE_BYTE_MESSAGE = 3,
00055    SYSEX_MESSAGE} input_state_t;
00056 
00057 typedef void (* midi_no_byte_func_t)(MidiDevice * device);
00058 
00069 struct _midi_device {
00070    //output send function
00071    midi_var_byte_func_t send_func;
00072 
00073    //********input callbacks
00074    //three byte funcs
00075    midi_three_byte_func_t input_cc_callback;
00076    midi_three_byte_func_t input_noteon_callback;
00077    midi_three_byte_func_t input_noteoff_callback;
00078    midi_three_byte_func_t input_aftertouch_callback;
00079    midi_three_byte_func_t input_pitchbend_callback;
00080    midi_three_byte_func_t input_songposition_callback;
00081    //two byte funcs
00082    midi_two_byte_func_t input_progchange_callback;
00083    midi_two_byte_func_t input_chanpressure_callback;
00084    midi_two_byte_func_t input_songselect_callback;
00085    midi_two_byte_func_t input_tc_quaterframe_callback;
00086    //one byte funcs
00087    midi_one_byte_func_t input_realtime_callback;
00088    midi_one_byte_func_t input_tunerequest_callback;
00089 
00090    //sysex, cnt is the count of bytes in the sysex message
00091    midi_var_byte_func_t input_sysex_callback;
00092 
00093    //only called if more specific callback is not matched
00094    midi_var_byte_func_t input_fallthrough_callback;
00095    //called if registered, independent of other callbacks
00096    midi_var_byte_func_t input_catchall_callback;
00097 
00098    //pre input processing function
00099    midi_no_byte_func_t pre_input_process_callback;
00100 
00101    //for internal input processing
00102    uint8_t input_buffer[3];
00103    input_state_t input_state;
00104    uint16_t input_count;
00105 
00106    //for queueing data between the input and the processing functions
00107    uint8_t input_queue_data[MIDI_INPUT_QUEUE_LENGTH];
00108    byteQueue_t input_queue;
00109 };
00110 
00123 void midi_device_input(MidiDevice * device, uint8_t cnt, uint8_t byte0, uint8_t byte1, uint8_t byte2);
00124 
00135 void midi_device_set_send_func(MidiDevice * device, midi_var_byte_func_t send_func);
00136 
00146 void midi_device_set_pre_input_process_func(MidiDevice * device, midi_no_byte_func_t pre_process_func);
00147 
00150 #endif

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