From b886aa1fcafc16fe93bfe19e2f63b4089234f9f6 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Sat, 2 Jan 2016 23:57:36 +0800 Subject: Mystic Flier. (WTF) --- ChangeLog | 5 ++ qmpchannelswindow.cpp | 2 +- qmpinfowindow.cpp | 24 +++++- qmpinfowindow.ui | 25 ++++-- qmpmainwindow.cpp | 44 ++++++++-- qmpmainwindow.hpp | 4 +- qmpmidiplay.cpp | 32 +++++--- qmpmidiplay.hpp | 10 ++- qmpmidiread.cpp | 22 ++++- qmpsettingswindow.cpp | 213 +++++++++++++++++++++++++++++++++++++++++++++++ qmpsettingswindow.hpp | 22 ++++- qmpsettingswindow.ui | 223 ++++++++++++++++++++++++++++++++++++++++++-------- 12 files changed, 553 insertions(+), 73 deletions(-) diff --git a/ChangeLog b/ChangeLog index a2c0e22..f3e5e97 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +2016-01-02 0.5.1 +Now sends SysEx(optional). +Primitive settings implementation(some of the audio tab and the +soundfont tab). + 2016-01-01 0.5.0 Bug fixes. Minor code refactoring. Initial stubs for the settings window. diff --git a/qmpchannelswindow.cpp b/qmpchannelswindow.cpp index 65ed055..b73f71b 100644 --- a/qmpchannelswindow.cpp +++ b/qmpchannelswindow.cpp @@ -22,7 +22,7 @@ qmpChannelsWindow::qmpChannelsWindow(QWidget *parent) : ui->twChannels->setCellWidget(i,2,new QComboBox()); QComboBox *cb=(QComboBox*)ui->twChannels->cellWidget(i,2); //stub - cb->addItem("Internal fluidsynth"); + cb->addItem("Internal FluidSynth"); ui->twChannels->setCellWidget(i,3,new QDCLabel("")); ((QDCLabel*)ui->twChannels->cellWidget(i,3))->setID(i); connect(ui->twChannels->cellWidget(i,3),SIGNAL(onDoubleClick(int)),this,SLOT(showPresetWindow(int))); diff --git a/qmpinfowindow.cpp b/qmpinfowindow.cpp index 4e214b4..aecd58f 100644 --- a/qmpinfowindow.cpp +++ b/qmpinfowindow.cpp @@ -1,9 +1,12 @@ +#include #include "qmpinfowindow.hpp" #include "ui_qmpinfowindow.h" #include "qmpmainwindow.hpp" +#include "qmpsettingswindow.hpp" const char* minors="abebbbf c g d a e b f#c#g#d#a#"; const char* majors="CbGbDbAbEbBbF C G D A E B F#C#"; +const char* standards="? GM GM2GS XG "; qmpInfoWindow::qmpInfoWindow(QWidget *parent) : QDialog(parent), @@ -21,10 +24,25 @@ void qmpInfoWindow::updateInfo() { char str[256]; CMidiPlayer* player=qmpMainWindow::getInstance()->getPlayer(); + const QSettings* settings=qmpSettingsWindow::getSettingsIntf(); ui->lbFileName->setText(QString("File name: ")+qmpMainWindow::getInstance()->getFileName()); - if(player->getTitle())ui->lbTitle->setText(QString("Title: ")+player->getTitle()); + if(player->getTitle()) + { + if(settings->value("Midi/TextEncoding","").toString()!="Unicode") + ui->lbTitle->setText(QString("Title: ")+ + QTextCodec::codecForName(settings->value("Midi/TextEncoding","").toString().toStdString().c_str())->toUnicode(player->getTitle())); + else + ui->lbTitle->setText(QString("Title: ")+player->getTitle()); + } else ui->lbTitle->setText(QString("Title: ")); - if(player->getCopyright())ui->lbCopyright->setText(QString("Copyright: ")+player->getCopyright()); + if(player->getCopyright()) + { + if(settings->value("Midi/TextEncoding","").toString()!="Unicode") + ui->lbCopyright->setText(QString("Copyright: ")+ + QTextCodec::codecForName(settings->value("Midi/TextEncoding","").toString().toStdString().c_str())->toUnicode(player->getCopyright())); + else + ui->lbCopyright->setText(QString("Copyright: ")+player->getCopyright()); + } else ui->lbCopyright->setText(QString("Copyright: ")); ui->lbTempo->setText(QString("Tempo: ")+QString::number(player->getTempo(),'g',5)); int t,r;player->getCurrentKeySignature(&t);r=(int8_t)((t>>8)&0xFF)+7; @@ -34,4 +52,6 @@ void qmpInfoWindow::updateInfo() ui->lbTimeSig->setText(str); sprintf(str,"Note count: %u",player->getFileNoteCount()); ui->lbNoteCount->setText(str); + strncpy(str,standards+player->getFileStandard()*3,3);str[3]='\0'; + ui->lbFileStandard->setText(QString("File standard: ")+str); } diff --git a/qmpinfowindow.ui b/qmpinfowindow.ui index 480c3ec..664531a 100644 --- a/qmpinfowindow.ui +++ b/qmpinfowindow.ui @@ -7,13 +7,13 @@ 0 0 400 - 135 + 142 400 - 135 + 142 @@ -67,11 +67,22 @@ - - - Note count: - - + + + + + Note count: + + + + + + + File standard: + + + + diff --git a/qmpmainwindow.cpp b/qmpmainwindow.cpp index 3756417..525cb1e 100644 --- a/qmpmainwindow.cpp +++ b/qmpmainwindow.cpp @@ -11,14 +11,14 @@ qmpMainWindow::qmpMainWindow(QWidget *parent) : ui(new Ui::qmpMainWindow) { ui->setupUi(this);player=new CMidiPlayer(); - ui->lbFileName->setText(""); + ui->lbFileName->setText("");ref=this; playing=false;stopped=true;dragging=false; + settingsw=new qmpSettingsWindow(this); plistw=new qmpPlistWindow(this); chnlw=new qmpChannelsWindow(this); efxw=new qmpEfxWindow(this); infow=new qmpInfoWindow(this); - settingsw=new qmpSettingsWindow(this); - timer=new QTimer(this);ref=this; + timer=new QTimer(this); fnA1=new QAction("File Information",ui->lbFileName); ui->lbFileName->addAction(fnA1); connect(fnA1,SIGNAL(triggered()),this,SLOT(onfnA1())); @@ -74,7 +74,10 @@ void qmpMainWindow::updateWidgets() char ts[100]; sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60); ui->lbFinTime->setText(ts); - player->playerInit();player->setGain(ui->vsMasterVol->value()/250.); + player->playerInit();playerSetup();player->fluidInitialize(); + for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->setGain(ui->vsMasterVol->value()/250.); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); @@ -97,6 +100,19 @@ void qmpMainWindow::updateWidgets() QString qmpMainWindow::getFileName(){return ui->lbFileName->text();} +void qmpMainWindow::playerSetup() +{ + fluid_settings_t* fsettings=player->getFluidSettings(); + const 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()); +} + void qmpMainWindow::on_pbPlayPause_clicked() { playing=!playing; @@ -109,7 +125,10 @@ 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();player->setGain(ui->vsMasterVol->value()/250.); + player->playerInit();playerSetup();player->fluidInitialize(); + for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->setGain(ui->vsMasterVol->value()/250.); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); @@ -207,7 +226,10 @@ 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();player->setGain(ui->vsMasterVol->value()/250.); + player->playerInit();playerSetup();player->fluidInitialize(); + for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->setGain(ui->vsMasterVol->value()/250.); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); @@ -224,7 +246,10 @@ 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();player->setGain(ui->vsMasterVol->value()/250.); + player->playerInit();playerSetup();player->fluidInitialize(); + for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->setGain(ui->vsMasterVol->value()/250.); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); @@ -244,7 +269,10 @@ void qmpMainWindow::selectionChanged() char ts[100]; sprintf(ts,"%02d:%02d",(int)player->getFtime()/60,(int)player->getFtime()%60); ui->lbFinTime->setText(ts); - player->playerInit();player->setGain(ui->vsMasterVol->value()/250.); + player->playerInit();playerSetup();player->fluidInitialize(); + for(int i=settingsw->getSFWidget()->count()-1;i>=0;--i) + player->pushSoundFont(settingsw->getSFWidget()->item(i)->text().toStdString().c_str()); + player->setGain(ui->vsMasterVol->value()/250.); playerTh=new std::thread(&CMidiPlayer::playerThread,player); st=std::chrono::steady_clock::now();offset=0; timer->start(100); diff --git a/qmpmainwindow.hpp b/qmpmainwindow.hpp index de45d3b..c251fc0 100644 --- a/qmpmainwindow.hpp +++ b/qmpmainwindow.hpp @@ -44,10 +44,9 @@ class qmpMainWindow:public QMainWindow void on_pbEfx_clicked(); void on_lbFileName_customContextMenuRequested(const QPoint &pos); void onfnA1(); - void on_pbSettings_clicked(); - public slots: + public slots: void dialogClosed(); void selectionChanged(); @@ -65,6 +64,7 @@ class qmpMainWindow:public QMainWindow qmpInfoWindow *infow; qmpSettingsWindow *settingsw; QAction *fnA1,*fnA2; + void playerSetup(); public: QString getFileName(); diff --git a/qmpmidiplay.cpp b/qmpmidiplay.cpp index adfdeb6..2b3a2a9 100644 --- a/qmpmidiplay.cpp +++ b/qmpmidiplay.cpp @@ -3,23 +3,21 @@ #include #include #include "qmpmidiplay.hpp" -void CMidiPlayer::fluidInitialize(const char* sf) +void CMidiPlayer::fluidInitialize() { - settings=new_fluid_settings(); - fluid_settings_setstr(settings,"audio.driver","pulseaudio"); - fluid_settings_setint(settings,"synth.cpu-cores",4); - fluid_settings_setint(settings,"synth.polyphony",2048); synth=new_fluid_synth(settings); adriver=new_fluid_audio_driver(settings,synth); - fluid_synth_sfload(synth,sf,1); + 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); } void CMidiPlayer::fluidDeinitialize() { if(!synth||!adriver||!settings)return; + delete_fluid_settings(settings); delete_fluid_audio_driver(adriver); delete_fluid_synth(synth); - delete_fluid_settings(settings); - synth=NULL;settings=NULL;adriver=NULL; + settings=NULL;synth=NULL;adriver=NULL; } void CMidiPlayer::processEvent(const SEvent *e) { @@ -64,6 +62,11 @@ void CMidiPlayer::processEvent(const SEvent *e) break; } } + if((e->type&0x0F)==0x00||(e->type&0x0F)==07) + { + int io=0; + fluid_synth_sysex(synth,e->str,e->p1,NULL,&io,NULL,0); + } break; } } @@ -163,6 +166,10 @@ CMidiPlayer::CMidiPlayer() { midiFile=NULL;resumed=false; settings=NULL;synth=NULL;adriver=NULL; +} +CMidiPlayer::~CMidiPlayer() +{ + } void CMidiPlayer::playerPanic() { @@ -180,10 +187,7 @@ 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; - fluidInitialize("/media/Files/FluidR3_Ext.sf2"); - 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); + settings=new_fluid_settings(); } void CMidiPlayer::playerDeinit() { @@ -211,6 +215,7 @@ double CMidiPlayer::getFtime(){return ftime;} void CMidiPlayer::getCurrentTimeSignature(int *n,int *d){*n=ctsn;*d=ctsd;} void CMidiPlayer::getCurrentKeySignature(int *ks){*ks=cks;} uint32_t CMidiPlayer::getFileNoteCount(){return midiFile->getNoteCount();} +uint32_t CMidiPlayer::getFileStandard(){return midiFile->getStandard();} const char* CMidiPlayer::getTitle(){return midiFile->getTitle();} const char* CMidiPlayer::getCopyright(){return midiFile->getCopyright();} double CMidiPlayer::getTempo(){return 60./(ctempo/1e6)*ctsd/4.;} @@ -277,6 +282,9 @@ void CMidiPlayer::setChorusPara(int e,int fb,double l,double r,double d,int type fluid_synth_set_chorus_on(synth,e); fluid_synth_set_chorus(synth,fb,l,r,d,type); } +fluid_settings_t* CMidiPlayer::getFluidSettings(){return settings;} +void CMidiPlayer::pushSoundFont(const char *sf) +{fluid_synth_sfload(synth,sf,1);} int CMidiPlayer::getSFCount() {return synth?fluid_synth_sfcount(synth):0;} fluid_sfont_t* CMidiPlayer::getSFPtr(int sfid) diff --git a/qmpmidiplay.hpp b/qmpmidiplay.hpp index 88aa097..7937c21 100644 --- a/qmpmidiplay.hpp +++ b/qmpmidiplay.hpp @@ -23,7 +23,7 @@ class CMidiFile private: SEvent *eventList[10000000]; char *title,*copyright; - uint32_t eventc; + uint32_t eventc,std;//standard 0=? 1=GM 2=GM2 3=GS 4=XG uint32_t fmt,trk,divs; FILE *f; int byteread; @@ -44,6 +44,7 @@ class CMidiFile uint32_t getEventCount(); uint32_t getDivision(); uint32_t getNoteCount(); + uint32_t getStandard(); const char* getTitle(); const char* getCopyright(); }; @@ -65,7 +66,6 @@ class CMidiPlayer uint32_t finished,resumed; void setBit(uint16_t &n,uint16_t bn,uint16_t b); - void fluidInitialize(const char* sf); void fluidDeinitialize(); void processEvent(const SEvent *e); void processEventStub(const SEvent *e); @@ -74,8 +74,10 @@ class CMidiPlayer void fileTimer2Pass(); public: CMidiPlayer(); + ~CMidiPlayer(); void playerLoadFile(const char* fn); void playerInit(); + void fluidInitialize(); void playerDeinit(); void playerThread(); void playerPanic(); @@ -93,6 +95,7 @@ class CMidiPlayer void getCurrentTimeSignature(int *n,int *d); void getCurrentKeySignature(int *ks); uint32_t getFileNoteCount(); + uint32_t getFileStandard(); double getTempo(); const char* getTitle(); const char* getCopyright(); @@ -113,7 +116,8 @@ class CMidiPlayer void getChorusPara(int *fb,double *l,double *r,double *d,int *type); void setChorusPara(int e,int fb,double l,double r,double d,int type); - //void pushSoundFont(const char* url); + fluid_settings_t* getFluidSettings(); + void pushSoundFont(const char* sf); int getSFCount(); fluid_sfont_t* getSFPtr(int sfid); }; diff --git a/qmpmidiread.cpp b/qmpmidiread.cpp index 8f7ad28..c9fff34 100644 --- a/qmpmidiread.cpp +++ b/qmpmidiread.cpp @@ -8,6 +8,10 @@ #include #include #include "qmpmidiplay.hpp" +const char* GM1SysX={"\xF0\x7E\x7F\x09\x01\xF7"}; +const char* GM2SysX={"\xF0\x7E\x7F\x09\x03\xF7"}; +const char* GSSysEx={"\xF0\x41\x10\x42\x12\x40\x00\x7F\x00\x41\xF7"}; +const char* XGSysEx={"\xF0\x43\x10\x4C\x00\x00\x7E\x00\xF7"}; bool cmp(SEvent *a,SEvent *b){return a->time-b->time?a->timetime:a->iidiid;} void CMidiFile::error(int fatal,const char* format,...) { @@ -147,8 +151,19 @@ retry: } else if((type&0x0F)==0x00||(type&0x0F)==0x07)//SysEx { - uint32_t len=readVL(); - while(len--){++byteread;fgetc(f);} + uint32_t len=readVL(),c;char* str=NULL; + str=new char[len+8]; + if((type&0x0F)==0x00) + { + str[0]=0xF0;++len; + for(c=1;c #include "qmpsettingswindow.hpp" #include "ui_qmpsettingswindow.h" #include "qmpmainwindow.hpp" +QSettings *qmpSettingsWindow::settings=NULL; + +void qmpFluidForEachOpt(void* data,char* /*name*/,char* option) +{ + QComboBox *pcb=(QComboBox*)data; + pcb->addItem(option); +} + qmpSettingsWindow::qmpSettingsWindow(QWidget *parent) : QDialog(parent), ui(new Ui::qmpSettingsWindow) { ui->setupUi(this); connect(this,SIGNAL(dialogClosing()),parent,SLOT(dialogClosed())); + settings=new QSettings(QString(getenv("HOME"))+QString("/.config/qmprc"),QSettings::IniFormat); + settingsInit(); } qmpSettingsWindow::~qmpSettingsWindow() { + settings->sync(); + delete settings; delete ui; } @@ -22,12 +35,212 @@ void qmpSettingsWindow::closeEvent(QCloseEvent *event) event->accept(); } +QListWidget* qmpSettingsWindow::getSFWidget(){return ui->lwSoundfont;} + void qmpSettingsWindow::on_buttonBox_accepted() { + settingsUpdate(); emit dialogClosing(); } void qmpSettingsWindow::on_buttonBox_rejected() { + settingsInit(); emit dialogClosing(); } + +void qmpSettingsWindow::settingsInit() +{ + fluid_settings_t *fsettings=new_fluid_settings(); + + settings->setValue("Midi/DefaultOutput",settings->value("Midi/DefaultOutput","Internal FluidSynth")); + //this item is still a stub... + + settings->setValue("Midi/DisableMapping",settings->value("Midi/DisableMapping",0)); + ui->cbDisableMapping->setChecked(settings->value("Midi/DisableMapping",0).toInt()); + + settings->setValue("Midi/SendSysEx",settings->value("Midi/SendSysEx",1)); + ui->cbSendSysx->setChecked(settings->value("Midi/SendSysEx",1).toInt()); + + int selected=-1; + for(int i=0;icbEncoding->count();++i) + if(ui->cbEncoding->itemText(i)==settings->value("Midi/TextEncoding","Unicode").toString()) + {selected=i;break;} + if(~selected)ui->cbEncoding->setCurrentIndex(selected); + settings->setValue("Midi/TextEncoding",ui->cbEncoding->currentText()); + + fluid_settings_foreach_option(fsettings,"audio.driver",(void*)ui->cbAudioDrv,qmpFluidForEachOpt); + selected=-1; + for(int i=0;icbAudioDrv->count();++i) + if(ui->cbAudioDrv->itemText(i)==settings->value("Audio/Driver","pulseaudio").toString()) + {selected=i;break;} + if(~selected)ui->cbAudioDrv->setCurrentIndex(selected); + settings->setValue("Audio/Driver",ui->cbAudioDrv->currentText()); + + selected=-1; + for(int i=0;icbBufSize->count();++i) + if(ui->cbBufSize->itemText(i).toInt()==settings->value("Audio/BufSize",128).toInt()) + {selected=i;break;} + if(~selected)ui->cbBufSize->setCurrentIndex(selected); + else if(settings->value("Audio/BufSize",128).toInt()>=64&&settings->value("Audio/BufSize",128).toInt()<=8192) + ui->cbBufSize->setCurrentText(settings->value("Audio/BufSize",128).toString()); + else ui->cbBufSize->setCurrentText("128"); + settings->setValue("Audio/BufSize",ui->cbBufSize->currentText().toInt()); + + selected=-1; + for(int i=0;icbBufCnt->count();++i) + if(ui->cbBufCnt->itemText(i).toInt()==settings->value("Audio/BufCnt",2).toInt()) + {selected=i;break;} + if(~selected)ui->cbBufCnt->setCurrentIndex(selected); + else if(settings->value("Audio/BufCnt",2).toInt()>=2&&settings->value("Audio/BufCnt",2).toInt()<=64) + ui->cbBufCnt->setCurrentText(settings->value("Audio/BufCnt",2).toString()); + else ui->cbBufCnt->setCurrentText("2"); + settings->setValue("Audio/BufCnt",ui->cbBufCnt->currentText().toInt()); + + selected=-1; + for(int i=0;icbFormat->count();++i) + if(ui->cbFormat->itemText(i)==settings->value("Audio/Format","16bits").toString()) + {selected=i;break;} + if(~selected)ui->cbFormat->setCurrentIndex(selected); + settings->setValue("Audio/Format",ui->cbFormat->currentText()); + + selected=-1; + for(int i=0;icbFrequency->count();++i) + if(ui->cbFormat->itemText(i).toInt()==settings->value("Audio/Frequency",48000).toInt()) + {selected=i;break;} + if(~selected)ui->cbFrequency->setCurrentIndex(selected); + settings->setValue("Audio/Frequency",ui->cbFrequency->currentText()); + + ui->sbPolyphony->setValue(settings->value("Audio/Polyphony",2048).toInt()); + if(ui->sbPolyphony->value()<1||ui->sbPolyphony->value()>65535)ui->sbPolyphony->setValue(2048); + settings->setValue("Audio/Polyphony",ui->sbPolyphony->value()); + + ui->sbCPUCores->setValue(settings->value("Audio/Threads",1).toInt()); + if(ui->sbCPUCores->value()<1||ui->sbCPUCores->value()>256)ui->sbCPUCores->setValue(1); + settings->setValue("Audio/Threads",ui->sbCPUCores->value()); + + settings->setValue("Audio/AutoBS",settings->value("Audio/AutoBS",1)); + ui->cbAutoBS->setChecked(settings->value("Audio/AutoBS",1).toInt()); + ui->lbBSMode->setText(ui->cbAutoBS->isChecked()?"Fallback bank select mode":"Bank select mode"); + + selected=-1; + for(int i=0;icbBSMode->count();++i) + if(ui->cbBSMode->itemText(i)==settings->value("Audio/BankSelect","GS").toString()) + {selected=i;break;} + if(~selected)ui->cbBSMode->setCurrentIndex(selected); + settings->setValue("Audio/BankSelect",ui->cbBSMode->currentText()); + + int sfc=settings->value("SoundFonts/SFCount",0).toInt(); + ui->lwSoundfont->clear();for(int i=1;i<=sfc;++i) + ui->lwSoundfont->addItem(settings->value("SoundFonts/SF"+QString::number(i),"").toString()); + settings->setValue("SoundFonts/SFCount",sfc); + + settings->setValue("Behavior/RestorePlaylist",settings->value("Behavior/RestorePlaylist",0)); + ui->cbRestorePlaylist->setChecked(settings->value("Behavior/RestorePlaylist",0).toInt()); + + settings->setValue("Behavior/LoadFolder",settings->value("Behavior/LoadFolder",0)); + ui->cbLoadFolder->setChecked(settings->value("Behavior/LoadFolder",0).toInt()); + + settings->setValue("Behavior/DialogStatus",settings->value("Behavior/DialogStatus",1)); + ui->cbDialogStatus->setChecked(settings->value("Behavior/DialogStatus",1).toInt()); + + settings->setValue("Behavior/SaveEfxParam",settings->value("Behavior/SaveEfxParam",1)); + ui->cbSaveEfxParam->setChecked(settings->value("Behavior/SaveEfxParam",1).toInt()); + + settings->sync(); + delete_fluid_settings(fsettings); +} + +void qmpSettingsWindow::settingsUpdate() +{ + settings->setValue("Midi/DefaultOutput",settings->value("Midi/DefaultOutput","Internal FluidSynth")); + //this item is still a stub... + + settings->setValue("Midi/DisableMapping",ui->cbDisableMapping->isChecked()?1:0); + + settings->setValue("Midi/SendSysEx",ui->cbSendSysx->isChecked()?1:0); + + settings->setValue("Midi/TextEncoding",ui->cbEncoding->currentText()); + + settings->setValue("Audio/Driver",ui->cbAudioDrv->currentText()); + + settings->setValue("Audio/BufSize",ui->cbBufSize->currentText().toInt()); + + settings->setValue("Audio/BufCnt",ui->cbBufCnt->currentText().toInt()); + + settings->setValue("Audio/Format",ui->cbFormat->currentText()); + + settings->setValue("Audio/Frequency",ui->cbFrequency->currentText()); + + settings->setValue("Audio/Polyphony",ui->sbPolyphony->value()); + + settings->setValue("Audio/Threads",ui->sbCPUCores->value()); + + settings->setValue("Audio/AutoBS",ui->cbAutoBS->isChecked()?1:0); + + settings->setValue("Audio/BankSelect",ui->cbBSMode->currentText()); + + settings->setValue("SoundFonts/SFCount",ui->lwSoundfont->count()); + for(int i=0;ilwSoundfont->count();++i) + settings->setValue("SoundFonts/SF"+QString::number(i+1),ui->lwSoundfont->item(i)->text()); + + settings->setValue("Behavior/RestorePlaylist",ui->cbRestorePlaylist->isChecked()?1:0); + + settings->setValue("Behavior/LoadFolder",ui->cbLoadFolder->isChecked()?1:0); + + settings->setValue("Behavior/DialogStatus",ui->cbDialogStatus->isChecked()?1:0); + + settings->setValue("Behavior/SaveEfxParam",ui->cbSaveEfxParam->isChecked()?1:0); + + settings->sync(); +} + +void qmpSettingsWindow::on_cbBufSize_currentTextChanged(const QString &s) +{ + if(s.toInt()<64||s.toInt()>8192)ui->cbBufSize->setCurrentIndex(1); +} + +void qmpSettingsWindow::on_cbBufCnt_currentTextChanged(const QString &s) +{ + if(s.toInt()<2||s.toInt()>64)ui->cbBufCnt->setCurrentIndex(1); +} + +void qmpSettingsWindow::on_pbAdd_clicked() +{ + QStringList sl=QFileDialog::getOpenFileNames(this,"Add File","","SoundFont files (*.sf2)"); + for(int i=0;ilwSoundfont->addItem(new QListWidgetItem(sl.at(i))); + } +} + +void qmpSettingsWindow::on_pbRemove_clicked() +{ + QList sl=ui->lwSoundfont->selectedItems(); + for(int i=0;ilwSoundfont->removeItemWidget(sl.at(i)); + delete sl.at(i); + } +} + +void qmpSettingsWindow::on_pbUp_clicked() +{ + int cid=ui->lwSoundfont->currentRow(); + QListWidgetItem *ci=ui->lwSoundfont->takeItem(cid); + ui->lwSoundfont->insertItem(cid-1,ci); + ui->lwSoundfont->setCurrentRow(cid-1); +} + +void qmpSettingsWindow::on_pbDown_clicked() +{ + int cid=ui->lwSoundfont->currentRow(); + QListWidgetItem *ci=ui->lwSoundfont->takeItem(cid); + ui->lwSoundfont->insertItem(cid+1,ci); + ui->lwSoundfont->setCurrentRow(cid+1); +} + +void qmpSettingsWindow::on_cbAutoBS_stateChanged() +{ + ui->lbBSMode->setText(ui->cbAutoBS->isChecked()?"Fallback bank select mode":"Bank select mode"); +} diff --git a/qmpsettingswindow.hpp b/qmpsettingswindow.hpp index 0b5f886..ef9dbab 100644 --- a/qmpsettingswindow.hpp +++ b/qmpsettingswindow.hpp @@ -3,6 +3,8 @@ #include #include +#include +#include namespace Ui { class qmpSettingsWindow; @@ -16,16 +18,30 @@ class qmpSettingsWindow:public QDialog explicit qmpSettingsWindow(QWidget *parent=0); ~qmpSettingsWindow(); void closeEvent(QCloseEvent *event); + void settingsInit(); + QListWidget* getSFWidget(); signals: void dialogClosing(); - private slots: + private slots: void on_buttonBox_accepted(); - void on_buttonBox_rejected(); - private: + void on_cbBufSize_currentTextChanged(const QString &s); + void on_cbBufCnt_currentTextChanged(const QString &s); + + void on_pbAdd_clicked(); + void on_pbRemove_clicked(); + void on_pbUp_clicked(); + void on_pbDown_clicked(); + + void on_cbAutoBS_stateChanged(); + + private: Ui::qmpSettingsWindow *ui; + void settingsUpdate(); + static QSettings *settings; + public: static const QSettings* getSettingsIntf(){return settings;} }; #endif // QMPSETTINGSWINDOW_H diff --git a/qmpsettingswindow.ui b/qmpsettingswindow.ui index 36f4616..c415782 100644 --- a/qmpsettingswindow.ui +++ b/qmpsettingswindow.ui @@ -6,14 +6,14 @@ 0 0 - 439 - 407 + 494 + 445 - 439 - 407 + 494 + 445 @@ -45,7 +45,13 @@ - + + + + Internal FluidSynth + + + @@ -146,6 +152,49 @@ true + + 1 + + + + 64 + + + + + 128 + + + + + 256 + + + + + 512 + + + + + 1024 + + + + + 2048 + + + + + 4096 + + + + + 8192 + + @@ -160,6 +209,36 @@ true + + + 2 + + + + + 4 + + + + + 8 + + + + + 16 + + + + + 32 + + + + + 64 + + @@ -170,7 +249,48 @@ - + + + + 16bits + + + + + float + + + + + + + + + + + 2 + + + + 22050 + + + + + 44100 + + + + + 48000 + + + + + 96000 + + + @@ -179,12 +299,6 @@ - - - - - - @@ -205,22 +319,63 @@ - + Auto bank select mode - + Bank select mode - - + + + + 1 + + + + Ignored + + + + + CC#0 + + + + + CC#32 + + + + + CC#0*128+CC#32 + + + + + + + + CPU Cores + + + + + + + 1 + + + 256 + + @@ -230,7 +385,11 @@ - + + + QAbstractItemView::DragDrop + + @@ -312,28 +471,28 @@ - + Restore last playlist on startup - + Load files in the same folder - + Save dialog status - + Save parameters in effects window @@ -342,21 +501,21 @@ - + Visualization Mode - + - + View distance @@ -379,7 +538,7 @@ - + 60 @@ -392,14 +551,14 @@ - + - + Note stretch @@ -422,7 +581,7 @@ - + 60 @@ -435,14 +594,14 @@ - + - + Fog Start @@ -465,7 +624,7 @@ - + 60 @@ -478,7 +637,7 @@ - + -- cgit v1.2.3