-
Notifications
You must be signed in to change notification settings - Fork 1
/
midi.hpp
84 lines (71 loc) · 1.79 KB
/
midi.hpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
/*
Copyright (c) 2014 Auston Sterling
See LICENSE for copying permissions.
-----MIDI Class Header-----
Auston Sterling
austonst@gmail.com
Contains the header for the MIDI class, representing a MIDI file.
*/
#ifndef _midi_hpp_
#define _midi_hpp_
#include "track.hpp"
#include "timedivision.hpp"
#include <vector>
#include <fstream>
#include <string>
namespace midi
{
class MIDI
{
public:
virtual ~MIDI() {};
virtual std::size_t size() const = 0;
void write(std::string filename) const;
virtual std::vector<std::uint8_t> data() const = 0;
void setTimeDivision(const TimeDivision & td);
virtual void clear() = 0;
protected:
TimeDivision td_;
};
class MIDI_Type0 : public MIDI
{
public:
MIDI_Type0(const Track & tr, const TimeDivision & td);
~MIDI_Type0();
std::size_t size() const;
std::vector<std::uint8_t> data() const;
void setTrack(const Track & tr);
void clear();
private:
Track* track_;
};
class MIDI_Type1 : public MIDI
{
public:
MIDI_Type1(const std::vector<Track*> & tr, const TimeDivision & td);
MIDI_Type1(const TimeDivision & td);
~MIDI_Type1();
std::size_t size() const;
std::vector<std::uint8_t> data() const;
void addTrack(const Track & tr);
void clear();
private:
std::vector<Track*> track_;
};
class MIDI_Type2 : public MIDI
{
public:
MIDI_Type2(const std::vector<Track*> & tr, const TimeDivision & td);
MIDI_Type2(const TimeDivision & td);
~MIDI_Type2();
std::size_t size() const;
std::vector<std::uint8_t> data() const;
void addTrack(const Track & tr);
void clear();
private:
std::vector<Track*> track_;
};
//MIDI* load(std::string filename); //IT'S NOT DONE YET. LOTS TO DO.
void freeLoadedMIDI(MIDI* mid);
} //Namespace
#endif