summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-09-14 22:49:22 +0000
committerDavid Robillard <d@drobilla.net>2011-09-14 22:49:22 +0000
commit728f510e8c542db2907dcd439a9ab99d07282220 (patch)
tree6aa01740b1def7a1fa0a32e22fef929bdc231a62 /src/gui
parente18380569bdbe1926be7540f3e2f9ebdf49a8e70 (diff)
downloadingen-728f510e8c542db2907dcd439a9ab99d07282220.tar.gz
ingen-728f510e8c542db2907dcd439a9ab99d07282220.tar.bz2
ingen-728f510e8c542db2907dcd439a9ab99d07282220.zip
Support lv2:sampleRate controls (mostly) correctly.
Fix initial control port values (was always 0.0). Fix numeric values in control window. git-svn-id: http://svn.drobilla.net/lad/trunk/ingen@3460 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/App.cpp28
-rw-r--r--src/gui/App.hpp8
-rw-r--r--src/gui/Controls.cpp10
-rw-r--r--src/gui/NodeMenu.cpp2
-rw-r--r--src/gui/Port.cpp22
-rw-r--r--src/gui/PortPropertiesWindow.cpp3
6 files changed, 58 insertions, 15 deletions
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index edd4ec06..35d31b3e 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -50,6 +50,8 @@
#include "WindowFactory.hpp"
#include "Port.hpp"
+#define LOG(s) s << "[GUI] "
+
using namespace std;
using namespace Raul;
using namespace Ingen::Client;
@@ -73,6 +75,7 @@ App::App(Ingen::Shared::World* world)
, _about_dialog(NULL)
, _window_factory(new WindowFactory())
, _world(world)
+ , _sample_rate(48000)
, _enable_signal(true)
{
Glib::set_application_name("Ingen");
@@ -146,7 +149,7 @@ App::run()
{
assert(_main);
_main->run();
- info << "[GUI] Exiting" << endl;
+ LOG(info) << "Exiting" << endl;
}
void
@@ -168,6 +171,8 @@ App::attach(SharedPtr<SigClientInterface> client)
sigc::mem_fun(this, &App::error_response));
_client->signal_error().connect(
sigc::mem_fun(this, &App::error_message));
+ _client->signal_property_change().connect(
+ sigc::mem_fun(this, &App::property_change));
}
void
@@ -211,6 +216,21 @@ App::error_message(const string& str)
}
void
+App::property_change(const Raul::URI& subject,
+ const Raul::URI& key,
+ const Raul::Atom& value)
+{
+ if (subject == uris().ingen_engine && key == uris().ingen_sampleRate) {
+ if (value.type() == Atom::INT) {
+ LOG(info) << "Sample rate: " << value << std::endl;
+ _sample_rate = value.get_int32();
+ } else {
+ error << "Engine sample rate property is not an integer" << std::endl;
+ }
+ }
+}
+
+void
App::port_activity(Port* port)
{
std::pair<ActivityPorts::iterator, bool> inserted = _activity_ports.insert(make_pair(port, false));
@@ -373,6 +393,12 @@ App::can_control(const Ingen::Port* port) const
|| port->supports(uris().atom_String)));
}
+uint32_t
+App::sample_rate() const
+{
+ return _sample_rate;
+}
+
} // namespace GUI
} // namespace Ingen
diff --git a/src/gui/App.hpp b/src/gui/App.hpp
index 96cd0152..bd753078 100644
--- a/src/gui/App.hpp
+++ b/src/gui/App.hpp
@@ -92,6 +92,8 @@ public:
bool disable_signals() { bool old = _enable_signal; _enable_signal = false; return old; }
void enable_signals(bool b) { _enable_signal = b; }
+ uint32_t sample_rate() const;
+
ConnectWindow* connect_window() const { return _connect_window; }
MessagesWindow* messages_dialog() const { return _messages_window; }
PatchTreeWindow* patch_tree() const { return _patch_tree_window; }
@@ -136,6 +138,10 @@ protected:
bool animate();
void error_response(int32_t id, const std::string& str);
+ void property_change(const Raul::URI& subject,
+ const Raul::URI& key,
+ const Raul::Atom& value);
+
static void* icon_destroyed(void* data);
static Gtk::Main* _main;
@@ -155,6 +161,8 @@ protected:
Ingen::Shared::World* _world;
+ uint32_t _sample_rate;
+
typedef std::map<Port*, bool> ActivityPorts;
ActivityPorts _activity_ports;
diff --git a/src/gui/Controls.cpp b/src/gui/Controls.cpp
index 98b1c726..e31c8d52 100644
--- a/src/gui/Controls.cpp
+++ b/src/gui/Controls.cpp
@@ -152,7 +152,7 @@ SliderControl::init(ControlPanel* panel, SharedPtr<const PortModel> pm)
boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
if (parent)
- parent->port_value_range(_port_model, min, max);
+ parent->port_value_range(_port_model, min, max, App::instance().sample_rate());
if (pm->is_integer() || pm->is_toggle()) {
_slider->set_increments(1, 10);
@@ -164,7 +164,8 @@ SliderControl::init(ControlPanel* panel, SharedPtr<const PortModel> pm)
pm->signal_property().connect(
sigc::mem_fun(this, &SliderControl::port_property_changed));
- _slider->set_range(std::min(min, pm->value().get_float()), std::max(max, pm->value().get_float()));
+ set_range(std::min(min, pm->value().get_float()),
+ std::max(max, pm->value().get_float()));
set_value(pm->value());
@@ -201,10 +202,8 @@ SliderControl::set_value(const Atom& atom)
if (val < lower || val > upper)
set_range(min(lower, val), max(lower, val));
_slider->set_value(val);
- }
-
- if (_value_spinner->get_value() != val)
_value_spinner->set_value(val);
+ }
_enable_signal = true;
}
@@ -231,6 +230,7 @@ SliderControl::set_range(float min, float max)
max = min + 1.0;
_slider->set_range(min, max);
+ _value_spinner->set_range(min, max);
}
void
diff --git a/src/gui/NodeMenu.cpp b/src/gui/NodeMenu.cpp
index 6cbba39d..0432d888 100644
--- a/src/gui/NodeMenu.cpp
+++ b/src/gui/NodeMenu.cpp
@@ -142,7 +142,7 @@ NodeMenu::on_menu_randomize()
for (NodeModel::Ports::const_iterator i = nm->ports().begin(); i != nm->ports().end(); ++i) {
if ((*i)->is_input() && App::instance().can_control(i->get())) {
float min = 0.0f, max = 1.0f;
- nm->port_value_range(*i, min, max);
+ nm->port_value_range(*i, min, max, App::instance().sample_rate());
const float val = ((rand() / (float)RAND_MAX) * (max - min) + min);
App::instance().engine()->set_property((*i)->path(),
App::instance().uris().ingen_value, val);
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 25edf685..9b2a1c8f 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -111,7 +111,7 @@ Port::update_metadata()
if (parent) {
float min = 0.0f;
float max = 1.0f;
- parent->port_value_range(pm, min, max);
+ parent->port_value_range(pm, min, max, App::instance().sample_rate());
set_control_min(min);
set_control_max(max);
}
@@ -193,12 +193,20 @@ Port::property_changed(const URI& key, const Atom& value)
{
const LV2URIMap& uris = App::instance().uris();
if (value.type() == Atom::FLOAT) {
- if (key == uris.ingen_value && !_pressed)
- set_control(value.get_float(), false);
- else if (key == uris.lv2_minimum)
- set_control_min(value.get_float());
- else if (key == uris.lv2_maximum)
- set_control_max(value.get_float());
+ float val = value.get_float();
+ if (key == uris.ingen_value && !_pressed) {
+ set_control(val, false);
+ } else if (key == uris.lv2_minimum) {
+ if (model()->port_property(uris.lv2_sampleRate)) {
+ val *= App::instance().sample_rate();
+ }
+ set_control_min(val);
+ } else if (key == uris.lv2_maximum) {
+ if (model()->port_property(uris.lv2_sampleRate)) {
+ val *= App::instance().sample_rate();
+ }
+ set_control_max(val);
+ }
} else if (key == uris.lv2_portProperty) {
if (value == uris.lv2_toggled)
set_toggled(true);
diff --git a/src/gui/PortPropertiesWindow.cpp b/src/gui/PortPropertiesWindow.cpp
index a584939c..0b51074b 100644
--- a/src/gui/PortPropertiesWindow.cpp
+++ b/src/gui/PortPropertiesWindow.cpp
@@ -70,7 +70,8 @@ PortPropertiesWindow::present(SharedPtr<const PortModel> pm)
float min = 0.0f, max = 1.0f;
boost::shared_ptr<NodeModel> parent = PtrCast<NodeModel>(_port_model->parent());
if (parent)
- parent->port_value_range(_port_model, min, max);
+ parent->port_value_range(_port_model, min, max,
+ App::instance().sample_rate());
_initial_min = min;
_initial_max = max;