#include <driver.h>
Inheritance diagram for jdkmidi::MIDIDriver:
Public Member Functions | |
MIDIDriver (int queue_size) | |
virtual | ~MIDIDriver () |
virtual void | Reset () |
MIDIQueue * | InputQueue () |
const MIDIQueue * | InputQueue () const |
MIDIQueue * | OutputQueue () |
const MIDIQueue * | OutputQueue () const |
bool | CanOutputMessage () const |
void | OutputMessage (MIDITimedBigMessage &msg) |
void | SetThruEnable (bool f) |
bool | GetThruEnable () const |
void | SetThruProcessor (MIDIProcessor *proc) |
void | SetOutProcessor (MIDIProcessor *proc) |
void | SetInProcessor (MIDIProcessor *proc) |
void | SetTickProc (MIDITick *tick) |
void | AllNotesOff (int chan) |
void | AllNotesOff () |
virtual bool | HardwareMsgIn (MIDITimedBigMessage &msg) |
virtual bool | HardwareMsgOut (const MIDITimedBigMessage &msg)=0 |
virtual void | TimeTick (unsigned long sys_time) |
Protected Attributes | |
MIDIQueue | in_queue |
MIDIQueue | out_queue |
MIDIProcessor * | in_proc |
MIDIProcessor * | out_proc |
MIDIProcessor * | thru_proc |
bool | thru_enable |
MIDITick * | tick_proc |
MIDIMatrix | out_matrix |
|
Definition at line 31 of file jdkmidi_driver.cpp.
|
|
Definition at line 44 of file jdkmidi_driver.cpp.
00045 { 00046 00047 } |
|
Definition at line 85 of file jdkmidi_driver.cpp.
00086 { 00087 for( int i=0; i<16; ++i ) 00088 { 00089 AllNotesOff(i); 00090 } 00091 } |
|
Definition at line 56 of file jdkmidi_driver.cpp. References jdkmidi::C_DAMPER, jdkmidi::MIDIMatrix::GetChannelCount(), jdkmidi::MIDIMatrix::GetNoteCount(), out_matrix, OutputMessage(), jdkmidi::MIDIMessage::SetAllNotesOff(), jdkmidi::MIDIMessage::SetControlChange(), and jdkmidi::MIDIMessage::SetNoteOn().
00057 { 00058 MIDITimedBigMessage msg; 00059 00060 // send a note off for every note on in the out_matrix 00061 00062 if( out_matrix.GetChannelCount(chan)>0 ) 00063 { 00064 for( int note=0; note<128; ++note ) 00065 { 00066 while( out_matrix.GetNoteCount(chan,note)>0 ) 00067 { 00068 // make a note off with note on msg, velocity 0 00069 msg.SetNoteOn( (unsigned char)chan, 00070 (unsigned char)note, 0 ); 00071 00072 OutputMessage( msg ); 00073 } 00074 } 00075 } 00076 00077 msg.SetControlChange(chan,C_DAMPER,0 ); 00078 OutputMessage( msg ); 00079 00080 msg.SetAllNotesOff( (unsigned char)chan ); 00081 OutputMessage( msg ); 00082 00083 } |
|
Definition at line 69 of file driver.h. References jdkmidi::MIDIQueue::CanPut(), and out_queue.
00070 { 00071 return out_queue.CanPut(); 00072 } |
|
Definition at line 91 of file driver.h. References thru_enable.
00092 { 00093 return thru_enable; 00094 } |
|
Definition at line 93 of file jdkmidi_driver.cpp. References jdkmidi::MIDIQueue::CanPut(), in_proc, in_queue, out_queue, jdkmidi::MIDIProcessor::Process(), jdkmidi::MIDIQueue::Put(), thru_enable, and thru_proc.
00094 { 00095 // put input midi messages thru the in processor 00096 00097 if( in_proc ) 00098 { 00099 if( in_proc->Process( &msg )==false ) 00100 { 00101 // message was deleted, so ignore it. 00102 return true; 00103 } 00104 } 00105 00106 // stick input into in queue 00107 00108 if( in_queue.CanPut() ) 00109 { 00110 in_queue.Put( msg ); 00111 } 00112 else 00113 { 00114 return false; 00115 } 00116 00117 00118 // now stick it through the THRU processor 00119 00120 if( thru_proc ) 00121 { 00122 if( thru_proc->Process( &msg )==false ) 00123 { 00124 // message was deleted, so ignore it. 00125 return true; 00126 } 00127 } 00128 00129 00130 if( thru_enable ) 00131 { 00132 // stick this message into the out queue so the tick procedure 00133 // will play it out asap 00134 00135 if( out_queue.CanPut() ) 00136 { 00137 out_queue.Put( msg ); 00138 } 00139 else 00140 { 00141 return false; 00142 } 00143 } 00144 00145 return true; 00146 } |
|
Implemented in jdkmidi::MIDIDriverDump. |
|
Definition at line 50 of file driver.h. References in_queue.
00051 { 00052 return &in_queue; 00053 } |
|
Definition at line 45 of file driver.h. References in_queue.
00046 { 00047 return &in_queue; 00048 } |
|
Definition at line 77 of file driver.h. References out_matrix, out_proc, out_queue, jdkmidi::MIDIMatrix::Process(), jdkmidi::MIDIProcessor::Process(), and jdkmidi::MIDIQueue::Put().
00078 { 00079 if( (out_proc && out_proc->Process( &msg )) || !out_proc ) 00080 { 00081 out_matrix.Process( msg ); 00082 out_queue.Put( msg ); 00083 } 00084 } |
|
Definition at line 61 of file driver.h. References out_queue.
00062 { 00063 return &out_queue; 00064 } |
|
Definition at line 56 of file driver.h. References out_queue.
00057 { 00058 return &out_queue; 00059 } |
|
Definition at line 49 of file jdkmidi_driver.cpp. References jdkmidi::MIDIMatrix::Clear(), jdkmidi::MIDIQueue::Clear(), in_queue, out_matrix, and out_queue.
00050 { 00051 in_queue.Clear(); 00052 out_queue.Clear(); 00053 out_matrix.Clear(); 00054 } |
|
Definition at line 107 of file driver.h. References in_proc.
00108 { 00109 in_proc = proc; 00110 } |
|
Definition at line 102 of file driver.h. References out_proc.
00103 { 00104 out_proc = proc; 00105 } |
|
Definition at line 86 of file driver.h. References thru_enable.
00087 { 00088 thru_enable = f; 00089 } |
|
Definition at line 97 of file driver.h. References thru_proc.
00098 { 00099 thru_proc = proc; 00100 } |
|
Definition at line 112 of file driver.h. References tick_proc.
00113 { 00114 tick_proc = tick; 00115 } |
|
Implements jdkmidi::MIDITick. Reimplemented in jdkmidi::MIDIDriverDump. Definition at line 148 of file jdkmidi_driver.cpp. References jdkmidi::MIDIQueue::CanGet(), HardwareMsgOut(), jdkmidi::MIDIQueue::Next(), out_queue, jdkmidi::MIDIQueue::Peek(), tick_proc, and jdkmidi::MIDITick::TimeTick().
00149 { 00150 // run the additional tick procedure if we need to 00151 if( tick_proc ) 00152 { 00153 tick_proc->TimeTick( sys_time ); 00154 } 00155 00156 // feed as many midi messages from out_queu to the hardware out port 00157 // as we can 00158 00159 while( out_queue.CanGet() ) 00160 { 00161 // use the Peek() function to avoid allocating memory for 00162 // a duplicate sysex 00163 00164 if( HardwareMsgOut( *(out_queue.Peek() ) )==true ) 00165 { 00166 // ok, got and sent a message - update our out_queue now 00167 out_queue.Next(); 00168 } 00169 else 00170 { 00171 // cant send any more, stop now. 00172 break; 00173 } 00174 00175 } 00176 00177 } |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|