From 4d9b1e98f4f3cd7387491ba1cc883230302a9022 Mon Sep 17 00:00:00 2001 From: Chris Xiong Date: Fri, 25 Jan 2019 22:44:17 +0800 Subject: Fixed a crash caused by improper preset probing. Further ensure CC#8 is initialized correctly. Minor string table update. --- core/qmpmidioutfluid.cpp | 11 +++++++++-- qmidiplayer-desktop/qmpchannelswindow.cpp | 2 +- qmidiplayer-desktop/qmpmainwindow.cpp | 2 +- qmidiplayer-desktop/qmpplugin.cpp | 6 +++--- qmidiplayer-desktop/qmppresetselect.cpp | 2 +- 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 @@ - Audio Frequency + Sample Rate @@ -347,7 +347,7 @@ - Audio Format + Sample Format -- cgit v1.2.3