| 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_EDITTRACK_H |
|---|
| 35 | #define JDKMIDI_EDITTRACK_H |
|---|
| 36 | |
|---|
| 37 | #include "jdkmidi/track.h" |
|---|
| 38 | #include "jdkmidi/matrix.h" |
|---|
| 39 | #include "jdkmidi/process.h" |
|---|
| 40 | |
|---|
| 41 | namespace jdkmidi |
|---|
| 42 | { |
|---|
| 43 | |
|---|
| 44 | class MIDIEditTrackEventMatcher |
|---|
| 45 | { |
|---|
| 46 | public: |
|---|
| 47 | MIDIEditTrackEventMatcher(); |
|---|
| 48 | virtual ~MIDIEditTrackEventMatcher(); |
|---|
| 49 | |
|---|
| 50 | virtual bool Match ( const MIDITimedBigMessage &ev ) =0; |
|---|
| 51 | }; |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | class MIDIEditTrack |
|---|
| 55 | { |
|---|
| 56 | public: |
|---|
| 57 | MIDIEditTrack ( MIDITrack *track_ ); |
|---|
| 58 | virtual ~MIDIEditTrack(); |
|---|
| 59 | |
|---|
| 60 | // |
|---|
| 61 | // Process applies a MIDI process to all events that are matched |
|---|
| 62 | // |
|---|
| 63 | |
|---|
| 64 | void Process ( |
|---|
| 65 | MIDIClockTime start_time, |
|---|
| 66 | MIDIClockTime end_time, |
|---|
| 67 | MIDIProcessor *process, |
|---|
| 68 | MIDIEditTrackEventMatcher *match |
|---|
| 69 | ); |
|---|
| 70 | |
|---|
| 71 | // |
|---|
| 72 | // Truncate erases all events after a certain time. then |
|---|
| 73 | // adds appropriate note off's |
|---|
| 74 | // |
|---|
| 75 | void Truncate ( MIDIClockTime start_time ); |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | // |
|---|
| 79 | // this merge function merges two other tracks into this track. |
|---|
| 80 | // this is the faster form of merge |
|---|
| 81 | // |
|---|
| 82 | void Merge ( |
|---|
| 83 | MIDITrack *trk1, MIDITrack *trk2, |
|---|
| 84 | MIDIEditTrackEventMatcher *match1, |
|---|
| 85 | MIDIEditTrackEventMatcher *match2 ); |
|---|
| 86 | |
|---|
| 87 | |
|---|
| 88 | // |
|---|
| 89 | // this erase function will erase all events from start to end time |
|---|
| 90 | // and can be jagged or not. |
|---|
| 91 | // |
|---|
| 92 | void Erase ( |
|---|
| 93 | MIDIClockTime start, |
|---|
| 94 | MIDIClockTime end, |
|---|
| 95 | bool jagged=true, |
|---|
| 96 | MIDIEditTrackEventMatcher *match=0 |
|---|
| 97 | ); |
|---|
| 98 | |
|---|
| 99 | |
|---|
| 100 | |
|---|
| 101 | // |
|---|
| 102 | // this delete function will delete all events like erase and then |
|---|
| 103 | // shift the events over |
|---|
| 104 | // |
|---|
| 105 | void Delete ( |
|---|
| 106 | MIDIClockTime start, |
|---|
| 107 | MIDIClockTime end, |
|---|
| 108 | bool jagged=true, |
|---|
| 109 | MIDIEditTrackEventMatcher *match=0 |
|---|
| 110 | ); |
|---|
| 111 | |
|---|
| 112 | |
|---|
| 113 | // |
|---|
| 114 | // this insert function will insert 'length' clicks starting at |
|---|
| 115 | // the events at start time. |
|---|
| 116 | // |
|---|
| 117 | void Insert ( |
|---|
| 118 | MIDIClockTime start, |
|---|
| 119 | MIDIClockTime length |
|---|
| 120 | ); |
|---|
| 121 | |
|---|
| 122 | |
|---|
| 123 | // |
|---|
| 124 | // this shift function will shift all event times by an offset. |
|---|
| 125 | // |
|---|
| 126 | void Shift ( |
|---|
| 127 | signed long offset, |
|---|
| 128 | MIDIEditTrackEventMatcher *match=0 |
|---|
| 129 | ); |
|---|
| 130 | |
|---|
| 131 | protected: |
|---|
| 132 | |
|---|
| 133 | MIDIMatrix matrix; |
|---|
| 134 | MIDITrack *track; |
|---|
| 135 | |
|---|
| 136 | private: |
|---|
| 137 | |
|---|
| 138 | }; |
|---|
| 139 | |
|---|
| 140 | |
|---|
| 141 | } |
|---|
| 142 | |
|---|
| 143 | #endif |
|---|
| 144 | |
|---|