diff options
| author | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-03-31 22:11:07 +0200 | 
|---|---|---|
| committer | Bent Bisballe Nyeng <deva@aasimon.org> | 2016-03-31 22:11:07 +0200 | 
| commit | 19691923340e5984e3ace837d39938f718fee608 (patch) | |
| tree | 85dd4ddab8e9c9b5632a92710dc36441a0fc7f6b | |
| parent | 2e4175d84cc0ca765fdc0b03bf5c8420deeec268 (diff) | |
Removed the last Conf:: namespace usage and replaced it with Settings.
| -rw-r--r-- | plugin/Makefile.mingw32.in | 1 | ||||
| -rw-r--r-- | src/Makefile.am | 2 | ||||
| -rw-r--r-- | src/Makefile.am.drumgizmo | 1 | ||||
| -rw-r--r-- | src/audiofile.cc | 2 | ||||
| -rw-r--r-- | src/configuration.cc | 38 | ||||
| -rw-r--r-- | src/configuration.h | 44 | ||||
| -rw-r--r-- | src/drumgizmo.cc | 55 | ||||
| -rw-r--r-- | src/instrument.cc | 1 | ||||
| -rw-r--r-- | src/settings.h | 36 | 
9 files changed, 53 insertions, 127 deletions
| diff --git a/plugin/Makefile.mingw32.in b/plugin/Makefile.mingw32.in index 40233b4..779f54b 100644 --- a/plugin/Makefile.mingw32.in +++ b/plugin/Makefile.mingw32.in @@ -19,7 +19,6 @@ DG_SRC = \  	@top_srcdir@/src/channelmixer.cc \  	@top_srcdir@/src/chresampler.cc \  	@top_srcdir@/src/configfile.cc \ -	@top_srcdir@/src/configuration.cc \  	@top_srcdir@/src/configparser.cc \  	@top_srcdir@/src/drumgizmo.cc \  	@top_srcdir@/src/drumkit.cc \ diff --git a/src/Makefile.am b/src/Makefile.am index a1b1615..9dd6c29 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -13,7 +13,6 @@ EXTRA_DIST = \  	channelmixer.h \  	chresampler.h \  	configfile.h \ -	configuration.h \  	configparser.h \  	cpp11fix.h \  	drumgizmo.h \ @@ -54,7 +53,6 @@ EXTRA_DIST = \  	channelmixer.cc \  	chresampler.cc \  	configfile.cc \ -	configuration.cc \  	configparser.cc \  	drumgizmo.cc \  	drumkit.cc \ diff --git a/src/Makefile.am.drumgizmo b/src/Makefile.am.drumgizmo index 8f648d0..e707fe2 100644 --- a/src/Makefile.am.drumgizmo +++ b/src/Makefile.am.drumgizmo @@ -11,7 +11,6 @@ DRUMGIZMO_SOURCES = \  	$(top_srcdir)/src/channelmixer.cc \  	$(top_srcdir)/src/chresampler.cc \  	$(top_srcdir)/src/configfile.cc \ -	$(top_srcdir)/src/configuration.cc \  	$(top_srcdir)/src/configparser.cc \  	$(top_srcdir)/src/drumgizmo.cc \  	$(top_srcdir)/src/drumkit.cc \ diff --git a/src/audiofile.cc b/src/audiofile.cc index 58b248b..84329f8 100644 --- a/src/audiofile.cc +++ b/src/audiofile.cc @@ -36,8 +36,6 @@  #include <sndfile.h>  #include <hugin.hpp> -#include "configuration.h" -  AudioFile::AudioFile(const std::string& filename, int filechannel)  {  	is_loaded = false; diff --git a/src/configuration.cc b/src/configuration.cc deleted file mode 100644 index 72f6e4a..0000000 --- a/src/configuration.cc +++ /dev/null @@ -1,38 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - *            configuration.cc - * - *  Sat Oct  8 14:37:14 CEST 2011 - *  Copyright 2011 Bent Bisballe Nyeng - *  deva@aasimon.org - ****************************************************************************/ - -/* - *  This file is part of DrumGizmo. - * - *  DrumGizmo is free software; you can redistribute it and/or modify - *  it under the terms of the GNU Lesser General Public License as published by - *  the Free Software Foundation; either version 3 of the License, or - *  (at your option) any later version. - * - *  DrumGizmo 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 Lesser General Public License for more details. - * - *  You should have received a copy of the GNU Lesser General Public License - *  along with DrumGizmo; if not, write to the Free Software - *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. - */ -#include "configuration.h" - -bool Conf::enable_velocity_modifier = true; -float Conf::velocity_modifier_falloff = 0.5; -float Conf::velocity_modifier_weight = 0.25; - -bool Conf::enable_velocity_randomiser = false; -float Conf::velocity_randomiser_weight = 0.1; - -int Conf::samplerate = 44100; - -bool Conf::enable_resampling = true; diff --git a/src/configuration.h b/src/configuration.h deleted file mode 100644 index 3adf525..0000000 --- a/src/configuration.h +++ /dev/null @@ -1,44 +0,0 @@ -/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ -/*************************************************************************** - *            configuration.h - * - *  Sat Oct  8 14:37:13 CEST 2011 - *  Copyright 2011 Bent Bisballe Nyeng - *  deva@aasimon.org - ****************************************************************************/ - -/* - *  This file is part of DrumGizmo. - * - *  DrumGizmo is free software; you can redistribute it and/or modify - *  it under the terms of the GNU Lesser General Public License as published by - *  the Free Software Foundation; either version 3 of the License, or - *  (at your option) any later version. - * - *  DrumGizmo 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 Lesser General Public License for more details. - * - *  You should have received a copy of the GNU Lesser General Public License - *  along with DrumGizmo; if not, write to the Free Software - *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA. - */ -#ifndef __DRUMGIZMO_CONFIGURATION_H__ -#define __DRUMGIZMO_CONFIGURATION_H__ - -namespace Conf { -  extern bool enable_velocity_modifier; -  extern float velocity_modifier_falloff; -  extern float velocity_modifier_weight; - -  extern bool enable_velocity_randomiser; -  extern float velocity_randomiser_weight; - -  extern int samplerate; - -  extern bool enable_resampling; -}; - - -#endif/*__DRUMGIZMO_CONFIGURATION_H__*/ diff --git a/src/drumgizmo.cc b/src/drumgizmo.cc index 4109249..f769f4e 100644 --- a/src/drumgizmo.cc +++ b/src/drumgizmo.cc @@ -41,7 +41,6 @@  #include "drumkitparser.h"  #include "audioinputenginemidi.h" -#include "configuration.h"  #include "configparser.h"  #include "nolocale.h" @@ -103,7 +102,7 @@ bool DrumGizmo::loadkit(std::string file)  #ifdef WITH_RESAMPLER  	for(int i = 0; i < MAX_NUM_CHANNELS; ++i)  	{ -		resampler[i].setup(kit.getSamplerate(), Conf::samplerate); +		resampler[i].setup(kit.getSamplerate(), settings.samplerate.load());  	}  #endif/*WITH_RESAMPLER*/ @@ -171,11 +170,11 @@ void DrumGizmo::handleMessage(Message *msg)  			msg->midimap_loaded = mmap_loaded;  			msg->drumkitfile = kit.getFile();  			msg->drumkit_loaded = loader.isDone(); -			msg->enable_velocity_modifier = Conf::enable_velocity_modifier; -			msg->velocity_modifier_falloff = Conf::velocity_modifier_falloff; -			msg->velocity_modifier_weight = Conf::velocity_modifier_weight; -			msg->enable_velocity_randomiser = Conf::enable_velocity_randomiser; -			msg->velocity_randomiser_weight = Conf::velocity_randomiser_weight; +			msg->enable_velocity_modifier = settings.enable_velocity_modifier.load(); +			msg->velocity_modifier_falloff = settings.velocity_modifier_falloff.load(); +			msg->velocity_modifier_weight = settings.velocity_modifier_weight.load(); +			msg->enable_velocity_randomiser = settings.enable_velocity_randomiser.load(); +			msg->velocity_randomiser_weight = settings.velocity_randomiser_weight.load();  			msghandler.sendMessage(MSGRCV_UI, msg);  		}  		break; @@ -184,13 +183,13 @@ void DrumGizmo::handleMessage(Message *msg)  			ChangeSettingMessage *ch = (ChangeSettingMessage*)msg;  			switch(ch->name) {  			case ChangeSettingMessage::enable_velocity_modifier: -				Conf::enable_velocity_modifier = ch->value; +				settings.enable_velocity_modifier.store(ch->value);  				break;  			case ChangeSettingMessage::velocity_modifier_weight: -				Conf::velocity_modifier_weight = ch->value; +				settings.velocity_modifier_weight.store(ch->value);  				break;  			case ChangeSettingMessage::velocity_modifier_falloff: -				Conf::velocity_modifier_falloff = ch->value; +				settings.velocity_modifier_falloff.store(ch->value);  				break;  			}  		} @@ -400,7 +399,7 @@ bool DrumGizmo::run(size_t pos, sample_t *samples, size_t nsamples)  	// Write audio  	//  #ifdef WITH_RESAMPLER -	if((Conf::enable_resampling == false) || +	if((settings.enable_resampling.load() == false) ||  	   (resampler[0].getRatio() == 1.0)) // No resampling needed  	{  #endif @@ -638,17 +637,17 @@ void DrumGizmo::stop()  int DrumGizmo::samplerate()  { -	return Conf::samplerate; +	return settings.samplerate.load();  }  void DrumGizmo::setSamplerate(int samplerate)  {  	DEBUG(dgeditor, "%s samplerate: %d\n", __PRETTY_FUNCTION__, samplerate); -	Conf::samplerate = samplerate; +	settings.samplerate.store(samplerate);  #ifdef WITH_RESAMPLER  	for(int i = 0; i < MAX_NUM_CHANNELS; ++i)  	{ -		resampler[i].setup(kit.getSamplerate(), Conf::samplerate); +		resampler[i].setup(kit.getSamplerate(), settings.samplerate.load());  	}  	if(resampler[0].getRatio() != 1)  	{ @@ -693,15 +692,15 @@ std::string DrumGizmo::configString()  		"  <value name=\"drumkitfile\">" + kit.getFile() + "</value>\n"  		"  <value name=\"midimapfile\">" + mmapfile + "</value>\n"  		"  <value name=\"enable_velocity_modifier\">" + -		bool2str(Conf::enable_velocity_modifier) + "</value>\n" +		bool2str(settings.enable_velocity_modifier.load()) + "</value>\n"  		"  <value name=\"velocity_modifier_falloff\">" + -		float2str(Conf::velocity_modifier_falloff) + "</value>\n" +		float2str(settings.velocity_modifier_falloff.load()) + "</value>\n"  		"  <value name=\"velocity_modifier_weight\">" + -		float2str(Conf::velocity_modifier_weight) + "</value>\n" +		float2str(settings.velocity_modifier_weight.load()) + "</value>\n"  		"  <value name=\"enable_velocity_randomiser\">" + -		bool2str(Conf::enable_velocity_randomiser) + "</value>\n" +		bool2str(settings.enable_velocity_randomiser.load()) + "</value>\n"  		"  <value name=\"velocity_randomiser_weight\">" + -		float2str(Conf::velocity_randomiser_weight) + "</value>\n" +		float2str(settings.velocity_randomiser_weight.load()) + "</value>\n"  		"</config>";  } @@ -719,38 +718,32 @@ bool DrumGizmo::setConfigString(std::string cfg)  	if(p.value("enable_velocity_modifier") != "")  	{ -		Conf::enable_velocity_modifier = -			p.value("enable_velocity_modifier") == "true"; +		settings.enable_velocity_modifier.store(p.value("enable_velocity_modifier") == "true");  	}  	if(p.value("velocity_modifier_falloff") != "")  	{ -		Conf::velocity_modifier_falloff = -			str2float(p.value("velocity_modifier_falloff")); +		settings.velocity_modifier_falloff.store(str2float(p.value("velocity_modifier_falloff")));  	}  	if(p.value("velocity_modifier_weight") != "")  	{ -		Conf::velocity_modifier_weight = -			str2float(p.value("velocity_modifier_weight")); +		settings.velocity_modifier_weight.store(str2float(p.value("velocity_modifier_weight")));  	}  	if(p.value("enable_velocity_randomiser") != "")  	{ -		Conf::enable_velocity_randomiser = -			p.value("enable_velocity_randomiser") == "true"; +		settings.enable_velocity_randomiser.store(p.value("enable_velocity_randomiser") == "true");  	}  	if(p.value("velocity_randomiser_weight") != "")  	{ -		Conf::velocity_randomiser_weight = -			str2float(p.value("velocity_randomiser_weight")); +		settings.velocity_randomiser_weight.store(str2float(p.value("velocity_randomiser_weight")));  	}  	if(p.value("enable_resampling") != "")  	{ -		Conf::enable_resampling = -			p.value("enable_resampling") == "true"; +		settings.enable_resampling.store(p.value("enable_resampling") == "true");  	}  	std::string newkit = p.value("drumkitfile"); diff --git a/src/instrument.cc b/src/instrument.cc index ee225d5..f187de0 100644 --- a/src/instrument.cc +++ b/src/instrument.cc @@ -29,7 +29,6 @@  #include <hugin.hpp>  #include "sample.h" -#include "configuration.h"  Instrument::Instrument(Settings& settings)  	: settings(settings) diff --git a/src/settings.h b/src/settings.h index ed031b2..2700e26 100644 --- a/src/settings.h +++ b/src/settings.h @@ -31,20 +31,34 @@  #include <cassert>  #include "atomic.h" +//bool Conf::enable_velocity_modifier = true; +//float Conf::velocity_modifier_falloff = 0.5; +//float Conf::velocity_modifier_weight = 0.25; +// +//bool Conf::enable_velocity_randomiser = false; +//float Conf::velocity_randomiser_weight = 0.1; +// +//int Conf::samplerate = 44100; +// +//bool Conf::enable_resampling = true; + +//operator Atomic<bool>  //! Engine settings  struct Settings  { -	Atomic<bool> enable_velocity_modifier; -	Atomic<float> velocity_modifier_falloff; -	Atomic<float> velocity_modifier_weight; +	Atomic<std::string> foo{"foo"}; -	Atomic<bool> enable_velocity_randomiser; -	Atomic<float> velocity_randomiser_weight; +	Atomic<bool> enable_velocity_modifier{true}; +	Atomic<float> velocity_modifier_falloff{0.5}; +	Atomic<float> velocity_modifier_weight{0.25}; -	Atomic<double> samplerate; +	Atomic<bool> enable_velocity_randomiser{false}; +	Atomic<float> velocity_randomiser_weight{0.1}; -	Atomic<bool> enable_resampling; +	Atomic<double> samplerate{44100.0}; + +	Atomic<bool> enable_resampling{true};  	Atomic<int> number_of_files;  	Atomic<int> number_of_files_loaded; @@ -66,6 +80,13 @@ public:  	{  		T tmp = cache;  		cache.exchange(value); + +		if(firstAccess) +		{ +			firstAccess = false; +			return true; +		} +  		return tmp == cache;  	} @@ -75,6 +96,7 @@ public:  	}  private: +	bool firstAccess{true};  	Atomic<T>& value;  	Atomic<T> cache;  }; | 
