From 24481b4334db3c45041db53503a7b6832deb704f Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 30 Jan 2016 23:54:52 +0800 Subject: Necro-Fantasy. (WTF) --- ChangeLog | 7 ++++- debian/changelog | 6 +++++ doc/index.html | 71 ++++++++++++++++++++++++++++++++------------------- qmphelpwindow.hpp | 2 +- qmpmainwindow.cpp | 40 +++++++++++++++++++---------- qmpmainwindow.hpp | 2 +- qmpmidiplay.cpp | 34 +++++++++++++++--------- qmpmidiplay.hpp | 7 ++--- qmppresetselect.cpp | 2 +- qmpsettingswindow.cpp | 4 +++ qmpsettingswindow.ui | 7 +++++ 11 files changed, 124 insertions(+), 58 deletions(-) diff --git a/ChangeLog b/ChangeLog index 9cedbc6..c39d55f 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,4 +1,9 @@ -2016-01-16 0.6.2 beta +2016-01-30 0.7.0 beta +Add support for a single, persistent fluidsynth instance. +(Experimental, may also break the original mode...) +A little documentaion work... + +2016-01-26 0.6.2 beta Maintaince release. Use skulpture style dials. Use QThread::usleep() in Windows to improve sleep precision. diff --git a/debian/changelog b/debian/changelog index 290b02b..d237db3 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,9 @@ +qmidiplayer (0.7.0-0) UNRELEASED; urgency=low + + * New upstream release. + + -- chrisoft Sat, 30 Jan 2016 23:47:54 +0800 + qmidiplayer (0.6.2-3) UNRELEASED; urgency=low * Maintaince release. diff --git a/doc/index.html b/doc/index.html index 2e9157b..6d1af38 100644 --- a/doc/index.html +++ b/doc/index.html @@ -4,31 +4,50 @@ QMidiPlayer Help -

Overview

- QMidiPlayer is a cross-platform player for midi files based on fluidsynth and Qt.
- Key features:
- -

Using QMidiPlayer

- -

About QMidiPlayer

- + + + + + +
+ + +

Overview

+ QMidiPlayer is a cross-platform player for midi files based on fluidsynth and Qt.
+ Key features:
+
    +
  • Playback of midi format 0/1 files.
  • +
  • Manipulate channel parameters on-the-fly.
  • +
  • Visualization of midi file playback.(Not yet implemented)
  • +
  • Playlists.
  • +
  • Midi mapping.(Not yet implemented)
  • +
  • Rendering midi files to wave.
  • +
+

Using QMidiPlayer

+
    +
  • The main window
  • +
  • The channels dialog
  • +
  • The channels parameters editor
  • +
  • The playlist dialog
  • +
  • The effects dialog
  • +
  • Visualization
  • +
  • Setting up QMidiPlayer
  • +
+

About QMidiPlayer

+ +
\ No newline at end of file diff --git a/qmphelpwindow.hpp b/qmphelpwindow.hpp index 73221ca..c2052b2 100644 --- a/qmphelpwindow.hpp +++ b/qmphelpwindow.hpp @@ -2,7 +2,7 @@ #define QMPHELPWINDOW_H #include -#define APP_VERSION "0.6.2" +#define APP_VERSION "0.7.0" namespace Ui { class qmpHelpWindow; diff --git a/qmpmainwindow.cpp b/qmpmainwindow.cpp index 646f3ad..1e05c5c 100644 --- a/qmpmainwindow.cpp +++ b/qmpmainwindow.cpp @@ -13,7 +13,7 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::qmpMainWindow) { - ui->setupUi(this);player=new CMidiPlayer(); + ui->setupUi(this); ui->lbFileName->setText("");ref=this; playing=false;stopped=true;dragging=false; settingsw=new qmpSettingsWindow(this); @@ -27,7 +27,12 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) : fnA2=new QAction("Render to Wave",ui->lbFileName); ui->lbFileName->addAction(fnA1); ui->lbFileName->addAction(fnA2); - if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus","").toInt()) + singleFS=qmpSettingsWindow::getSettingsIntf()->value("Behavior/SingleInstance",0).toInt(); + player=new CMidiPlayer(singleFS); + if(singleFS){player->fluidPreInitialize();playerSetup();player->fluidInitialize(); + for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str());} + if(qmpSettingsWindow::getSettingsIntf()->value("Behavior/DialogStatus",0).toInt()) { QRect g=geometry(); g.setTopLeft(qmpSettingsWindow::getSettingsIntf()->value("DialogStatus/MainW",QPoint(-999,-999)).toPoint()); @@ -51,6 +56,7 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) : qmpMainWindow::~qmpMainWindow() { + delete player; delete timer; delete ui; } @@ -148,6 +154,7 @@ void qmpMainWindow::updateWidgets() fnA2->setEnabled(stopped); player->playerDeinit();playerTh->join(); delete playerTh;playerTh=NULL; + if(singleFS)player->playerPanic(); chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked(); ui->pbPlayPause->setIcon(QIcon(":/img/play.png")); ui->hsTimer->setValue(0); @@ -159,6 +166,7 @@ void qmpMainWindow::updateWidgets() timer->stop();player->playerDeinit();playerTh->join(); delete playerTh;playerTh=NULL; ui->hsTimer->setValue(0); + if(singleFS)player->playerPanic(); chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked(); QString fns=plistw->getNextItem(); ui->lbFileName->setText(QUrl(fns).fileName()); @@ -166,9 +174,9 @@ void qmpMainWindow::updateWidgets() char ts[100]; sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60); ui->lbFinTime->setText(ts); - player->playerInit();playerSetup();player->fluidInitialize(); + player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) - player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str());} player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; @@ -183,6 +191,7 @@ void qmpMainWindow::updateWidgets() ui->centralWidget->setEnabled(true); delete renderTh;renderTh=NULL; player->rendererDeinit(); + if(singleFS){player->fluidPreInitialize();playerSetup();player->fluidInitialize();} } } while(!player->isFinished()&&player->getTCeptr()>player->getStamp(ui->hsTimer->value()) @@ -214,7 +223,7 @@ void qmpMainWindow::playerSetup() fluid_settings_setint(fsettings,"synth.polyphony",settings->value("Audio/Polyphony","").toInt()); fluid_settings_setint(fsettings,"synth.cpu-cores",settings->value("Audio/Threads","").toInt()); char bsmode[4]; - if(settings->value("Audio/AutoBS",1).toInt()&&player->getFileStandard()) + if(!singleFS&&settings->value("Audio/AutoBS",1).toInt()&&player->getFileStandard()) switch(player->getFileStandard()) { case 1:strcpy(bsmode,"gm");break; @@ -254,9 +263,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();playerSetup();player->fluidInitialize(); + player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) - player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str());} player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; @@ -317,6 +326,7 @@ void qmpMainWindow::on_pbStop_clicked() { timer->stop();stopped=true;playing=false; player->playerDeinit();fnA2->setEnabled(stopped); + if(singleFS)player->playerPanic(); if(playerTh){playerTh->join();delete playerTh;playerTh=NULL;} chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked(); ui->pbPlayPause->setIcon(QIcon(":/img/play.png")); @@ -364,6 +374,7 @@ void qmpMainWindow::on_pbPrev_clicked() { timer->stop();player->playerDeinit(); if(playerTh){playerTh->join();delete playerTh;playerTh=NULL;} + if(singleFS)player->playerPanic(); ui->hsTimer->setValue(0);chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked(); QString fns=plistw->getPrevItem();if(fns.length()==0)return on_pbStop_clicked(); ui->lbFileName->setText(QUrl(fns).fileName()); @@ -371,9 +382,9 @@ void qmpMainWindow::on_pbPrev_clicked() char ts[100]; sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60); ui->lbFinTime->setText(ts); - player->playerInit();playerSetup();player->fluidInitialize(); + player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) - player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str());} player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; @@ -384,6 +395,7 @@ void qmpMainWindow::on_pbNext_clicked() { timer->stop();player->playerDeinit(); if(playerTh){playerTh->join();delete playerTh;playerTh=NULL;} + if(singleFS)player->playerPanic(); ui->hsTimer->setValue(0);chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked(); QString fns=plistw->getNextItem();if(fns.length()==0)return on_pbStop_clicked(); ui->lbFileName->setText(QUrl(fns).fileName()); @@ -391,9 +403,9 @@ void qmpMainWindow::on_pbNext_clicked() char ts[100]; sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60); ui->lbFinTime->setText(ts); - player->playerInit();playerSetup();player->fluidInitialize(); + player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) - player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str());} player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; @@ -406,6 +418,7 @@ void qmpMainWindow::selectionChanged() ui->pbPlayPause->setIcon(QIcon(":/img/pause.png")); timer->stop();player->playerDeinit(); if(playerTh){playerTh->join();delete playerTh;playerTh=NULL;} + if(singleFS)player->playerPanic(); ui->hsTimer->setValue(0); chnlw->on_pbUnmute_clicked();chnlw->on_pbUnsolo_clicked(); QString fns=plistw->getSelectedItem(); @@ -414,9 +427,9 @@ void qmpMainWindow::selectionChanged() char ts[100]; sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60); ui->lbFinTime->setText(ts); - player->playerInit();playerSetup();player->fluidInitialize(); + player->playerInit();if(!singleFS){playerSetup();player->fluidInitialize(); for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) - player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str());} player->setGain(ui->vsMasterVol->value()/250.);efxw->sendEfxChange(); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; @@ -451,6 +464,7 @@ void qmpMainWindow::onfnA1() void qmpMainWindow::onfnA2() { + if(singleFS)player->fluidDeinitialize(); player->rendererLoadFile((plistw->getSelectedItem()+QString(".wav")).toStdString().c_str()); playerSetup();player->rendererInit(plistw->getSelectedItem().toStdString().c_str()); ui->centralWidget->setEnabled(false); diff --git a/qmpmainwindow.hpp b/qmpmainwindow.hpp index fad2d8e..0b83c39 100644 --- a/qmpmainwindow.hpp +++ b/qmpmainwindow.hpp @@ -66,7 +66,7 @@ class qmpMainWindow:public QMainWindow private: Ui::qmpMainWindow *ui; QTimer *timer; - bool playing,stopped,dragging,fin; + bool playing,stopped,dragging,fin,singleFS; std::thread *playerTh=NULL; std::thread *renderTh=NULL; std::chrono::steady_clock::time_point st; diff --git a/qmpmidiplay.cpp b/qmpmidiplay.cpp index 2dbc753..8f89e88 100644 --- a/qmpmidiplay.cpp +++ b/qmpmidiplay.cpp @@ -6,6 +6,10 @@ #include #endif #include "qmpmidiplay.hpp" +void CMidiPlayer::fluidPreInitialize() +{ + settings=new_fluid_settings(); +} void CMidiPlayer::fluidInitialize() { synth=new_fluid_synth(settings); @@ -13,15 +17,20 @@ void CMidiPlayer::fluidInitialize() fluid_synth_set_chorus(synth,FLUID_CHORUS_DEFAULT_N,FLUID_CHORUS_DEFAULT_LEVEL, FLUID_CHORUS_DEFAULT_SPEED,FLUID_CHORUS_DEFAULT_DEPTH, FLUID_CHORUS_DEFAULT_TYPE); - if(midiFile->getStandard()==4) - fluid_synth_set_channel_type(synth,9,CHANNEL_TYPE_MELODIC); - else if(midiFile->getStandard()==1) - fluid_synth_set_channel_type(synth,9,CHANNEL_TYPE_DRUM); - else +#ifndef WIN32 + if(!singleInstance) { - fluid_synth_set_channel_type(synth,9,CHANNEL_TYPE_DRUM); - fluid_synth_bank_select(synth,9,128); + if(midiFile->getStandard()==4) + fluid_synth_set_channel_type(synth,9,CHANNEL_TYPE_MELODIC); + else if(midiFile->getStandard()==1) + fluid_synth_set_channel_type(synth,9,CHANNEL_TYPE_DRUM); + else + { + fluid_synth_set_channel_type(synth,9,CHANNEL_TYPE_DRUM); + fluid_synth_bank_select(synth,9,128); + } } +#endif } void CMidiPlayer::fluidDeinitialize() { @@ -188,12 +197,12 @@ void CMidiPlayer::fileTimer2Pass() stamps[c++]=midiFile->getEventCount(); } } -CMidiPlayer::CMidiPlayer() +CMidiPlayer::CMidiPlayer(bool singleInst) { - midiFile=NULL;resumed=false; + midiFile=NULL;resumed=false;singleInstance=singleInst; settings=NULL;synth=NULL;adriver=NULL; } -CMidiPlayer::~CMidiPlayer(){} +CMidiPlayer::~CMidiPlayer(){if(singleInstance)fluidDeinitialize();} void CMidiPlayer::playerPanic() { for(int i=0;i<16;++i)fluid_synth_all_notes_off(synth,i); @@ -212,13 +221,14 @@ void CMidiPlayer::playerInit() { ctempo=0x7A120;ctsn=4;ctsd=4;cks=0;dpt=ctempo*1000/divs; tceptr=0;tcstop=0;tcpaused=0;finished=0;mute=solo=0; - sendSysEx=true;settings=new_fluid_settings(); + sendSysEx=true; + if(!singleInstance)fluidPreInitialize(); } void CMidiPlayer::playerDeinit() { tceptr=0;tcstop=1;tcpaused=0; delete midiFile;midiFile=NULL; - fluidDeinitialize(); + if(!singleInstance)fluidDeinitialize(); } void CMidiPlayer::playerThread() { diff --git a/qmpmidiplay.hpp b/qmpmidiplay.hpp index 188a796..6525c87 100644 --- a/qmpmidiplay.hpp +++ b/qmpmidiplay.hpp @@ -58,7 +58,7 @@ class CMidiPlayer //0..127:cc 128:pc 129:cp 130:pb 131:tempo 132:ts 133:ks uint16_t mute,solo; double ftime; - bool sendSysEx; + bool sendSysEx,singleInstance; fluid_settings_t* settings; fluid_synth_t* synth; fluid_audio_driver_t* adriver; @@ -70,18 +70,19 @@ class CMidiPlayer uint32_t finished,resumed; void setBit(uint16_t &n,uint16_t bn,uint16_t b); - void fluidDeinitialize(); void processEvent(const SEvent *e); void processEventStub(const SEvent *e); void playEvents(); void fileTimer1Pass(); void fileTimer2Pass(); public: - CMidiPlayer(); + CMidiPlayer(bool singleInst=false); ~CMidiPlayer(); bool playerLoadFile(const char* fn); void playerInit(); + void fluidPreInitialize(); void fluidInitialize(); + void fluidDeinitialize(); void playerDeinit(); void playerThread(); void playerPanic(); diff --git a/qmppresetselect.cpp b/qmppresetselect.cpp index c0e6f75..be589c5 100644 --- a/qmppresetselect.cpp +++ b/qmppresetselect.cpp @@ -44,7 +44,7 @@ void qmpPresetSelector::setupWindow(int chid) CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer(); if(!plyr->getSFCount())return; ch=chid;int b=0,p=0,r;char name[64]; - sprintf(name,"Preset Selection - Channel #%d",ch); + sprintf(name,"Preset Selection - Channel #%d",ch+1); setWindowTitle(name); plyr->getChannelPreset(chid,&b,&p,name); for(int i=0;ilwBankSelect->count();++i) diff --git a/qmpsettingswindow.cpp b/qmpsettingswindow.cpp index 465bbc8..622093e 100644 --- a/qmpsettingswindow.cpp +++ b/qmpsettingswindow.cpp @@ -148,6 +148,9 @@ void qmpSettingsWindow::settingsInit() settings->setValue("Behavior/SaveEfxParam",settings->value("Behavior/SaveEfxParam",1)); ui->cbSaveEfxParam->setChecked(settings->value("Behavior/SaveEfxParam",1).toInt()); + settings->setValue("Behavior/SingleInstance",settings->value("Behavior/SingleInstance",0)); + ui->cbPersistentfs->setChecked(settings->value("Behavior/SingleInstance",0).toInt()); + settings->sync(); delete_fluid_settings(fsettings); } @@ -219,6 +222,7 @@ void qmpSettingsWindow::settingsUpdate() settings->remove("Effects/ChorusType"); } + settings->setValue("Behavior/SingleInstance",ui->cbPersistentfs->isChecked()?1:0); settings->sync(); } diff --git a/qmpsettingswindow.ui b/qmpsettingswindow.ui index 92895bb..4fdb6f1 100644 --- a/qmpsettingswindow.ui +++ b/qmpsettingswindow.ui @@ -498,6 +498,13 @@ + + + + Persistent fluidsynth instance + + + -- cgit v1.2.3