diff options
| -rw-r--r-- | plugin/Makefile.mingw32.in | 5 | ||||
| -rw-r--r-- | plugingui/Makefile.am | 6 | ||||
| -rw-r--r-- | plugingui/humaniservisualiser.cc | 150 | ||||
| -rw-r--r-- | plugingui/humaniservisualiser.h | 58 | ||||
| -rw-r--r-- | plugingui/humanizerframecontent.h | 4 | ||||
| -rw-r--r-- | plugingui/maintab.cc | 12 | ||||
| -rw-r--r-- | plugingui/maintab.h | 3 | ||||
| -rw-r--r-- | plugingui/resources/stddev_horizontal.png | bin | 0 -> 271 bytes | |||
| -rw-r--r-- | plugingui/resources/stddev_horizontal_disabled.png | bin | 0 -> 273 bytes | |||
| -rw-r--r-- | plugingui/resources/stddev_vertical.png | bin | 0 -> 277 bytes | |||
| -rw-r--r-- | plugingui/resources/stddev_vertical_disabled.png | bin | 0 -> 277 bytes | |||
| -rw-r--r-- | plugingui/timingframecontent.cc | 10 | ||||
| -rw-r--r-- | plugingui/timingframecontent.h | 2 | ||||
| -rw-r--r-- | plugingui/visualizerframecontent.cc | 51 | ||||
| -rw-r--r-- | plugingui/visualizerframecontent.h | 56 | ||||
| -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 | 
24 files changed, 345 insertions, 80 deletions
| diff --git a/plugin/Makefile.mingw32.in b/plugin/Makefile.mingw32.in index d0589d6..5979663 100644 --- a/plugin/Makefile.mingw32.in +++ b/plugin/Makefile.mingw32.in @@ -95,6 +95,7 @@ GUI_SRC = \  	@top_srcdir@/plugingui/toggle.cc \  	@top_srcdir@/plugingui/utf8.cc \  	@top_srcdir@/plugingui/verticalline.cc \ +	@top_srcdir@/plugingui/visualizerframecontent.cc \  	@top_srcdir@/plugingui/widget.cc \  	@top_srcdir@/plugingui/window.cc \  	@top_srcdir@/plugingui/lodepng/lodepng.cpp @@ -143,6 +144,10 @@ RES = \  	resources/pushbutton.png \  	resources/sidebar.png \  	resources/slider.png \ +	resources/stddev_horizontal.png \ +	resources/stddev_horizontal_disabled.png \ +	resources/stddev_vertical.png \ +	resources/stddev_vertical_disabled.png \  	resources/switch_back_off.png \  	resources/switch_back_on.png \  	resources/switch_front.png \ diff --git a/plugingui/Makefile.am b/plugingui/Makefile.am index fc31f35..84b351f 100644 --- a/plugingui/Makefile.am +++ b/plugingui/Makefile.am @@ -14,6 +14,10 @@ RES = \  	resources/pushbutton.png \  	resources/sidebar.png \  	resources/slider.png \ +	resources/stddev_horizontal.png \ +	resources/stddev_horizontal_disabled.png \ +	resources/stddev_vertical.png \ +	resources/stddev_vertical_disabled.png \  	resources/switch_back_off.png \  	resources/switch_back_on.png \  	resources/switch_front.png \ @@ -102,6 +106,7 @@ nodist_libdggui_la_SOURCES = \  	toggle.cc \  	utf8.cc \  	verticalline.cc \ +	visualizerframecontent.cc \  	widget.cc \  	window.cc \  	lodepng/lodepng.cpp @@ -231,6 +236,7 @@ EXTRA_DIST = \  	toggle.h \  	utf8.h \  	verticalline.h \ +	visualizerframecontent.h \  	widget.h \  	window.h \  	lodepng/lodepng.h diff --git a/plugingui/humaniservisualiser.cc b/plugingui/humaniservisualiser.cc index 5b5abb7..a823c64 100644 --- a/plugingui/humaniservisualiser.cc +++ b/plugingui/humaniservisualiser.cc @@ -31,96 +31,168 @@  #include <notifier.h>  #include <settings.h> -#include <iostream> +#include <hugin.hpp>  HumaniserVisualiser::HumaniserVisualiser(GUI::Widget* parent, +                                         Settings& settings,                                           SettingsNotifier& settings_notifier)  	: GUI::Widget(parent) +	, canvas(this, settings, settings_notifier) +{ +	canvas.move(7, 7); +} + +void HumaniserVisualiser::repaintEvent(GUI::RepaintEvent *repaintEvent) +{ +	GUI::Painter p(*this); + +	box.setSize(width(), height()); +	p.drawImage(0, 0, box); +} + +void HumaniserVisualiser::resize(std::size_t width, std::size_t height) +{ +	Widget::resize(width, height); +	if(width < 14 || height < 14) +	{ +		canvas.resize(1, 1); +		return; +	} +	canvas.resize(width - 14, height - 14); +} + +HumaniserVisualiser::Canvas::Canvas(GUI::Widget* parent, +                                    Settings& settings, +                                    SettingsNotifier& settings_notifier) +	: GUI::Widget(parent)  	, settings_notifier(settings_notifier) +	, latency_max_samples(settings.latency_max.load() * +	                      settings.samplerate.load() / 1000)  { +	CONNECT(this, settings_notifier.enable_latency_modifier, +	        this, &HumaniserVisualiser::Canvas::latencyEnabledChanged); +	CONNECT(this, settings_notifier.enable_velocity_modifier, +	        this, &HumaniserVisualiser::Canvas::velocityEnabledChanged); +  	CONNECT(this, settings_notifier.latency_current, -	        this, &HumaniserVisualiser::latencyOffsetChanged); +	        this, &HumaniserVisualiser::Canvas::latencyOffsetChanged);  	CONNECT(this, settings_notifier.velocity_modifier_current, -	        this, &HumaniserVisualiser::velocityOffsetChanged); +	        this, &HumaniserVisualiser::Canvas::velocityOffsetChanged);  	CONNECT(this, settings_notifier.latency_stddev, -	        this, &HumaniserVisualiser::latencyStddevChanged); +	        this, &HumaniserVisualiser::Canvas::latencyStddevChanged);  	CONNECT(this, settings_notifier.latency_laid_back, -	        this, &HumaniserVisualiser::latencyLaidbackChanged); +	        this, &HumaniserVisualiser::Canvas::latencyLaidbackChanged);  	CONNECT(this, settings_notifier.velocity_stddev, -	        this, &HumaniserVisualiser::velocityStddevChanged); +	        this, &HumaniserVisualiser::Canvas::velocityStddevChanged);  } -void HumaniserVisualiser::repaintEvent(GUI::RepaintEvent *repaintEvent) +void HumaniserVisualiser::Canvas::repaintEvent(GUI::RepaintEvent *repaintEvent)  { +	if(width() < 1 || height() < 1) +	{ +		return; +	} +  	GUI::Painter p(*this); -	// Background -	p.setColour(GUI::Colour(0, 0, 1)); -	p.drawFilledRectangle(0, 0, width(), height()); +	p.clear(); + +	const int spx = latency_max_samples * 2 / width(); // samples pr. pixel + +	int x = latency_offset / spx + width() / 2; +	float v = (-1.0f * velocity_offset + 1.0f) * 0.8; +	int y = height() * 0.2 + v * height(); +	y = std::max(0, y); +	int w = latency_stddev / spx * 3 * 2; // stddev is ~ +/- 3 span +	int h = velocity_stddev * height() / 4; -	int x = latency_offset / 2000.0 * width() / 2 + width() / 2; -	int y = velocity_offset * height(); -	int w = latency_stddev / 10; -	int h = velocity_stddev * 20; +	DEBUG(vis, "max: %d, spx: %d, x: %d, w: %d", latency_max_samples, spx, x, w);  	// Stddev squares -	float v = w; -	while(v > 1) +	if(latency_enabled)  	{ -		float a = 1.0f - v / (float)w; -		a = a * a * a; -		p.setColour(GUI::Colour(1.0f, 0.0f, 1.0f, a)); -		p.drawFilledRectangle(x - v / 2, 0, -		                      x + v / 2 + 1, height()); -		v -= 1.0f; +		p.drawImageStretched(x - w / 2, 0, stddev_h, w, height()); +	} +	else +	{ +		p.drawImageStretched(x - w / 2, 0, stddev_h_disabled, w, height());  	} -	v = h; -	while(v > 1) +	if(velocity_enabled) +	{ +		p.drawImageStretched(0, y - h / 2, stddev_v, width(), h); +	} +	else  	{ -		float a = 1.0f - v / (float)h; -		a = a * a * a; -		p.setColour(GUI::Colour(1.0f, 0.0f, 1.0f, a)); -		p.drawFilledRectangle(0, y - v / 2, -		                      width(), y + v / 2 + 1); -		v -= 1.0f; +		p.drawImageStretched(0, y - h / 2, stddev_v_disabled, width(), h);  	}  	// Lines -	p.setColour(GUI::Colour(0, 1, 1)); +	if(velocity_enabled) +	{ +		p.setColour(GUI::Colour(0.0f, 1.0f, 1.0f)); +	} +	else +	{ +		p.setColour(GUI::Colour(0.4f, 0.4f, 0.4f)); +	}  	p.drawLine(0, y, width(), y); + +	if(latency_enabled) +	{ +		p.setColour(GUI::Colour(0.0f, 1.0f, 1.0f)); +	} +	else +	{ +		p.setColour(GUI::Colour(0.4f, 0.4f, 0.4f)); +	}  	p.drawLine(x, 0, x, height()); + +	// Zero-lines +	p.setColour(GUI::Colour(0.0f, 1.0f, 0.0f, 0.9f)); +	p.drawLine(0, height() * 0.2f, width(), height() * 0.2f); +	p.drawLine(width() / 2, 0, width() / 2, height()); +} + +void HumaniserVisualiser::Canvas::latencyEnabledChanged(bool enabled) +{ +	latency_enabled = enabled; +	redraw(); +} + +void HumaniserVisualiser::Canvas::velocityEnabledChanged(bool enabled) +{ +	velocity_enabled = enabled; +	redraw();  } -void HumaniserVisualiser::latencyOffsetChanged(int offset) +void HumaniserVisualiser::Canvas::latencyOffsetChanged(int offset)  {  	latency_offset = offset;  	redraw();  } -void HumaniserVisualiser::velocityOffsetChanged(float offset) +void HumaniserVisualiser::Canvas::velocityOffsetChanged(float offset)  { -	std::cout << "velocity_offset: " << offset << std::endl; -	velocity_offset = -1.0f * offset + 1.0f; +	velocity_offset = offset;  	redraw();  } -void HumaniserVisualiser::latencyStddevChanged(float stddev) +void HumaniserVisualiser::Canvas::latencyStddevChanged(float stddev)  {  	latency_stddev = stddev;  	redraw();  } -void HumaniserVisualiser::latencyLaidbackChanged(int laidback) +void HumaniserVisualiser::Canvas::latencyLaidbackChanged(int laidback)  {  	this->laidback = laidback;  	redraw();  } -void HumaniserVisualiser::velocityStddevChanged(float stddev) +void HumaniserVisualiser::Canvas::velocityStddevChanged(float stddev)  { -	std::cout << "velocity_stddev: " << stddev << std::endl;  	velocity_stddev = stddev;  	redraw();  } diff --git a/plugingui/humaniservisualiser.h b/plugingui/humaniservisualiser.h index f7f4c15..6ef39b9 100644 --- a/plugingui/humaniservisualiser.h +++ b/plugingui/humaniservisualiser.h @@ -27,7 +27,10 @@  #pragma once  #include "widget.h" +#include "texturedbox.h" +#include "texture.h" +struct Settings;  class SettingsNotifier;  class HumaniserVisualiser @@ -35,22 +38,53 @@ class HumaniserVisualiser  {  public:  	HumaniserVisualiser(GUI::Widget* parent, +	                    Settings& settings,  	                    SettingsNotifier& settings_notifier);  	// From Widget:  	virtual void repaintEvent(GUI::RepaintEvent *repaintEvent) override; - -	void latencyOffsetChanged(int offset); -	void velocityOffsetChanged(float offset); -	void latencyStddevChanged(float stddev); -	void latencyLaidbackChanged(int laidback); -	void velocityStddevChanged(float stddev); +	virtual void resize(std::size_t width, std::size_t height) override;  private: -	int latency_offset; -	float velocity_offset; -	float latency_stddev; -	int laidback; -	float velocity_stddev; -	SettingsNotifier& settings_notifier; +	GUI::TexturedBox box{getImageCache(), ":resources/widget.png", +			0, 0, // atlas offset (x, y) +			7, 1, 7, // dx1, dx2, dx3 +			7, 63, 7}; // dy1, dy2, dy3 + +	class Canvas +		: public GUI::Widget +	{ +	public: +		Canvas(GUI::Widget* parent, Settings& settings, +		       SettingsNotifier& settings_notifier); + +		// From Widget: +		virtual void repaintEvent(GUI::RepaintEvent *repaintEvent) override; + +		void latencyEnabledChanged(bool enabled); +		void velocityEnabledChanged(bool enabled); +		void latencyOffsetChanged(int offset); +		void velocityOffsetChanged(float offset); +		void latencyStddevChanged(float stddev); +		void latencyLaidbackChanged(int laidback); +		void velocityStddevChanged(float stddev); + +		GUI::Texture stddev_h{getImageCache(), ":resources/stddev_horizontal.png"}; +		GUI::Texture stddev_h_disabled{getImageCache(), ":resources/stddev_horizontal_disabled.png"}; +		GUI::Texture stddev_v{getImageCache(), ":resources/stddev_vertical.png"}; +		GUI::Texture stddev_v_disabled{getImageCache(), ":resources/stddev_vertical_disabled.png"}; + +		bool latency_enabled{false}; +		bool velocity_enabled{false}; + +		int latency_offset; +		float velocity_offset; +		float latency_stddev; +		int laidback; +		float velocity_stddev; +		SettingsNotifier& settings_notifier; +		const int latency_max_samples; +	}; + +	Canvas canvas;  }; diff --git a/plugingui/humanizerframecontent.h b/plugingui/humanizerframecontent.h index 2cf708d..4befae0 100644 --- a/plugingui/humanizerframecontent.h +++ b/plugingui/humanizerframecontent.h @@ -56,8 +56,8 @@ private:  	GridLayout layout{this, 3, 1}; -	LabeledControl attack{this, "Attack"}; -	LabeledControl falloff{this, "Release"}; +	LabeledControl attack{this, "Attack"}; // drummer strength +	LabeledControl falloff{this, "Release"}; // regain  	LabeledControl stddev{this, "StdDev"};  	Knob attack_knob{&attack}; diff --git a/plugingui/maintab.cc b/plugingui/maintab.cc index 170d937..3aae788 100644 --- a/plugingui/maintab.cc +++ b/plugingui/maintab.cc @@ -41,6 +41,7 @@ MainTab::MainTab(Widget* parent,  	, bleedcontrolframe_content{this, settings, settings_notifier}  	, resamplingframe_content{this, settings_notifier}  	, timingframe_content{this, settings, settings_notifier} +	, visualizerframe_content{this, settings, settings_notifier}  	, settings(settings)  	, settings_notifier(settings_notifier)  { @@ -49,12 +50,13 @@ MainTab::MainTab(Widget* parent,  	add("Drumkit", drumkit_frame, drumkitframe_content, 15, 0);  	add("Status", status_frame, statusframe_content, 24, 0); -	add("Disk Streaming", diskstreaming_frame, diskstreamingframe_content, 10, 0); +	add("Resampling", resampling_frame, resamplingframe_content, 10, 0); -	add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 12, 1); -	add("Timing Humanizer", timing_frame, timingframe_content, 12, 1); -	add("Bleed Control", bleedcontrol_frame, bleedcontrolframe_content, 10, 1); -	add("Resampling", resampling_frame, resamplingframe_content, 15, 1); +	add("Velocity Humanizer", humanizer_frame, humanizerframe_content, 10, 1); +	add("Visualizer", visualizer_frame, visualizerframe_content, 10, 1); +	add("Timing Humanizer", timing_frame, timingframe_content, 10, 1); +	add("Bleed Control", bleedcontrol_frame, bleedcontrolframe_content, 9, 1); +	add("Disk Streaming", diskstreaming_frame, diskstreamingframe_content, 10, 1);  	humanizer_frame.setOnSwitch(settings.enable_velocity_modifier);  	bleedcontrol_frame.setOnSwitch(settings.enable_bleed_control); diff --git a/plugingui/maintab.h b/plugingui/maintab.h index c52205b..efd83e9 100644 --- a/plugingui/maintab.h +++ b/plugingui/maintab.h @@ -36,6 +36,7 @@  #include "bleedcontrolframecontent.h"  #include "resamplingframecontent.h"  #include "timingframecontent.h" +#include "visualizerframecontent.h"  struct Settings;  class SettingsNotifier; @@ -73,6 +74,7 @@ private:  	FrameWidget bleedcontrol_frame{this, true};  	FrameWidget resampling_frame{this, true};  	FrameWidget timing_frame{this, true}; +	FrameWidget visualizer_frame{this, false};  	DrumkitframeContent drumkitframe_content;  	StatusframeContent statusframe_content; @@ -81,6 +83,7 @@ private:  	BleedcontrolframeContent bleedcontrolframe_content;  	ResamplingframeContent resamplingframe_content;  	TimingframeContent timingframe_content; +	VisualizerframeContent visualizerframe_content;  	void add(std::string const& title, FrameWidget& frame, Widget& content,  	         std::size_t height, int column); diff --git a/plugingui/resources/stddev_horizontal.png b/plugingui/resources/stddev_horizontal.pngBinary files differ new file mode 100644 index 0000000..efed3cf --- /dev/null +++ b/plugingui/resources/stddev_horizontal.png diff --git a/plugingui/resources/stddev_horizontal_disabled.png b/plugingui/resources/stddev_horizontal_disabled.pngBinary files differ new file mode 100644 index 0000000..12c4f2f --- /dev/null +++ b/plugingui/resources/stddev_horizontal_disabled.png diff --git a/plugingui/resources/stddev_vertical.png b/plugingui/resources/stddev_vertical.pngBinary files differ new file mode 100644 index 0000000..50dab80 --- /dev/null +++ b/plugingui/resources/stddev_vertical.png diff --git a/plugingui/resources/stddev_vertical_disabled.png b/plugingui/resources/stddev_vertical_disabled.pngBinary files differ new file mode 100644 index 0000000..786f468 --- /dev/null +++ b/plugingui/resources/stddev_vertical_disabled.png diff --git a/plugingui/timingframecontent.cc b/plugingui/timingframecontent.cc index d6b4c29..d02f86f 100644 --- a/plugingui/timingframecontent.cc +++ b/plugingui/timingframecontent.cc @@ -40,7 +40,6 @@ TimingframeContent::TimingframeContent(Widget* parent,  	: Widget(parent)  	, settings(settings)  	, settings_notifier(settings_notifier) -	, visualiser(this, settings_notifier)  {  	layout.setResizeChildren(false); @@ -72,9 +71,6 @@ TimingframeContent::TimingframeContent(Widget* parent,  	layout.setPosition(®ain, GridLayout::GridRange{1, 2, 0, 1});  	layout.setPosition(&laidback, GridLayout::GridRange{2, 3, 0, 1}); -	visualiser.move(80, 40); -	visualiser.resize(40, 40); -  	CONNECT(this, settings_notifier.latency_stddev,  	        this, &TimingframeContent::tightnessSettingsValueChanged);  	CONNECT(this, settings_notifier.latency_regain, @@ -111,7 +107,7 @@ float TimingframeContent::tightnessSettingsToKnob(float value) const  float TimingframeContent::laidbackKnobToSettings(float value) const  {  	value -= 0.5f; -	value *= 2.0f; +	value *= 4.0f;  	value *= settings.latency_max.load();  	return std::lround(value); @@ -121,8 +117,8 @@ float TimingframeContent::laidbackSettingsToKnob(int int_value) const  {  	float value = int_value;  	value /= (float)settings.latency_max.load(); -	value *= 0.5; -	value += 0.5; +	value /= 4.0f; +	value += 0.5f;  	return value;  } diff --git a/plugingui/timingframecontent.h b/plugingui/timingframecontent.h index e0131e3..a8ed62c 100644 --- a/plugingui/timingframecontent.h +++ b/plugingui/timingframecontent.h @@ -31,7 +31,6 @@  #include "labeledcontrol.h"  #include "layout.h"  #include "widget.h" -#include "humaniservisualiser.h"  #include <settings.h> @@ -79,7 +78,6 @@ private:  	Settings& settings;  	SettingsNotifier& settings_notifier; -	HumaniserVisualiser visualiser;  };  } // GUI:: diff --git a/plugingui/visualizerframecontent.cc b/plugingui/visualizerframecontent.cc new file mode 100644 index 0000000..7e5b298 --- /dev/null +++ b/plugingui/visualizerframecontent.cc @@ -0,0 +1,51 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + *            visualizerframecontent.cc + * + *  Tue Jul 10 20:52:22 CEST 2018 + *  Copyright 2018 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 "visualizerframecontent.h" + +#include <cmath> +#include <iostream> + +#include "painter.h" + +namespace GUI +{ + +VisualizerframeContent::VisualizerframeContent(Widget* parent, +                                               Settings& settings, +                                               SettingsNotifier& settings_notifier) +	: Widget(parent) +	, visualizer(this, settings, settings_notifier) +{ +} + +void VisualizerframeContent::resize(std::size_t width, std::size_t height) +{ +	Widget::resize(width, height); +	visualizer.resize(width, height); +} + +} // GUI:: diff --git a/plugingui/visualizerframecontent.h b/plugingui/visualizerframecontent.h new file mode 100644 index 0000000..edf8f35 --- /dev/null +++ b/plugingui/visualizerframecontent.h @@ -0,0 +1,56 @@ +/* -*- Mode: c++ -*- */ +/*************************************************************************** + *            visualizerframecontent.h + * + *  Tue Jul 10 20:52:22 CEST 2018 + *  Copyright 2018 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. + */ +#pragma once +#include "layout.h" +#include "widget.h" +#include "humaniservisualiser.h" + +#include <settings.h> + +#include <iomanip> +#include <sstream> + +class SettingsNotifier; + +namespace GUI +{ + +class VisualizerframeContent +	: public Widget +{ +public: +	VisualizerframeContent(Widget* parent, Settings& settings, +	                       SettingsNotifier& settings_notifier); + +		// From Widget +	virtual void resize(std::size_t width, std::size_t height) override; + +private: +	HumaniserVisualiser visualizer; +}; + +} // GUI:: 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;  } | 
