jdkmidi class library documentation

Copyright © 2004 J.D. Koftinoff Software, Ltd.

Released under the GNU General Public License (GPL)




Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | File List | Namespace Members | Class Members | File Members

jdkmidi::MIDIDriver Class Reference

#include <driver.h>

Inheritance diagram for jdkmidi::MIDIDriver:

jdkmidi::MIDITick jdkmidi::MIDIDriverDump List of all members.

Public Member Functions

 MIDIDriver (int queue_size)
virtual ~MIDIDriver ()
virtual void Reset ()
MIDIQueueInputQueue ()
const MIDIQueueInputQueue () const
MIDIQueueOutputQueue ()
const MIDIQueueOutputQueue () 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
MIDIProcessorin_proc
MIDIProcessorout_proc
MIDIProcessorthru_proc
bool thru_enable
MIDITicktick_proc
MIDIMatrix out_matrix

Constructor & Destructor Documentation

jdkmidi::MIDIDriver::MIDIDriver int  queue_size  ) 
 

Definition at line 31 of file jdkmidi_driver.cpp.

00032     :   
00033     in_queue(queue_size),
00034     out_queue(queue_size),
00035     in_proc(0),
00036     out_proc(0),
00037     thru_proc(0),
00038     thru_enable(false),
00039     tick_proc(0)
00040   {
00041     
00042   } 

jdkmidi::MIDIDriver::~MIDIDriver  )  [virtual]
 

Definition at line 44 of file jdkmidi_driver.cpp.

00045   {
00046     
00047   } 


Member Function Documentation

void jdkmidi::MIDIDriver::AllNotesOff  ) 
 

Definition at line 85 of file jdkmidi_driver.cpp.

00086   {
00087     for( int i=0; i<16; ++i )
00088     {
00089       AllNotesOff(i);
00090     }
00091   } 

void jdkmidi::MIDIDriver::AllNotesOff int  chan  ) 
 

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   } 

bool jdkmidi::MIDIDriver::CanOutputMessage  )  const [inline]
 

Definition at line 69 of file driver.h.

References jdkmidi::MIDIQueue::CanPut(), and out_queue.

00070         {
00071           return out_queue.CanPut();
00072         } 

bool jdkmidi::MIDIDriver::GetThruEnable  )  const [inline]
 

Definition at line 91 of file driver.h.

References thru_enable.

00092         {
00093           return thru_enable;
00094         } 

bool jdkmidi::MIDIDriver::HardwareMsgIn MIDITimedBigMessage msg  )  [virtual]
 

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   } 

virtual bool jdkmidi::MIDIDriver::HardwareMsgOut const MIDITimedBigMessage msg  )  [pure virtual]
 

Implemented in jdkmidi::MIDIDriverDump.

const MIDIQueue* jdkmidi::MIDIDriver::InputQueue  )  const [inline]
 

Definition at line 50 of file driver.h.

References in_queue.

00051         {
00052           return &in_queue;
00053         } 

MIDIQueue* jdkmidi::MIDIDriver::InputQueue  )  [inline]
 

Definition at line 45 of file driver.h.

References in_queue.

00046         {
00047           return &in_queue;
00048         } 

void jdkmidi::MIDIDriver::OutputMessage MIDITimedBigMessage msg  )  [inline]
 

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         } 

const MIDIQueue* jdkmidi::MIDIDriver::OutputQueue  )  const [inline]
 

Definition at line 61 of file driver.h.

References out_queue.

00062         {
00063           return &out_queue;
00064         } 

MIDIQueue* jdkmidi::MIDIDriver::OutputQueue  )  [inline]
 

Definition at line 56 of file driver.h.

References out_queue.

00057         {
00058           return &out_queue;
00059         } 

void jdkmidi::MIDIDriver::Reset  )  [virtual]
 

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   }

void jdkmidi::MIDIDriver::SetInProcessor MIDIProcessor proc  )  [inline]
 

Definition at line 107 of file driver.h.

References in_proc.

00108         {
00109           in_proc = proc;
00110         } 

void jdkmidi::MIDIDriver::SetOutProcessor MIDIProcessor proc  )  [inline]
 

Definition at line 102 of file driver.h.

References out_proc.

00103         {
00104           out_proc = proc;
00105         } 

void jdkmidi::MIDIDriver::SetThruEnable bool  f  )  [inline]
 

Definition at line 86 of file driver.h.

References thru_enable.

00087         {
00088           thru_enable = f;
00089         } 

void jdkmidi::MIDIDriver::SetThruProcessor MIDIProcessor proc  )  [inline]
 

Definition at line 97 of file driver.h.

References thru_proc.

00098         {
00099           thru_proc = proc;
00100         } 

void jdkmidi::MIDIDriver::SetTickProc MIDITick tick  )  [inline]
 

Definition at line 112 of file driver.h.

References tick_proc.

00113         {
00114           tick_proc = tick;
00115         } 

void jdkmidi::MIDIDriver::TimeTick unsigned long  sys_time  )  [virtual]
 

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   } 


Member Data Documentation

MIDIProcessor* jdkmidi::MIDIDriver::in_proc [protected]
 

Definition at line 156 of file driver.h.

MIDIQueue jdkmidi::MIDIDriver::in_queue [protected]
 

Definition at line 152 of file driver.h.

MIDIMatrix jdkmidi::MIDIDriver::out_matrix [protected]
 

Definition at line 168 of file driver.h.

MIDIProcessor* jdkmidi::MIDIDriver::out_proc [protected]
 

Definition at line 157 of file driver.h.

MIDIQueue jdkmidi::MIDIDriver::out_queue [protected]
 

Definition at line 153 of file driver.h.

bool jdkmidi::MIDIDriver::thru_enable [protected]
 

Definition at line 160 of file driver.h.

MIDIProcessor* jdkmidi::MIDIDriver::thru_proc [protected]
 

Definition at line 158 of file driver.h.

MIDITick* jdkmidi::MIDIDriver::tick_proc [protected]
 

Definition at line 164 of file driver.h.


The documentation for this class was generated from the following files: