/* ZynAddSubFX - a software synthesizer Config.cpp - Configuration file functions Copyright (C) 2003-2005 Nasca Octavian Paul Author: Nasca Octavian Paul This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. */ #include #include #include #include #include #include #include "Config.h" #include "../globals.h" #include "XMLwrapper.h" namespace zyncarla { #define rStdString(name, len, ...) \ {STRINGIFY(name) "::s", rMap(length, len) rProp(parameter) DOC(__VA_ARGS__), NULL, rStringCb(name,len)} #define rStdStringCb(name, length) rBOIL_BEGIN \ if(!strcmp("", args)) {\ data.reply(loc, "s", obj->name); \ } else { \ strncpy(obj->name, rtosc_argument(msg, 0).s, length); \ data.broadcast(loc, "s", obj->name);\ rChangeCb \ } rBOIL_END #if 1 #define rObject Config static const rtosc::Ports ports = { //rString(cfg.LinuxOSSWaveOutDev), //rString(cfg.LinuxOSSSeqInDev), rParamI(cfg.SampleRate, "samples of audio per second"), rParamI(cfg.SoundBufferSize, "Size of processed audio buffer"), rParamI(cfg.OscilSize, "Size Of Oscillator Wavetable"), rToggle(cfg.SwapStereo, "Swap Left And Right Channels"), rToggle(cfg.BankUIAutoClose, "Automatic Closing of BackUI After Patch Selection"), rParamI(cfg.GzipCompression, "Level of Gzip Compression For Save Files"), rParamI(cfg.Interpolation, "Level of Interpolation, Linear/Cubic"), {"cfg.presetsDirList", rDoc("list of preset search directories"), 0, [](const char *msg, rtosc::RtData &d) { Config &c = *(Config*)d.obj; if(rtosc_narguments(msg) != 0) { std::string args = rtosc_argument_string(msg); //clear everything c.clearpresetsdirlist(); for(int i=0; i<(int)args.size(); ++i) if(args[i] == 's') c.cfg.presetsDirList[i] = rtosc_argument(msg, i).s; } char types[MAX_BANK_ROOT_DIRS+1]; rtosc_arg_t args[MAX_BANK_ROOT_DIRS]; size_t pos = 0; //zero out data memset(types, 0, sizeof(types)); memset(args, 0, sizeof(args)); for(int i=0; ibeginbranch("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); xmlcfg->addpar("gzip_compression", cfg.GzipCompression); xmlcfg->addpar("check_pad_synth", cfg.CheckPADsynth); xmlcfg->addpar("ignore_program_change", cfg.IgnoreProgramChange); xmlcfg->addparstr("bank_current", cfg.currentBankDir); xmlcfg->addpar("user_interface_mode", cfg.UserInterfaceMode); xmlcfg->addpar("virtual_keyboard_layout", cfg.VirKeybLayout); for(int i = 0; i < MAX_BANK_ROOT_DIRS; ++i) if(!cfg.bankRootDirList[i].empty()) { xmlcfg->beginbranch("BANKROOT", i); xmlcfg->addparstr("bank_root", cfg.bankRootDirList[i]); xmlcfg->endbranch(); } for(int i = 0; i < MAX_BANK_ROOT_DIRS; ++i) if(!cfg.presetsDirList[i].empty()) { xmlcfg->beginbranch("PRESETSROOT", i); xmlcfg->addparstr("presets_root", cfg.presetsDirList[i]); xmlcfg->endbranch(); } for(int i = 0; i < MAX_BANK_ROOT_DIRS; ++i) if(!cfg.favoriteList[i].empty()) { xmlcfg->beginbranch("FAVSROOT", i); xmlcfg->addparstr("favoirtes_root", cfg.favoriteList[i]); xmlcfg->endbranch(); } xmlcfg->addpar("interpolation", cfg.Interpolation); //linux stuff xmlcfg->addparstr("linux_oss_wave_out_dev", cfg.oss_devs.linux_wave_out); xmlcfg->addparstr("linux_oss_seq_in_dev", cfg.oss_devs.linux_seq_in); //windows stuff xmlcfg->addpar("windows_wave_out_id", cfg.WindowsWaveOutId); xmlcfg->addpar("windows_midi_in_id", cfg.WindowsMidiInId); xmlcfg->endbranch(); // for some reason (which one?), the gzip compression is bashed to 0 xmlcfg->saveXMLfile(filename, 0); delete (xmlcfg); } void Config::getConfigFileName(char *name, int namesize) const { name[0] = 0; snprintf(name, namesize, "%s%s", getenv("HOME"), "/.zynaddsubfxXML.cfg"); } }