diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/inputprocessor.cc | 8 | ||||
| -rw-r--r-- | src/instrument.cc | 24 | ||||
| -rw-r--r-- | src/instrument.h | 3 | ||||
| -rw-r--r-- | src/powerlist.cc | 10 | ||||
| -rw-r--r-- | src/powerlist.h | 3 | ||||
| -rw-r--r-- | src/sample.cc | 5 | ||||
| -rw-r--r-- | src/sample.h | 2 | ||||
| -rw-r--r-- | src/settings.h | 2 | ||||
| -rw-r--r-- | src/staminafilter.cc | 11 | 
9 files changed, 55 insertions, 13 deletions
| diff --git a/src/inputprocessor.cc b/src/inputprocessor.cc index 96bc2c0..5e58661 100644 --- a/src/inputprocessor.cc +++ b/src/inputprocessor.cc @@ -28,7 +28,7 @@  #include <list> -#include "hugin.hpp" +#include <hugin.hpp>  #include "instrument.h" @@ -133,6 +133,7 @@ bool InputProcessor::processOnset(event_t& event,  		}  	} +	auto orig_level = event.velocity;  	for(auto& filter : filters)  	{  		// This line might change the 'event' variable @@ -152,6 +153,11 @@ bool InputProcessor::processOnset(event_t& event,  		return false;  	} +	auto selected_level = +		(sample->getPower() - instr->getMinPower()) / +		(instr->getMaxPower() - instr->getMinPower()); +	settings.velocity_modifier_current.store(selected_level / orig_level); +  	for(Channel& ch: kit.channels)  	{  		AudioFile* af = sample->getAudioFile(ch); diff --git a/src/instrument.cc b/src/instrument.cc index 077ae55..6627a41 100644 --- a/src/instrument.cc +++ b/src/instrument.cc @@ -124,3 +124,27 @@ std::size_t Instrument::getNumberOfFiles() const  	// multi-channel files.  	return audiofiles.size();  } + +float Instrument::getMaxPower() const +{ +	if(version >= VersionStr("2.0")) +	{ +		return powerlist.getMaxPower(); +	} +	else +	{ +		return 1.0f; +	} +} + +float Instrument::getMinPower() const +{ +	if(version >= VersionStr("2.0")) +	{ +		return powerlist.getMinPower(); +	} +	else +	{ +		return 0.0f; +	} +} diff --git a/src/instrument.h b/src/instrument.h index e18c14a..6deb5d2 100644 --- a/src/instrument.h +++ b/src/instrument.h @@ -63,6 +63,9 @@ public:  	//! Get the number of audio files (as in single channel) in this instrument.  	std::size_t getNumberOfFiles() const; +	float getMaxPower() const; +	float getMinPower() const; +  private:  	// For parser:  	friend class InstrumentParser; diff --git a/src/powerlist.cc b/src/powerlist.cc index 5ce9404..56962d7 100644 --- a/src/powerlist.cc +++ b/src/powerlist.cc @@ -269,3 +269,13 @@ Sample* PowerList::get(level_t level)  	return sample;  } + +float PowerList::getMaxPower() const +{ +	return power_max; +} + +float PowerList::getMinPower() const +{ +	return power_min; +} diff --git a/src/powerlist.h b/src/powerlist.h index c00136a..6741828 100644 --- a/src/powerlist.h +++ b/src/powerlist.h @@ -43,6 +43,9 @@ public:  	Sample* get(level_t velocity); +	float getMaxPower() const; +	float getMinPower() const; +  private:  	struct PowerListItem  	{ diff --git a/src/sample.cc b/src/sample.cc index 1f624d3..c1795e8 100644 --- a/src/sample.cc +++ b/src/sample.cc @@ -62,3 +62,8 @@ AudioFile* Sample::getAudioFile(const Channel& channel)  	return nullptr;  } + +float Sample::getPower() const +{ +	return power; +} diff --git a/src/sample.h b/src/sample.h index 7eb4076..daac6aa 100644 --- a/src/sample.h +++ b/src/sample.h @@ -42,6 +42,8 @@ public:  	AudioFile* getAudioFile(const Channel& channel); +	float getPower() const; +  private:  	friend class InstrumentParser;  	friend class PowerList; diff --git a/src/settings.h b/src/settings.h index 0d76cfc..b9d627a 100644 --- a/src/settings.h +++ b/src/settings.h @@ -102,7 +102,7 @@ struct Settings  	Atomic<bool> enable_latency_modifier{false};  	//! Maximum "early hits" introduces latency in milliseconds. -	Atomic<std::size_t> latency_max{250u}; +	Atomic<std::size_t> latency_max{100u};  	//! 0 := on-beat  	//! positive := laid back diff --git a/src/staminafilter.cc b/src/staminafilter.cc index 8fdbfbb..a8f6a86 100644 --- a/src/staminafilter.cc +++ b/src/staminafilter.cc @@ -76,16 +76,5 @@ bool StaminaFilter::filter(event_t& event, size_t pos)  		mod *= velocity_modifier_weight;  	} -	{ -		auto velocity_modifier_current = settings.velocity_modifier_current.load(); -		float p = 0.9f; -		float new_value = mod * p + velocity_modifier_current * (1.0f - p); -		if(mod > new_value) -		{ -			new_value = mod; -		} -		settings.velocity_modifier_current.store(new_value); -	} -  	return true;  } | 
