zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit af16734346cfbc2f69eb6d294a5507cbffaf2624
parent fea3c57d6629959b5f9bdeb0dc39622479a5e4c5
Author: paulnasca <paulnasca>
Date:   Thu, 19 Aug 2004 19:07:50 +0000

*** empty log message ***

Diffstat:
Msrc/Misc/Config.C | 60+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-
Msrc/Misc/Config.h | 2++
Msrc/UI/ConfigUI.fl | 76+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++-----
3 files changed, 132 insertions(+), 6 deletions(-)

diff --git a/src/Misc/Config.C b/src/Misc/Config.C @@ -83,12 +83,14 @@ Config::Config(){ cfg.currentBankDir=new char[MAX_STRING_SIZE]; sprintf(cfg.currentBankDir,"./testbnk"); + for (int i=0;i<MAX_BANK_ROOT_DIRS;i++) cfg.presetsDirList[i]=NULL; char filename[MAX_STRING_SIZE]; getConfigFileName(filename,MAX_STRING_SIZE); readConfig(filename); if (cfg.bankRootDirList[0]==NULL){ #if defined(OS_LINUX) + //banks cfg.bankRootDirList[0]=new char[MAX_STRING_SIZE]; sprintf(cfg.bankRootDirList[0],"~/banks"); @@ -106,7 +108,9 @@ Config::Config(){ cfg.bankRootDirList[5]=new char[MAX_STRING_SIZE]; sprintf(cfg.bankRootDirList[5],"banks"); + #else + //banks cfg.bankRootDirList[0]=new char[MAX_STRING_SIZE]; sprintf(cfg.bankRootDirList[0],"./"); @@ -115,8 +119,42 @@ Config::Config(){ cfg.bankRootDirList[2]=new char[MAX_STRING_SIZE]; sprintf(cfg.bankRootDirList[2],"banks"); + +#endif + }; + + if (cfg.presetsDirList[0]==NULL){ +#if defined(OS_LINUX) + //presets + cfg.presetsDirList[0]=new char[MAX_STRING_SIZE]; + sprintf(cfg.presetsDirList[0],"./"); + + cfg.presetsDirList[1]=new char[MAX_STRING_SIZE]; + sprintf(cfg.presetsDirList[1],"../presets"); + + cfg.presetsDirList[2]=new char[MAX_STRING_SIZE]; + sprintf(cfg.presetsDirList[2],"presets"); + + cfg.presetsDirList[3]=new char[MAX_STRING_SIZE]; + sprintf(cfg.presetsDirList[3],"/usr/share/zynaddsubfx/presets"); + + cfg.presetsDirList[4]=new char[MAX_STRING_SIZE]; + sprintf(cfg.presetsDirList[4],"/usr/local/share/zynaddsubfx/presets"); + +#else + //presets + cfg.presetsDirList[0]=new char[MAX_STRING_SIZE]; + sprintf(cfg.presetsDirList[0],"./"); + + cfg.presetsDirList[1]=new char[MAX_STRING_SIZE]; + sprintf(cfg.presetsDirList[1],"../presets"); + + cfg.presetsDirList[2]=new char[MAX_STRING_SIZE]; + sprintf(cfg.presetsDirList[2],"presets"); #endif }; + + }; Config::~Config(){ @@ -139,6 +177,12 @@ void Config::clearbankrootdirlist(){ }; }; +void Config::clearpresetsdirlist(){ + for (int i=0;i<MAX_BANK_ROOT_DIRS;i++) { + if (cfg.presetsDirList[i]==NULL) delete(cfg.presetsDirList[i]); + cfg.presetsDirList[i]=NULL; + }; +}; void Config::readConfig(char *filename){ XMLwrapper *xmlcfg=new XMLwrapper(); @@ -166,7 +210,15 @@ void Config::readConfig(char *filename){ xmlcfg->getparstr("bank_root",cfg.bankRootDirList[i],MAX_STRING_SIZE); xmlcfg->exitbranch(); }; - //xmlcfg->getparstr("bank_root_list",cfg.bankRootDirList,MAX_STRING_SIZE); + }; + + //get preset root dirs + for (int i=0;i<MAX_BANK_ROOT_DIRS;i++){ + if (xmlcfg->enterbranch("PRESETSROOT",i)){ + cfg.presetsDirList[i]=new char[MAX_STRING_SIZE]; + xmlcfg->getparstr("presets_root",cfg.presetsDirList[i],MAX_STRING_SIZE); + xmlcfg->exitbranch(); + }; }; //linux stuff @@ -212,6 +264,12 @@ void Config::saveConfig(char *filename){ xmlcfg->endbranch(); }; + for (int i=0;i<MAX_BANK_ROOT_DIRS;i++) if (cfg.presetsDirList[i]!=NULL) { + xmlcfg->beginbranch("PRESETSROOT",i); + xmlcfg->addparstr("presets_root",cfg.presetsDirList[i]); + xmlcfg->endbranch(); + }; + xmlcfg->addpar("interpolation",cfg.Interpolation); //linux stuff diff --git a/src/Misc/Config.h b/src/Misc/Config.h @@ -40,6 +40,7 @@ class Config{ int Interpolation; char *DumpFile; char *bankRootDirList[MAX_BANK_ROOT_DIRS],*currentBankDir; + char *presetsDirList[MAX_BANK_ROOT_DIRS]; } cfg; int winwavemax,winmidimax;//number of wave/midi devices on Windows int maxstringsize; @@ -50,6 +51,7 @@ class Config{ winmidionedevice *winmididevices; void clearbankrootdirlist(); + void clearpresetsdirlist(); private: void readConfig(char *filename); diff --git a/src/UI/ConfigUI.fl b/src/UI/ConfigUI.fl @@ -287,18 +287,61 @@ activatebutton_rootdir(true);} code0 {o->deactivate();} } } + Fl_Group {} { + label {Presets dirs} + xywh {5 25 500 285} hide + } { + Fl_Browser presetbrowse { + callback {activatebutton_presetdir(o->value()!=0);} + xywh {15 35 485 220} type Hold + } + Fl_Button {} { + label {Add preset directory...} + callback {const char *dirname; +dirname=fl_dir_chooser("Add a preset directory :",NULL,0); +if (dirname==NULL) return; + +presetbrowse->add(dirname);} + xywh {15 265 80 35} box THIN_UP_BOX align 128 + } + Fl_Button removepresetbutton { + label {Remove preset dir...} + callback {if (presetbrowse->value()!=0) { + presetbrowse->remove(rootsbrowse->value()); +}; +activatebutton_presetdir(false);} + xywh {105 265 80 35} box THIN_UP_BOX align 128 + code0 {o->deactivate();} + } + Fl_Button makedefaultpresetbutton { + label {Make default} + callback {int n=presetbrowse->value(); + +if (n!=0) { + presetbrowse->move(1,n); + presetbrowse->value(1); + presetbrowse->redraw(); +}; +activatebutton_presetdir(true);} + xywh {190 265 80 35} box THIN_UP_BOX align 128 + code0 {o->deactivate();} + } + } } Fl_Button {} { label Close callback {configwindow->hide(); -writebankcfg();} +writebankcfg(); +writepresetcfg();} xywh {200 315 105 20} box THIN_UP_BOX } } } - Function {ConfigUI()} {} { + Function {ConfigUI()} {selected + } { code {make_window(); -readbankcfg();} {} +readbankcfg(); +readpresetcfg();} {} } Function {activatebutton_rootdir(bool active)} {} { code {if (active) { @@ -309,6 +352,15 @@ readbankcfg();} {} makedefaultrootdirbutton->deactivate(); };} {} } + Function {activatebutton_presetdir(bool active)} {} { + code {if (active) { + removepresetbutton->activate(); + makedefaultpresetbutton->activate(); +}else{ + removepresetbutton->deactivate(); + makedefaultpresetbutton->deactivate(); +};} {} + } Function {readbankcfg()} {} { code {rootsbrowse->clear(); @@ -322,8 +374,22 @@ for (int i=0;i<MAX_BANK_ROOT_DIRS;i++){ for (int n=0;n<rootsbrowse->size();n++){ config.cfg.bankRootDirList[n]=new char [MAX_STRING_SIZE]; strncpy(config.cfg.bankRootDirList[n],rootsbrowse->text(n+1),MAX_STRING_SIZE); -};} {selected - } +};} {} + } + Function {readpresetcfg()} {} { + code {presetbrowse->clear(); + +for (int i=0;i<MAX_BANK_ROOT_DIRS;i++){ + if (config.cfg.presetsDirList[i]!=NULL) presetbrowse->add(config.cfg.presetsDirList[i]); +};} {} + } + Function {writepresetcfg()} {} { + code {config.clearpresetsdirlist(); + +for (int n=0;n<presetbrowse->size();n++){ + config.cfg.presetsDirList[n]=new char [MAX_STRING_SIZE]; + strncpy(config.cfg.presetsDirList[n],presetbrowse->text(n+1),MAX_STRING_SIZE); +};} {} } Function {getsamplerateorder()} {return_type int } {