• Skip to content
  • Skip to link menu
Trinity API Reference
  • Trinity API Reference
  • libtdemid
 

libtdemid

  • libtdemid
track.h
1/* track.h - class track, which has a midi file track and its events
2 This file is part of LibKMid 0.9.5
3 Copyright (C) 1997,98,99,2000 Antonio Larrosa Jimenez
4 LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libtdemid.html
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Library General Public
8 License as published by the Free Software Foundation; either
9 version 2 of the License, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Library General Public License for more details.
15
16 You should have received a copy of the GNU Library General Public License
17 along with this library; see the file COPYING.LIB. If not, write to
18 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
19 Boston, MA 02110-1301, USA.
20
21 Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org>
22
23***************************************************************************/
24#ifndef _TRACK_H
25#define _TRACK_H
26
27#include <stdio.h>
28#include <libtdemid/dattypes.h>
29
37struct MidiEvent
38{
44 uchar command;
45
49 uchar chn;
50
54 uchar note;
55
59 uchar vel;
60
64 uchar patch;
65
69 uchar ctl;
70
74 uchar d1;
75
79 uchar d2;
80
84 uchar d3;
85
89 uchar d4;
90
94 uchar d5;
95
99 uchar d6;
100
104 ulong length;
105
109 uchar *data;
110
111};
112
126class MidiTrack
127{
128 private:
129 class MidiTrackPrivate;
130 MidiTrackPrivate *d;
131
132 int id;
133
134 ulong size;
135 uchar *data;
136 uchar *ptrdata;
137
138 bool note[16][128]; // Notes that are set on or off by this track
139 ulong current_ticks; // Total number of ticks since beginning of song
140 ulong delta_ticks; // Delta ticks from previous event to next event
141 ulong wait_ticks; // Wait ticks from previous event in other track
142 // to next event in this track
143
144 ulong currentpos; // Some songs don't have a endoftrack event, so
145 // we have to see when currentpos > size
146 int endoftrack;
147
148 ulong readVariableLengthValue(void);
149
150 uchar lastcommand; // This is to run light without overbyte :-)
151
152
153 double current_time; // in ms.
154 double time_at_previous_tempochange; // in ms.
155 double ticks_from_previous_tempochange; // in ticks
156 // double time_to_next_event; // in ms.
157 double time_at_next_event; // in ms.
158 int tPCN;
159 ulong tempo;
160
161 int power2to(int i);
162
163 public:
172 MidiTrack(FILE *file,int tpcn,int Id);
173
177 ~MidiTrack();
178
186 int ticksPassed (ulong ticks);
187
195 int msPassed (ulong ms);
196
200 int currentMs (double ms);
201
205 ulong waitTicks (void) { return wait_ticks; }
206
207 // ulong waitMs (void) {return time_to_next_event;};
208
212 double absMsOfNextEvent (void) { return time_at_next_event; }
213
217 void changeTempo(ulong t);
218
223 void readEvent(MidiEvent *ev);
224
228 void init(void);
229
233 void clear(void);
234
235};
236
237#endif
MidiTrack
Stores a MIDI track.
Definition: track.h:127
MidiTrack::readEvent
void readEvent(MidiEvent *ev)
Reads the event at the iterator position, and puts it on the structure pointed to by ev.
Definition: track.cpp:190
MidiTrack::clear
void clear(void)
Clears the internal variables.
Definition: track.cpp:498
MidiTrack::init
void init(void)
Initializes the iterator.
Definition: track.cpp:519
MidiTrack::waitTicks
ulong waitTicks(void)
Returns the number of ticks left for the next event.
Definition: track.h:205
MidiTrack::MidiTrack
MidiTrack(FILE *file, int tpcn, int Id)
Constructor.
Definition: track.cpp:49
MidiTrack::currentMs
int currentMs(double ms)
Returns the current millisecond which the iterator is at.
Definition: track.cpp:174
MidiTrack::~MidiTrack
~MidiTrack()
Destructor.
Definition: track.cpp:88
MidiTrack::ticksPassed
int ticksPassed(ulong ticks)
Makes the iterator advance the given number of ticks.
Definition: track.cpp:146
MidiTrack::changeTempo
void changeTempo(ulong t)
Change the tempo of the song.
Definition: track.cpp:544
MidiTrack::msPassed
int msPassed(ulong ms)
Makes the iterator advance the given number of milliseconds.
Definition: track.cpp:158
MidiTrack::absMsOfNextEvent
double absMsOfNextEvent(void)
Returns the absolute number of milliseconds of the next event.
Definition: track.h:212
MidiEvent
An structure that represents a MIDI event.
Definition: track.h:38
MidiEvent::length
ulong length
Length of the generic data variable.
Definition: track.h:104
MidiEvent::d5
uchar d5
Data 5.
Definition: track.h:94
MidiEvent::command
uchar command
MIDI Command.
Definition: track.h:44
MidiEvent::ctl
uchar ctl
Patch (if command was a controller command)
Definition: track.h:69
MidiEvent::chn
uchar chn
Channel.
Definition: track.h:49
MidiEvent::d6
uchar d6
Data 6.
Definition: track.h:99
MidiEvent::note
uchar note
Note.
Definition: track.h:54
MidiEvent::d3
uchar d3
Data 3.
Definition: track.h:84
MidiEvent::d2
uchar d2
Data 2.
Definition: track.h:79
MidiEvent::patch
uchar patch
Patch (if command was a change patch command)
Definition: track.h:64
MidiEvent::d1
uchar d1
Data 1.
Definition: track.h:74
MidiEvent::vel
uchar vel
Velocity.
Definition: track.h:59
MidiEvent::d4
uchar d4
Data 4.
Definition: track.h:89
MidiEvent::data
uchar * data
The data for commands like text, sysex, etc.
Definition: track.h:109

libtdemid

Skip menu "libtdemid"
  • Main Page
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Class Members
  • Related Pages

libtdemid

Skip menu "libtdemid"
  • arts
  • dcop
  • dnssd
  • interfaces
  •   kspeech
  •     interface
  •     library
  •   tdetexteditor
  • kate
  • kded
  • kdoctools
  • kimgio
  • kjs
  • libtdemid
  • libtdescreensaver
  • tdeabc
  • tdecmshell
  • tdecore
  • tdefx
  • tdehtml
  • tdeinit
  • tdeio
  •   bookmarks
  •   httpfilter
  •   kpasswdserver
  •   kssl
  •   tdefile
  •   tdeio
  •   tdeioexec
  • tdeioslave
  •   http
  • tdemdi
  •   tdemdi
  • tdenewstuff
  • tdeparts
  • tdeprint
  • tderandr
  • tderesources
  • tdespell2
  • tdesu
  • tdeui
  • tdeunittest
  • tdeutils
  • tdewallet
Generated for libtdemid by doxygen 1.9.4
This website is maintained by Timothy Pearson.