summaryrefslogtreecommitdiffstats
path: root/src/gui
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2016-10-01 05:46:29 -0400
committerDavid Robillard <d@drobilla.net>2016-10-02 12:24:57 -0400
commit0f50e9239bbda77ce38f297870f8cf4158025acc (patch)
tree89e255ade0257ca3f1adf9d1e9d8a81195b45d15 /src/gui
parent9b8bce71893ef450992f82a28a6a0287c479baaf (diff)
downloadingen-0f50e9239bbda77ce38f297870f8cf4158025acc.tar.gz
ingen-0f50e9239bbda77ce38f297870f8cf4158025acc.tar.bz2
ingen-0f50e9239bbda77ce38f297870f8cf4158025acc.zip
Show audio and load information in status line
Diffstat (limited to 'src/gui')
-rw-r--r--src/gui/App.cpp81
-rw-r--r--src/gui/App.hpp21
-rw-r--r--src/gui/GraphBox.cpp14
-rw-r--r--src/gui/GraphBox.hpp3
-rw-r--r--src/gui/Port.cpp37
-rw-r--r--src/gui/rgba.hpp58
6 files changed, 170 insertions, 44 deletions
diff --git a/src/gui/App.cpp b/src/gui/App.cpp
index c023fe8c..a3055c91 100644
--- a/src/gui/App.cpp
+++ b/src/gui/App.cpp
@@ -51,6 +51,7 @@
#include "ThreadedLoader.hpp"
#include "WidgetFactory.hpp"
#include "WindowFactory.hpp"
+#include "rgba.hpp"
using namespace std;
@@ -74,6 +75,11 @@ App::App(Ingen::World* world)
, _window_factory(new WindowFactory(*this))
, _world(world)
, _sample_rate(48000)
+ , _block_length(1024)
+ , _n_threads(1)
+ , _max_event_load(0.0f)
+ , _min_run_load(0.0f)
+ , _max_run_load(0.0f)
, _enable_signal(true)
, _requested_plugins(false)
, _is_plugin(false)
@@ -193,6 +199,8 @@ App::attach(SPtr<SigClientInterface> client)
sigc::mem_fun(this, &App::response));
_client->signal_error().connect(
sigc::mem_fun(this, &App::error_message));
+ _client->signal_put().connect(
+ sigc::mem_fun(this, &App::put));
_client->signal_property_change().connect(
sigc::mem_fun(this, &App::property_change));
}
@@ -271,18 +279,77 @@ App::set_tooltip(Gtk::Widget* widget, const LilvNode* node)
}
void
+App::put(const Raul::URI& uri,
+ const Resource::Properties& properties,
+ Resource::Graph ctx)
+{
+ _enable_signal = false;
+ for (const auto& p : properties) {
+ property_change(uri, p.first, p.second);
+ }
+ _enable_signal = true;
+ _status_text = status_text();
+ signal_status_text_changed.emit(_status_text);
+}
+
+void
App::property_change(const Raul::URI& subject,
const Raul::URI& key,
const Atom& value)
{
- if (subject == Raul::URI("ingen:/engine") && key == uris().param_sampleRate) {
- if (value.type() == forge().Int) {
- log().info(fmt("Sample rate: %1%\n") % uris().forge.str(value));
- _sample_rate = value.get<int32_t>();
- } else {
- log().error("Engine sample rate property is not an integer\n");
- }
+ if (subject != Raul::URI("ingen:/engine")) {
+ return;
+ } else if (key == uris().param_sampleRate && value.type() == forge().Int) {
+ _sample_rate = value.get<int32_t>();
+ } else if (key == uris().bufsz_maxBlockLength && value.type() == forge().Int) {
+ _block_length = value.get<int32_t>();
+ } else if (key == uris().ingen_numThreads && value.type() == forge().Int) {
+ _n_threads = value.get<int>();
+ } else if (key == uris().ingen_maxEventLoad && value.type() == forge().Float) {
+ _max_event_load = value.get<float>();
+ } else if (key == uris().ingen_minRunLoad && value.type() == forge().Float) {
+ _min_run_load = value.get<float>();
+ } else if (key == uris().ingen_meanRunLoad && value.type() == forge().Float) {
+ _mean_run_load = value.get<float>();
+ } else if (key == uris().ingen_maxRunLoad && value.type() == forge().Float) {
+ _max_run_load = value.get<float>();
+ } else {
+ _world->log().warn(fmt("Unknown engine property %1%\n") % key);
+ return;
}
+
+ if (_enable_signal) {
+ _status_text = status_text();
+ signal_status_text_changed.emit(_status_text);
+ }
+}
+
+static std::string
+fraction_label(float f)
+{
+ static const uint32_t GREEN = 0x4A8A0EFF;
+ static const uint32_t RED = 0x960909FF;
+
+ const uint32_t col = rgba_interpolate(GREEN, RED, std::min(f, 1.0f));
+ char col_str[8];
+ snprintf(col_str, sizeof(col_str), "%02X%02X%02X",
+ RGBA_R(col), RGBA_G(col), RGBA_B(col));
+ return (fmt("<span color='#%s'>%d%%</span>") % col_str % (f * 100)).str();
+}
+
+std::string
+App::status_text() const
+{
+ return (fmt("<b>Audio:</b> %2.1f kHz / %.1f ms <b>Load: </b> %s events + %s <b>DSP:</b> %s ≤ %s ≤ %s")
+ % (_sample_rate / 1e3f)
+ % (_block_length * 1e3f / (float)_sample_rate)
+ % fraction_label(_max_event_load)
+ % ((_n_threads == 1)
+ ? "1 thread"
+ : (fmt("%1% threads") % _n_threads).str())
+ % fraction_label(_min_run_load)
+ % fraction_label(_mean_run_load)
+ % fraction_label(_max_run_load)).str();
}
void
diff --git a/src/gui/App.hpp b/src/gui/App.hpp
index 6071c750..61336747 100644
--- a/src/gui/App.hpp
+++ b/src/gui/App.hpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-2016 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -25,6 +25,7 @@
#include <gtkmm/window.h>
#include "ingen/Atom.hpp"
+#include "ingen/Resource.hpp"
#include "ingen/Status.hpp"
#include "ingen/World.hpp"
#include "ingen/ingen.h"
@@ -125,8 +126,13 @@ public:
SPtr<Serialiser> serialiser();
static SPtr<App> create(Ingen::World* world);
+
void run();
+ std::string status_text() const;
+
+ sigc::signal<void, const std::string&> signal_status_text_changed;
+
inline Ingen::World* world() const { return _world; }
inline Ingen::URIs& uris() const { return _world->uris(); }
inline Ingen::Log& log() const { return _world->log(); }
@@ -137,6 +143,10 @@ protected:
bool animate();
void response(int32_t id, Ingen::Status status, const std::string& subject);
+ void put(const Raul::URI& uri,
+ const Resource::Properties& properties,
+ Resource::Graph ctx);
+
void property_change(const Raul::URI& subject,
const Raul::URI& key,
const Atom& value);
@@ -158,7 +168,14 @@ protected:
Ingen::World* _world;
- uint32_t _sample_rate;
+ int32_t _sample_rate;
+ int32_t _block_length;
+ int32_t _n_threads;
+ float _max_event_load;
+ float _mean_run_load;
+ float _min_run_load;
+ float _max_run_load;
+ std::string _status_text;
typedef std::map<Port*, bool> ActivityPorts;
ActivityPorts _activity_ports;
diff --git a/src/gui/GraphBox.cpp b/src/gui/GraphBox.cpp
index 10f063cc..692e378a 100644
--- a/src/gui/GraphBox.cpp
+++ b/src/gui/GraphBox.cpp
@@ -179,6 +179,10 @@ GraphBox::GraphBox(BaseObjectType* cobject,
Glib::RefPtr<Gtk::Clipboard> clipboard = Gtk::Clipboard::get();
clipboard->signal_owner_change().connect(
sigc::mem_fun(this, &GraphBox::event_clipboard_changed));
+
+ _status_label = Gtk::manage(new Gtk::Label("STATUS"));
+ _status_bar->pack_start(*_status_label, false, true, 0);
+ _status_label->show();
}
GraphBox::~GraphBox()
@@ -228,6 +232,16 @@ GraphBox::init_box(App& app)
_breadcrumbs = new BreadCrumbs(*_app);
_breadcrumbs->signal_graph_selected.connect(
sigc::mem_fun(this, &GraphBox::set_graph_from_path));
+
+ _status_label->set_markup(app.status_text());
+ app.signal_status_text_changed.connect(
+ sigc::mem_fun(*this, &GraphBox::set_status_text));
+}
+
+void
+GraphBox::set_status_text(const std::string& text)
+{
+ _status_label->set_markup(text);
}
void
diff --git a/src/gui/GraphBox.hpp b/src/gui/GraphBox.hpp
index 0a55227e..af17a1ac 100644
--- a/src/gui/GraphBox.hpp
+++ b/src/gui/GraphBox.hpp
@@ -73,6 +73,8 @@ public:
void init_box(App& app);
+ void set_status_text(const std::string& text);
+
void set_graph(SPtr<const Client::GraphModel> graph,
SPtr<GraphView> view);
@@ -186,6 +188,7 @@ private:
Gtk::Alignment* _alignment;
BreadCrumbs* _breadcrumbs;
Gtk::Statusbar* _status_bar;
+ Gtk::Label* _status_label;
Gtk::HPaned* _doc_paned;
Gtk::ScrolledWindow* _doc_scrolledwindow;
diff --git a/src/gui/Port.cpp b/src/gui/Port.cpp
index 1a9750a6..c643b379 100644
--- a/src/gui/Port.cpp
+++ b/src/gui/Port.cpp
@@ -1,6 +1,6 @@
/*
This file is part of Ingen.
- Copyright 2007-2015 David Robillard <http://drobilla.net/>
+ Copyright 2007-2016 David Robillard <http://drobilla.net/>
Ingen is free software: you can redistribute it and/or modify it under the
terms of the GNU Affero General Public License as published by the Free
@@ -33,6 +33,7 @@
#include "WidgetFactory.hpp"
#include "WindowFactory.hpp"
#include "ingen_config.h"
+#include "rgba.hpp"
using namespace Ingen::Client;
using namespace std;
@@ -339,38 +340,6 @@ Port::on_event(GdkEvent* ev)
return false;
}
-/* Peak colour stuff */
-
-static inline uint32_t
-rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
-{
- return ((((uint32_t)(r)) << 24) |
- (((uint32_t)(g)) << 16) |
- (((uint32_t)(b)) << 8) |
- (((uint32_t)(a))));
-}
-
-static inline uint8_t
-mono_interpolate(uint8_t v1, uint8_t v2, float f)
-{
- return ((int)rint((v2) * (f) + (v1) * (1 - (f))));
-}
-
-#define RGBA_R(x) (((uint32_t)(x)) >> 24)
-#define RGBA_G(x) ((((uint32_t)(x)) >> 16) & 0xFF)
-#define RGBA_B(x) ((((uint32_t)(x)) >> 8) & 0xFF)
-#define RGBA_A(x) (((uint32_t)(x)) & 0xFF)
-
-static inline uint32_t
-rgba_interpolate(uint32_t c1, uint32_t c2, float f)
-{
- return rgba_to_uint(
- mono_interpolate(RGBA_R(c1), RGBA_R(c2), f),
- mono_interpolate(RGBA_G(c1), RGBA_G(c2), f),
- mono_interpolate(RGBA_B(c1), RGBA_B(c2), f),
- mono_interpolate(RGBA_A(c1), RGBA_A(c2), f));
-}
-
inline static uint32_t
peak_color(float peak)
{
@@ -386,8 +355,6 @@ peak_color(float peak)
}
}
-/* End peak colour stuff */
-
void
Port::activity(const Atom& value)
{
diff --git a/src/gui/rgba.hpp b/src/gui/rgba.hpp
new file mode 100644
index 00000000..8648aece
--- /dev/null
+++ b/src/gui/rgba.hpp
@@ -0,0 +1,58 @@
+/*
+ This file is part of Ingen.
+ Copyright 2007-2016 David Robillard <http://drobilla.net/>
+
+ Ingen is free software: you can redistribute it and/or modify it under the
+ terms of the GNU Affero General Public License as published by the Free
+ Software Foundation, either version 3 of the License, or any later version.
+
+ Ingen 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 Affero General Public License for details.
+
+ You should have received a copy of the GNU Affero General Public License
+ along with Ingen. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef INGEN_GUI_RGBA_HPP
+#define INGEN_GUI_RGBA_HPP
+
+#include <math.h>
+
+namespace Ingen {
+namespace GUI {
+
+static inline uint32_t
+rgba_to_uint(uint8_t r, uint8_t g, uint8_t b, uint8_t a)
+{
+ return ((((uint32_t)(r)) << 24) |
+ (((uint32_t)(g)) << 16) |
+ (((uint32_t)(b)) << 8) |
+ (((uint32_t)(a))));
+}
+
+static inline uint8_t
+mono_interpolate(uint8_t v1, uint8_t v2, float f)
+{
+ return ((int)rint((v2) * (f) + (v1) * (1 - (f))));
+}
+
+#define RGBA_R(x) (((uint32_t)(x)) >> 24)
+#define RGBA_G(x) ((((uint32_t)(x)) >> 16) & 0xFF)
+#define RGBA_B(x) ((((uint32_t)(x)) >> 8) & 0xFF)
+#define RGBA_A(x) (((uint32_t)(x)) & 0xFF)
+
+static inline uint32_t
+rgba_interpolate(uint32_t c1, uint32_t c2, float f)
+{
+ return rgba_to_uint(
+ mono_interpolate(RGBA_R(c1), RGBA_R(c2), f),
+ mono_interpolate(RGBA_G(c1), RGBA_G(c2), f),
+ mono_interpolate(RGBA_B(c1), RGBA_B(c2), f),
+ mono_interpolate(RGBA_A(c1), RGBA_A(c2), f));
+}
+
+} // namespace GUI
+} // namespace Ingen
+
+#endif // INGEN_GUI_RGBA_HPP