blob: ace14272cbb639602eb46e0ef85d8d2ac7505458 (
plain) (
blame)
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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
import QtQuick 2.3
import QtQuick.Window 2.2
import QtQuick.Controls 1.0
import QtQuick.Dialogs 1.0
import org.chrisoft.qmpcore 1.0
Window {
id: window1
width: 420
height: 240
title: "QMidiPlayer Lite TP"
visible: true
property bool playing
playing: false
property string soundfont
soundfont: ""
MouseArea {
id: mouseArea1
anchors.rightMargin: 0
anchors.bottomMargin: 0
anchors.leftMargin: 0
anchors.topMargin: 0
anchors.fill: parent
Button {
id: button2
x: 170
text: qsTr("Play")
anchors.top: parent.top
anchors.topMargin: 172
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
if(!playing)
{
qmpcore.loadFile(fileName.text);
qmpcore.initFluidSynth(soundfont);
qmpcore.playFile();
playing=true;
uiTimer.start();
text="Stop";
}
else
{
qmpcore.stop();
playing=false;
text="Play";
hsTimer.value=0;uiTimer.stop();
}
}
}
Slider {
id: hsTimer
y: 210
height: 22
anchors.right: parent.right
anchors.rightMargin: 8
anchors.left: parent.left
anchors.leftMargin: 8
anchors.bottom: parent.bottom
anchors.bottomMargin: 8
tickmarksEnabled: false
stepSize: 1
maximumValue: 100
property bool autovalchange: false
onValueChanged: {
if(autovalchange||pressed)return;
if(playing){qmpcore.setTCeptr(value);qmpcore.panic();}
}
onPressedChanged: {
if(!pressed)
{
/*if(playing)
{
if(ui->hsTimer->value()==100){on_pbNext_clicked();return;}
player->setTCeptr(player->getStamp(ui->hsTimer->value()),ui->hsTimer->value());
player->playerPanic();
offset=ui->hsTimer->value()/100.*player->getFtime();
st=std::chrono::steady_clock::now();
}
else
{
player->setTCeptr(player->getStamp(ui->hsTimer->value()),ui->hsTimer->value());
offset=ui->hsTimer->value()/100.*player->getFtime();
char ts[100];
sprintf(ts,"%02d:%02d",(int)(offset)/60,(int)(offset)%60);
ui->lbCurTime->setText(ts);
}*/
if(playing){qmpcore.setTCeptr(value);qmpcore.panic();}
}
}
}
Button {
id: button
anchors.top: parent.top
anchors.topMargin: 67
anchors.horizontalCenter: parent.horizontalCenter
x: 139
text: qsTr("Load SoundFont")
onClicked: {
sfFileDialog.open()
}
}
}
CQMPCoreWrapper {
id: qmpcore
}
Timer {
id: uiTimer
interval: 100
running: false
repeat: true
onTriggered: {
if(!hsTimer.pressed)
{
hsTimer.autovalchange=true;
hsTimer.value=qmpcore.getProgress();
hsTimer.autovalchange=false;
}
}
}
Text {
id: fileName
text: qsTr("...")
anchors.top: parent.top
anchors.topMargin: 100
anchors.horizontalCenter: parent.horizontalCenter
x: 139
}
Button {
id: button1
x: 170
text: qsTr("Open")
anchors.top: parent.top
anchors.topMargin: 130
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
fileDialog.open();
}
}
FileDialog {
id: fileDialog
title: qsTr("Select midi file")
nameFilters: ["MIDI Files (*.mid *.midi)"]
onAccepted: {
fileName.text=fileUrl;
}
}
FileDialog {
id: sfFileDialog
title: qsTr("Select SoundFont")
nameFilters: ["SoundFont (*.sf2)"]
onAccepted: {soundfont=fileUrl;}
}
}
|