zynaddsubfx

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

commit 3c3b762a01a0b9b11652393044eb91848315f121
parent 9b87526e1565c137d2a330d6cec1d2c544f64546
Author: paulnasca <paulnasca>
Date:   Wed, 16 Jun 2004 20:30:48 +0000

*** empty log message ***

Diffstat:
MChangeLog | 2++
Msrc/Misc/Bank.C | 58++--------------------------------------------------------
Msrc/Misc/Config.C | 55+++++++++++++++++++++++++++++++++----------------------
3 files changed, 37 insertions(+), 78 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -578,5 +578,7 @@ - Imbunatatit modulatia basefunc la OscilGen (adaugat inca un parametru si inca un tip de modulatie ("power")) - Adaugat inca o noua functie basefunc la OscilGen (sqr=atan(sin(x)*a)) 15 Iun 2004 - Adaugat posibilitatea de a face armonicele ca sa depinda de frecventa ("adaptive") si rezultatul suna foarte frumos pentru ca tendinta este de pastrare a frecventelor armonicelor si nu a numarului de ordine al lor +16 Iun 2004 - Inceput sa trec configul pe XML + diff --git a/src/Misc/Bank.C b/src/Misc/Bank.C @@ -52,46 +52,7 @@ Bank::Bank(){ clearbank(); - char bankcfg[1000];//hope the filename is shorter than that :) -#if defined(OS_WINDOWS) - strcpy(bankcfg,"zynaddsubfx_usedbank"); -#endif -#if defined(OS_LINUX) - strcpy(bankcfg,getenv("HOME")); - strcat(bankcfg,"/.zynaddsubfx_usedbank"); -#endif - - - struct stat statbuf; - int result=stat(bankcfg,&statbuf); - if (result==0){ - char *fn=new char [statbuf.st_size+2]; - for (int i=0;i<statbuf.st_size;i++) fn[i]=0; - int file=open(bankcfg,O_RDONLY,00444+00222); - if (file!=-1){ - read(file,fn,statbuf.st_size); - - loadbank(fn); - }; - close(file); - delete(fn); - } else { - - result=1; -#if defined(OS_LINUX) - result=stat("/usr/local/share/zynaddsubfx/default_bank",&statbuf); - if (result==0) loadbank("/usr/local/share/zynaddsubfx/default_bank"); - else { - result=stat("/usr/share/zynaddsubfx/default_bank",&statbuf); - if (result==0) loadbank("/usr/share/zynaddsubfx/default_bank"); - }; -#endif - if (result!=0) loadbank("default_bank"); - }; - - - -// loadbank("bank_xml"); +// loadbank("nume directorbank"); for (int i=0;i<MAX_NUM_BANKS;i++){ banks[i].dir=NULL; @@ -103,23 +64,8 @@ Bank::Bank(){ Bank::~Bank(){ if (dirname!=NULL) { - //**************// - char bankcfg[1000];//hope the filename is shorter than that :) -#if defined(OS_WINDOWS) - strcpy(bankcfg,"zynaddsubfx_usedbank"); -#endif -#if defined(OS_LINUX) - strcpy(bankcfg,getenv("HOME")); - strcat(bankcfg,"/.zynaddsubfx_usedbank"); -#endif - int file=open(bankcfg,O_CREAT|O_WRONLY|O_TRUNC,00444+00222); - if (file!=-1){ - write(file,dirname,strlen(dirname)+1); - close(file); - }; - //**************// + //salvez numele bank-ul aici cu numele "dirname" }; - for (int i=0;i<MAX_NUM_BANKS;i++){ if (banks[i].dir!=NULL) delete (banks[i].dir); if (banks[i].name!=NULL) delete (banks[i].name); diff --git a/src/Misc/Config.C b/src/Misc/Config.C @@ -30,6 +30,7 @@ #endif #include "Config.h" +#include "XMLwrapper.h" Config::Config(){ maxstringsize=MAX_STRING_SIZE;//for ui @@ -205,39 +206,49 @@ void Config::readConfig(char *filename){ }; void Config::saveConfig(char *filename){ - FILE *file=fopen(filename,"w"); - if (file==NULL) return; - fprintf(file,"%s","#ZynAddSubFX configuration file\n"); - fprintf(file,"SAMPLE_RATE = %d\n",cfg.SampleRate); - fprintf(file,"SOUND_BUFFER_SIZE = %d\n",cfg.SoundBufferSize); - fprintf(file,"OSCIL_SIZE = %d\n",cfg.OscilSize); - fprintf(file,"SWAP_STEREO = %d\n",cfg.SwapStereo); + XMLwrapper *xmlcfg=new XMLwrapper(); + + xmlcfg->beginbranch("CONFIGURATION"); + + xmlcfg->addpar("sample_rate",cfg.SampleRate); + xmlcfg->addpar("sound_buffer_size",cfg.SoundBufferSize); + xmlcfg->addpar("oscil_size",cfg.OscilSize); + xmlcfg->addpar("swap_stereo",cfg.SwapStereo); + xmlcfg->addpar("bank_window_auto_close",cfg.BankUIAutoClose); - fprintf(file,"BANK_WINDOW_AUTO_CLOSE = %d\n",cfg.BankUIAutoClose); + xmlcfg->addpar("dump_notes_to_file",cfg.DumpNotesToFile); + xmlcfg->addpar("dump_append",cfg.DumpAppend); + xmlcfg->addparstr("dump_file",cfg.DumpFile); - fprintf(file,"DUMP_NOTES_TO_FILE = %d\n",cfg.DumpNotesToFile); - fprintf(file,"DUMP_APPEND = %d\n",cfg.DumpAppend); - fprintf(file,"DUMP_FILE = %s\n",cfg.DumpFile); - - fprintf(file,"GZIP_COMPRESSION = %d\n",cfg.GzipCompression); + xmlcfg->addpar("gzip_compression",cfg.GzipCompression); - fprintf(file,"#Linux\n"); - fprintf(file,"LINUX_OSS_WAVE_OUT_DEV = %s\n",cfg.LinuxOSSWaveOutDev); - fprintf(file,"LINUX_OSS_SEQ_IN_DEV = %s\n",cfg.LinuxOSSSeqInDev); + xmlcfg->addparstr("bank_current",cfg.currentBankDir); + xmlcfg->addparstr("bank_root_list",cfg.bankRootDirList); - fprintf(file,"#Windows\n"); - fprintf(file,"WINDOWS_WAVE_OUT_ID = %d\n",cfg.WindowsWaveOutId); - fprintf(file,"WINDOWS_MIDI_IN_ID = %d\n",cfg.WindowsMidiInId); + //linux stuff + xmlcfg->addparstr("linux_oss_wave_out_dev",cfg.LinuxOSSWaveOutDev); + xmlcfg->addparstr("linux_oss_seq_in_dev",cfg.LinuxOSSSeqInDev); + + //windows stuff + xmlcfg->addpar("windows_wave_out_id",cfg.WindowsWaveOutId); + xmlcfg->addpar("windows_midi_in_id",cfg.WindowsMidiInId); + + xmlcfg->endbranch(); - fclose(file); + int tmp=cfg.GzipCompression; + cfg.GzipCompression=0; + xmlcfg->saveXMLfile(filename); + cfg.GzipCompression=tmp; + + delete(xmlcfg); }; void Config::getConfigFileName(char *name, int namesize){ name[0]=0; #ifdef OS_LINUX - snprintf(name,namesize,"%s%s",getenv("HOME"),"/.zynaddsubfx.cfg"); + snprintf(name,namesize,"%s%s",getenv("HOME"),"/.zynaddsubfxXML.cfg"); #else - snprintf(name,namesize,"%s","zynaddsubfx.cfg"); + snprintf(name,namesize,"%s","zynaddsubfxXML.cfg"); #endif };