-
Notifications
You must be signed in to change notification settings - Fork 2
/
smdFile.hpp
92 lines (86 loc) · 2.19 KB
/
smdFile.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
85
86
87
88
89
90
91
92
#ifndef __SMDFILE_HPP
#define __SMDFILE_HPP
class smdSong;
class smdTrack;
class smdEvent;
#include <fstream>
#include <ostream>
#include <stdint.h>
#include <string>
#include <vector>
// TODO Empty constructors and data-writing functions are not prototyped until
// we have a lot more data on unknown stuff
class smdSong {
private:
std::string name;
std::vector< smdTrack > tracks;
int instrumentGroup;
friend std::ostream& operator<<(std::ostream&, const smdSong&);
public:
smdSong (std::ifstream&);
std::string GetName () const;
int GetInstrumentGroup() const;
int GetTrackCount () const;
const std::vector< smdTrack >& Tracks () const;
const smdTrack& operator[] (int) const;
bool OutputInUse (int) const;
bool OutputInUseNotDrum (int) const;
};
class smdTrack {
private:
friend class smdSong;
int trackID;
int outputID;
int instrumentGroup;
std::vector< smdEvent > events;
smdTrack(std::ifstream&,int);
friend std::ostream& operator<<(std::ostream&, const smdTrack&);
public:
int GetTrackID () const;
int GetOutputID () const;
int GetInstrumentGroup() const;
bool IsDrum () const;
int GetEventCount () const;
const std::vector< smdEvent >& Events () const;
const smdEvent& operator[] (int) const;
size_t LongestCmdSize () const;
};
class smdEvent {
public:
typedef enum {
NOTE_PLAY,
DELTA_TIME,
WAIT_AGAIN = 0x90,
WAIT_ADD = 0x91,
WAIT_1BYTE = 0x92,
WAIT_2BYTE = 0x93,
TRACK_END = 0x98,
LOOP_POINT = 0x99,
SET_OCTAVE = 0xA0,
SET_TEMPO = 0xA4,
SET_SAMPLE = 0xAC,
SET_MODU = 0xBE,
SET_BEND = 0xD7,
SET_VOLUME = 0xE0,
SET_XPRESS = 0xE3,
SET_PAN = 0xE8,
GENERAL_UNKNOWN
} EventType;
private:
friend class smdTrack;
static int prevWaitLength;
uint8_t eventCode;
std::vector< uint8_t > params;
int waitAgainLength;
smdEvent (std::ifstream&);
friend std::ostream& operator<<(std::ostream&, const smdEvent&);
public:
static size_t DisplayBytes;
EventType GetType () const;
uint8_t GetEventCode () const;
int GetParamCount () const;
uint8_t Param (int) const;
int TickLength () const;
size_t CmdSize () const;
};
#endif