summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Chris Xiong <chirs241097@gmail.com> 2016-01-02 23:57:36 +0800
committerGravatar Chris Xiong <chirs241097@gmail.com> 2016-01-02 23:57:36 +0800
commitb886aa1fcafc16fe93bfe19e2f63b4089234f9f6 (patch)
tree929ed0c3fc60b4e9fce421718c21062059c2cbd9
parentd418712c981d9854fa6429d65773368ca63b8dac (diff)
downloadQMidiPlayer-b886aa1fcafc16fe93bfe19e2f63b4089234f9f6.tar.xz
Mystic Flier. (WTF)
-rw-r--r--ChangeLog5
-rw-r--r--qmpchannelswindow.cpp2
-rw-r--r--qmpinfowindow.cpp24
-rw-r--r--qmpinfowindow.ui25
-rw-r--r--qmpmainwindow.cpp44
-rw-r--r--qmpmainwindow.hpp4
-rw-r--r--qmpmidiplay.cpp32
-rw-r--r--qmpmidiplay.hpp10
-rw-r--r--qmpmidiread.cpp22
-rw-r--r--qmpsettingswindow.cpp213
-rw-r--r--qmpsettingswindow.hpp22
-rw-r--r--qmpsettingswindow.ui223
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 <QTextCodec>
#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 @@
<x>0</x>
<y>0</y>
<width>400</width>
- <height>135</height>
+ <height>142</height>
</rect>
</property>
<property name="minimumSize">
<size>
<width>400</width>
- <height>135</height>
+ <height>142</height>
</size>
</property>
<property name="windowTitle">
@@ -67,11 +67,22 @@
</widget>
</item>
<item>
- <widget class="QLabel" name="lbNoteCount">
- <property name="text">
- <string>Note count: </string>
- </property>
- </widget>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
+ <item>
+ <widget class="QLabel" name="lbNoteCount">
+ <property name="text">
+ <string>Note count: </string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLabel" name="lbFileStandard">
+ <property name="text">
+ <string>File standard: </string>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
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 <thread>
#include <fluidsynth.h>
#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;
}
}
@@ -164,6 +167,10 @@ CMidiPlayer::CMidiPlayer()
midiFile=NULL;resumed=false;
settings=NULL;synth=NULL;adriver=NULL;
}
+CMidiPlayer::~CMidiPlayer()
+{
+
+}
void CMidiPlayer::playerPanic()
{
for(int i=0;i<16;++i)fluid_synth_all_notes_off(synth,i);
@@ -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 <cstdarg>
#include <algorithm>
#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->time<b->time:a->iid<b->iid;}
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<len;++c){++byteread;str[c]=fgetc(f);}
+ }
+ else for(c=0;c<len;++c){++byteread;str[c]=fgetc(f);}
+ eventList[eventc++]=new SEvent(curid,curt,type,len,0,str);
+ if(!strcmp(str,GM1SysX))std=1;
+ if(!strcmp(str,GM2SysX))std=2;
+ if(!strcmp(str,GSSysEx))std=3;
+ if(!strcmp(str,XGSysEx))std=4;
}
else error(0,"W: Unknown event type %#x",type);
break;
@@ -200,7 +215,7 @@ CMidiFile::CMidiFile(const char* fn)
{
if(title)delete[] title;
if(copyright)delete[] copyright;
- title=copyright=NULL;notes=0;
+ title=copyright=NULL;notes=0;std=0;
if(!(f=fopen(fn,"rb")))exit((printf("E: file %s doesn't exist!\n",fn),2));
chunkReader(1);
for(uint32_t i=0;i<trk;i+=chunkReader(0));
@@ -217,5 +232,6 @@ const SEvent* CMidiFile::getEvent(uint32_t id){return id<eventc?eventList[id]:NU
uint32_t CMidiFile::getEventCount(){return eventc;}
uint32_t CMidiFile::getDivision(){return divs;}
uint32_t CMidiFile::getNoteCount(){return notes;}
+uint32_t CMidiFile::getStandard(){return std;}
const char* CMidiFile::getTitle(){return title;}
const char* CMidiFile::getCopyright(){return copyright;}
diff --git a/qmpsettingswindow.cpp b/qmpsettingswindow.cpp
index d27547d..1bb7da9 100644
--- a/qmpsettingswindow.cpp
+++ b/qmpsettingswindow.cpp
@@ -1,17 +1,30 @@
+#include <QFileDialog>
#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;i<ui->cbEncoding->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;i<ui->cbAudioDrv->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;i<ui->cbBufSize->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;i<ui->cbBufCnt->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;i<ui->cbFormat->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;i<ui->cbFrequency->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;i<ui->cbBSMode->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;i<ui->lwSoundfont->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;i<sl.size();++i)
+ {
+ ui->lwSoundfont->addItem(new QListWidgetItem(sl.at(i)));
+ }
+}
+
+void qmpSettingsWindow::on_pbRemove_clicked()
+{
+ QList<QListWidgetItem*> sl=ui->lwSoundfont->selectedItems();
+ for(int i=0;i<sl.size();++i)
+ {
+ ui->lwSoundfont->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 <QDialog>
#include <QCloseEvent>
+#include <QSettings>
+#include <QListWidget>
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 @@
<rect>
<x>0</x>
<y>0</y>
- <width>439</width>
- <height>407</height>
+ <width>494</width>
+ <height>445</height>
</rect>
</property>
<property name="minimumSize">
<size>
- <width>439</width>
- <height>407</height>
+ <width>494</width>
+ <height>445</height>
</size>
</property>
<property name="windowTitle">
@@ -45,7 +45,13 @@
</widget>
</item>
<item row="0" column="1">
- <widget class="QComboBox" name="cbOutputDevice"/>
+ <widget class="QComboBox" name="cbOutputDevice">
+ <item>
+ <property name="text">
+ <string>Internal FluidSynth</string>
+ </property>
+ </item>
+ </widget>
</item>
<item row="2" column="0">
<widget class="QCheckBox" name="cbSendSysx">
@@ -146,6 +152,49 @@
<property name="editable">
<bool>true</bool>
</property>
+ <property name="currentIndex">
+ <number>1</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>64</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>128</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>256</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>512</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>1024</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>2048</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>4096</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>8192</string>
+ </property>
+ </item>
</widget>
</item>
<item row="4" column="0">
@@ -160,6 +209,36 @@
<property name="editable">
<bool>true</bool>
</property>
+ <item>
+ <property name="text">
+ <string>2</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>4</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>8</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>16</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>32</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>64</string>
+ </property>
+ </item>
</widget>
</item>
<item row="0" column="0">
@@ -170,7 +249,48 @@
</widget>
</item>
<item row="3" column="1">
- <widget class="QComboBox" name="cbFormat"/>
+ <widget class="QComboBox" name="cbFormat">
+ <item>
+ <property name="text">
+ <string>16bits</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>float</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QComboBox" name="cbAudioDrv"/>
+ </item>
+ <item row="4" column="1">
+ <widget class="QComboBox" name="cbFrequency">
+ <property name="currentIndex">
+ <number>2</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>22050</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>44100</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>48000</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>96000</string>
+ </property>
+ </item>
+ </widget>
</item>
<item row="3" column="0">
<widget class="QLabel" name="lbFormat">
@@ -179,12 +299,6 @@
</property>
</widget>
</item>
- <item row="0" column="1">
- <widget class="QComboBox" name="cbAudioDrv"/>
- </item>
- <item row="4" column="1">
- <widget class="QComboBox" name="cbFrequency"/>
- </item>
<item row="5" column="1">
<widget class="QSpinBox" name="sbPolyphony">
<property name="minimum">
@@ -205,22 +319,63 @@
</property>
</widget>
</item>
- <item row="6" column="0">
+ <item row="7" column="0">
<widget class="QCheckBox" name="cbAutoBS">
<property name="text">
<string>Auto bank select mode</string>
</property>
</widget>
</item>
- <item row="7" column="0">
+ <item row="8" column="0">
<widget class="QLabel" name="lbBSMode">
<property name="text">
<string>Bank select mode</string>
</property>
</widget>
</item>
- <item row="7" column="1">
- <widget class="QComboBox" name="cbBSMode"/>
+ <item row="8" column="1">
+ <widget class="QComboBox" name="cbBSMode">
+ <property name="currentIndex">
+ <number>1</number>
+ </property>
+ <item>
+ <property name="text">
+ <string>Ignored</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>CC#0</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>CC#32</string>
+ </property>
+ </item>
+ <item>
+ <property name="text">
+ <string>CC#0*128+CC#32</string>
+ </property>
+ </item>
+ </widget>
+ </item>
+ <item row="6" column="0">
+ <widget class="QLabel" name="lbCPUCores">
+ <property name="text">
+ <string>CPU Cores</string>
+ </property>
+ </widget>
+ </item>
+ <item row="6" column="1">
+ <widget class="QSpinBox" name="sbCPUCores">
+ <property name="minimum">
+ <number>1</number>
+ </property>
+ <property name="maximum">
+ <number>256</number>
+ </property>
+ </widget>
</item>
</layout>
</widget>
@@ -230,7 +385,11 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_2">
<item>
- <widget class="QListWidget" name="lwSoundfont"/>
+ <widget class="QListWidget" name="lwSoundfont">
+ <property name="dragDropMode">
+ <enum>QAbstractItemView::DragDrop</enum>
+ </property>
+ </widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
@@ -312,28 +471,28 @@
</attribute>
<layout class="QVBoxLayout" name="verticalLayout_3">
<item>
- <widget class="QCheckBox" name="checkBox">
+ <widget class="QCheckBox" name="cbRestorePlaylist">
<property name="text">
<string>Restore last playlist on startup</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="checkBox_2">
+ <widget class="QCheckBox" name="cbLoadFolder">
<property name="text">
<string>Load files in the same folder</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="checkBox_3">
+ <widget class="QCheckBox" name="cbDialogStatus">
<property name="text">
<string>Save dialog status</string>
</property>
</widget>
</item>
<item>
- <widget class="QCheckBox" name="checkBox_4">
+ <widget class="QCheckBox" name="cbSaveEfxParam">
<property name="text">
<string>Save parameters in effects window</string>
</property>
@@ -342,21 +501,21 @@
<item>
<layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <widget class="QLabel" name="label">
+ <widget class="QLabel" name="lbVisualMode">
<property name="text">
<string>Visualization Mode</string>
</property>
</widget>
</item>
<item>
- <widget class="QComboBox" name="comboBox"/>
+ <widget class="QComboBox" name="cbVisualMode"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_3">
<item>
- <widget class="QLabel" name="label_2">
+ <widget class="QLabel" name="lbViewDist">
<property name="text">
<string>View distance</string>
</property>
@@ -379,7 +538,7 @@
</spacer>
</item>
<item>
- <widget class="QSlider" name="horizontalSlider">
+ <widget class="QSlider" name="hsViewDist">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>60</horstretch>
@@ -392,14 +551,14 @@
</widget>
</item>
<item>
- <widget class="QSpinBox" name="spinBox"/>
+ <widget class="QSpinBox" name="sbViewDist"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_4">
<item>
- <widget class="QLabel" name="label_3">
+ <widget class="QLabel" name="lbNoteStretch">
<property name="text">
<string>Note stretch</string>
</property>
@@ -422,7 +581,7 @@
</spacer>
</item>
<item>
- <widget class="QSlider" name="horizontalSlider_2">
+ <widget class="QSlider" name="hsNoteStretch">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>60</horstretch>
@@ -435,14 +594,14 @@
</widget>
</item>
<item>
- <widget class="QSpinBox" name="spinBox_2"/>
+ <widget class="QSpinBox" name="sbNoteStretch"/>
</item>
</layout>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout_5">
<item>
- <widget class="QLabel" name="label_4">
+ <widget class="QLabel" name="lbFog">
<property name="text">
<string>Fog Start</string>
</property>
@@ -465,7 +624,7 @@
</spacer>
</item>
<item>
- <widget class="QSlider" name="horizontalSlider_3">
+ <widget class="QSlider" name="hsFog">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Fixed">
<horstretch>60</horstretch>
@@ -478,7 +637,7 @@
</widget>
</item>
<item>
- <widget class="QSpinBox" name="spinBox_3"/>
+ <widget class="QSpinBox" name="sbFog"/>
</item>
</layout>
</item>