diff options
author | Chris Xiong <chirs241097@gmail.com> | 2019-01-25 22:44:17 +0800 |
---|---|---|
committer | Chris Xiong <chirs241097@gmail.com> | 2019-01-25 22:44:17 +0800 |
commit | 4d9b1e98f4f3cd7387491ba1cc883230302a9022 (patch) | |
tree | 7147e208bdab4356e317cb46ea4958de23f6800f | |
parent | 003c637ef40e1826b7c829afbfba82ea028e21a5 (diff) | |
download | QMidiPlayer-4d9b1e98f4f3cd7387491ba1cc883230302a9022.tar.xz |
Fixed a crash caused by improper preset probing.
Further ensure CC#8 is initialized correctly.
Minor string table update.
-rw-r--r-- | core/qmpmidioutfluid.cpp | 11 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpchannelswindow.cpp | 2 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpmainwindow.cpp | 2 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpplugin.cpp | 6 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmppresetselect.cpp | 2 | ||||
-rw-r--r-- | qmidiplayer-desktop/qmpsettingswindow.ui | 4 |
6 files changed, 17 insertions, 10 deletions
diff --git a/core/qmpmidioutfluid.cpp b/core/qmpmidioutfluid.cpp index 8c8cd30..8055421 100644 --- a/core/qmpmidioutfluid.cpp +++ b/core/qmpmidioutfluid.cpp @@ -110,6 +110,7 @@ void qmpMidiOutFluid::reset(uint8_t ch) this->panic(ch); fluid_synth_cc(synth,ch,0,0); fluid_synth_cc(synth,ch,7,100); + fluid_synth_cc(synth,ch,8,64); fluid_synth_cc(synth,ch,10,64); fluid_synth_cc(synth,ch,11,127); fluid_synth_cc(synth,ch,32,0); @@ -172,13 +173,19 @@ void qmpMidiOutFluid::setGain(double gain) { if(settings)fluid_settings_setnum(settings,"synth.gain",gain); } -void qmpMidiOutFluid::getChannelInfo(int ch,int *b, int *p, char *s) +void qmpMidiOutFluid::getChannelInfo(int ch,int *b,int *p,char *s) { if(!synth)return; fluid_preset_t* chpreset=fluid_synth_get_channel_preset(synth,ch); + if(!chpreset) + { + *b=*p=-1; + strcpy(s,"---"); + return; + } *b=fluid_preset_get_banknum(chpreset); *p=fluid_preset_get_num(chpreset); - strcpy(s,fluid_preset_get_name(chpreset)); + strncpy(s,fluid_preset_get_name(chpreset),256); } void qmpMidiOutFluid::getReverbPara(double *r,double *d,double *w,double *l) { diff --git a/qmidiplayer-desktop/qmpchannelswindow.cpp b/qmidiplayer-desktop/qmpchannelswindow.cpp index c154383..87eae10 100644 --- a/qmidiplayer-desktop/qmpchannelswindow.cpp +++ b/qmidiplayer-desktop/qmpchannelswindow.cpp @@ -148,7 +148,7 @@ void qmpChannelsWindow::channelWindowsUpdate() } for(int i=0;i<16;++i) { - char data[128],nm[25]; + char data[128],nm[256]; int b,p; qmpMainWindow::getInstance()->getPlayer()->getChannelPreset(i,&b,&p,nm); sprintf(data,"%03d:%03d %s",b,p,nm); diff --git a/qmidiplayer-desktop/qmpmainwindow.cpp b/qmidiplayer-desktop/qmpmainwindow.cpp index c83152c..adbd6d5 100644 --- a/qmidiplayer-desktop/qmpmainwindow.cpp +++ b/qmidiplayer-desktop/qmpmainwindow.cpp @@ -309,7 +309,7 @@ void qmpMainWindow::playerSetup(IFluidSettings* fs) 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->setOptNum("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]; diff --git a/qmidiplayer-desktop/qmpplugin.cpp b/qmidiplayer-desktop/qmpplugin.cpp index 7ef31f3..13d5730 100644 --- a/qmidiplayer-desktop/qmpplugin.cpp +++ b/qmidiplayer-desktop/qmpplugin.cpp @@ -153,7 +153,7 @@ int qmpPluginAPI::getChannelCC(int ch,int cc) {return qmw&&qmw->getPlayer()?qmw->getPlayer()->getCC(ch,cc):0;} int qmpPluginAPI::getChannelPreset(int ch) { - int b,p;char nm[25]; + int b,p;char nm[256]; if(qmw&&qmw->getPlayer()) { qmw->getPlayer()->getChannelPreset(ch,&b,&p,nm); @@ -173,11 +173,11 @@ std::wstring qmpPluginAPI::getWTitle() {return qmw?qmw->getWTitle():L"";} std::string qmpPluginAPI::getChannelPresetString(int ch) { - int b,p;char nm[25],ret[33];ret[0]=0; + int b,p;char nm[256],ret[320];ret[0]=0; if(qmw&&qmw->getPlayer()) { qmw->getPlayer()->getChannelPreset(ch,&b,&p,nm); - sprintf(ret,"%03d:%03d %s",b,p,nm); + snprintf(ret,320,"%03d:%03d %s",b,p,nm); } return std::string(ret); } diff --git a/qmidiplayer-desktop/qmppresetselect.cpp b/qmidiplayer-desktop/qmppresetselect.cpp index 57dbe7f..87071f4 100644 --- a/qmidiplayer-desktop/qmppresetselect.cpp +++ b/qmidiplayer-desktop/qmppresetselect.cpp @@ -40,7 +40,7 @@ void qmpPresetSelector::setupWindow(int chid) { CMidiPlayer *plyr=qmpMainWindow::getInstance()->getPlayer(); if(!plyr->fluid()->getSFCount())return; - ch=chid;int b=0,p=0,r;char name[64]; + ch=chid;int b=0,p=0,r;char name[256]; sprintf(name,"Preset Selection - Channel #%d",ch+1); setWindowTitle(name); plyr->getChannelPreset(chid,&b,&p,name); diff --git a/qmidiplayer-desktop/qmpsettingswindow.ui b/qmidiplayer-desktop/qmpsettingswindow.ui index bbeddd4..dc9a8b0 100644 --- a/qmidiplayer-desktop/qmpsettingswindow.ui +++ b/qmidiplayer-desktop/qmpsettingswindow.ui @@ -252,7 +252,7 @@ <item row="4" column="0"> <widget class="QLabel" name="lbFrequency"> <property name="text"> - <string>Audio Frequency</string> + <string>Sample Rate</string> </property> </widget> </item> @@ -347,7 +347,7 @@ <item row="3" column="0"> <widget class="QLabel" name="lbFormat"> <property name="text"> - <string>Audio Format</string> + <string>Sample Format</string> </property> </widget> </item> |