track.h
/* track.h - class track, which has a midi file track and its events
This file is part of LibKMid 0.9.5
Copyright (C) 1997,98,99,2000 Antonio Larrosa Jimenez
LibKMid's homepage : http://www.arrakis.es/~rlarrosa/libkmid.html
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
Send comments and bug fixes to Antonio Larrosa <larrosa@kde.org>
***************************************************************************/
#ifndef _TRACK_H
#define _TRACK_H
#include <stdio.h>
#include <libkmid/dattypes.h>
struct MidiEvent
{
uchar command;
uchar chn;
uchar note;
uchar vel;
uchar patch;
uchar ctl;
uchar d1;
uchar d2;
uchar d3;
uchar d4;
uchar d5;
uchar d6;
ulong length;
uchar *data;
};
class MidiTrack
{
private:
class MidiTrackPrivate;
MidiTrackPrivate *d;
int id;
ulong size;
uchar *data;
uchar *ptrdata;
bool note[16][128]; // Notes that are set on or off by this track
ulong current_ticks; // Total number of ticks since beginning of song
ulong delta_ticks; // Delta ticks from previous event to next event
ulong wait_ticks; // Wait ticks from previous event in other track
// to next event in this track
ulong currentpos; // Some songs don't have a endoftrack event, so
// we have to see when currentpos > size
int endoftrack;
ulong readVariableLengthValue(void);
uchar lastcommand; // This is to run light without overbyte :-)
double current_time; // in ms.
double time_at_previous_tempochange; // in ms.
double ticks_from_previous_tempochange; // in ticks
// double time_to_next_event; // in ms.
double time_at_next_event; // in ms.
int tPCN;
ulong tempo;
int power2to(int i);
public:
MidiTrack(FILE *file,int tpcn,int Id);
~MidiTrack();
int ticksPassed (ulong ticks);
int msPassed (ulong ms);
int currentMs (double ms);
ulong waitTicks (void) { return wait_ticks; }
// ulong waitMs (void) {return time_to_next_event;};
double absMsOfNextEvent (void) { return time_at_next_event; }
void changeTempo(ulong t);
void readEvent(MidiEvent *ev);
void init(void);
void clear(void);
};
#endif
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
MidiTrack::waitTicks
ulong waitTicks(void)
Returns the number of ticks left for the next event.
Definition: track.h:205
MidiEvent::d5
uchar d5
Data 5.
Definition: track.h:94
MidiEvent::command
uchar command
MIDI Command.
Definition: track.h:44
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.cc:190
MidiEvent::d4
uchar d4
Data 4.
Definition: track.h:89
MidiEvent::length
ulong length
Length of the generic data variable.
Definition: track.h:104
MidiEvent
An structure that represents a MIDI event.
Definition: track.h:37
MidiTrack::clear
void clear(void)
Clears the internal variables.
Definition: track.cc:498
MidiEvent::d1
uchar d1
Data 1.
Definition: track.h:74
MidiTrack::changeTempo
void changeTempo(ulong t)
Change the tempo of the song.
Definition: track.cc:544
MidiTrack::ticksPassed
int ticksPassed(ulong ticks)
Makes the iterator advance the given number of ticks.
Definition: track.cc:146
MidiEvent::d3
uchar d3
Data 3.
Definition: track.h:84
MidiTrack::MidiTrack
MidiTrack(FILE *file, int tpcn, int Id)
Constructor.
Definition: track.cc:49
MidiTrack::~MidiTrack
~MidiTrack()
Destructor.
Definition: track.cc:88
MidiTrack::init
void init(void)
Initializes the iterator.
Definition: track.cc:519
MidiTrack::absMsOfNextEvent
double absMsOfNextEvent(void)
Returns the absolute number of milliseconds of the next event.
Definition: track.h:212
MidiEvent::data
uchar * data
The data for commands like text, sysex, etc.
Definition: track.h:109
MidiEvent::chn
uchar chn
Channel.
Definition: track.h:49
MidiEvent::vel
uchar vel
Velocity.
Definition: track.h:59
MidiTrack
Stores a MIDI track.
Definition: track.h:126
MidiEvent::d6
uchar d6
Data 6.
Definition: track.h:99
MidiTrack::currentMs
int currentMs(double ms)
Returns the current millisecond which the iterator is at.
Definition: track.cc:174
MidiEvent::ctl
uchar ctl
Patch (if command was a controller command)
Definition: track.h:69
MidiTrack::msPassed
int msPassed(ulong ms)
Makes the iterator advance the given number of milliseconds.
Definition: track.cc:158
MidiEvent::note
uchar note
Note.
Definition: track.h:54

KDE Home | KDE Accessibility Home | Description of Access Keys