-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdisplaywindow.cpp
More file actions
75 lines (70 loc) · 2.15 KB
/
Copy pathdisplaywindow.cpp
File metadata and controls
75 lines (70 loc) · 2.15 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
#include "displaywindow.h"
#include "ui_displaywindow.h"
#include "CMidiPacket43.h"
#include <vector>
#include <QDebug>
int g_chan[5] = {1,1,1,1,1};
int g_note_count[5] = {0,0,0,0,0};
DisplayWindow::DisplayWindow(QWidget *parent) :
QDialog(parent),
ui(new Ui::DisplayWindow)
{
ui->setupUi(this);
}
DisplayWindow::~DisplayWindow()
{
delete ui;
}
void DisplayWindow::on_pushButton_close_display_clicked()
{
this->close();
}
int get_trk_num(int chan) {
for(int i = 0; i < 5; i++) {
if(g_chan[i] == chan) {
return i;
}
}
return -1;
}
void DisplayWindow::set_display_text(std::vector<CMidiPacket43> mp_vector) {
for(int i = 0; i < 5; i++) {
g_note_count[i] = 0;
}
ui->plainTextEdit_display->clear();
int trk;
int max_count = -1;
for(auto mp : mp_vector) {
ui->plainTextEdit_display->appendPlainText(QString::fromStdString(mp.to_string()));
trk = get_trk_num(mp.get_status() % 16);
if(trk != -1 && mp.is_status_9n()) {
g_note_count[trk] = g_note_count[trk] + 1;
}
}
//get maximum of note count
for (int i = 0; i < 5; i++) {
if(g_note_count[i] > max_count) {
max_count = g_note_count[i];
}
}
ui->progressBar_1->setMaximum(max_count);
ui->progressBar_2->setMaximum(max_count);
ui->progressBar_3->setMaximum(max_count);
ui->progressBar_4->setMaximum(max_count);
ui->progressBar_5->setMaximum(max_count);
ui->progressBar_1->setValue(g_note_count[0]);
ui->progressBar_2->setValue(g_note_count[1]);
ui->progressBar_3->setValue(g_note_count[2]);
ui->progressBar_4->setValue(g_note_count[3]);
ui->progressBar_5->setValue(g_note_count[4]);
ui->label_length_1->setText(QString::number(g_note_count[0]));
ui->label_length_2->setText(QString::number(g_note_count[1]));
ui->label_length_3->setText(QString::number(g_note_count[2]));
ui->label_length_4->setText(QString::number(g_note_count[3]));
ui->label_length_5->setText(QString::number(g_note_count[4]));
}
void DisplayWindow::set_channels(int chan[]) {
for(int i = 0; i < 5; i++) {
g_chan[i] = chan[i];
}
}