Jack2 1.9.6
|
00001 /* 00002 Copyright (C) 2009 Devin Anderson 00003 00004 This program is free software; you can redistribute it and/or modify 00005 it under the terms of the GNU Lesser General Public License as published by 00006 the Free Software Foundation; either version 2.1 of the License, or 00007 (at your option) any later version. 00008 00009 This program is distributed in the hope that it will be useful, 00010 but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 GNU Lesser General Public License for more details. 00013 00014 You should have received a copy of the GNU Lesser General Public License 00015 along with this program; if not, write to the Free Software 00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 00017 00018 */ 00019 00020 #ifndef __JackPhysicalMidiInput__ 00021 #define __JackPhysicalMidiInput__ 00022 00023 #include "JackMidiPort.h" 00024 #include "ringbuffer.h" 00025 00026 namespace Jack { 00027 00028 class JackPhysicalMidiInput { 00029 00030 private: 00031 00032 size_t buffered_bytes; 00033 size_t expected_data_bytes; 00034 jack_ringbuffer_t *input_ring; 00035 JackMidiBuffer *port_buffer; 00036 jack_midi_data_t status_byte; 00037 size_t unbuffered_bytes; 00038 00039 void 00040 Clear(); 00041 00042 void 00043 WriteBufferedEvent(jack_nframes_t); 00044 00045 void 00046 WriteBufferedSysexEvent(jack_nframes_t); 00047 00048 void 00049 WriteByteEvent(jack_nframes_t, jack_midi_data_t); 00050 00051 protected: 00052 00062 virtual void 00063 HandleBufferFailure(size_t, size_t); 00064 00072 virtual void 00073 HandleIncompleteMessage(size_t); 00074 00082 virtual void 00083 HandleInvalidStatusByte(jack_midi_data_t); 00084 00093 virtual void 00094 HandleUnexpectedSysexEnd(size_t); 00095 00103 virtual void 00104 HandleWriteFailure(size_t); 00105 00117 virtual jack_nframes_t 00118 Receive(jack_midi_data_t *, jack_nframes_t, jack_nframes_t) = 0; 00119 00120 public: 00121 00122 JackPhysicalMidiInput(size_t buffer_size=1024); 00123 virtual ~JackPhysicalMidiInput(); 00124 00129 void 00130 Process(jack_nframes_t); 00131 00136 inline void 00137 SetPortBuffer(JackMidiBuffer *port_buffer) 00138 { 00139 this->port_buffer = port_buffer; 00140 } 00141 00142 }; 00143 00144 } 00145 00146 #endif