diff options
author | David Robillard <d@drobilla.net> | 2013-02-03 22:29:15 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2013-02-03 22:29:15 +0000 |
commit | c2f0d423f8881376b8e9642a6ab92d9506cdfb41 (patch) | |
tree | 457ded511bac9926b2855717888e23daa38dd6f0 /src | |
parent | 32044a3733aab0f913c86738ebabbe63aed7f1d6 (diff) | |
download | ingen-c2f0d423f8881376b8e9642a6ab92d9506cdfb41.tar.gz ingen-c2f0d423f8881376b8e9642a6ab92d9506cdfb41.tar.bz2 ingen-c2f0d423f8881376b8e9642a6ab92d9506cdfb41.zip |
Port control performance improvements (further improvement for #879).
Only request a redraw, not a full update, where appropriate.
Use a raw double instead of GVariant for port control-changed signal.
git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@5045 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/Port.cpp | 9 | ||||
-rw-r--r-- | src/gui/Port.hpp | 2 | ||||
-rw-r--r-- | src/server/Engine.cpp | 2 | ||||
-rw-r--r-- | src/server/Engine.hpp | 8 | ||||
-rw-r--r-- | src/server/PortImpl.cpp | 2 |
5 files changed, 14 insertions, 9 deletions
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp index d1c0eda3..0ab079c5 100644 --- a/src/gui/Port.cpp +++ b/src/gui/Port.cpp @@ -152,14 +152,9 @@ Port::moved() } void -Port::on_value_changed(GVariant* value) +Port::on_value_changed(double value) { - if (!g_variant_is_of_type(value, G_VARIANT_TYPE_DOUBLE)) { - _app.log().warn("TODO: Non-float port value changed\n"); - return; - } - - const Raul::Atom atom = _app.forge().make(float(g_variant_get_double(value))); + const Raul::Atom atom = _app.forge().make(float(value)); if (atom != model()->value()) { Ingen::World* const world = _app.world(); _app.interface()->set_property(model()->uri(), diff --git a/src/gui/Port.hpp b/src/gui/Port.hpp index 67862e17..7d95009a 100644 --- a/src/gui/Port.hpp +++ b/src/gui/Port.hpp @@ -80,7 +80,7 @@ private: void property_changed(const Raul::URI& key, const Raul::Atom& value); void moved(); - void on_value_changed(GVariant* value); + void on_value_changed(double value); void on_scale_point_activated(float f); void on_uri_activated(const Raul::URI& uri); bool on_event(GdkEvent* ev); diff --git a/src/server/Engine.cpp b/src/server/Engine.cpp index 1af7be1b..3d76a032 100644 --- a/src/server/Engine.cpp +++ b/src/server/Engine.cpp @@ -64,6 +64,8 @@ Engine::Engine(Ingen::World* world) , _root_graph(NULL) , _worker(new Worker(world->log(), event_queue_size())) , _process_context(*this) + , _rand_engine(0) + , _uniform_dist(0.0f, 1.0f) , _quit_flag(false) , _direct_driver(true) { diff --git a/src/server/Engine.hpp b/src/server/Engine.hpp index e7327ef4..851b3127 100644 --- a/src/server/Engine.hpp +++ b/src/server/Engine.hpp @@ -17,6 +17,8 @@ #ifndef INGEN_ENGINE_ENGINE_HPP #define INGEN_ENGINE_ENGINE_HPP +#include <random> + #include <boost/utility.hpp> #include "ingen/EngineBase.hpp" @@ -76,6 +78,9 @@ public: SPtr<Interface> client); virtual bool unregister_client(const Raul::URI& uri); + /** Return a random [0..1] float with uniform distribution */ + float frand() { return _uniform_dist(_rand_engine); } + void set_driver(SPtr<Driver> driver); SampleCount event_time(); @@ -128,6 +133,9 @@ private: ProcessContext _process_context; + std::mt19937 _rand_engine; + std::uniform_real_distribution<float> _uniform_dist; + bool _quit_flag; bool _direct_driver; }; diff --git a/src/server/PortImpl.cpp b/src/server/PortImpl.cpp index 950c8739..0e71de96 100644 --- a/src/server/PortImpl.cpp +++ b/src/server/PortImpl.cpp @@ -147,7 +147,7 @@ PortImpl::activate(BufferFactory& bufs) */ const double srate = bufs.engine().driver()->sample_rate(); const uint32_t period = srate / monitor_rate; - _frames_since_monitor = rand() % period; + _frames_since_monitor = bufs.engine().frand() * period; _last_monitor_value = 0.0f; } |