aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-lite
diff options
context:
space:
mode:
Diffstat (limited to 'qmidiplayer-lite')
-rw-r--r--qmidiplayer-lite/main.qml36
-rw-r--r--qmidiplayer-lite/qmidiplayer-lite.pro6
-rw-r--r--qmidiplayer-lite/qmpcorewrapper.hpp16
3 files changed, 39 insertions, 19 deletions
diff --git a/qmidiplayer-lite/main.qml b/qmidiplayer-lite/main.qml
index 0ec0975..ace1427 100644
--- a/qmidiplayer-lite/main.qml
+++ b/qmidiplayer-lite/main.qml
@@ -8,10 +8,12 @@ Window {
id: window1
width: 420
height: 240
- title: "QMidiPlayer Lite"
+ title: "QMidiPlayer Lite TP"
visible: true
property bool playing
playing: false
+ property string soundfont
+ soundfont: ""
MouseArea {
id: mouseArea1
@@ -20,9 +22,6 @@ Window {
anchors.leftMargin: 0
anchors.topMargin: 0
anchors.fill: parent
- onClicked: {
- //Qt.quit();
- }
Button {
id: button2
@@ -35,7 +34,7 @@ Window {
if(!playing)
{
qmpcore.loadFile(fileName.text);
- qmpcore.initFluidSynth();
+ qmpcore.initFluidSynth(soundfont);
qmpcore.playFile();
playing=true;
uiTimer.start();
@@ -92,6 +91,18 @@ Window {
}
}
}
+
+ Button {
+ id: button
+ anchors.top: parent.top
+ anchors.topMargin: 67
+ anchors.horizontalCenter: parent.horizontalCenter
+ x: 139
+ text: qsTr("Load SoundFont")
+ onClicked: {
+ sfFileDialog.open()
+ }
+ }
}
CQMPCoreWrapper {
@@ -115,17 +126,18 @@ Window {
Text {
id: fileName
text: qsTr("...")
- anchors.centerIn: parent
+ anchors.top: parent.top
+ anchors.topMargin: 100
+ anchors.horizontalCenter: parent.horizontalCenter
+ x: 139
}
Button {
id: button1
x: 170
- width: 80
- height: 27
text: qsTr("Open")
anchors.top: parent.top
- anchors.topMargin: 142
+ anchors.topMargin: 130
anchors.horizontalCenter: parent.horizontalCenter
onClicked: {
fileDialog.open();
@@ -140,5 +152,11 @@ Window {
fileName.text=fileUrl;
}
}
+ FileDialog {
+ id: sfFileDialog
+ title: qsTr("Select SoundFont")
+ nameFilters: ["SoundFont (*.sf2)"]
+ onAccepted: {soundfont=fileUrl;}
+ }
}
diff --git a/qmidiplayer-lite/qmidiplayer-lite.pro b/qmidiplayer-lite/qmidiplayer-lite.pro
index 1534d53..9b02387 100644
--- a/qmidiplayer-lite/qmidiplayer-lite.pro
+++ b/qmidiplayer-lite/qmidiplayer-lite.pro
@@ -7,8 +7,8 @@ CONFIG += c++11
SOURCES += main.cpp \
../core/qmpmidiplay.cpp \
- ../core/qmpmidiread.cpp \
- ../core/qmpmidimapperrtmidi.cpp
+ ../core/qmpmidiread.cpp \
+ ../core/qmpmidioutfluid.cpp
RESOURCES += qml.qrc
@@ -21,7 +21,7 @@ include(deployment.pri)
HEADERS += \
../core/qmpmidiplay.hpp \
qmpcorewrapper.hpp \
- ../core/qmpmidimappers.hpp \
+ ../core/qmpmidioutfluid.hpp \
../include/qmpcorepublic.hpp
unix{
LIBS += -lfluidsynth -lrtmidi
diff --git a/qmidiplayer-lite/qmpcorewrapper.hpp b/qmidiplayer-lite/qmpcorewrapper.hpp
index ed024df..090edc7 100644
--- a/qmidiplayer-lite/qmpcorewrapper.hpp
+++ b/qmidiplayer-lite/qmpcorewrapper.hpp
@@ -15,19 +15,20 @@ private:
public:
explicit CQMPCoreWrapper(QObject* parent=0):QObject(parent)
{
- mp=new CMidiPlayer(false);
+ mp=new CMidiPlayer();
}
~CQMPCoreWrapper(){delete mp;}
- Q_INVOKABLE void initFluidSynth()
+ Q_INVOKABLE void initFluidSynth(QUrl sfpath)
{
- fluid_settings_t *fsettings=mp->getFluidSettings();
- fluid_settings_setstr(fsettings,"audio.driver","pulseaudio");
- mp->fluidInitialize();
- mp->pushSoundFont("/media/Files/FluidR3_Ext.sf2");
+ mp->fluid()->setOptStr("audio.driver","pulseaudio");
+ mp->fluid()->deviceInit();
+ mp->fluid()->loadSFont(sfpath.toLocalFile().toStdString().c_str());
+ for(int i=0;i<16;++i)
+ mp->setChannelOutput(i,0);
}
Q_INVOKABLE void deinitFluidSynth()
{
- mp->fluidDeinitialize();
+ mp->fluid()->deviceDeinit();
}
Q_INVOKABLE void loadFile(QUrl file)
{
@@ -41,6 +42,7 @@ public:
Q_INVOKABLE void stop()
{
mp->playerDeinit();playerTh->join();delete playerTh;
+ mp->playerPanic();
}
Q_INVOKABLE int getProgress()
{