/* * nonlimitedSynth * * Copyright (c) 2007-2008 Karsten Krispin * * 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. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * */ #ifndef INCLUDED_CONFIGURATION_H #define INCLUDED_CONFIGURATION_H #include "common.h" #include "Configuration/Base/ConfigurationNode.h" #include "Configuration/Nodes/Nodes.h" #include /** * @brief Provides global configuration properties * @ingroup Configuration * @todo replace internal structures with ConfigurationNode derived from SynthObject * @nosubgrouping */ class Configuration : public ConfigurationNode { public: public: Configuration(); ~Configuration(); DefaultsMap * classDefaults(QString className); DefaultsMap * classDefaults(QString topLevelClass, QList classNames); DefaultsMap * fiducialDefaults(unsigned int fid, QList classNames); static Configuration * instance() { if(!_configInstance) _configInstance = new Configuration; return _configInstance; } void clear(); ObjectName objectName() { return "Config: Configuration"; } private: static Configuration * _configInstance; /* Fiducials */ QHash > _classDefaults; QHash _cachedClassDefaults; public: /** * shortcut to audio configuration */ class Audio { public: static int sampleRate(int def = 48000) { return Configuration::instance()->node("audio").attributeAsInt("sampleRate", def); } static int hopSize(int def = 256) { return Configuration::instance()->node("audio").attributeAsInt("hopSize", def); } static int bufferSize(int def = 1024) { return Configuration::instance()->node("audio").attributeAsInt("bufferSize", def); } /** * @brief name of the device to open */ static AttributeValue device(QString def = "default") { return Configuration::instance()->node("audio").attribute("device", def); } /** * @returns the number of inputs to be opened */ static int inputs(int def = 0) { return Configuration::instance()->node("audio").attributeAsInt("inputs", def); } /** * @returns the number of outputs to be opened */ static int outputs(int def = 2) { return Configuration::instance()->node("audio").attributeAsInt("outputs", def); } static ConfigurationNode & node() { return Configuration::instance()->node("audio"); } }; /** * shortcut to video configuration */ class Video { public: static int width() { return Configuration::instance()->node("video").attributeAsInt("width", 1024); } static int height() { return Configuration::instance()->node("video").attributeAsInt("height", 768); } static qreal tangibleScale() { return Configuration::instance()->node("video").attributeAsDouble("tangibleScale", 0.1); } }; }; #endif