summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2011-02-17 18:54:13 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2011-02-17 18:54:13 +0000
commit96cc6c3410c927ca14f50a52487e304967efdbf3 (patch)
tree1d583674cf6bbce3a1aecae26191716c79b8bd96
parent0d61f205ab4432480dc0e12787774f1d859f2dbf (diff)
draw pucks (signal positions) on vbap panner
git-svn-id: svn://localhost/ardour2/branches/3.0@8890 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--gtk2_ardour/panner2d.cc42
-rw-r--r--gtk2_ardour/panner2d.h1
-rw-r--r--libs/ardour/ardour/panner.h4
-rw-r--r--libs/panners/vbap/vbap.cc10
-rw-r--r--libs/panners/vbap/vbap.h1
-rw-r--r--libs/panners/vbap/vbap_speakers.cc8
-rw-r--r--libs/panners/vbap/vbap_speakers.h1
7 files changed, 40 insertions, 27 deletions
diff --git a/gtk2_ardour/panner2d.cc b/gtk2_ardour/panner2d.cc
index 4c22c5649f..40618a2210 100644
--- a/gtk2_ardour/panner2d.cc
+++ b/gtk2_ardour/panner2d.cc
@@ -24,10 +24,11 @@
#include <cairo.h>
#include <gtkmm/menu.h>
+#include "gtkmm2ext/gtk_ui.h"
+
#include "pbd/error.h"
#include "pbd/cartesian.h"
#include "ardour/panner.h"
-#include <gtkmm2ext/gtk_ui.h>
#include "panner2d.h"
#include "keyboard.h"
@@ -94,10 +95,6 @@ Panner2d::reset (uint32_t n_inputs)
pucks.resize (n_inputs);
}
- for (Targets::iterator x = pucks.begin(); x != pucks.end(); ++x) {
- (*x)->visible = false;
- }
-
switch (n_inputs) {
case 0:
break;
@@ -120,12 +117,9 @@ Panner2d::reset (uint32_t n_inputs)
break;
}
-#ifdef PANNER_HACKS
- for (uint32_t i = existing_pucks; i < n_inputs; ++i) {
- pucks[i]->position = panner->streampanner (i).get_position ();
- pucks[i]->visible = true;
- }
-#endif
+ for (uint32_t i = 0; i < n_inputs; ++i) {
+ pucks[i]->position = panner->signal_position (i);
+ }
/* add all outputs */
@@ -165,11 +159,16 @@ Panner2d::on_size_allocate (Gtk::Allocation& alloc)
width = alloc.get_width();
height = alloc.get_height();
+ /* our idea of our width/height must be "square
+ */
+
if (height > 100) {
width -= 20;
height -= 20;
}
+ dimen = min (width, height);
+
DrawingArea::on_size_allocate (alloc);
}
@@ -244,8 +243,6 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
which = 0;
pwhich = 0;
- cerr << "@ " << x << ", " << y << endl;
-
for (Targets::const_iterator i = pucks.begin(); i != pucks.end(); ++i, ++pwhich) {
candidate = *i;
@@ -257,8 +254,6 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
distance = sqrt ((c.x - x) * (c.x - x) +
(c.y - y) * (c.y - y));
- cerr << "\tConsider candiate " << candidate->text << " @ " << c.x << ", " << c.y << ", " << c.z << " distance = " << distance << endl;
-
if (distance < best_distance) {
closest = candidate;
best_distance = distance;
@@ -271,8 +266,6 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
return 0;
}
- cerr << "the winner is " << closest->text << endl;
-
return closest;
}
@@ -330,7 +323,7 @@ Panner2d::on_expose_event (GdkEventExpose *event)
/* the circle on which signals live */
- cairo_arc (cr, width/2, height/2, height/2, 0, 2.0 * M_PI);
+ cairo_arc (cr, width/2, height/2, dimen/2, 0, 2.0 * M_PI);
cairo_stroke (cr);
if (!panner->bypassed()) {
@@ -357,7 +350,7 @@ Panner2d::on_expose_event (GdkEventExpose *event)
puck->position.cartesian (c);
cart_to_gtk (c);
-
+
x = (gint) floor (c.x);
y = (gint) floor (c.y);
@@ -561,9 +554,12 @@ Panner2d::cart_to_gtk (CartesianVector& c) const
so max values along each axis are 0,width and
0,height
*/
+
+ const uint32_t hoffset = (width - dimen)/2;
+ const uint32_t voffset = (height - dimen)/2;
- c.x = (width / 2) * (c.x + 1);
- c.y = (height / 2) * (1 - c.y);
+ c.x = hoffset + ((dimen / 2) * (c.x + 1));
+ c.y = voffset + ((dimen / 2) * (1 - c.y));
/* XXX z-axis not handled - 2D for now */
}
@@ -571,8 +567,8 @@ Panner2d::cart_to_gtk (CartesianVector& c) const
void
Panner2d::gtk_to_cart (CartesianVector& c) const
{
- c.x = (c.x / (width / 2.0)) - 1.0;
- c.y = -((c.y / (height / 2.0)) - 1.0);
+ c.x = ((c.x / (dimen / 2.0)) - 1.0);
+ c.y = -((c.y / (dimen / 2.0)) - 1.0);
/* XXX z-axis not handled - 2D for now */
}
diff --git a/gtk2_ardour/panner2d.h b/gtk2_ardour/panner2d.h
index 4a324e4c8a..6580b99668 100644
--- a/gtk2_ardour/panner2d.h
+++ b/gtk2_ardour/panner2d.h
@@ -113,6 +113,7 @@ class Panner2d : public Gtk::DrawingArea
bool allow_target;
int width;
int height;
+ int dimen;
bool bypassflag;
diff --git a/libs/ardour/ardour/panner.h b/libs/ardour/ardour/panner.h
index 75f9ea598c..7ebfe5ee03 100644
--- a/libs/ardour/ardour/panner.h
+++ b/libs/ardour/ardour/panner.h
@@ -78,8 +78,10 @@ class Panner : public PBD::Stateful, public PBD::ScopedConnectionList
virtual double width () const { return 0.0; }
virtual double elevation () const { return 0.0; }
- virtual void reset() {}
+ virtual PBD::AngularVector signal_position (uint32_t) const { return PBD::AngularVector(); }
+ virtual void reset() {}
+
virtual bool bypassed() const { return _bypassed; }
virtual void set_bypassed (bool yn);
diff --git a/libs/panners/vbap/vbap.cc b/libs/panners/vbap/vbap.cc
index e563952efd..c76a514eaa 100644
--- a/libs/panners/vbap/vbap.cc
+++ b/libs/panners/vbap/vbap.cc
@@ -331,3 +331,13 @@ VBAPanner::value_as_string (boost::shared_ptr<AutomationControl> ac) const
return _pannable->value_as_string (ac);
}
}
+
+AngularVector
+VBAPanner::signal_position (uint32_t n) const
+{
+ if (n < _signals.size()) {
+ return _signals[n]->direction;
+ }
+
+ return AngularVector();
+}
diff --git a/libs/panners/vbap/vbap.h b/libs/panners/vbap/vbap.h
index 937199194f..183554132c 100644
--- a/libs/panners/vbap/vbap.h
+++ b/libs/panners/vbap/vbap.h
@@ -59,6 +59,7 @@ public:
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
+ PBD::AngularVector signal_position (uint32_t n) const;
private:
struct Signal {
diff --git a/libs/panners/vbap/vbap_speakers.cc b/libs/panners/vbap/vbap_speakers.cc
index 506ad4a25b..bf87791b60 100644
--- a/libs/panners/vbap/vbap_speakers.cc
+++ b/libs/panners/vbap/vbap_speakers.cc
@@ -45,9 +45,9 @@ using namespace std;
VBAPSpeakers::VBAPSpeakers (boost::shared_ptr<Speakers> s)
: _dimension (2)
- , _speakers (s->speakers())
+ , parent (s)
{
- // s.Changed.connect_same_thread (speaker_connection, boost::bind (&VBAPSpeakers::update, this));
+ parent->Changed.connect_same_thread (speaker_connection, boost::bind (&VBAPSpeakers::update, this));
update ();
}
@@ -59,7 +59,9 @@ void
VBAPSpeakers::update ()
{
int dim = 2;
-
+
+ _speakers = parent->speakers();
+
for (vector<Speaker>::const_iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
if ((*i).angles().ele != 0.0) {
cerr << "\n\n\nSPEAKER " << (*i).id << " has ele = " << (*i).angles().ele << "\n\n\n\n";
diff --git a/libs/panners/vbap/vbap_speakers.h b/libs/panners/vbap/vbap_speakers.h
index 3bd298ba3d..85cd75d085 100644
--- a/libs/panners/vbap/vbap_speakers.h
+++ b/libs/panners/vbap/vbap_speakers.h
@@ -51,6 +51,7 @@ public:
private:
static const double MIN_VOL_P_SIDE_LGTH = 0.01;
int _dimension;
+ boost::shared_ptr<Speakers> parent;
std::vector<Speaker> _speakers;
PBD::ScopedConnection speaker_connection;