-
Notifications
You must be signed in to change notification settings - Fork 0
/
parsetrack.cpp
47 lines (33 loc) · 926 Bytes
/
parsetrack.cpp
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
#include "parsetrack.h"
#include "MidiFile.h"
#include <iostream>
#include <QString>
#include <string>
#include <QtAlgorithms>
QList<int> noteList;
MidiFile midifile;
parseTrack::parseTrack(QString filename)
{
string file = filename.toStdString().c_str();
midifile.read(file);
tracks = midifile.getTrackCount();
tpq = midifile.getTicksPerQuarterNote();
}
int parseTrack::getTrackCount() {
return tracks;
}
int parseTrack::getTPQ() {
return tpq;
}
QList<int> parseTrack::getNoteList(int track) {
noteList.clear();
for (int event=0; event < midifile[track].size(); event++) {
if (midifile[track][event].isNoteOn()) {
if(!noteList.contains(midifile[track][event].getKeyNumber())) {
noteList.append(midifile[track][event].getKeyNumber());
}
}
}
std::stable_sort(noteList.begin(), noteList.end());
return noteList;
}