aboutsummaryrefslogtreecommitdiff
path: root/qmidiplayer-desktop
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2017-06-21 13:03:30 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2017-06-21 13:03:30 +0800
commit0c3fe540e925829022d9d8aa567c2dc2bd3d33d5 (patch)
treeab9ecae4def5a329b5e796839ece97f4b9c0297f /qmidiplayer-desktop
parent64c91c7da66ba71e2bb32077680f234aba4ac65d (diff)
downloadQMidiPlayer-0c3fe540e925829022d9d8aa567c2dc2bd3d33d5.tar.xz
Complete rewrite of the MIDI mapper.
Enforces single fluidsynth instance. Documentation update. Minor changes to make lite version work.
Diffstat (limited to 'qmidiplayer-desktop')
-rw-r--r--qmidiplayer-desktop/qmidiplayer-desktop.pro10
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.cpp22
-rw-r--r--qmidiplayer-desktop/qmpchannelswindow.hpp3
-rw-r--r--qmidiplayer-desktop/qmpefxwindow.cpp9
-rw-r--r--qmidiplayer-desktop/qmpefxwindow.hpp2
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.cpp109
-rw-r--r--qmidiplayer-desktop/qmpmainwindow.hpp4
-rw-r--r--qmidiplayer-desktop/qmpplugin.cpp8
-rw-r--r--qmidiplayer-desktop/qmppresetselect.cpp17
-rw-r--r--qmidiplayer-desktop/qmpsettingswindow.ui5
10 files changed, 91 insertions, 98 deletions
diff --git a/qmidiplayer-desktop/qmidiplayer-desktop.pro b/qmidiplayer-desktop/qmidiplayer-desktop.pro
index 427a2ff..74317c2 100644
--- a/qmidiplayer-desktop/qmidiplayer-desktop.pro
+++ b/qmidiplayer-desktop/qmidiplayer-desktop.pro
@@ -26,9 +26,10 @@ SOURCES += main.cpp\
qmpsettingswindow.cpp \
qmphelpwindow.cpp \
qdialskulpturestyle.cpp \
- ../core/qmpmidimapperrtmidi.cpp \
qmpplugin.cpp \
- qmpcustomizewindow.cpp
+ qmpcustomizewindow.cpp \
+ ../core/qmpmidioutrtmidi.cpp \
+ ../core/qmpmidioutfluid.cpp
HEADERS += qmpmainwindow.hpp \
../core/qmpmidiplay.hpp \
@@ -41,10 +42,11 @@ HEADERS += qmpmainwindow.hpp \
qmpsettingswindow.hpp \
qmphelpwindow.hpp \
qdialskulpturestyle.hpp \
- ../core/qmpmidimappers.hpp \
../include/qmpcorepublic.hpp \
qmpplugin.hpp \
- qmpcustomizewindow.hpp
+ qmpcustomizewindow.hpp \
+ ../core/qmpmidioutrtmidi.hpp \
+ ../core/qmpmidioutfluid.hpp
FORMS += qmpmainwindow.ui \
qmpplistwindow.ui \
diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp
index 9b6df60..0626697 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.cpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.cpp
@@ -15,18 +15,18 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) :
setMaximumWidth(w);setMaximumHeight(h);setMinimumWidth(w);setMinimumHeight(h);
pselectw=new qmpPresetSelector(this);
ceditw=new qmpChannelEditor(this);
- mapper=qmpMainWindow::getInstance()->getPlayer()->getMidiMapper();
cha=new QIcon(":/img/ledon.svg");chi=new QIcon(":/img/ledoff.svg");
cb=new qmpCWNoteOnCB();fused=callbacksc=cbcnt=0;
qmpMainWindow::getInstance()->getPlayer()->setEventHandlerCB(cb,NULL);
connect(cb,SIGNAL(onNoteOn()),this,SLOT(updateChannelActivity()));
- int devc=mapper->enumDevices();
+ std::vector<std::string> devs=qmpMainWindow::getInstance()->getPlayer()->getMidiOutDevices();
+ size_t devc=devs.size();
//We setup default output here...
//Pretty strange...
- for(int i=0;i<devc;++i)
+ for(size_t i=0;i<devc;++i)
{
- qmpSettingsWindow::getDefaultOutWidget()->addItem(mapper->deviceName(i).c_str());
- if(!QString(mapper->deviceName(i).c_str()).compare(qmpSettingsWindow::getSettingsIntf()->
+ qmpSettingsWindow::getDefaultOutWidget()->addItem(devs[i].c_str());
+ if(!QString(devs[i].c_str()).compare(qmpSettingsWindow::getSettingsIntf()->
value("Midi/DefaultOutput","Internal FluidSynth").toString()))
qmpSettingsWindow::getDefaultOutWidget()->setCurrentIndex(i+1);
}
@@ -44,16 +44,16 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) :
connect(ui->twChannels->cellWidget(i,2),SIGNAL(stateChanged(int)),this,SLOT(channelMSChanged()));
ui->twChannels->setCellWidget(i,3,new QDCComboBox());
QDCComboBox *cb=(QDCComboBox*)ui->twChannels->cellWidget(i,3);
- cb->addItem("Internal FluidSynth");cb->setID(i);
- for(int j=0;j<devc;++j)
+ cb->setID(i);
+ for(size_t j=0;j<devc;++j)
{
- cb->addItem(mapper->deviceName(j).c_str());
+ cb->addItem(devs[j].c_str());
if(!qmpSettingsWindow::getSettingsIntf()->
value("Midi/DefaultOutput","Internal FluidSynth").toString().compare(
- QString(mapper->deviceName(j).c_str())))
+ QString(devs[j].c_str())))
{
- cb->setCurrentIndex(j+1);
- changeMidiMapping(i,j+1);
+ cb->setCurrentIndex(j);
+ changeMidiMapping(i,j);
}
}
if(qmpSettingsWindow::getSettingsIntf()->value("Midi/DisableMapping",0).toInt())
diff --git a/qmidiplayer-desktop/qmpchannelswindow.hpp b/qmidiplayer-desktop/qmpchannelswindow.hpp
index 9db3689..3d0444b 100644
--- a/qmidiplayer-desktop/qmpchannelswindow.hpp
+++ b/qmidiplayer-desktop/qmpchannelswindow.hpp
@@ -11,7 +11,7 @@
#include "qmppresetselect.hpp"
#include "qmpchanneleditor.hpp"
#include "../core/qmpmidiplay.hpp"
-#include "../core/qmpmidimappers.hpp"
+#include "../core/qmpmidioutrtmidi.hpp"
namespace Ui {
class qmpChannelsWindow;
@@ -105,7 +105,6 @@ class qmpChannelsWindow:public QDialog
Ui::qmpChannelsWindow *ui;
qmpPresetSelector *pselectw;
qmpChannelEditor *ceditw;
- qmpMidiMapperRtMidi *mapper;
QIcon *cha,*chi;
qmpCWNoteOnCB *cb;
qmpChannelFunc *chnlf;
diff --git a/qmidiplayer-desktop/qmpefxwindow.cpp b/qmidiplayer-desktop/qmpefxwindow.cpp
index 6546547..e9f19bd 100644
--- a/qmidiplayer-desktop/qmpefxwindow.cpp
+++ b/qmidiplayer-desktop/qmpefxwindow.cpp
@@ -95,7 +95,7 @@ void qmpEfxWindow::showEvent(QShowEvent *event)
event->accept();
}
-void qmpEfxWindow::sendEfxChange()
+void qmpEfxWindow::sendEfxChange(void *_fs)
{
if(!qmpMainWindow::getInstance()||!initialized)return;
rr=ui->sbRoom->value()/100.;rd=ui->sbDamp->value()/100.;
@@ -103,9 +103,10 @@ void qmpEfxWindow::sendEfxChange()
ct=ui->rbSine->isChecked()?FLUID_CHORUS_MOD_SINE:FLUID_CHORUS_MOD_TRIANGLE;
cfb=ui->sbFeedBack->value();cl=ui->sbLevelC->value()/100.;
cr=ui->sbRate->value();cd=ui->sbDepth->value();
- CMidiPlayer* player=qmpMainWindow::getInstance()->getPlayer();
- player->setReverbPara(ui->cbEnabledR->isChecked()?1:0,rr,rd,rw,rl);
- player->setChorusPara(ui->cbEnabledC->isChecked()?1:0,cfb,cl,cr,cd,ct);
+ IFluidSettings* fs=(IFluidSettings*)_fs;
+ if(!_fs)fs=qmpMainWindow::getInstance()->getPlayer()->fluid();
+ fs->setReverbPara(ui->cbEnabledR->isChecked()?1:0,rr,rd,rw,rl);
+ fs->setChorusPara(ui->cbEnabledC->isChecked()?1:0,cfb,cl,cr,cd,ct);
QSettings *settings=qmpSettingsWindow::getSettingsIntf();
settings->setValue("Effects/ChorusEnabled",ui->cbEnabledC->isChecked()?1:0);
diff --git a/qmidiplayer-desktop/qmpefxwindow.hpp b/qmidiplayer-desktop/qmpefxwindow.hpp
index b016254..3bc8e40 100644
--- a/qmidiplayer-desktop/qmpefxwindow.hpp
+++ b/qmidiplayer-desktop/qmpefxwindow.hpp
@@ -34,7 +34,7 @@ class qmpEfxWindow : public QDialog
~qmpEfxWindow();
void closeEvent(QCloseEvent *event);
void showEvent(QShowEvent *event);
- void sendEfxChange();
+ void sendEfxChange(void *_fs=NULL);
private slots:
void on_dRoom_valueChanged();
diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp
index d2c2d0d..1c4d7d3 100644
--- a/qmidiplayer-desktop/qmpmainwindow.cpp
+++ b/qmidiplayer-desktop/qmpmainwindow.cpp
@@ -23,10 +23,10 @@ char* wcsto8bit(const wchar_t* s)
WideCharToMultiByte(CP_OEMCP,WC_NO_BEST_FIT_CHARS,s,-1,c,size,0,0);
return c;
}
-#define LOAD_SOUNDFONT \
+#define LOAD_SOUNDFONT(a) \
{\
char* c=wcsto8bit(settingsw->getSFWidget()->item(i,1)->text().toStdWString().c_str());\
- player->pushSoundFont(c);\
+ a->loadSFont(c);\
free(c);\
}
#define LOAD_FILE \
@@ -37,8 +37,8 @@ char* wcsto8bit(const wchar_t* s)
free(c);\
}
#else
-#define LOAD_SOUNDFONT \
- player->pushSoundFont(settingsw->getSFWidget()->item(i,1)->text().toStdString().c_str())
+#define LOAD_SOUNDFONT(a) \
+ a->loadSFont(settingsw->getSFWidget()->item(i,1)->text().toStdString().c_str())
#define LOAD_FILE \
{\
for(auto i=mfunc.begin();i!=mfunc.end();++i)if(i->second.isVisualization())((qmpVisualizationIntf*)(i->second.i()))->reset();\
@@ -64,7 +64,7 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) :
//setButtonHeight(ui->pbEfx,36);setButtonHeight(ui->pbVisualization,36);
playing=false;stopped=true;dragging=false;fin=false;
settingsw=new qmpSettingsWindow(this);pmgr=new qmpPluginManager();
- plistw=new qmpPlistWindow(this);player=NULL;timer=NULL;
+ plistw=new qmpPlistWindow(this);player=NULL;timer=NULL;fluidrenderer=NULL;
singleFS=qmpSettingsWindow::getSettingsIntf()->value("Behavior/SingleInstance",0).toInt();
}
@@ -77,6 +77,9 @@ qmpMainWindow::~qmpMainWindow()
delete a[i];
}
pmgr->deinitPlugins();
+ std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> rtdev=rtmididev->getDevices();
+ for(auto &i:rtdev)player->unregisterMidiOutDevice(i.second);
+ rtmididev->deleteDevices();
delete pmgr;if(player)delete player;
if(timer)delete timer;
delete helpw;helpw=NULL;
@@ -93,7 +96,11 @@ qmpMainWindow::~qmpMainWindow()
void qmpMainWindow::init()
{
- player=new CMidiPlayer(singleFS);
+ player=new CMidiPlayer();
+ rtmididev=new qmpRtMidiManager();
+ rtmididev->createDevices();
+ std::vector<std::pair<qmpMidiOutRtMidi*,std::string>> rtdev=rtmididev->getDevices();
+ for(auto &i:rtdev)player->registerMidiOutDevice(i.first,i.second);
chnlw=new qmpChannelsWindow(this);
efxw=new qmpEfxWindow(this);
infow=new qmpInfoWindow(this);
@@ -106,10 +113,10 @@ void qmpMainWindow::init()
registerFunctionality(panicf,"Panic",tr("Panic").toStdString(),getThemedIconc(":/img/panic.svg"),0,false);
registerFunctionality(reloadsynf,"ReloadSynth",tr("Restart fluidsynth").toStdString(),getThemedIconc(":/img/repeat-base.svg"),0,false);
pmgr->scanPlugins();settingsw->updatePluginList(pmgr);pmgr->initPlugins();
- if(singleFS){player->fluidPreInitialize();playerSetup();player->fluidInitialize();
- for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
- LOAD_SOUNDFONT;
- }}
+ playerSetup(player->fluid());player->fluid()->deviceInit();
+ for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
+ LOAD_SOUNDFONT(player->fluid());
+ }
if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus",0).toInt())
{
QRect g=qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/MainW",QRect(-999,-999,999,999)).toRect();
@@ -242,7 +249,7 @@ void qmpMainWindow::updateWidgets()
chnlw->resetAcitivity();
player->playerDeinit();playerTh->join();
delete playerTh;playerTh=NULL;
- if(singleFS)player->playerPanic(true);
+ player->playerPanic(true);
chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
ui->hsTimer->setValue(0);
@@ -254,21 +261,13 @@ void qmpMainWindow::updateWidgets()
}
if(renderTh)
{
- if(player->isFinished())
+ if(fluidrenderer->isFinished())
{
renderTh->join();timer->stop();
ui->centralWidget->setEnabled(true);
delete renderTh;renderTh=NULL;
- player->rendererDeinit();
- if(singleFS)
- {
- player->fluidPreInitialize();
- playerSetup();
- player->fluidInitialize();
- for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
- LOAD_SOUNDFONT;
- }
- }
+ fluidrenderer->renderDeinit();
+ delete fluidrenderer;fluidrenderer=NULL;
}
}
while(!player->isFinished()&&player->getTCeptr()>player->getStamp(ui->hsTimer->value())
@@ -281,8 +280,8 @@ void qmpMainWindow::updateWidgets()
char ts[100];
sprintf(ts,"%02d:%02d",(int)(elapsed.count()+offset)/60,(int)(elapsed.count()+offset)%60);
ui->lbCurTime->setText(ts);
- ui->lbCurPoly->setText(QString("%1").arg(player->getPolyphone(),5,10,QChar('0')));
- ui->lbMaxPoly->setText(QString("%1").arg(player->getMaxPolyphone(),5,10,QChar('0')));
+ ui->lbCurPoly->setText(QString("%1").arg(player->fluid()->getPolyphone(),5,10,QChar('0')));
+ ui->lbMaxPoly->setText(QString("%1").arg(player->fluid()->getMaxPolyphone(),5,10,QChar('0')));
}
}
@@ -295,7 +294,7 @@ void qmpMainWindow::switchTrack(QString s)
timer->stop();player->playerDeinit();
for(auto i=mfunc.begin();i!=mfunc.end();++i)if(i->second.isVisualization())((qmpVisualizationIntf*)(i->second.i()))->stop();
if(playerTh){playerTh->join();delete playerTh;playerTh=NULL;}
- if(singleFS)player->playerPanic(true);
+ player->playerPanic(true);
ui->hsTimer->setValue(0);
chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
QString fns=s;setWindowTitle(QUrl::fromLocalFile(fns).fileName().left(QUrl::fromLocalFile(fns).fileName().lastIndexOf('.'))+" - QMidiPlayer");
@@ -305,12 +304,9 @@ void qmpMainWindow::switchTrack(QString s)
char ts[100];
sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
ui->lbFinTime->setText(ts);
- player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize();
- for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
- LOAD_SOUNDFONT;
- }}
+ player->playerInit();
for(auto i=mfunc.begin();i!=mfunc.end();++i)if(i->second.isVisualization())((qmpVisualizationIntf*)(i->second.i()))->start();
- player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
+ player->fluid()->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt());
playerTh=new std::thread(&CMidiPlayer::playerThread,player);
#ifdef _WIN32
@@ -340,19 +336,18 @@ std::wstring qmpMainWindow::getWTitle()
toUnicode(player->getTitle()).toStdWString();
}
-void qmpMainWindow::playerSetup()
+void qmpMainWindow::playerSetup(IFluidSettings* fs)
{
- fluid_settings_t* fsettings=player->getFluidSettings();
QSettings* settings=qmpSettingsWindow::getSettingsIntf();
- fluid_settings_setstr(fsettings,"audio.driver",settings->value("Audio/Driver","").toString().toStdString().c_str());
- fluid_settings_setint(fsettings,"audio.period-size",settings->value("Audio/BufSize","").toInt());
- fluid_settings_setint(fsettings,"audio.periods",settings->value("Audio/BufCnt","").toInt());
- fluid_settings_setstr(fsettings,"audio.sample-format",settings->value("Audio/Format","").toString().toStdString().c_str());
- fluid_settings_setint(fsettings,"synth.sample-rate",settings->value("Audio/Frequency","").toInt());
- fluid_settings_setint(fsettings,"synth.polyphony",settings->value("Audio/Polyphony","").toInt());
- fluid_settings_setint(fsettings,"synth.cpu-cores",settings->value("Audio/Threads","").toInt());
+ fs->setOptStr("audio.driver",settings->value("Audio/Driver","").toString().toStdString().c_str());
+ fs->setOptInt("audio.period-size",settings->value("Audio/BufSize","").toInt());
+ fs->setOptInt("audio.periods",settings->value("Audio/BufCnt","").toInt());
+ fs->setOptStr("audio.sample-format",settings->value("Audio/Format","").toString().toStdString().c_str());
+ fs->setOptInt("synth.sample-rate",settings->value("Audio/Frequency","").toInt());
+ fs->setOptInt("synth.polyphony",settings->value("Audio/Polyphony","").toInt());
+ fs->setOptInt("synth.cpu-cores",settings->value("Audio/Threads","").toInt());
char bsmode[4];
- if(!singleFS&&settings->value("Audio/AutoBS",1).toInt()&&player->getFileStandard())
+ if(settings->value("Audio/AutoBS",1).toInt()&&player->getFileStandard())
switch(player->getFileStandard())
{
case 1:strcpy(bsmode,"gm");break;
@@ -371,7 +366,7 @@ void qmpMainWindow::playerSetup()
if(settings->value("Audio/BankSelect","CC#0").toString()==QString("CC#0*128+CC#32"))
strcpy(bsmode,"mma");
}
- fluid_settings_setstr(fsettings,"synth.midi-bank-select",bsmode);
+ fs->setOptStr("synth.midi-bank-select",bsmode);
player->sendSysX(settings->value("Midi/SendSysEx",1).toInt());
}
@@ -393,13 +388,9 @@ void qmpMainWindow::on_pbPlayPause_clicked()
char ts[100];
sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60);
ui->lbFinTime->setText(ts);
- player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize();
- for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
- LOAD_SOUNDFONT;
- }
- }
+ player->playerInit();
for(auto i=mfunc.begin();i!=mfunc.end();++i)if(i->second.isVisualization())((qmpVisualizationIntf*)(i->second.i()))->start();
- player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
+ player->fluid()->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();
player->setWaitVoice(qmpSettingsWindow::getSettingsIntf()->value("Midi/WaitVoice",1).toInt());
playerTh=new std::thread(&CMidiPlayer::playerThread,player);
#ifdef _WIN32
@@ -480,7 +471,7 @@ void qmpMainWindow::playerSeek(uint32_t percentage)
void qmpMainWindow::on_vsMasterVol_valueChanged()
{
- if(!stopped)player->setGain(ui->vsMasterVol->value()/250.);
+ if(!stopped)player->fluid()->setGain(ui->vsMasterVol->value()/250.);
qmpSettingsWindow::getSettingsIntf()->setValue("Audio/Gain",ui->vsMasterVol->value());
}
@@ -492,7 +483,7 @@ void qmpMainWindow::on_pbStop_clicked()
for(auto i=mfunc.begin();i!=mfunc.end();++i)if(i->second.isVisualization())((qmpVisualizationIntf*)(i->second.i()))->stop();
player->playerDeinit();
setFuncEnabled("Render",stopped);setFuncEnabled("ReloadSynth",stopped);
- if(singleFS)player->playerPanic(true);chnlw->resetAcitivity();
+ player->playerPanic(true);chnlw->resetAcitivity();
if(playerTh){playerTh->join();delete playerTh;playerTh=NULL;}
chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked();
ui->pbPlayPause->setIcon(QIcon(getThemedIcon(":/img/play.svg")));
@@ -583,7 +574,6 @@ bool qmpMainWindow::isDarkTheme()
void qmpMainWindow::startRender()
{
- if(singleFS)player->fluidDeinitialize();
#ifdef _WIN32
char* ofstr=wcsto8bit((plistw->getSelectedItem()+QString(".wav")).toStdWString().c_str());
char* ifstr=wcsto8bit(plistw->getSelectedItem().toStdWString().c_str());
@@ -591,22 +581,27 @@ void qmpMainWindow::startRender()
playerSetup();player->rendererInit(ifstr);
free(ofstr);free(ifstr);
#else
- player->rendererLoadFile((plistw->getSelectedItem()+QString(".wav")).toStdString().c_str());
- playerSetup();player->rendererInit(plistw->getSelectedItem().toStdString().c_str());
+ fluidrenderer=new qmpFileRendererFluid(
+ plistw->getSelectedItem().toStdString().c_str(),
+ (plistw->getSelectedItem()+QString(".wav")).toStdString().c_str()
+ );
+ playerSetup(fluidrenderer);
+ fluidrenderer->renderInit();
#endif
ui->centralWidget->setEnabled(false);
for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
- LOAD_SOUNDFONT;
+ LOAD_SOUNDFONT(fluidrenderer);
}
- player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange();timer->start(UPDATE_INTERVAL);
- renderTh=new std::thread(&CMidiPlayer::rendererThread,player);
+ fluidrenderer->setGain(ui->vsMasterVol->value()/250.);
+ efxw->sendEfxChange(fluidrenderer);timer->start(UPDATE_INTERVAL);
+ renderTh=new std::thread(&qmpFileRendererFluid::renderWorker,fluidrenderer);
}
void qmpMainWindow::reloadSynth()
{
- player->fluidDeinitialize();player->fluidPreInitialize();playerSetup();player->fluidInitialize();
+ player->fluid()->deviceDeinit(true);playerSetup(player->fluid());player->fluid()->deviceInit();
for(int i=settingsw->getSFWidget()->rowCount()-1;i>=0;--i){if(!((QCheckBox*)settingsw->getSFWidget()->cellWidget(i,0))->isChecked())continue;
- LOAD_SOUNDFONT;
+ LOAD_SOUNDFONT(player->fluid());
}
}
diff --git a/qmidiplayer-desktop/qmpmainwindow.hpp b/qmidiplayer-desktop/qmpmainwindow.hpp
index baadb6d..fd1a5eb 100644
--- a/qmidiplayer-desktop/qmpmainwindow.hpp
+++ b/qmidiplayer-desktop/qmpmainwindow.hpp
@@ -180,6 +180,8 @@ class qmpMainWindow:public QMainWindow
std::chrono::steady_clock::time_point st;
double offset;
CMidiPlayer *player;
+ qmpRtMidiManager *rtmididev;
+ qmpFileRendererFluid *fluidrenderer;
qmpPluginManager *pmgr;
QPointer<qmpPlistWindow> plistw;
QPointer<qmpChannelsWindow> chnlw;
@@ -194,7 +196,7 @@ class qmpMainWindow:public QMainWindow
std::vector<std::string> enabled_buttons,enabled_actions;
void onfnChanged();
- void playerSetup();
+ void playerSetup(IFluidSettings *fs);
private:
static qmpMainWindow* ref;
diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp
index 5889b9f..2cafa7f 100644
--- a/qmidiplayer-desktop/qmpplugin.cpp
+++ b/qmidiplayer-desktop/qmpplugin.cpp
@@ -135,9 +135,9 @@ uint32_t qmpPluginAPI::getNoteCount()
uint32_t qmpPluginAPI::getMaxTick()
{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getMaxTick():0;}
uint32_t qmpPluginAPI::getCurrentPolyphone()
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getPolyphone():0;}
+{return qmw&&qmw->getPlayer()?qmw->getPlayer()->fluid()->getPolyphone():0;}
uint32_t qmpPluginAPI::getMaxPolyphone()
-{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getMaxPolyphone():0;}
+{return qmw&&qmw->getPlayer()?qmw->getPlayer()->fluid()->getMaxPolyphone():0;}
uint32_t qmpPluginAPI::getCurrentTimeStamp()
{return qmw&&qmw->getPlayer()?qmw->getPlayer()->getTick():0;}
uint32_t qmpPluginAPI::getCurrentPlaybackPercentage()
@@ -182,6 +182,10 @@ void qmpPluginAPI::callEventReaderCB(SEventCallBackData d){if(qmw&&qmw->getPlaye
void qmpPluginAPI::setFuncState(std::string name,bool state){if(qmw)qmw->setFuncState(name,state);}
void qmpPluginAPI::setFuncEnabled(std::string name,bool enable){if(qmw)qmw->setFuncEnabled(name,enable);}
+void qmpPluginAPI::registerMidiOutDevice(qmpMidiOutDevice *dev, std::string name)
+{qmw->getPlayer()->registerMidiOutDevice(dev,name);}
+void qmpPluginAPI::unregisterMidiOutDevice(std::string name)
+{qmw->getPlayer()->unregisterMidiOutDevice(name);}
int qmpPluginAPI::registerEventHandlerIntf(IMidiCallBack *cb,void *userdata)
{return qmw->getPlayer()->setEventHandlerCB(cb,userdata);}
void qmpPluginAPI::unregisterEventHandlerIntf(int intfhandle)
diff --git a/qmidiplayer-desktop/qmppresetselect.cpp b/qmidiplayer-desktop/qmppresetselect.cpp
index c5132b3..57dbe7f 100644
--- a/qmidiplayer-desktop/qmppresetselect.cpp
+++ b/qmidiplayer-desktop/qmppresetselect.cpp
@@ -21,16 +21,11 @@ void qmpPresetSelector::showEvent(QShowEvent *e)
{
memset(presets,0,sizeof(presets));
CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer();
- if(!plyr->getSFCount())return e->ignore();
- int sfc=plyr->getSFCount();
- for(int i=sfc-1;i>=0;--i)
- {
- fluid_sfont_t* psf=plyr->getSFPtr(i);
- fluid_preset_t preset;
- psf->iteration_start(psf);
- while(psf->iteration_next(psf,&preset))
- strcpy(presets[preset.get_banknum(&preset)][preset.get_num(&preset)],preset.get_name(&preset));
- }
+ if(!plyr->fluid()->getSFCount())return e->ignore();
+ std::vector<std::pair<std::pair<int,int>,std::string>>
+ presetlist=plyr->fluid()->listPresets();
+ for(auto &i:presetlist)
+ strcpy(presets[i.first.first][i.first.second],i.second.c_str());
ui->lwBankSelect->clear();
ui->lwPresetSelect->clear();
for(int i=0;i<=128;++i)
@@ -44,7 +39,7 @@ void qmpPresetSelector::showEvent(QShowEvent *e)
void qmpPresetSelector::setupWindow(int chid)
{
CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer();
- if(!plyr->getSFCount())return;
+ if(!plyr->fluid()->getSFCount())return;
ch=chid;int b=0,p=0,r;char name[64];
sprintf(name,"Preset Selection - Channel #%d",ch+1);
setWindowTitle(name);
diff --git a/qmidiplayer-desktop/qmpsettingswindow.ui b/qmidiplayer-desktop/qmpsettingswindow.ui
index ad359f7..bbeddd4 100644
--- a/qmidiplayer-desktop/qmpsettingswindow.ui
+++ b/qmidiplayer-desktop/qmpsettingswindow.ui
@@ -53,11 +53,6 @@
<verstretch>0</verstretch>
</sizepolicy>
</property>
- <item>
- <property name="text">
- <string>Internal FluidSynth</string>
- </property>
- </item>
</widget>
</item>
</layout>