//------------------------------------------------------------------------- // Filename: events.hh // Version: $Id: events.hh,v 1.1.4.1 1999/05/24 22:54:46 erik Exp $ // Copyright: Copyright (C) 1999, Erik Mouw (J.A.K.Mouw@its.tudelft.nl) // Author: Erik Mouw // Description: MIDI event classes // Created at: Sun Mar 28 17:56:02 1999 // Modified by: Erik Mouw // Modified at: Mon May 24 22:43:12 1999 //------------------------------------------------------------------------- // // This program is free software; you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation; either version 2 of the License, or // (at your option) any later version. // // This program 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 General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program; if not, write to the Free Software // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA // #ident "$Id: events.hh,v 1.1.4.1 1999/05/24 22:54:46 erik Exp $" #ifndef musica_events_hh #define musica_events_hh #include "mididevice.hh" // forward declaration class midiPlayer; // base class for all midi events class midiEvent { private: friend class midiPlayer; long int deltaTime; midiEvent *next; public: // constructor midiEvent(long int dT = 0L, midiEvent *n = 0) { deltaTime = dT; next = n; }; // get/set functions void setDeltaTime(long int dT) { deltaTime = dT; }; long int getDeltaTime(void) { return(deltaTime); }; void setNextEvent(midiEvent *n) { next = n; }; midiEvent *getNextEvent(void) { return(next); }; // play function virtual void play(midiDevice *device, midiPlayer *player) = 0; }; // unknown MIDI event // no idea what to do with it, but it is important for timing class midiUnknownEvent: public midiEvent { public: midiUnknownEvent(long int dT = 0L, midiEvent *n = 0) : midiEvent(dT, n) { } ; // play function virtual void play(midiDevice *device, midiPlayer *player); }; // base class for all channel related events class midiChannelEvent: public midiEvent { protected: int channel; public: // constructor midiChannelEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1) : midiEvent(dT, n) { channel = ch; }; // get/set functions void setChannel(int ch) { channel = ch; }; int getChannel(void) { return(channel); }; }; // base class for all key related events class midiKeyEvent: public midiChannelEvent { protected: int key; public: midiKeyEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1, int k = -1) : midiChannelEvent(dT, n, ch) { key = k; } // get/set functions void setKey(int k) { key = k; }; int getKey(int k) { return(key); }; }; // base class for all events that use velocity class midiVelocityEvent: public midiKeyEvent { protected: int velocity; public: // constructor midiVelocityEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1, int k = -1, int v = -1) : midiKeyEvent(dT, n, ch, k) { velocity = v; } // get/set functions void setVelocity(int v) { velocity = v; }; int getVelocity(int v) { return(velocity); }; }; class midiNoteOnEvent: public midiVelocityEvent { public: // constructor midiNoteOnEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1, int k = -1, int v = -1) : midiVelocityEvent(dT, n, ch, k, v) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiNoteOffEvent: public midiVelocityEvent { public: // constructor midiNoteOffEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1, int k = -1, int v = -1) : midiVelocityEvent(dT, n, ch, k, v) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiKeyPressureEvent : public midiKeyEvent { private: int pressure; public: // constructor midiKeyPressureEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1, int k = -1, int p = -1) : midiKeyEvent(dT, n, ch, k) { pressure = p; }; // get/set functions void setPressure(int p) { pressure = p; }; int getPressure(void) { return(pressure); }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiChannelPressureEvent : public midiChannelEvent { private: int pressure; public: // constructor midiChannelPressureEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1, int p = -1) : midiChannelEvent(dT, n, ch) { pressure = p; } // get/set functions void setPressure(int p) { pressure = p; }; int getPressure(void) { return(pressure); }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiPitchWheelEvent: public midiChannelEvent { private: int fine; int coarse; public: // constructor midiPitchWheelEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1, int f = -1, int c = -1) : midiChannelEvent(dT, n, ch) { fine = f; coarse = c; } // get/set functions void setFine(int f) { fine = f; }; int getFine(void) { return(fine); }; void setCoarse(int c) { coarse = c; }; int getChannel(void) { return(coarse); }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiControlChangeEvent: public midiChannelEvent { private: int controller; int value; public: // constructor midiControlChangeEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1, int c = -1, int v = -1) : midiChannelEvent(dT, n, ch) { controller = c; value = v; } // get/set functions void setController(int c) { controller = c; }; int getController(void) { return(controller); }; void setValue(int v) { value = v; }; int getValue(void) { return(value); }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiProgramChangeEvent: public midiChannelEvent { private: int program; public: // constructor midiProgramChangeEvent(long int dT = 0L, midiEvent *n = 0, int ch = -1, int p = -1) : midiChannelEvent(dT, n, ch) { program = p; } // get/set functions void setProgram(int p) { program = p; }; int getProgram(void) { return(program); }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; // set division // this is not a real MIDI event according to the MIDI specs, // but we'll have to set it anyway, so why not make it an event? class midiDivisionEvent: public midiEvent { private: int division; public: // constructor midiDivisionEvent(long int dT = 0L, midiEvent *n = 0, int d = -1) : midiEvent(dT, n) { division = d; }; // set/get functions void setDivision(int d) { division = d; }; int getDivision(void) { return(division); } // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiSequenceNumberEvent: public midiEvent { private: int number; public: // constructor midiSequenceNumberEvent(long int dT = 0L, midiEvent *n = 0, int num = -1) : midiEvent(dT, n) { number = num; }; // set/get functions void setNumber(int num) { number = num; }; int getNumber(void) { return(number); } // play function virtual void play(midiDevice *device, midiPlayer *player); }; // base class for meta text events class midiMetaTextEvent: public midiEvent { protected: char *text; public: // constructor midiMetaTextEvent(long int dT = 0L, midiEvent *n = 0, char *t = 0); // destructor virtual ~midiMetaTextEvent(void); // set/get functions void setText(char *t); char *getText(void) const; }; class midiTextEvent: public midiMetaTextEvent { public: // constructor midiTextEvent(long int dT = 0L, midiEvent *n = 0, char *t = 0) : midiMetaTextEvent(dT, n, t) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiCopyrightNoticeEvent: public midiMetaTextEvent { public: // constructor midiCopyrightNoticeEvent(long int dT = 0L, midiEvent *n = 0, char *t = 0) : midiMetaTextEvent(dT, n, t) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiTrackNameEvent: public midiMetaTextEvent { public: // constructor midiTrackNameEvent(long int dT = 0L, midiEvent *n = 0, char *t = 0) : midiMetaTextEvent(dT, n, t) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiIntrumentNameEvent: public midiMetaTextEvent { public: // constructor midiIntrumentNameEvent(long int dT = 0L, midiEvent *n = 0, char *t = 0) : midiMetaTextEvent(dT, n, t) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiLyricEvent: public midiMetaTextEvent { public: // constructor midiLyricEvent(long int dT = 0L, midiEvent *n = 0, char *t = 0) : midiMetaTextEvent(dT, n, t) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiMarkerEvent: public midiMetaTextEvent { public: // constructor midiMarkerEvent(long int dT = 0L, midiEvent *n = 0, char *t = 0) : midiMetaTextEvent(dT, n, t) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiCuePointEvent: public midiMetaTextEvent { public: // constructor midiCuePointEvent(long int dT = 0L, midiEvent *n = 0, char *t = 0) : midiMetaTextEvent(dT, n, t) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiReservedTextEvent: public midiMetaTextEvent { public: // constructor midiReservedTextEvent(long int dT = 0L, midiEvent *n = 0, char *t = 0) : midiMetaTextEvent(dT, n, t) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiEndOfTrackEvent: public midiEvent { public: midiEndOfTrackEvent(long int dT = 0L, midiEvent *n = 0) : midiEvent(dT, n) { } ; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiTempoEvent: public midiEvent { private: int tempo; public: // constructor midiTempoEvent(long int dT = 0L, midiEvent *n = 0, int t = -1) : midiEvent(dT, n) { tempo = t; }; // get/set functions void settempo(int t) { tempo = t; }; int getTempo(void) { return(tempo); } // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiSmpteOffsetEvent: public midiEvent { private: int hours; int minutes; int seconds; int frames; int fraction; public: // constructor midiSmpteOffsetEvent(long int dT = 0L, midiEvent *n = 0, int h = -1, int m = -1, int s = -1, int f = -1, int fr = -1) : midiEvent(dT, n) { hours = h; minutes = m; seconds = s; frames = f; fraction = fr; }; // get/set functions void setHours(int h) { hours = h; }; int getHours(void) { return(hours); }; void setMinutes(int m) { minutes = m; }; int getMinutes(void) { return(minutes); }; void setSeconds(int s) { seconds = s; }; int getSeconds(void) { return(seconds); }; void setFrames(int f) { frames = f; }; int getFrames(void) { return(frames); }; void setFraction(int fr) { fraction = fr; }; int getFraction(void) { return(fraction); }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiTimeSignatureEvent: public midiEvent { private: int numerator; int denominator; int clocks; int bb; public: // constructor midiTimeSignatureEvent(long int dT = 0L, midiEvent *n = 0, int num = -1, int d = -1, int c = -1, int b = -1) : midiEvent(dT, n) { numerator = num; denominator = d; clocks = c; bb = b; }; // get/set functions void setNumerator(int num) { numerator = num; }; int getNumerator(void) { return(numerator); }; void setDenominator(int d) { denominator = d; }; int getDenominator(void) { return(denominator); }; void setClocks(int c) { clocks = c; }; int getClocks(void) { return(clocks); }; void setBb(int b) { bb = b; }; int getBb(void) { return(bb); }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiKeySignatureEvent: public midiEvent { private: int key; int signature; public: // constructor midiKeySignatureEvent(long int dT = 0L, midiEvent *n = 0, int k = -1, int s = -1) : midiEvent(dT, n) { key = k; signature = s; }; // get/set functions void setKey(int k) { key = k; }; int getKey(void) { return(key); }; void setSignature(int s) { signature = s; }; int getSignature(void) { return(signature); }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiSequencerSpecificEvent: public midiEvent { private: unsigned char *data; int len; public: // constructor midiSequencerSpecificEvent(long int dT = 0L, midiEvent *n = 0, unsigned char *d = 0, int l = 0); // destructor virtual ~midiSequencerSpecificEvent(void); // get/set functions void setData(unsigned char *d, int l); unsigned char *getData(void) const; // play function virtual void play(midiDevice *device, midiPlayer *player); }; class midiSysexEvent : public midiEvent { public: // constructor midiSysexEvent(long int dT = 0L, midiEvent *n = 0) : midiEvent(dT, n) { }; // play function virtual void play(midiDevice *device, midiPlayer *player); }; #endif