| 1 | /* |
|---|
| 2 | * libjdkmidi-2004 C++ Class Library for MIDI |
|---|
| 3 | * |
|---|
| 4 | * Copyright (C) 2004 J.D. Koftinoff Software, Ltd. |
|---|
| 5 | * www.jdkoftinoff.com |
|---|
| 6 | * jeffk@jdkoftinoff.com |
|---|
| 7 | * |
|---|
| 8 | * *** RELEASED UNDER THE GNU GENERAL PUBLIC LICENSE (GPL) April 27, 2004 *** |
|---|
| 9 | * |
|---|
| 10 | * This program is free software; you can redistribute it and/or modify |
|---|
| 11 | * it under the terms of the GNU General Public License as published by |
|---|
| 12 | * the Free Software Foundation; either version 2 of the License, or |
|---|
| 13 | * (at your option) any later version. |
|---|
| 14 | * |
|---|
| 15 | * This program is distributed in the hope that it will be useful, |
|---|
| 16 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|---|
| 17 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|---|
| 18 | * GNU General Public License for more details. |
|---|
| 19 | * |
|---|
| 20 | * You should have received a copy of the GNU General Public License |
|---|
| 21 | * along with this program; if not, write to the Free Software |
|---|
| 22 | * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
|---|
| 23 | */ |
|---|
| 24 | /* |
|---|
| 25 | ** Copyright 1986 to 1998 By J.D. Koftinoff Software, Ltd. |
|---|
| 26 | ** |
|---|
| 27 | ** All rights reserved. |
|---|
| 28 | ** |
|---|
| 29 | ** No one may duplicate this source code in any form for any reason |
|---|
| 30 | ** without the written permission given by J.D. Koftinoff Software, Ltd. |
|---|
| 31 | ** |
|---|
| 32 | */ |
|---|
| 33 | |
|---|
| 34 | #ifndef JDKMIDI_MATRIX_H |
|---|
| 35 | #define JDKMIDI_MATRIX_H |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | #include "jdkmidi/midi.h" |
|---|
| 39 | #include "jdkmidi/msg.h" |
|---|
| 40 | |
|---|
| 41 | namespace jdkmidi |
|---|
| 42 | { |
|---|
| 43 | |
|---|
| 44 | class MIDIMatrix |
|---|
| 45 | { |
|---|
| 46 | public: |
|---|
| 47 | MIDIMatrix(); |
|---|
| 48 | virtual ~MIDIMatrix(); |
|---|
| 49 | |
|---|
| 50 | virtual bool Process ( const MIDIMessage &m ); |
|---|
| 51 | |
|---|
| 52 | virtual void Clear(); |
|---|
| 53 | |
|---|
| 54 | int GetTotalCount() const |
|---|
| 55 | { |
|---|
| 56 | return total_count; |
|---|
| 57 | } |
|---|
| 58 | int GetChannelCount ( int channel ) const |
|---|
| 59 | { |
|---|
| 60 | return channel_count[channel]; |
|---|
| 61 | } |
|---|
| 62 | |
|---|
| 63 | int GetNoteCount ( int channel, int note ) const |
|---|
| 64 | { |
|---|
| 65 | return note_on_count[channel][note]; |
|---|
| 66 | } |
|---|
| 67 | |
|---|
| 68 | bool GetHoldPedal ( int channel ) const |
|---|
| 69 | { |
|---|
| 70 | return hold_pedal[channel]; |
|---|
| 71 | } |
|---|
| 72 | |
|---|
| 73 | |
|---|
| 74 | protected: |
|---|
| 75 | virtual void DecNoteCount ( const MIDIMessage &m, int channel, int note ); |
|---|
| 76 | virtual void IncNoteCount ( const MIDIMessage &m, int channel, int note ); |
|---|
| 77 | virtual void ClearChannel ( int channel ); |
|---|
| 78 | virtual void OtherMessage ( const MIDIMessage &m ); |
|---|
| 79 | |
|---|
| 80 | void SetNoteCount ( unsigned char chan,unsigned char note,unsigned char val ) |
|---|
| 81 | { |
|---|
| 82 | note_on_count[chan][note]=val; |
|---|
| 83 | } |
|---|
| 84 | void SetChannelCount ( unsigned char chan, int val ) |
|---|
| 85 | { |
|---|
| 86 | channel_count[chan]=val; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | private: |
|---|
| 90 | unsigned char note_on_count[16][128]; |
|---|
| 91 | int channel_count[16]; |
|---|
| 92 | bool hold_pedal[16]; |
|---|
| 93 | int total_count; |
|---|
| 94 | }; |
|---|
| 95 | |
|---|
| 96 | } |
|---|
| 97 | |
|---|
| 98 | |
|---|
| 99 | #endif |
|---|
| 100 | |
|---|