00001 /* 00002 * libjdkmidi-2004 C++ Class Library for MIDI 00003 * 00004 * Copyright (C) 2004 J.D. Koftinoff Software, Ltd. 00005 * www.jdkoftinoff.com 00006 * jeffk@jdkoftinoff.com 00007 * 00008 * *** RELEASED UNDER THE GNU GENERAL PUBLIC LICENSE (GPL) April 27, 2004 *** 00009 * 00010 * This program is free software; you can redistribute it and/or modify 00011 * it under the terms of the GNU General Public License as published by 00012 * the Free Software Foundation; either version 2 of the License, or 00013 * (at your option) any later version. 00014 * 00015 * This program is distributed in the hope that it will be useful, 00016 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00017 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00018 * GNU General Public License for more details. 00019 * 00020 * You should have received a copy of the GNU General Public License 00021 * along with this program; if not, write to the Free Software 00022 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 00023 */ 00024 /* 00025 ** Copyright 1986 to 1998 By J.D. Koftinoff Software, Ltd. 00026 ** 00027 ** All rights reserved. 00028 ** 00029 ** No one may duplicate this source code in any form for any reason 00030 ** without the written permission given by J.D. Koftinoff Software, Ltd. 00031 ** 00032 */ 00033 00034 #ifndef _JDKMIDI_MATRIX_H 00035 #define _JDKMIDI_MATRIX_H 00036 00037 00038 #include "jdkmidi/midi.h" 00039 #include "jdkmidi/msg.h" 00040 00041 namespace jdkmidi 00042 { 00043 00044 class MIDIMatrix 00045 { 00046 public: 00047 MIDIMatrix(); 00048 virtual ~MIDIMatrix(); 00049 00050 virtual bool Process( const MIDIMessage &m ); 00051 00052 virtual void Clear(); 00053 00054 int GetTotalCount() const 00055 { 00056 return total_count; 00057 } 00058 int GetChannelCount( int channel ) const 00059 { 00060 return channel_count[channel]; 00061 } 00062 00063 int GetNoteCount( int channel, int note ) const 00064 { 00065 return note_on_count[channel][note]; 00066 } 00067 00068 bool GetHoldPedal( int channel ) const 00069 { 00070 return hold_pedal[channel]; 00071 } 00072 00073 00074 protected: 00075 virtual void DecNoteCount( const MIDIMessage &m, int channel, int note ); 00076 virtual void IncNoteCount( const MIDIMessage &m, int channel, int note ); 00077 virtual void ClearChannel( int channel ); 00078 virtual void OtherMessage( const MIDIMessage &m ); 00079 00080 void SetNoteCount(unsigned char chan,unsigned char note,unsigned char val) 00081 { 00082 note_on_count[chan][note]=val; 00083 } 00084 void SetChannelCount( unsigned char chan, int val ) 00085 { 00086 channel_count[chan]=val; 00087 } 00088 00089 private: 00090 unsigned char note_on_count[16][128]; 00091 int channel_count[16]; 00092 bool hold_pedal[16]; 00093 int total_count; 00094 }; 00095 00096 } 00097 00098 00099 #endif 00100 00101