| 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 | #ifndef JDKMIDI_PROCESS_H |
|---|
| 25 | #define JDKMIDI_PROCESS_H |
|---|
| 26 | |
|---|
| 27 | #include "jdkmidi/msg.h" |
|---|
| 28 | #include "jdkmidi/sysex.h" |
|---|
| 29 | |
|---|
| 30 | namespace jdkmidi |
|---|
| 31 | { |
|---|
| 32 | class MIDIProcessor; |
|---|
| 33 | class MIDIMultiProcessor; |
|---|
| 34 | class MIDIProcessorTransposer; |
|---|
| 35 | class MIDIProcessor; |
|---|
| 36 | |
|---|
| 37 | |
|---|
| 38 | class MIDIProcessor |
|---|
| 39 | { |
|---|
| 40 | public: |
|---|
| 41 | MIDIProcessor(); |
|---|
| 42 | virtual ~MIDIProcessor(); |
|---|
| 43 | |
|---|
| 44 | virtual bool Process ( MIDITimedBigMessage *msg ) = 0; |
|---|
| 45 | }; |
|---|
| 46 | |
|---|
| 47 | class MIDIMultiProcessor : public MIDIProcessor |
|---|
| 48 | { |
|---|
| 49 | public: |
|---|
| 50 | MIDIMultiProcessor ( int num_processors ); |
|---|
| 51 | virtual ~MIDIMultiProcessor(); |
|---|
| 52 | |
|---|
| 53 | // MIDIProcessors given to a MIDIMultiProcessor are NOT owned |
|---|
| 54 | // by MIDIMultiProcessor. |
|---|
| 55 | |
|---|
| 56 | void SetProcessor ( int position, MIDIProcessor *proc ) |
|---|
| 57 | { |
|---|
| 58 | processors[position]=proc; |
|---|
| 59 | } |
|---|
| 60 | |
|---|
| 61 | MIDIProcessor *GetProcessor ( int position ) |
|---|
| 62 | { |
|---|
| 63 | return processors[position]; |
|---|
| 64 | } |
|---|
| 65 | |
|---|
| 66 | const MIDIProcessor *GetProcessor ( int position ) const |
|---|
| 67 | { |
|---|
| 68 | return processors[position]; |
|---|
| 69 | } |
|---|
| 70 | |
|---|
| 71 | virtual bool Process ( MIDITimedBigMessage *msg ); |
|---|
| 72 | |
|---|
| 73 | private: |
|---|
| 74 | MIDIProcessor **processors; |
|---|
| 75 | int num_processors; |
|---|
| 76 | }; |
|---|
| 77 | |
|---|
| 78 | class MIDIProcessorTransposer : public MIDIProcessor |
|---|
| 79 | { |
|---|
| 80 | public: |
|---|
| 81 | MIDIProcessorTransposer(); |
|---|
| 82 | virtual ~MIDIProcessorTransposer(); |
|---|
| 83 | |
|---|
| 84 | void SetTransposeChannel ( int chan, int trans ) |
|---|
| 85 | { |
|---|
| 86 | trans_amount[chan] = trans; |
|---|
| 87 | } |
|---|
| 88 | |
|---|
| 89 | int GetTransposeChannel ( int chan ) const |
|---|
| 90 | { |
|---|
| 91 | return trans_amount[chan]; |
|---|
| 92 | } |
|---|
| 93 | |
|---|
| 94 | void SetAllTranspose ( int trans ); |
|---|
| 95 | |
|---|
| 96 | virtual bool Process ( MIDITimedBigMessage *msg ); |
|---|
| 97 | private: |
|---|
| 98 | int trans_amount[16]; |
|---|
| 99 | }; |
|---|
| 100 | |
|---|
| 101 | class MIDIProcessorRechannelizer : public MIDIProcessor |
|---|
| 102 | { |
|---|
| 103 | public: |
|---|
| 104 | MIDIProcessorRechannelizer(); |
|---|
| 105 | virtual ~MIDIProcessorRechannelizer(); |
|---|
| 106 | |
|---|
| 107 | void SetRechanMap ( int src_chan, int dest_chan ) |
|---|
| 108 | { |
|---|
| 109 | rechan_map[src_chan] = dest_chan; |
|---|
| 110 | } |
|---|
| 111 | |
|---|
| 112 | int GetRechanMap ( int src_chan ) const |
|---|
| 113 | { |
|---|
| 114 | return rechan_map[src_chan]; |
|---|
| 115 | } |
|---|
| 116 | |
|---|
| 117 | void SetAllRechan ( int dest_chan ); |
|---|
| 118 | |
|---|
| 119 | virtual bool Process ( MIDITimedBigMessage *msg ); |
|---|
| 120 | |
|---|
| 121 | private: |
|---|
| 122 | |
|---|
| 123 | int rechan_map[16]; |
|---|
| 124 | }; |
|---|
| 125 | } |
|---|
| 126 | |
|---|
| 127 | #endif |
|---|