NiCMidi 1.1.0
A MIDI library derived from J.D.Koftinoff jdksmidi
filereadmultitrack.h
Go to the documentation of this file.
1/*
2 * NiCMidi - A C++ Class Library for MIDI
3 *
4 * Copyright (C) 2004 J.D. Koftinoff Software, Ltd.
5 * www.jdkoftinoff.com jeffk@jdkoftinoff.com
6 * Copyright (C) 2021, 2022 Nicola Cassetta
7 * https://github.com/ncassetta/NiCMidi
8 *
9 * This file is part of NiCMidi.
10 *
11 * NiCMidi is free software: you can redistribute it and/or modify
12 * it under the terms of the GNU Lesser General Public License as
13 * published by the Free Software Foundation, either version 3 of
14 * the License, or (at your option) any later version.
15 *
16 * NiCMidi is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU Lesser General Public License for more details.
20 *
21 * You should have received a copy of the GNU Lesser General Public
22 * License along with NiCMidi. If not, see <http://www.gnu.org/licenses/>.
23 */
24
25
28
29
30#ifndef _NICMIDI_FILEREADMULTITRACK_H
31#define _NICMIDI_FILEREADMULTITRACK_H
32
33//#include "midi.h"
34//#include "msg.h"
35//#include "sysex.h"
36#include "fileread.h"
37#include "multitrack.h"
38
39#include <string>
40
41
51class MIDIFileReadMultiTrack : public MIDIFileEventHandler {
53 public:
55 virtual ~MIDIFileReadMultiTrack() {}
56
57//
58// The possible events in a MIDI Files
59//
60 // these are all unused because globally managed by ChanMessage()
61 virtual void mf_system_mode(const MIDITimedMessage &msg) {}
62 virtual void mf_note_on(const MIDITimedMessage &msg) {}
63 virtual void mf_note_off(const MIDITimedMessage &msg) {}
64 virtual void mf_poly_after(const MIDITimedMessage &msg) {}
65 virtual void mf_bender(const MIDITimedMessage &msg) {}
66 virtual void mf_program(const MIDITimedMessage &msg) {}
67 virtual void mf_chan_after(const MIDITimedMessage &msg) {}
68 virtual void mf_control(const MIDITimedMessage &msg) {}
69
70 // these implement pure virtual methods in MIDIFile EventHandler
71 virtual void mf_sysex(MIDIClockTime time, const MIDISystemExclusive &ex);
72 virtual void mf_arbitrary(MIDIClockTime time, int len, unsigned char *data);
73 virtual void mf_metamisc(MIDIClockTime time, int b1, int b2, unsigned char *ch);
74 virtual void mf_meta16(MIDIClockTime time, int type, int b1, int b2);
75 virtual void mf_smpte(MIDIClockTime time, int h, int m, int s, int f, int sf);
76 virtual void mf_timesig(MIDIClockTime time, int a, int b, int c, int d);
77 virtual void mf_tempo(MIDIClockTime time, int b1, int b2, int b3);
78 virtual void mf_keysig(MIDIClockTime time, int sf, int majmin);
79 virtual void mf_sqspecific(MIDIClockTime time, int len, unsigned char *data);
80 virtual void mf_text(MIDIClockTime time, int type, int len, unsigned char *data);
81 virtual void mf_eot(MIDIClockTime time);
82
83//
84// the following methods are to be overridden for your specific purpose
85//
86
87 virtual void mf_error(const char* err);
88 virtual void mf_starttrack(int trk);
89 virtual void mf_endtrack(int trk);
90 virtual void mf_header(int format_, int ntrks_, int division_);
91
92//
93// Higher level dispatch functions
94//
95
96 virtual void UpdateTime(MIDIClockTime delta_time) {}
97 virtual void ChanMessage(const MIDITimedMessage &msg);
98
99 protected:
100
101 MIDIMultiTrack* multitrack;
102 int cur_track;
103 MIDIFileHeader header;
105};
106
107
110
113
117MIDIFileHeader& GetMIDIFileHeader(const char* filename);
121MIDIFileHeader& GetMIDIFileHeader(const std::string& filename);
131bool LoadMIDIFile(const char* filename, MIDIMultiTrack* tracks,
132 MIDIFileHeader* const head = 0);
134bool LoadMIDIFile(const std::string& filename, MIDIMultiTrack* tracks,
135 MIDIFileHeader* const head = 0);
138
139
140#endif
Receives MIDI data from a MIDIFileReader (not documented) class and writes them to a MIDIMultiTrack.
Definition: filereadmultitrack.h:51
Holds an array of pointers to MIDITrack objects to be played simultaneously.
Definition: multitrack.h:50
Stores a buffer of MIDI data bytes in a std::vector, plus a byte for the checksum.
Definition: sysex.h:45
The MIDITimedMessage class inherits from the MIDIMessage and represents a message associated with a s...
Definition: msg.h:382
Contains the definition of the classes MIDIFileEventHandler and MIDIFileReader and of the struct MIDI...
unsigned long MIDIClockTime
The type of a variable which can hold a time in MIDI ticks.
Definition: midi.h:40
bool LoadMIDIFile(const char *filename, MIDIMultiTrack *tracks, MIDIFileHeader *const head=0)
Loads a MIDI file into a MIDIMultiTrack object.
MIDIFileHeader & GetMIDIFileHeader(const char *filename)
Returns the header of the MIDI file specified by filename.
Contains the definition of the classes MIDIMultiTrack, MIDIMultiTrackIteratorState,...
A structure holding data which represent the header of a MIDI file.
Definition: fileread.h:100