-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMidiPiece.cpp
More file actions
105 lines (84 loc) · 2.39 KB
/
Copy pathMidiPiece.cpp
File metadata and controls
105 lines (84 loc) · 2.39 KB
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
93
94
95
96
97
98
99
100
101
102
103
104
105
#include <iostream>
#include <fstream>
#include "MidiPiece.h"
#include "windows.h"
using namespace std;
MidiPiece::MidiPiece(string* fileName) {
this->stream = new ifstream(*fileName, ios::in | ios::binary);
this->format = nullptr;
this->ntrks = nullptr;
this->division = nullptr;
this->microsecondsPerQuarterNote = new uint32_t(700000);
this->timeSignaure = new TimeSignature(new uint8_t(4), new uint8_t(2), new uint8_t(0), new uint8_t(0));
this->smpteOffset = nullptr;
this->toSendInterface = new HMIDIOUT;
}
MidiPiece::~MidiPiece() {
stream->close();
delete(stream, format, ntrks, division);
}
void MidiPiece::setStream(ifstream* newStream) {
this->stream = newStream;
}
void MidiPiece::setFormat(uint16_t* newFormat) {
this->format = newFormat;
}
void MidiPiece::setNtrks(uint16_t* newNtrks) {
this->ntrks = newNtrks;
}
void MidiPiece::setDivision(uint16_t* newDivision) {
this->division = newDivision;
}
void MidiPiece::setMicrosecnodsPerQuaterNote(uint32_t* newMicrosecondsPerQuarterNote) {
this->microsecondsPerQuarterNote = newMicrosecondsPerQuarterNote;
}
void MidiPiece::setTimeSignature(TimeSignature* newTimeSignaure) {
this->timeSignaure = newTimeSignaure;
}
void MidiPiece::setSmpteOffset(SmpteOffset* newSmpteOffset) {
this->smpteOffset = newSmpteOffset;
}
void MidiPiece::setToSendInterface(HMIDIOUT* newToSendInterface) {
this->toSendInterface = newToSendInterface;
}
ifstream* MidiPiece::getStream() {
return stream;
}
uint16_t* MidiPiece::getFormat() {
return format;
}
uint16_t* MidiPiece::getNtrks() {
return ntrks;
}
uint16_t* MidiPiece::getDivision() {
return division;
}
uint32_t* MidiPiece::getMicrosecondsPerQuaterNote() {
return microsecondsPerQuarterNote;
}
TimeSignature* MidiPiece::getTimeSignature() {
return timeSignaure;
}
SmpteOffset* MidiPiece::getSmpteOffset() {
return smpteOffset;
}
HMIDIOUT* MidiPiece::getToSendInterface() {
return toSendInterface;
}
uint8_t* MidiPiece::read1() {
uint8_t* result = new uint8_t;
getStream()->read((char*)result, sizeof(uint8_t));
return result;
}
uint16_t* MidiPiece::read2() {
uint16_t* result = new uint16_t;
getStream()->read((char*)result, sizeof(uint16_t));
*result =_byteswap_ushort((unsigned short)*result);
return result;
}
uint32_t* MidiPiece::read4() {
uint32_t* result = new uint32_t;
getStream()->read((char*)result, sizeof(uint32_t));
*result = _byteswap_ulong((unsigned long)*result);
return result;
}