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_TRACK_H 00035 #define _JDKMIDI_TRACK_H 00036 00037 #include "jdkmidi/midi.h" 00038 #include "jdkmidi/msg.h" 00039 #include "jdkmidi/sysex.h" 00040 00041 namespace jdkmidi 00042 { 00043 00044 const int MIDITrackChunkSize=512; 00045 00046 class MIDITrackChunk 00047 { 00048 public: 00049 const MIDITimedBigMessage * GetEventAddress( int event_num ) const; 00050 MIDITimedBigMessage * GetEventAddress( int event_num ); 00051 00052 protected: 00053 00054 private: 00055 MIDITimedBigMessage buf[MIDITrackChunkSize]; 00056 }; 00057 00058 const int MIDIChunksPerTrack=512; 00059 00060 class MIDITrack 00061 { 00062 public: 00063 MIDITrack( int size=0 ); 00064 00065 MIDITrack( const MIDITrack &t ); 00066 00067 ~MIDITrack(); 00068 00069 void Clear(); 00070 void Shrink(); 00071 00072 void ClearAndMerge( const MIDITrack *src1, const MIDITrack *src2 ); 00073 00074 // bool Insert( int start_event, int num_events ); 00075 // bool Delete( int start_event, int num_events); 00076 // void Sort(); 00077 00078 bool Expand( int increase_amount=(MIDITrackChunkSize) ); 00079 00080 MIDITimedBigMessage * GetEventAddress( int event_num ); 00081 00082 const MIDITimedBigMessage * GetEventAddress( int event_num ) const; 00083 00084 const MIDITimedBigMessage *GetEvent( int event_num ) const; 00085 MIDITimedBigMessage *GetEvent( int event_num ); 00086 bool GetEvent( int event_num, MIDITimedBigMessage *msg ) const; 00087 00088 bool PutEvent( const MIDITimedBigMessage &msg ); 00089 bool PutEvent( const MIDITimedMessage &msg, MIDISystemExclusive *sysex ); 00090 bool SetEvent( int event_num, const MIDITimedBigMessage &msg ); 00091 00092 bool MakeEventNoOp( int event_num ); 00093 00094 bool FindEventNumber( MIDIClockTime time, int *event_num ) const; 00095 00096 int GetBufferSize() const; 00097 int GetNumEvents() const; 00098 00099 private: 00100 00101 // void QSort( int left, int right ); 00102 00103 MIDITrackChunk * chunk[MIDIChunksPerTrack]; 00104 00105 int buf_size; 00106 int num_events; 00107 }; 00108 00109 } 00110 00111 #endif 00112