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::MIDIMatrix Class Reference

#include <matrix.h>

List of all members.

Public Member Functions

 MIDIMatrix ()
virtual ~MIDIMatrix ()
virtual bool Process (const MIDIMessage &m)
virtual void Clear ()
int GetTotalCount () const
int GetChannelCount (int channel) const
int GetNoteCount (int channel, int note) const
bool GetHoldPedal (int channel) const

Protected Member Functions

virtual void DecNoteCount (const MIDIMessage &m, int channel, int note)
virtual void IncNoteCount (const MIDIMessage &m, int channel, int note)
virtual void ClearChannel (int channel)
virtual void OtherMessage (const MIDIMessage &m)
void SetNoteCount (unsigned char chan, unsigned char note, unsigned char val)
void SetChannelCount (unsigned char chan, int val)

Private Attributes

unsigned char note_on_count [16][128]
int channel_count [16]
bool hold_pedal [16]
int total_count


Constructor & Destructor Documentation

jdkmidi::MIDIMatrix::MIDIMatrix  ) 
 

Definition at line 53 of file jdkmidi_matrix.cpp.

References channel_count, ENTER, hold_pedal, note_on_count, and total_count.

00054   {
00055     ENTER("MIDIMatrix::MIDIMatrix()");
00056     
00057     for( int channel=0; channel<16; channel++ )
00058     {
00059       channel_count[channel]=0;
00060       hold_pedal[channel]= false;
00061       for( unsigned char note=0; note<128; note++ )
00062         note_on_count[channel][note]=0;
00063     }
00064     
00065     total_count=0;
00066   }

jdkmidi::MIDIMatrix::~MIDIMatrix  )  [virtual]
 

Definition at line 68 of file jdkmidi_matrix.cpp.

References ENTER.

00069   {
00070     ENTER("MIDIMatrix::~MIDIMatrix()");
00071   }


Member Function Documentation

void jdkmidi::MIDIMatrix::Clear  )  [virtual]
 

Definition at line 151 of file jdkmidi_matrix.cpp.

References ClearChannel(), ENTER, and total_count.

00152   {
00153     ENTER( "MIDIMatrix::Clear()" );
00154     
00155     for( int channel=0; channel<16; ++channel )
00156     {
00157       ClearChannel( channel );
00158     }
00159     total_count=0;
00160   }

void jdkmidi::MIDIMatrix::ClearChannel int  channel  )  [protected, virtual]
 

Definition at line 162 of file jdkmidi_matrix.cpp.

References channel_count, ENTER, hold_pedal, note_on_count, and total_count.

00163   {
00164     ENTER( "MIDIMatrix::ClearChannel()" );
00165     
00166     for( int note=0; note<128; ++note )
00167     {
00168       total_count -= note_on_count[channel][note];
00169       note_on_count[channel][note]=0;
00170     }
00171     channel_count[channel]=0;
00172     hold_pedal[channel]=0;
00173   }

void jdkmidi::MIDIMatrix::DecNoteCount const MIDIMessage m,
int  channel,
int  note
[protected, virtual]
 

Definition at line 74 of file jdkmidi_matrix.cpp.

References channel_count, ENTER, note_on_count, and total_count.

00075   {
00076     ENTER( "MIDIMatrix::DecNoteCount()" );
00077     
00078     if( note_on_count[channel][note]>0 )
00079     {
00080       --note_on_count[channel][note];
00081       --channel_count[channel];
00082       --total_count;
00083     }
00084   }

int jdkmidi::MIDIMatrix::GetChannelCount int  channel  )  const [inline]
 

Definition at line 58 of file matrix.h.

References channel_count.

00059         { 
00060           return channel_count[channel];    
00061         }

bool jdkmidi::MIDIMatrix::GetHoldPedal int  channel  )  const [inline]
 

Definition at line 68 of file matrix.h.

References hold_pedal.

00069         { 
00070           return hold_pedal[channel];       
00071         }

int jdkmidi::MIDIMatrix::GetNoteCount int  channel,
int  note
const [inline]
 

Definition at line 63 of file matrix.h.

References note_on_count.

00064         { 
00065           return note_on_count[channel][note];  
00066         }

int jdkmidi::MIDIMatrix::GetTotalCount  )  const [inline]
 

Definition at line 54 of file matrix.h.

References total_count.

00055         { 
00056           return total_count;           
00057         }

void jdkmidi::MIDIMatrix::IncNoteCount const MIDIMessage m,
int  channel,
int  note
[protected, virtual]
 

Definition at line 86 of file jdkmidi_matrix.cpp.

References channel_count, ENTER, note_on_count, and total_count.

00087   {
00088     ENTER( "MIDIMatrix::IncNoteCount()" );
00089     
00090     ++note_on_count[channel][note];
00091     ++channel_count[channel];
00092     ++total_count;
00093   }

void jdkmidi::MIDIMatrix::OtherMessage const MIDIMessage m  )  [protected, virtual]
 

Definition at line 95 of file jdkmidi_matrix.cpp.

References ENTER.

00096   {
00097     ENTER( "MIDIMatrix::OtherMessage()" );
00098     
00099   }

bool jdkmidi::MIDIMatrix::Process const MIDIMessage m  )  [virtual]
 

Definition at line 102 of file jdkmidi_matrix.cpp.

References jdkmidi::C_DAMPER, ClearChannel(), DecNoteCount(), ENTER, jdkmidi::MIDIMessage::GetChannel(), jdkmidi::MIDIMessage::GetController(), jdkmidi::MIDIMessage::GetControllerValue(), jdkmidi::MIDIMessage::GetNote(), jdkmidi::MIDIMessage::GetVelocity(), hold_pedal, IncNoteCount(), jdkmidi::MIDIMessage::IsAllNotesOff(), jdkmidi::MIDIMessage::IsChannelMsg(), jdkmidi::MIDIMessage::IsControlChange(), jdkmidi::MIDIMessage::IsNoteOff(), jdkmidi::MIDIMessage::IsNoteOn(), and OtherMessage().

00103   {
00104     ENTER( "MIDIMatrix::Process()" );
00105     
00106     bool status=false;
00107     
00108     if( m.IsChannelMsg() )
00109     {
00110       int channel=m.GetChannel();
00111       int note=m.GetNote();
00112       
00113       if( m.IsAllNotesOff() )
00114       {
00115         ClearChannel( channel );
00116         status=true;
00117       }
00118       else
00119         if( m.IsNoteOn() )
00120         {
00121           if( m.GetVelocity()!=0 )
00122             IncNoteCount( m, channel, note );
00123           else
00124             DecNoteCount( m, channel, note );
00125           status=true;
00126         }
00127         else
00128           if( m.IsNoteOff() )
00129           {
00130             DecNoteCount( m, channel, note );
00131             status=true;
00132           }
00133           else
00134             if( m.IsControlChange() && m.GetController()==C_DAMPER )
00135             {
00136               if( m.GetControllerValue() & 0x40 )
00137               {
00138                 hold_pedal[channel]=true;
00139               }
00140               else
00141               {
00142                 hold_pedal[channel]=false;
00143               }
00144             }
00145             else
00146               OtherMessage( m );
00147     }
00148     return status;
00149   }

void jdkmidi::MIDIMatrix::SetChannelCount unsigned char  chan,
int  val
[inline, protected]
 

Definition at line 84 of file matrix.h.

References channel_count.

00085         { 
00086           channel_count[chan]=val;    
00087         }

void jdkmidi::MIDIMatrix::SetNoteCount unsigned char  chan,
unsigned char  note,
unsigned char  val
[inline, protected]
 

Definition at line 80 of file matrix.h.

References note_on_count.

00081         { 
00082           note_on_count[chan][note]=val;  
00083         }


Member Data Documentation

int jdkmidi::MIDIMatrix::channel_count[16] [private]
 

Definition at line 91 of file matrix.h.

bool jdkmidi::MIDIMatrix::hold_pedal[16] [private]
 

Definition at line 92 of file matrix.h.

unsigned char jdkmidi::MIDIMatrix::note_on_count[16][128] [private]
 

Definition at line 90 of file matrix.h.

int jdkmidi::MIDIMatrix::total_count [private]
 

Definition at line 93 of file matrix.h.


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