track.h
00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 #ifndef _TRACK_H
00025 #define _TRACK_H
00026 
00027 #include <stdio.h>
00028 #include <libkmid/dattypes.h>
00029 
00037 struct MidiEvent
00038 {
00044   uchar command;
00045 
00049   uchar   chn;
00050 
00054   uchar   note;
00055 
00059   uchar   vel;
00060 
00064   uchar   patch;
00065 
00069   uchar   ctl;
00070 
00074   uchar   d1;
00075 
00079   uchar   d2;
00080 
00084   uchar   d3;
00085 
00089   uchar   d4;
00090 
00094   uchar   d5;
00095 
00099   uchar   d6;
00100 
00104   ulong length;
00105 
00109   uchar  *data;
00110 
00111 };
00112 
00126 class MidiTrack
00127 {
00128   private:
00129     class MidiTrackPrivate;
00130     MidiTrackPrivate *d;
00131 
00132     int id;
00133 
00134     ulong size;
00135     uchar *data;
00136     uchar *ptrdata;
00137 
00138     bool  note[16][128]; 
00139     ulong current_ticks; 
00140     ulong delta_ticks;   
00141     ulong wait_ticks;    
00142     
00143 
00144     ulong currentpos; 
00145     
00146     int endoftrack;
00147 
00148     ulong readVariableLengthValue(void);
00149 
00150     uchar lastcommand;  
00151 
00152 
00153     double current_time; 
00154     double time_at_previous_tempochange;  
00155     double ticks_from_previous_tempochange; 
00156     
00157     double  time_at_next_event;  
00158     int tPCN;
00159     ulong   tempo;
00160 
00161     int power2to(int i);
00162 
00163   public:
00172     MidiTrack(FILE *file,int tpcn,int Id);
00173 
00177     ~MidiTrack();
00178 
00186     int ticksPassed (ulong ticks); 
00187 
00195     int msPassed    (ulong ms);
00196 
00200     int currentMs   (double ms);
00201 
00205     ulong   waitTicks   (void) { return wait_ticks; };
00206 
00207     
00208 
00212     double   absMsOfNextEvent (void) { return time_at_next_event; };
00213 
00217     void    changeTempo(ulong t);
00218 
00223     void    readEvent(MidiEvent *ev);
00224 
00228     void    init(void);
00229 
00233     void    clear(void);
00234 
00235 };
00236 
00237 #endif
 
This file is part of the documentation for libkmid Library Version 3.2.0.