summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--gtk2_ardour/panner2d.cc137
-rw-r--r--gtk2_ardour/panner2d.h52
-rw-r--r--libs/ardour/ardour/panner.h45
-rw-r--r--libs/ardour/ardour/session.h8
-rw-r--r--libs/ardour/ardour/speaker.h18
-rw-r--r--libs/ardour/ardour/speakers.h26
-rw-r--r--libs/ardour/ardour/vbap.h38
-rw-r--r--libs/ardour/ardour/vbap_speakers.h110
-rw-r--r--libs/ardour/panner.cc187
-rw-r--r--libs/ardour/session.cc809
-rw-r--r--libs/ardour/speakers.cc73
-rw-r--r--libs/ardour/vbap.cc193
-rw-r--r--libs/ardour/vbap_speakers.cc974
-rw-r--r--libs/ardour/wscript2
-rw-r--r--libs/pbd/cartesian.cc88
-rw-r--r--libs/pbd/pbd/cartesian.h125
-rw-r--r--libs/surfaces/mackie/mackie_control_protocol.cc8
17 files changed, 1446 insertions, 1447 deletions
diff --git a/gtk2_ardour/panner2d.cc b/gtk2_ardour/panner2d.cc
index 2864bfe607..0700685056 100644
--- a/gtk2_ardour/panner2d.cc
+++ b/gtk2_ardour/panner2d.cc
@@ -44,7 +44,7 @@ using Gtkmm2ext::Keyboard;
Panner2d::Target::Target (const AngularVector& a, const char *txt)
: position (a)
, text (txt)
- , _selected (false)
+ , _selected (false)
{
}
@@ -209,7 +209,7 @@ Panner2d::handle_position_change ()
}
for (n = 0; n < targets.size(); ++n) {
- targets[n]->position = panner->output(n).position;
+ targets[n]->position = panner->output(n).position;
}
queue_draw ();
@@ -238,20 +238,20 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
which = 0;
pwhich = 0;
- cerr << "@ " << x << ", " << y << endl;
+ cerr << "@ " << x << ", " << y << endl;
for (Targets::const_iterator i = pucks.begin(); i != pucks.end(); ++i, ++pwhich) {
candidate = *i;
- CartesianVector c;
+ CartesianVector c;
- candidate->position.cartesian (c);
- cart_to_gtk (c);
+ candidate->position.cartesian (c);
+ cart_to_gtk (c);
distance = sqrt ((c.x - x) * (c.x - x) +
- (c.y - y) * (c.y - y));
+ (c.y - y) * (c.y - y));
- cerr << "\tConsider candiate " << candidate->text << " @ " << c.x << ", " << c.y << ", " << c.z << " distance = " << distance << endl;
+ cerr << "\tConsider candiate " << candidate->text << " @ " << c.x << ", " << c.y << ", " << c.z << " distance = " << distance << endl;
if (distance < best_distance) {
closest = candidate;
@@ -261,11 +261,11 @@ Panner2d::find_closest_object (gdouble x, gdouble y, int& which) const
}
- if (best_distance > 20) { // arbitrary
- return 0;
- }
+ if (best_distance > 20) { // arbitrary
+ return 0;
+ }
- cerr << "the winner is " << closest->text << endl;
+ cerr << "the winner is " << closest->text << endl;
return closest;
}
@@ -309,20 +309,20 @@ Panner2d::on_expose_event (GdkEventExpose *event)
cairo_translate (cr, 10.0, 10.0);
}
- /* horizontal line of "crosshairs" */
+ /* horizontal line of "crosshairs" */
cairo_set_source_rgb (cr, 0.0, 0.1, 0.7);
cairo_move_to (cr, 0.5, height/2.0+0.5);
cairo_line_to (cr, width+0.5, height/2+0.5);
cairo_stroke (cr);
- /* vertical line of "crosshairs" */
-
+ /* vertical line of "crosshairs" */
+
cairo_move_to (cr, width/2+0.5, 0.5);
cairo_line_to (cr, width/2+0.5, height+0.5);
cairo_stroke (cr);
- /* the circle on which signals live */
+ /* the circle on which signals live */
cairo_arc (cr, width/2, height/2, height/2, 0, 2.0 * M_PI);
cairo_stroke (cr);
@@ -347,15 +347,15 @@ Panner2d::on_expose_event (GdkEventExpose *event)
if (puck->visible) {
/* redraw puck */
- CartesianVector c;
+ CartesianVector c;
- puck->position.cartesian (c);
- cart_to_gtk (c);
+ puck->position.cartesian (c);
+ cart_to_gtk (c);
- x = (gint) floor (c.x);
- y = (gint) floor (c.y);
+ x = (gint) floor (c.x);
+ y = (gint) floor (c.y);
- /* XXX need to shift circles so that they are centered on the circle */
+ /* XXX need to shift circles so that they are centered on the circle */
cairo_arc (cr, x, y, arc_radius, 0, 2.0 * M_PI);
cairo_set_source_rgb (cr, 0.8, 0.2, 0.1);
@@ -364,8 +364,8 @@ Panner2d::on_expose_event (GdkEventExpose *event)
cairo_move_to (cr, x + 6, y + 6);
- char buf[256];
- snprintf (buf, sizeof (buf), "%s:%d", puck->text.c_str(), (int) lrint (puck->position.azi));
+ char buf[256];
+ snprintf (buf, sizeof (buf), "%s:%d", puck->text.c_str(), (int) lrint (puck->position.azi));
cairo_show_text (cr, buf);
}
}
@@ -381,13 +381,13 @@ Panner2d::on_expose_event (GdkEventExpose *event)
if (target->visible) {
- CartesianVector c;
+ CartesianVector c;
- target->position.cartesian (c);
- cart_to_gtk (c);
+ target->position.cartesian (c);
+ cart_to_gtk (c);
- x = (int) floor (c.x);
- y = (int) floor (c.y);
+ x = (int) floor (c.x);
+ y = (int) floor (c.y);
snprintf (buf, sizeof (buf), "%d", n);
@@ -419,8 +419,8 @@ Panner2d::on_button_press_event (GdkEventButton *ev)
case 1:
case 2:
if ((drag_target = find_closest_object (ev->x, ev->y, drag_index)) != 0) {
- drag_target->set_selected (true);
- }
+ drag_target->set_selected (true);
+ }
drag_x = (int) floor (ev->x);
drag_y = (int) floor (ev->y);
@@ -458,7 +458,7 @@ Panner2d::on_button_release_event (GdkEventButton *ev)
queue_draw ();
PuckMoved (-1);
- ret = true;
+ ret = true;
} else {
ret = handle_motion (x, y, state);
@@ -503,33 +503,32 @@ Panner2d::handle_motion (gint evx, gint evy, GdkModifierType state)
if (state & GDK_BUTTON1_MASK && !(state & GDK_BUTTON2_MASK)) {
-
- CartesianVector c;
- bool need_move = false;
+ CartesianVector c;
+ bool need_move = false;
- drag_target->position.cartesian (c);
- cart_to_gtk (c);
+ drag_target->position.cartesian (c);
+ cart_to_gtk (c);
- if ((evx != c.x) || (evy != c.y)) {
- need_move = true;
- }
+ if ((evx != c.x) || (evy != c.y)) {
+ need_move = true;
+ }
- if (need_move) {
- CartesianVector cp (evx, evy, 0.0);
+ if (need_move) {
+ CartesianVector cp (evx, evy, 0.0);
- /* canonicalize position */
+ /* canonicalize position */
- gtk_to_cart (cp);
+ gtk_to_cart (cp);
- /* position actual signal on circle */
+ /* position actual signal on circle */
- clamp_to_circle (cp.x, cp.y);
+ clamp_to_circle (cp.x, cp.y);
- /* generate an angular representation and set drag target (GUI) position */
+ /* generate an angular representation and set drag target (GUI) position */
- cp.angular (drag_target->position); /* sets drag target position */
+ cp.angular (drag_target->position); /* sets drag target position */
- panner->streampanner (drag_index).set_position (drag_target->position);
+ panner->streampanner (drag_index).set_position (drag_target->position);
queue_draw ();
}
@@ -541,43 +540,43 @@ Panner2d::handle_motion (gint evx, gint evy, GdkModifierType state)
void
Panner2d::cart_to_gtk (CartesianVector& c) const
{
- /* "c" uses a coordinate space that is:
+ /* "c" uses a coordinate space that is:
- center = 0.0
- dimension = 2.0 * 2.0
- so max values along each axis are -1..+1
+ center = 0.0
+ dimension = 2.0 * 2.0
+ so max values along each axis are -1..+1
- GTK uses a coordinate space that is:
+ GTK uses a coordinate space that is:
- top left = 0.0
- dimension = width * height
- so max values along each axis are 0,width and
- 0,height
- */
+ top left = 0.0
+ dimension = width * height
+ so max values along each axis are 0,width and
+ 0,height
+ */
- c.x = (width / 2) * (c.x + 1);
- c.y = (height / 2) * (1 - c.y);
+ c.x = (width / 2) * (c.x + 1);
+ c.y = (height / 2) * (1 - c.y);
- /* XXX z-axis not handled - 2D for now */
+ /* XXX z-axis not handled - 2D for now */
}
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 / (width / 2.0)) - 1.0;
+ c.y = -((c.y / (height / 2.0)) - 1.0);
- /* XXX z-axis not handled - 2D for now */
+ /* XXX z-axis not handled - 2D for now */
}
void
Panner2d::clamp_to_circle (double& x, double& y)
{
- double azi, ele;
- double z = 0.0;
+ double azi, ele;
+ double z = 0.0;
- PBD::cart_to_azi_ele (x, y, z, azi, ele);
- PBD::azi_ele_to_cart (azi, ele, x, y, z);
+ PBD::cart_to_azi_ele (x, y, z, azi, ele);
+ PBD::azi_ele_to_cart (azi, ele, x, y, z);
}
void
diff --git a/gtk2_ardour/panner2d.h b/gtk2_ardour/panner2d.h
index e1572c11b2..4a324e4c8a 100644
--- a/gtk2_ardour/panner2d.h
+++ b/gtk2_ardour/panner2d.h
@@ -67,8 +67,8 @@ class Panner2d : public Gtk::DrawingArea
sigc::signal<void,int> PuckMoved;
sigc::signal<void,int> TargetMoved;
- void cart_to_gtk (PBD::CartesianVector&) const;
- void gtk_to_cart (PBD::CartesianVector&) const;
+ void cart_to_gtk (PBD::CartesianVector&) const;
+ void gtk_to_cart (PBD::CartesianVector&) const;
protected:
bool on_expose_event (GdkEventExpose *);
@@ -79,24 +79,24 @@ class Panner2d : public Gtk::DrawingArea
private:
class Target {
- public:
- PBD::AngularVector position;
- bool visible;
- std::string text;
+ public:
+ PBD::AngularVector position;
+ bool visible;
+ std::string text;
- Target (const PBD::AngularVector&, const char* txt = 0);
- ~Target ();
+ Target (const PBD::AngularVector&, const char* txt = 0);
+ ~Target ();
- void set_text (const char*);
- void set_selected (bool yn) {
- _selected = yn;
- }
- bool selected() const {
- return _selected;
- }
+ void set_text (const char*);
+ void set_selected (bool yn) {
+ _selected = yn;
+ }
+ bool selected() const {
+ return _selected;
+ }
- private:
- bool _selected;
+ private:
+ bool _selected;
};
boost::shared_ptr<ARDOUR::Panner> panner;
@@ -130,10 +130,10 @@ class Panner2d : public Gtk::DrawingArea
PBD::ScopedConnection state_connection;
PBD::ScopedConnection change_connection;
- /* cartesian coordinates in GTK units ; adjust to same but on a circle of radius 1.0
- and centered in the middle of our area
- */
- void clamp_to_circle (double& x, double& y);
+ /* cartesian coordinates in GTK units ; adjust to same but on a circle of radius 1.0
+ and centered in the middle of our area
+ */
+ void clamp_to_circle (double& x, double& y);
};
class Panner2dWindow : public Gtk::Window
@@ -146,13 +146,13 @@ class Panner2dWindow : public Gtk::Window
private:
Panner2d widget;
- Gtk::HBox hpacker;
- Gtk::VBox button_box;
- Gtk::Button reset_button;
+ Gtk::HBox hpacker;
+ Gtk::VBox button_box;
+ Gtk::Button reset_button;
Gtk::ToggleButton bypass_button;
Gtk::ToggleButton mute_button;
- Gtk::VBox spinner_box;
- Gtk::VBox left_side;
+ Gtk::VBox spinner_box;
+ Gtk::VBox left_side;
std::vector<Gtk::SpinButton*> spinners;
};
diff --git a/libs/ardour/ardour/panner.h b/libs/ardour/ardour/panner.h
index a4e063884e..5a4c008c5f 100644
--- a/libs/ardour/ardour/panner.h
+++ b/libs/ardour/ardour/panner.h
@@ -51,10 +51,10 @@ class StreamPanner : public PBD::Stateful
void set_muted (bool yn);
bool muted() const { return _muted; }
- const PBD::AngularVector& get_position() const { return _angles; }
- const PBD::AngularVector& get_effective_position() const { return _effective_angles; }
- void set_position (const PBD::AngularVector&, bool link_call = false);
- void set_diffusion (double);
+ const PBD::AngularVector& get_position() const { return _angles; }
+ const PBD::AngularVector& get_effective_position() const { return _effective_angles; }
+ void set_position (const PBD::AngularVector&, bool link_call = false);
+ void set_diffusion (double);
void distribute (AudioBuffer &, BufferSet &, gain_t, nframes_t);
void distribute_automated (AudioBuffer &, BufferSet &, nframes_t, nframes_t, nframes_t, pan_t **);
@@ -71,7 +71,8 @@ class StreamPanner : public PBD::Stateful
*/
virtual void do_distribute (AudioBuffer& src, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes) = 0;
virtual void do_distribute_automated (AudioBuffer& src, BufferSet& obufs,
- nframes_t start, nframes_t end, nframes_t nframes, pan_t** buffers) = 0;
+ nframes_t start, nframes_t end, nframes_t nframes,
+ pan_t** buffers) = 0;
boost::shared_ptr<AutomationControl> pan_control() { return _control; }
@@ -92,9 +93,9 @@ class StreamPanner : public PBD::Stateful
void set_mono (bool);
- PBD::AngularVector _angles;
- PBD::AngularVector _effective_angles;
- double _diffusion;
+ PBD::AngularVector _angles;
+ PBD::AngularVector _effective_angles;
+ double _diffusion;
bool _muted;
bool _mono;
@@ -121,19 +122,18 @@ class BaseStereoPanner : public StreamPanner
void do_distribute (AudioBuffer& src, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes);
- static double azimuth_to_lr_fract (double azi) {
- /* 180.0 degrees=> left => 0.0 */
- /* 0.0 degrees => right => 1.0 */
- return 1.0 - (azi/180.0);
- }
-
- static double lr_fract_to_azimuth (double fract) {
- /* fract = 0.0 => degrees = 180.0 => left */
- /* fract = 1.0 => degrees = 0.0 => right */
- return 180.0 - (fract * 180.0);
- }
-
+ static double azimuth_to_lr_fract (double azi) {
+ /* 180.0 degrees=> left => 0.0 */
+ /* 0.0 degrees => right => 1.0 */
+ return 1.0 - (azi/180.0);
+ }
+ static double lr_fract_to_azimuth (double fract) {
+ /* fract = 0.0 => degrees = 180.0 => left */
+ /* fract = 1.0 => degrees = 0.0 => right */
+ return 180.0 - (fract * 180.0);
+ }
+
/* old school automation loading */
int load (std::istream&, std::string path, uint32_t&);
@@ -154,7 +154,8 @@ class EqualPowerStereoPanner : public BaseStereoPanner
~EqualPowerStereoPanner ();
void do_distribute_automated (AudioBuffer& src, BufferSet& obufs,
- nframes_t start, nframes_t end, nframes_t nframes, pan_t** buffers);
+ nframes_t start, nframes_t end, nframes_t nframes,
+ pan_t** buffers);
void get_current_coefficients (pan_t*) const;
void get_desired_coefficients (pan_t*) const;
@@ -295,7 +296,7 @@ public:
static float current_automation_version_number;
- void setup_speakers (uint32_t nouts);
+ void setup_speakers (uint32_t nouts);
/* old school automation handling */
diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h
index db334f6f19..2f0a546e5a 100644
--- a/libs/ardour/ardour/session.h
+++ b/libs/ardour/ardour/session.h
@@ -729,7 +729,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
/* Speakers */
- Speakers& get_speakers ();
+ Speakers& get_speakers ();
/* Controllables */
@@ -1440,7 +1440,9 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
static int ask_about_playlist_deletion (boost::shared_ptr<Playlist>);
/* realtime "apply to set of routes" operations */
- SessionEvent* get_rt_event (boost::shared_ptr<RouteList> rl, bool yn, SessionEvent::RTeventCallback after, bool group_override,
+ SessionEvent* get_rt_event (
+ boost::shared_ptr<RouteList> rl, bool yn,
+ SessionEvent::RTeventCallback after, bool group_override,
void (Session::*method) (boost::shared_ptr<RouteList>, bool, bool));
void rt_set_solo (boost::shared_ptr<RouteList>, bool yn, bool group_override);
@@ -1471,7 +1473,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi
void start_time_changed (framepos_t);
void end_time_changed (framepos_t);
- Speakers* _speakers;
+ Speakers* _speakers;
};
} // namespace ARDOUR
diff --git a/libs/ardour/ardour/speaker.h b/libs/ardour/ardour/speaker.h
index 8e9e9116ae..8bf1556936 100644
--- a/libs/ardour/ardour/speaker.h
+++ b/libs/ardour/ardour/speaker.h
@@ -24,19 +24,19 @@
namespace ARDOUR {
class Speaker {
- public:
- Speaker (int, const PBD::AngularVector& position);
+public:
+ Speaker (int, const PBD::AngularVector& position);
- void move (const PBD::AngularVector& new_position);
+ void move (const PBD::AngularVector& new_position);
- const PBD::CartesianVector& coords() const { return _coords; }
- const PBD::AngularVector& angles() const { return _angles; }
+ const PBD::CartesianVector& coords() const { return _coords; }
+ const PBD::AngularVector& angles() const { return _angles; }
- int id;
+ int id;
- private:
- PBD::CartesianVector _coords;
- PBD::AngularVector _angles;
+private:
+ PBD::CartesianVector _coords;
+ PBD::AngularVector _angles;
};
} /* namespace */
diff --git a/libs/ardour/ardour/speakers.h b/libs/ardour/ardour/speakers.h
index ee8d752ed9..bae8cb96db 100644
--- a/libs/ardour/ardour/speakers.h
+++ b/libs/ardour/ardour/speakers.h
@@ -29,25 +29,25 @@
namespace ARDOUR {
class Speakers {
- public:
- Speakers ();
- virtual ~Speakers ();
+public:
+ Speakers ();
+ virtual ~Speakers ();
- virtual int add_speaker (const PBD::AngularVector&);
- virtual void remove_speaker (int id);
- virtual void move_speaker (int id, const PBD::AngularVector& new_position);
- virtual void clear_speakers ();
+ virtual int add_speaker (const PBD::AngularVector&);
+ virtual void remove_speaker (int id);
+ virtual void move_speaker (int id, const PBD::AngularVector& new_position);
+ virtual void clear_speakers ();
- std::vector<Speaker>& speakers() { return _speakers; }
+ std::vector<Speaker>& speakers() { return _speakers; }
- void dump_speakers (std::ostream&);
+ void dump_speakers (std::ostream&);
- PBD::Signal0<void> Changed;
+ PBD::Signal0<void> Changed;
- protected:
- std::vector<Speaker> _speakers;
+protected:
+ std::vector<Speaker> _speakers;
- virtual void update () {}
+ virtual void update () {}
};
} /* namespace */
diff --git a/libs/ardour/ardour/vbap.h b/libs/ardour/ardour/vbap.h
index e3dc60c97c..4b6b42e732 100644
--- a/libs/ardour/ardour/vbap.h
+++ b/libs/ardour/ardour/vbap.h
@@ -30,40 +30,40 @@ namespace ARDOUR {
class Speakers;
class VBAPanner : public StreamPanner {
- public:
- VBAPanner (Panner& parent, Evoral::Parameter param, Speakers& s);
- ~VBAPanner ();
+public:
+ VBAPanner (Panner& parent, Evoral::Parameter param, Speakers& s);
+ ~VBAPanner ();
- static StreamPanner* factory (Panner& parent, Evoral::Parameter param, Speakers& s);
- static std::string name;
+ static StreamPanner* factory (Panner& parent, Evoral::Parameter param, Speakers& s);
+ static std::string name;
- void do_distribute (AudioBuffer&, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes);
+ void do_distribute (AudioBuffer&, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes);
void do_distribute_automated (AudioBuffer& src, BufferSet& obufs,
- nframes_t start, nframes_t end, nframes_t nframes, pan_t** buffers);
+ nframes_t start, nframes_t end, nframes_t nframes, pan_t** buffers);
- void set_azimuth_elevation (double azimuth, double elevation);
+ void set_azimuth_elevation (double azimuth, double elevation);
XMLNode& state (bool full_state);
XMLNode& get_state ();
int set_state (const XMLNode&, int version);
- /* there never was any old-school automation */
+ /* there never was any old-school automation */
int load (std::istream&, std::string path, uint32_t&) { return 0; }
- private:
- bool _dirty;
- double gains[3];
- double desired_gains[3];
- int outputs[3];
- int desired_outputs[3];
+private:
+ bool _dirty;
+ double gains[3];
+ double desired_gains[3];
+ int outputs[3];
+ int desired_outputs[3];
- VBAPSpeakers& _speakers;
+ VBAPSpeakers& _speakers;
- void compute_gains (double g[3], int ls[3], int azi, int ele);
+ void compute_gains (double g[3], int ls[3], int azi, int ele);
- void update ();
- void mark_dirty ();
+ void update ();
+ void mark_dirty ();
};
} /* namespace */
diff --git a/libs/ardour/ardour/vbap_speakers.h b/libs/ardour/ardour/vbap_speakers.h
index 19dc56c988..80989646bc 100644
--- a/libs/ardour/ardour/vbap_speakers.h
+++ b/libs/ardour/ardour/vbap_speakers.h
@@ -34,71 +34,71 @@ namespace ARDOUR {
class Speakers;
class VBAPSpeakers : public boost::noncopyable {
- public:
- typedef std::vector<double> dvector;
+public:
+ typedef std::vector<double> dvector;
- const dvector matrix (int tuple) const { return _matrices[tuple]; }
- int speaker_for_tuple (int tuple, int which) const { return _speaker_tuples[tuple][which]; }
+ const dvector matrix (int tuple) const { return _matrices[tuple]; }
+ int speaker_for_tuple (int tuple, int which) const { return _speaker_tuples[tuple][which]; }
- int n_tuples () const { return _matrices.size(); }
- int dimension() const { return _dimension; }
+ int n_tuples () const { return _matrices.size(); }
+ int dimension() const { return _dimension; }
- static VBAPSpeakers& instance (Speakers&);
+ static VBAPSpeakers& instance (Speakers&);
- ~VBAPSpeakers ();
+ ~VBAPSpeakers ();
- private:
- static VBAPSpeakers* _instance;
- static const double MIN_VOL_P_SIDE_LGTH = 0.01;
- int _dimension;
- std::vector<Speaker>& _speakers;
- PBD::ScopedConnection speaker_connection;
+private:
+ static VBAPSpeakers* _instance;
+ static const double MIN_VOL_P_SIDE_LGTH = 0.01;
+ int _dimension;
+ std::vector<Speaker>& _speakers;
+ PBD::ScopedConnection speaker_connection;
- VBAPSpeakers (Speakers&);
+ VBAPSpeakers (Speakers&);
- struct azimuth_sorter {
- bool operator() (const Speaker& s1, const Speaker& s2) {
- return s1.angles().azi < s2.angles().azi;
- }
- };
+ struct azimuth_sorter {
+ bool operator() (const Speaker& s1, const Speaker& s2) {
+ return s1.angles().azi < s2.angles().azi;
+ }
+ };
- struct twoDmatrix : public dvector {
- twoDmatrix() : dvector (4, 0.0) {}
- };
+ struct twoDmatrix : public dvector {
+ twoDmatrix() : dvector (4, 0.0) {}
+ };
- struct threeDmatrix : public dvector {
- threeDmatrix() : dvector (9, 0.0) {}
- };
+ struct threeDmatrix : public dvector {
+ threeDmatrix() : dvector (9, 0.0) {}
+ };
- struct tmatrix : public dvector {
- tmatrix() : dvector (3, 0.0) {}
- };
-
- std::vector<dvector> _matrices; /* holds matrices for a given speaker combinations */
- std::vector<tmatrix> _speaker_tuples; /* holds speakers IDs for a given combination */
-
- /* A struct for all loudspeakers */
- struct ls_triplet_chain {
- int ls_nos[3];
- float inv_mx[9];
- struct ls_triplet_chain *next;
- };
-
- static float vec_angle(PBD::CartesianVector v1, PBD::CartesianVector v2);
- static float vec_length(PBD::CartesianVector v1);
- static float vec_prod(PBD::CartesianVector v1, PBD::CartesianVector v2);
- static float vol_p_side_lgth(int i, int j,int k, const std::vector<Speaker>&);
- static void cross_prod(PBD::CartesianVector v1,PBD::CartesianVector v2, PBD::CartesianVector *res);
-
- void update ();
- int any_ls_inside_triplet (int a, int b, int c);
- void add_ldsp_triplet (int i, int j, int k, struct ls_triplet_chain **ls_triplets);
- int lines_intersect (int i,int j,int k,int l);
- void calculate_3x3_matrixes (struct ls_triplet_chain *ls_triplets);
- void choose_speaker_triplets (struct ls_triplet_chain **ls_triplets);
- void choose_speaker_pairs ();
- void sort_2D_lss (int* sorted_lss);
- int calc_2D_inv_tmatrix (double azi1,double azi2, double* inv_mat);
+ struct tmatrix : public dvector {
+ tmatrix() : dvector (3, 0.0) {}
+ };
+
+ std::vector<dvector> _matrices; /* holds matrices for a given speaker combinations */
+ std::vector<tmatrix> _speaker_tuples; /* holds speakers IDs for a given combination */
+
+ /* A struct for all loudspeakers */
+ struct ls_triplet_chain {
+ int ls_nos[3];
+ float inv_mx[9];
+ struct ls_triplet_chain *next;
+ };
+
+ static float vec_angle(PBD::CartesianVector v1, PBD::CartesianVector v2);
+ static float vec_length(PBD::CartesianVector v1);
+ static float vec_prod(PBD::CartesianVector v1, PBD::CartesianVector v2);
+ static float vol_p_side_lgth(int i, int j,int k, const std::vector<Speaker>&);
+ static void cross_prod(PBD::CartesianVector v1,PBD::CartesianVector v2, PBD::CartesianVector *res);
+
+ void update ();
+ int any_ls_inside_triplet (int a, int b, int c);
+ void add_ldsp_triplet (int i, int j, int k, struct ls_triplet_chain **ls_triplets);
+ int lines_intersect (int i,int j,int k,int l);
+ void calculate_3x3_matrixes (struct ls_triplet_chain *ls_triplets);
+ void choose_speaker_triplets (struct ls_triplet_chain **ls_triplets);
+ void choose_speaker_pairs ();
+ void sort_2D_lss (int* sorted_lss);
+ int calc_2D_inv_tmatrix (double azi1,double azi2, double* inv_mat);
};
diff --git a/libs/ardour/panner.cc b/libs/ardour/panner.cc
index e438742266..67aae8c86b 100644
--- a/libs/ardour/panner.cc
+++ b/libs/ardour/panner.cc
@@ -1,3 +1,4 @@
+
/*
Copyright (C) 2004 Paul Davis
@@ -125,8 +126,8 @@ StreamPanner::set_position (const AngularVector& av, bool link_call)
parent.set_position (av, *this);
}
- if (_angles != av) {
- _angles = av;
+ if (_angles != av) {
+ _angles = av;
update ();
Changed ();
_control->Changed ();
@@ -397,7 +398,7 @@ EqualPowerStereoPanner::update ()
x == 1 => hard right = 0.0 degrees
*/
- double _x = BaseStereoPanner::azimuth_to_lr_fract (_angles.azi);
+ double _x = BaseStereoPanner::azimuth_to_lr_fract (_angles.azi);
float const panR = _x;
float const panL = 1 - panR;
@@ -502,7 +503,7 @@ EqualPowerStereoPanner::state (bool /*full_state*/)
LocaleGuard lg (X_("POSIX"));
snprintf (buf, sizeof (buf), "%.12g", _angles.azi);
- root->add_property (X_("azimuth"), buf);
+ root->add_property (X_("azimuth"), buf);
root->add_property (X_("type"), EqualPowerStereoPanner::name);
// XXX: dont save automation here... its part of the automatable panner now.
@@ -522,13 +523,13 @@ EqualPowerStereoPanner::set_state (const XMLNode& node, int version)
if ((prop = node.property (X_("azimuth")))) {
AngularVector a (atof (prop->value().c_str()), 0.0);
- set_position (a, true);
- } else if ((prop = node.property (X_("x")))) {
- /* old school cartesian positioning */
- AngularVector a;
- a.azi = BaseStereoPanner::lr_fract_to_azimuth (atof (prop->value().c_str()));
- set_position (a, true);
- }
+ set_position (a, true);
+ } else if ((prop = node.property (X_("x")))) {
+ /* old school cartesian positioning */
+ AngularVector a;
+ a.azi = BaseStereoPanner::lr_fract_to_azimuth (atof (prop->value().c_str()));
+ set_position (a, true);
+ }
StreamPanner::set_state (node, version);
@@ -544,7 +545,7 @@ EqualPowerStereoPanner::set_state (const XMLNode& node, int version)
_control->alist()->set_state (*((*iter)->children().front()), version);
if (_control->alist()->automation_state() != Off) {
- double degrees = BaseStereoPanner::lr_fract_to_azimuth (_control->list()->eval (parent.session().transport_frame()));
+ double degrees = BaseStereoPanner::lr_fract_to_azimuth (_control->list()->eval (parent.session().transport_frame()));
set_position (AngularVector (degrees, 0.0));
}
}
@@ -613,19 +614,19 @@ Panner::reset_to_default ()
}
if (outputs.size() == 2) {
- AngularVector a;
+ AngularVector a;
switch (_streampanners.size()) {
case 1:
- a.azi = 90.0; /* "front" or "top", in degrees */
+ a.azi = 90.0; /* "front" or "top", in degrees */
_streampanners.front()->set_position (a);
_streampanners.front()->pan_control()->list()->reset_default (0.5);
return;
break;
case 2:
- a.azi = 180.0; /* "left", in degrees */
+ a.azi = 180.0; /* "left", in degrees */
_streampanners.front()->set_position (a);
_streampanners.front()->pan_control()->list()->reset_default (0.0);
- a.azi = 0.0; /* "right", in degrees */
+ a.azi = 0.0; /* "right", in degrees */
_streampanners.back()->set_position (a);
_streampanners.back()->pan_control()->list()->reset_default (1.0);
return;
@@ -645,7 +646,7 @@ Panner::reset_to_default ()
void
Panner::reset_streampanner (uint32_t which)
{
- AngularVector a;
+ AngularVector a;
if (which >= _streampanners.size() || which >= outputs.size()) {
return;
@@ -660,20 +661,20 @@ Panner::reset_streampanner (uint32_t which)
switch (_streampanners.size()) {
case 1:
/* stereo out, 1 stream, default = middle */
- a.azi = 90.0; /* "front" or "top", in degrees */
+ a.azi = 90.0; /* "front" or "top", in degrees */
_streampanners.front()->set_position (a);
_streampanners.front()->pan_control()->list()->reset_default (0.5);
break;
case 2:
/* stereo out, 2 streams, default = hard left/right */
if (which == 0) {
- a.azi = 180.0; /* "left", in degrees */
- _streampanners.front()->set_position (a);
- _streampanners.front()->pan_control()->list()->reset_default (0.0);
- } else {
- a.azi = 0.0; /* "right", in degrees */
- _streampanners.back()->set_position (a);
- _streampanners.back()->pan_control()->list()->reset_default (1.0);
+ a.azi = 180.0; /* "left", in degrees */
+ _streampanners.front()->set_position (a);
+ _streampanners.front()->pan_control()->list()->reset_default (0.0);
+ } else {
+ a.azi = 0.0; /* "right", in degrees */
+ _streampanners.back()->set_position (a);
+ _streampanners.back()->pan_control()->list()->reset_default (1.0);
}
break;
}
@@ -747,10 +748,10 @@ Panner::reset (uint32_t nouts, uint32_t npans)
for (n = 0; n < npans; ++n) {
_streampanners.push_back (new EqualPowerStereoPanner (*this, Evoral::Parameter(PanAutomation, 0, n)));
}
- break;
+ break;
- default:
- setup_speakers (nouts);
+ default:
+ setup_speakers (nouts);
for (n = 0; n < npans; ++n) {
_streampanners.push_back (new VBAPanner (*this, Evoral::Parameter(PanAutomation, 0, n), _session.get_speakers()));
}
@@ -784,7 +785,7 @@ Panner::reset (uint32_t nouts, uint32_t npans)
left = _streampanners.front()->get_position ();
right = _streampanners.back()->get_position ();
- if (changed || ((left.azi == 0.0) && (right.azi == 0.0))) {
+ if (changed || ((left.azi == 0.0) && (right.azi == 0.0))) {
_streampanners.front()->set_position (AngularVector (180.0, 0.0));
_streampanners.front()->pan_control()->list()->reset_default (0.0);
@@ -795,26 +796,26 @@ Panner::reset (uint32_t nouts, uint32_t npans)
} else if (npans > 1 && outputs.size() > 2) {
- /* 2d panning: spread signals equally around a circle */
+ /* 2d panning: spread signals equally around a circle */
- double degree_step = 360.0 / nouts;
- double deg;
+ double degree_step = 360.0 / nouts;
+ double deg;
- /* even number of signals? make sure the top two are either side of "top".
- otherwise, just start at the "top" (90.0 degrees) and rotate around
- */
+ /* even number of signals? make sure the top two are either side of "top".
+ otherwise, just start at the "top" (90.0 degrees) and rotate around
+ */
- if (npans % 2) {
- deg = 90.0 - degree_step;
- } else {
- deg = 90.0;
- }
+ if (npans % 2) {
+ deg = 90.0 - degree_step;
+ } else {
+ deg = 90.0;
+ }
- for (std::vector<StreamPanner*>::iterator x = _streampanners.begin(); x != _streampanners.end(); ++x) {
- (*x)->set_position (AngularVector (deg, 0.0));
- deg += degree_step;
- }
- }
+ for (std::vector<StreamPanner*>::iterator x = _streampanners.begin(); x != _streampanners.end(); ++x) {
+ (*x)->set_position (AngularVector (deg, 0.0));
+ deg += degree_step;
+ }
+ }
}
void
@@ -971,18 +972,18 @@ Panner::set_state (const XMLNode& node, int version)
for (niter = nlist.begin(); niter != nlist.end(); ++niter) {
if ((*niter)->name() == X_("Output")) {
- AngularVector a;
+ AngularVector a;
if ((prop = (*niter)->property (X_("azimuth")))) {
- sscanf (prop->value().c_str(), "%lg", &a.azi);
- } else if ((prop = (*niter)->property (X_("x")))) {
- /* old school cartesian */
- a.azi = BaseStereoPanner::lr_fract_to_azimuth (atof (prop->value().c_str()));
- }
+ sscanf (prop->value().c_str(), "%lg", &a.azi);
+ } else if ((prop = (*niter)->property (X_("x")))) {
+ /* old school cartesian */
+ a.azi = BaseStereoPanner::lr_fract_to_azimuth (atof (prop->value().c_str()));
+ }
if ((prop = (*niter)->property (X_("elevation")))) {
- sscanf (prop->value().c_str(), "%lg", &a.ele);
- }
+ sscanf (prop->value().c_str(), "%lg", &a.ele);
+ }
outputs.push_back (Output (a));
}
@@ -1064,10 +1065,10 @@ Panner::touching () const
void
Panner::set_position (const AngularVector& a, StreamPanner& orig)
{
- AngularVector delta;
- AngularVector new_position;
+ AngularVector delta;
+ AngularVector new_position;
- delta = orig.get_position() - a;
+ delta = orig.get_position() - a;
if (_link_direction == SameDirection) {
@@ -1075,7 +1076,7 @@ Panner::set_position (const AngularVector& a, StreamPanner& orig)
if (*i == &orig) {
(*i)->set_position (a, true);
} else {
- new_position = (*i)->get_position() + delta;
+ new_position = (*i)->get_position() + delta;
(*i)->set_position (new_position, true);
}
}
@@ -1086,7 +1087,7 @@ Panner::set_position (const AngularVector& a, StreamPanner& orig)
if (*i == &orig) {
(*i)->set_position (a, true);
} else {
- new_position = (*i)->get_position() - delta;
+ new_position = (*i)->get_position() - delta;
(*i)->set_position (new_position, true);
}
}
@@ -1343,47 +1344,47 @@ Panner::value_as_string (double v)
void
Panner::setup_speakers (uint32_t nouts)
{
- switch (nouts) {
- case 3:
- /* top, bottom kind-of-left & bottom kind-of-right */
- outputs.push_back (AngularVector (90.0, 0.0));
- outputs.push_back (AngularVector (215.0, 0,0));
- outputs.push_back (AngularVector (335.0, 0,0));
- break;
- case 4:
- /* clockwise from top left */
- outputs.push_back (AngularVector (135.0, 0.0));
- outputs.push_back (AngularVector (45.0, 0.0));
- outputs.push_back (AngularVector (335.0, 0.0));
- outputs.push_back (AngularVector (215.0, 0.0));
- break;
+ switch (nouts) {
+ case 3:
+ /* top, bottom kind-of-left & bottom kind-of-right */
+ outputs.push_back (AngularVector (90.0, 0.0));
+ outputs.push_back (AngularVector (215.0, 0,0));
+ outputs.push_back (AngularVector (335.0, 0,0));
+ break;
+ case 4:
+ /* clockwise from top left */
+ outputs.push_back (AngularVector (135.0, 0.0));
+ outputs.push_back (AngularVector (45.0, 0.0));
+ outputs.push_back (AngularVector (335.0, 0.0));
+ outputs.push_back (AngularVector (215.0, 0.0));
+ break;
default:
- {
- double degree_step = 360.0 / nouts;
- double deg;
- uint32_t n;
-
- /* even number of speakers? make sure the top two are either side of "top".
- otherwise, just start at the "top" (90.0 degrees) and rotate around
- */
-
- if (nouts % 2) {
- deg = 90.0 - degree_step;
- } else {
- deg = 90.0;
- }
+ {
+ double degree_step = 360.0 / nouts;
+ double deg;
+ uint32_t n;
+
+ /* even number of speakers? make sure the top two are either side of "top".
+ otherwise, just start at the "top" (90.0 degrees) and rotate around
+ */
+
+ if (nouts % 2) {
+ deg = 90.0 - degree_step;
+ } else {
+ deg = 90.0;
+ }
for (n = 0; n < nouts; ++n, deg += degree_step) {
outputs.push_back (Output (AngularVector (deg, 0.0)));
}
- }
- }
+ }
+ }
- Speakers& speakers (_session.get_speakers());
+ Speakers& speakers (_session.get_speakers());
- speakers.clear_speakers ();
+ speakers.clear_speakers ();
- for (vector<Output>::iterator o = outputs.begin(); o != outputs.end(); ++o) {
- speakers.add_speaker ((*o).position);
- }
+ for (vector<Output>::iterator o = outputs.begin(); o != outputs.end(); ++o) {
+ speakers.add_speaker ((*o).position);
+ }
}
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc
index 5457f514e4..5190c453d6 100644
--- a/libs/ardour/session.cc
+++ b/libs/ardour/session.cc
@@ -140,33 +140,33 @@ Session::Session (AudioEngine &eng,
string mix_template)
: _engine (eng)
- , _target_transport_speed (0.0)
- , _requested_return_frame (-1)
- , _session_dir (new SessionDirectory(fullpath))
- , state_tree (0)
+ , _target_transport_speed (0.0)
+ , _requested_return_frame (-1)
+ , _session_dir (new SessionDirectory(fullpath))
+ , state_tree (0)
, _state_of_the_state (Clean)
- , _butler (new Butler (*this))
- , _post_transport_work (0)
- , _send_timecode_update (false)
- , _all_route_group (new RouteGroup (*this, "all"))
- , route_graph (new Graph(*this))
- , routes (new RouteList)
- , _total_free_4k_blocks (0)
- , _bundles (new BundleList)
- , _bundle_xml_node (0)
- , _click_io ((IO*) 0)
- , click_data (0)
- , click_emphasis_data (0)
- , main_outs (0)
- , _metadata (new SessionMetadata())
- , _have_rec_enabled_track (false)
- , _suspend_timecode_transmission (0)
+ , _butler (new Butler (*this))
+ , _post_transport_work (0)
+ , _send_timecode_update (false)
+ , _all_route_group (new RouteGroup (*this, "all"))
+ , route_graph (new Graph(*this))
+ , routes (new RouteList)
+ , _total_free_4k_blocks (0)
+ , _bundles (new BundleList)
+ , _bundle_xml_node (0)
+ , _click_io ((IO*) 0)
+ , click_data (0)
+ , click_emphasis_data (0)
+ , main_outs (0)
+ , _metadata (new SessionMetadata())
+ , _have_rec_enabled_track (false)
+ , _suspend_timecode_transmission (0)
{
_locations = new Locations (*this);
playlists.reset (new SessionPlaylists);
- _all_route_group->set_active (true, this);
+ _all_route_group->set_active (true, this);
interpolation.add_channel_to (0, 0);
@@ -179,14 +179,14 @@ Session::Session (AudioEngine &eng,
first_stage_init (fullpath, snapshot_name);
- _is_new = !Glib::file_test (_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR));
+ _is_new = !Glib::file_test (_path, Glib::FileTest (G_FILE_TEST_EXISTS | G_FILE_TEST_IS_DIR));
if (_is_new) {
if (create (mix_template, bus_profile)) {
destroy ();
throw failed_constructor ();
}
- }
+ }
if (second_stage_init ()) {
destroy ();
@@ -240,9 +240,9 @@ Session::destroy ()
delete state_tree;
- /* remove all stubfiles that might still be lurking */
+ /* remove all stubfiles that might still be lurking */
- cleanup_stubfiles ();
+ cleanup_stubfiles ();
/* reset dynamic state version back to default */
@@ -679,12 +679,12 @@ Session::hookup_io ()
*/
try {
- Auditioner* a = new Auditioner (*this);
- if (a->init()) {
- delete a;
- throw failed_constructor();
- }
- a->use_new_diskstream ();
+ Auditioner* a = new Auditioner (*this);
+ if (a->init()) {
+ delete a;
+ throw failed_constructor();
+ }
+ a->use_new_diskstream ();
auditioner.reset (a);
}
@@ -714,26 +714,26 @@ Session::hookup_io ()
they connect to the control out specifically.
*/
- if (_monitor_out) {
+ if (_monitor_out) {
boost::shared_ptr<RouteList> r = routes.reader ();
- for (RouteList::iterator x = r->begin(); x != r->end(); ++x) {
+ for (RouteList::iterator x = r->begin(); x != r->end(); ++x) {
- if ((*x)->is_monitor()) {
+ if ((*x)->is_monitor()) {
- /* relax */
+ /* relax */
- } else if ((*x)->is_master()) {
+ } else if ((*x)->is_master()) {
- /* relax */
+ /* relax */
- } else {
+ } else {
- (*x)->listen_via (_monitor_out,
- (Config->get_listen_position() == AfterFaderListen ? PostFader : PreFader),
- false, false);
- }
- }
- }
+ (*x)->listen_via (_monitor_out,
+ (Config->get_listen_position() == AfterFaderListen ? PostFader : PreFader),
+ false, false);
+ }
+ }
+ }
/* Anyone who cares about input state, wake up and do something */
@@ -1014,33 +1014,33 @@ Session::handle_locations_changed (Locations::LocationList& locations)
void
Session::enable_record ()
{
- while (1) {
- RecordState rs = (RecordState) g_atomic_int_get (&_record_status);
+ while (1) {
+ RecordState rs = (RecordState) g_atomic_int_get (&_record_status);
- if (rs == Recording) {
- break;
- }
+ if (rs == Recording) {
+ break;
+ }
- if (g_atomic_int_compare_and_exchange (&_record_status, rs, Recording)) {
+ if (g_atomic_int_compare_and_exchange (&_record_status, rs, Recording)) {
- _last_record_location = _transport_frame;
+ _last_record_location = _transport_frame;
MIDI::Manager::instance()->mmc()->send (MIDI::MachineControlCommand (MIDI::MachineControl::cmdRecordStrobe));
- if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) {
+ if (Config->get_monitoring_model() == HardwareMonitoring && config.get_auto_input()) {
- boost::shared_ptr<RouteList> rl = routes.reader ();
- for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
- boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
- if (tr && tr->record_enabled ()) {
- tr->monitor_input (true);
- }
- }
- }
+ boost::shared_ptr<RouteList> rl = routes.reader ();
+ for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+ boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
+ if (tr && tr->record_enabled ()) {
+ tr->monitor_input (true);
+ }
+ }
+ }
- RecordStateChanged ();
- break;
- }
- }
+ RecordStateChanged ();
+ break;
+ }
+ }
}
void
@@ -1099,9 +1099,9 @@ Session::step_back_from_record ()
void
Session::maybe_enable_record ()
{
- if (_step_editors > 0) {
- return;
- }
+ if (_step_editors > 0) {
+ return;
+ }
g_atomic_int_set (&_record_status, Enabled);
@@ -1342,7 +1342,7 @@ trace_terminal (shared_ptr<Route> r1, shared_ptr<Route> rbase)
/* make a copy of the existing list of routes that feed r1 */
- Route::FedBy existing (r1->fed_by());
+ Route::FedBy existing (r1->fed_by());
/* for each route that feeds r1, recurse, marking it as feeding
rbase as well.
@@ -1401,19 +1401,19 @@ Session::resort_routes ()
//route_graph->dump(1);
#ifndef NDEBUG
- boost::shared_ptr<RouteList> rl = routes.reader ();
- for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
- DEBUG_TRACE (DEBUG::Graph, string_compose ("%1 fed by ...\n", (*i)->name()));
+ boost::shared_ptr<RouteList> rl = routes.reader ();
+ for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
+ DEBUG_TRACE (DEBUG::Graph, string_compose ("%1 fed by ...\n", (*i)->name()));
- const Route::FedBy& fb ((*i)->fed_by());
-
- for (Route::FedBy::const_iterator f = fb.begin(); f != fb.end(); ++f) {
- boost::shared_ptr<Route> sf = f->r.lock();
- if (sf) {
- DEBUG_TRACE (DEBUG::Graph, string_compose ("\t%1 (sends only ? %2)\n", sf->name(), f->sends_only));
- }
- }
- }
+ const Route::FedBy& fb ((*i)->fed_by());
+
+ for (Route::FedBy::const_iterator f = fb.begin(); f != fb.end(); ++f) {
+ boost::shared_ptr<Route> sf = f->r.lock();
+ if (sf) {
+ DEBUG_TRACE (DEBUG::Graph, string_compose ("\t%1 (sends only ? %2)\n", sf->name(), f->sends_only));
+ }
+ }
+ }
#endif
}
@@ -1438,7 +1438,7 @@ Session::resort_routes_using (shared_ptr<RouteList> r)
continue;
}
- bool via_sends_only;
+ bool via_sends_only;
if ((*j)->direct_feeds (*i, &via_sends_only)) {
(*i)->add_fed_by (*j, via_sends_only);
@@ -1456,10 +1456,10 @@ Session::resort_routes_using (shared_ptr<RouteList> r)
route_graph->rechain (r);
#ifndef NDEBUG
- DEBUG_TRACE (DEBUG::Graph, "Routes resorted, order follows:\n");
+ DEBUG_TRACE (DEBUG::Graph, "Routes resorted, order follows:\n");
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
DEBUG_TRACE (DEBUG::Graph, string_compose ("\t%1 signal order %2\n",
- (*i)->name(), (*i)->order_key ("signal")));
+ (*i)->name(), (*i)->order_key ("signal")));
}
#endif
@@ -1534,12 +1534,12 @@ Session::new_midi_track (TrackMode mode, RouteGroup* route_group, uint32_t how_m
try {
MidiTrack* mt = new MidiTrack (*this, track_name, Route::Flag (0), mode);
- if (mt->init ()) {
- delete mt;
- goto failed;
- }
+ if (mt->init ()) {
+ delete mt;
+ goto failed;
+ }
- mt->use_new_diskstream();
+ mt->use_new_diskstream();
boost_debug_shared_ptr_mark_interesting (mt, "Track");
track = boost::shared_ptr<MidiTrack>(mt);
@@ -1703,12 +1703,12 @@ Session::new_audio_track (int input_channels, int output_channels, TrackMode mod
try {
AudioTrack* at = new AudioTrack (*this, track_name, Route::Flag (0), mode);
- if (at->init ()) {
- delete at;
- goto failed;
- }
+ if (at->init ()) {
+ delete at;
+ goto failed;
+ }
- at->use_new_diskstream();
+ at->use_new_diskstream();
boost_debug_shared_ptr_mark_interesting (at, "Track");
track = boost::shared_ptr<AudioTrack>(at);
@@ -1823,10 +1823,10 @@ Session::new_audio_route (bool aux, int input_channels, int output_channels, Rou
try {
Route* rt = new Route (*this, bus_name, Route::Flag(0), DataType::AUDIO);
- if (rt->init ()) {
- delete rt;
- goto failure;
- }
+ if (rt->init ()) {
+ delete rt;
+ goto failure;
+ }
boost_debug_shared_ptr_mark_interesting (rt, "Route");
shared_ptr<Route> bus (rt);
@@ -2022,10 +2022,10 @@ Session::add_routes (RouteList& new_routes, bool save)
track_playlist_changed (boost::weak_ptr<Track> (tr));
tr->RecordEnableChanged.connect_same_thread (*this, boost::bind (&Session::update_have_rec_enabled_track, this));
- boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (tr);
- if (mt) {
- mt->StepEditStatusChange.connect_same_thread (*this, boost::bind (&Session::step_edit_status_change, this, _1));
- }
+ boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (tr);
+ if (mt) {
+ mt->StepEditStatusChange.connect_same_thread (*this, boost::bind (&Session::step_edit_status_change, this, _1));
+ }
}
}
@@ -2033,14 +2033,14 @@ Session::add_routes (RouteList& new_routes, bool save)
for (RouteList::iterator x = new_routes.begin(); x != new_routes.end(); ++x) {
if ((*x)->is_monitor()) {
- /* relax */
- } else if ((*x)->is_master()) {
- /* relax */
+ /* relax */
+ } else if ((*x)->is_master()) {
+ /* relax */
} else {
- (*x)->listen_via (_monitor_out,
- (Config->get_listen_position() == AfterFaderListen ? PostFader : PreFader),
- false, false);
- }
+ (*x)->listen_via (_monitor_out,
+ (Config->get_listen_position() == AfterFaderListen ? PostFader : PreFader),
+ false, false);
+ }
}
resort_routes ();
@@ -2150,11 +2150,11 @@ Session::add_internal_sends (boost::shared_ptr<Route> dest, Placement p, boost::
void
Session::remove_route (shared_ptr<Route> route)
{
- if (((route == _master_out) || (route == _monitor_out)) && !Config->get_allow_special_bus_removal()) {
- return;
- }
+ if (((route == _master_out) || (route == _monitor_out)) && !Config->get_allow_special_bus_removal()) {
+ return;
+ }
- route->set_solo (false, this);
+ route->set_solo (false, this);
{
RCUWriter<RouteList> writer (routes);
@@ -2185,7 +2185,7 @@ Session::remove_route (shared_ptr<Route> route)
/* writer goes out of scope, forces route list update */
}
- update_route_solo_state ();
+ update_route_solo_state ();
update_session_range_location_marker ();
// We need to disconnect the route's inputs and outputs
@@ -2205,22 +2205,22 @@ Session::remove_route (shared_ptr<Route> route)
}
}
- boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
- if (mt && mt->step_editing()) {
- if (_step_editors > 0) {
- _step_editors--;
- }
- }
+ boost::shared_ptr<MidiTrack> mt = boost::dynamic_pointer_cast<MidiTrack> (route);
+ if (mt && mt->step_editing()) {
+ if (_step_editors > 0) {
+ _step_editors--;
+ }
+ }
update_latency_compensation (false, false);
set_dirty();
- /* Re-sort routes to remove the graph's current references to the one that is
+ /* Re-sort routes to remove the graph's current references to the one that is
* going away, then flush old references out of the graph.
- */
+ */
resort_routes ();
- route_graph->clear_other_chain ();
+ route_graph->clear_other_chain ();
/* get rid of it from the dead wood collection in the route list manager */
@@ -2260,16 +2260,16 @@ Session::route_listen_changed (void* /*src*/, boost::weak_ptr<Route> wpr)
if (route->listening()) {
- if (Config->get_exclusive_solo()) {
- /* new listen: disable all other listen */
- shared_ptr<RouteList> r = routes.reader ();
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden()) {
- continue;
- }
- (*i)->set_listen (false, this);
- }
- }
+ if (Config->get_exclusive_solo()) {
+ /* new listen: disable all other listen */
+ shared_ptr<RouteList> r = routes.reader ();
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden()) {
+ continue;
+ }
+ (*i)->set_listen (false, this);
+ }
+ }
_listen_cnt++;
@@ -2292,29 +2292,29 @@ Session::route_solo_isolated_changed (void* /*src*/, boost::weak_ptr<Route> wpr)
bool send_changed = false;
if (route->solo_isolated()) {
- if (_solo_isolated_cnt == 0) {
- send_changed = true;
- }
- _solo_isolated_cnt++;
+ if (_solo_isolated_cnt == 0) {
+ send_changed = true;
+ }
+ _solo_isolated_cnt++;
} else if (_solo_isolated_cnt > 0) {
- _solo_isolated_cnt--;
- if (_solo_isolated_cnt == 0) {
- send_changed = true;
- }
+ _solo_isolated_cnt--;
+ if (_solo_isolated_cnt == 0) {
+ send_changed = true;
+ }
}
if (send_changed) {
- IsolatedChanged (); /* EMIT SIGNAL */
+ IsolatedChanged (); /* EMIT SIGNAL */
}
}
void
Session::route_solo_changed (bool self_solo_change, void* /*src*/, boost::weak_ptr<Route> wpr)
{
- if (!self_solo_change) {
- // session doesn't care about changes to soloed-by-others
- return;
- }
+ if (!self_solo_change) {
+ // session doesn't care about changes to soloed-by-others
+ return;
+ }
if (solo_update_disabled) {
// We know already
@@ -2338,59 +2338,59 @@ Session::route_solo_changed (bool self_solo_change, void* /*src*/, boost::weak_p
delta = -1;
}
- if (delta == 1 && Config->get_exclusive_solo()) {
- /* new solo: disable all other solos */
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden()) {
- continue;
- }
- (*i)->set_solo (false, this);
- }
- }
+ if (delta == 1 && Config->get_exclusive_solo()) {
+ /* new solo: disable all other solos */
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden()) {
+ continue;
+ }
+ (*i)->set_solo (false, this);
+ }
+ }
solo_update_disabled = true;
- RouteList uninvolved;
+ RouteList uninvolved;
for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
bool via_sends_only;
- bool in_signal_flow;
+ bool in_signal_flow;
if ((*i) == route || (*i)->solo_isolated() || (*i)->is_master() || (*i)->is_monitor() || (*i)->is_hidden()) {
continue;
}
- in_signal_flow = false;
+ in_signal_flow = false;
- if ((*i)->feeds (route, &via_sends_only)) {
+ if ((*i)->feeds (route, &via_sends_only)) {
if (!via_sends_only) {
- if (!route->soloed_by_others_upstream()) {
- (*i)->mod_solo_by_others_downstream (delta);
- }
- in_signal_flow = true;
+ if (!route->soloed_by_others_upstream()) {
+ (*i)->mod_solo_by_others_downstream (delta);
+ }
+ in_signal_flow = true;
}
}
- if (route->feeds (*i, &via_sends_only)) {
- (*i)->mod_solo_by_others_upstream (delta);
- in_signal_flow = true;
- }
+ if (route->feeds (*i, &via_sends_only)) {
+ (*i)->mod_solo_by_others_upstream (delta);
+ in_signal_flow = true;
+ }
- if (!in_signal_flow) {
- uninvolved.push_back (*i);
- }
+ if (!in_signal_flow) {
+ uninvolved.push_back (*i);
+ }
}
solo_update_disabled = false;
update_route_solo_state (r);
- /* now notify that the mute state of the routes not involved in the signal
- pathway of the just-solo-changed route may have altered.
- */
+ /* now notify that the mute state of the routes not involved in the signal
+ pathway of the just-solo-changed route may have altered.
+ */
- for (RouteList::iterator i = uninvolved.begin(); i != uninvolved.end(); ++i) {
- (*i)->mute_changed (this);
- }
+ for (RouteList::iterator i = uninvolved.begin(); i != uninvolved.end(); ++i) {
+ (*i)->mute_changed (this);
+ }
SoloChanged (); /* EMIT SIGNAL */
set_dirty();
@@ -2402,8 +2402,8 @@ Session::update_route_solo_state (boost::shared_ptr<RouteList> r)
/* now figure out if anything that matters is soloed (or is "listening")*/
bool something_soloed = false;
- uint32_t listeners = 0;
- uint32_t isolated = 0;
+ uint32_t listeners = 0;
+ uint32_t isolated = 0;
if (!r) {
r = routes.reader();
@@ -2414,30 +2414,30 @@ Session::update_route_solo_state (boost::shared_ptr<RouteList> r)
something_soloed = true;
}
- if (!(*i)->is_hidden() && (*i)->listening()) {
- if (Config->get_solo_control_is_listen_control()) {
- listeners++;
- } else {
- (*i)->set_listen (false, this);
- }
- }
+ if (!(*i)->is_hidden() && (*i)->listening()) {
+ if (Config->get_solo_control_is_listen_control()) {
+ listeners++;
+ } else {
+ (*i)->set_listen (false, this);
+ }
+ }
- if ((*i)->solo_isolated()) {
- isolated++;
- }
+ if ((*i)->solo_isolated()) {
+ isolated++;
+ }
}
- if (something_soloed != _non_soloed_outs_muted) {
- _non_soloed_outs_muted = something_soloed;
- SoloActive (_non_soloed_outs_muted); /* EMIT SIGNAL */
- }
+ if (something_soloed != _non_soloed_outs_muted) {
+ _non_soloed_outs_muted = something_soloed;
+ SoloActive (_non_soloed_outs_muted); /* EMIT SIGNAL */
+ }
- _listen_cnt = listeners;
+ _listen_cnt = listeners;
- if (isolated != _solo_isolated_cnt) {
- _solo_isolated_cnt = isolated;
- IsolatedChanged (); /* EMIT SIGNAL */
- }
+ if (isolated != _solo_isolated_cnt) {
+ _solo_isolated_cnt = isolated;
+ IsolatedChanged (); /* EMIT SIGNAL */
+ }
}
boost::shared_ptr<RouteList>
@@ -2457,19 +2457,19 @@ Session::get_routes_with_internal_returns() const
bool
Session::io_name_is_legal (const std::string& name)
{
- shared_ptr<RouteList> r = routes.reader ();
+ shared_ptr<RouteList> r = routes.reader ();
- for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
- if ((*i)->name() == name) {
- return false;
- }
+ for (RouteList::iterator i = r->begin(); i != r->end(); ++i) {
+ if ((*i)->name() == name) {
+ return false;
+ }
- if ((*i)->has_io_processor_named (name)) {
- return false;
- }
- }
+ if ((*i)->has_io_processor_named (name)) {
+ return false;
+ }
+ }
- return true;
+ return true;
}
shared_ptr<Route>
@@ -2579,7 +2579,7 @@ Session::get_extent () const
boost::shared_ptr<Region>
Session::find_whole_file_parent (boost::shared_ptr<Region const> child) const
{
- const RegionFactory::RegionMap& regions (RegionFactory::regions());
+ const RegionFactory::RegionMap& regions (RegionFactory::regions());
RegionFactory::RegionMap::const_iterator i;
boost::shared_ptr<Region> region;
@@ -2603,48 +2603,48 @@ Session::find_whole_file_parent (boost::shared_ptr<Region const> child) const
int
Session::destroy_sources (list<boost::shared_ptr<Source> > srcs)
{
- set<boost::shared_ptr<Region> > relevant_regions;
+ set<boost::shared_ptr<Region> > relevant_regions;
for (list<boost::shared_ptr<Source> >::iterator s = srcs.begin(); s != srcs.end(); ++s) {
- RegionFactory::get_regions_using_source (*s, relevant_regions);
+ RegionFactory::get_regions_using_source (*s, relevant_regions);
}
- cerr << "There are " << relevant_regions.size() << " using " << srcs.size() << " sources" << endl;
+ cerr << "There are " << relevant_regions.size() << " using " << srcs.size() << " sources" << endl;
- for (set<boost::shared_ptr<Region> >::iterator r = relevant_regions.begin(); r != relevant_regions.end(); ) {
- set<boost::shared_ptr<Region> >::iterator tmp;
+ for (set<boost::shared_ptr<Region> >::iterator r = relevant_regions.begin(); r != relevant_regions.end(); ) {
+ set<boost::shared_ptr<Region> >::iterator tmp;
- tmp = r;
- ++tmp;
+ tmp = r;
+ ++tmp;
- cerr << "Cleanup " << (*r)->name() << " UC = " << (*r).use_count() << endl;
+ cerr << "Cleanup " << (*r)->name() << " UC = " << (*r).use_count() << endl;
- playlists->destroy_region (*r);
- RegionFactory::map_remove (*r);
+ playlists->destroy_region (*r);
+ RegionFactory::map_remove (*r);
- (*r)->drop_sources ();
- (*r)->drop_references ();
+ (*r)->drop_sources ();
+ (*r)->drop_references ();
- cerr << "\tdone UC = " << (*r).use_count() << endl;
+ cerr << "\tdone UC = " << (*r).use_count() << endl;
- relevant_regions.erase (r);
+ relevant_regions.erase (r);
- r = tmp;
- }
+ r = tmp;
+ }
for (list<boost::shared_ptr<Source> >::iterator s = srcs.begin(); s != srcs.end(); ) {
- {
- Glib::Mutex::Lock ls (source_lock);
- /* remove from the main source list */
- sources.erase ((*s)->id());
- }
+ {
+ Glib::Mutex::Lock ls (source_lock);
+ /* remove from the main source list */
+ sources.erase ((*s)->id());
+ }
- (*s)->mark_for_remove ();
- (*s)->drop_references ();
+ (*s)->mark_for_remove ();
+ (*s)->drop_references ();
- s = srcs.erase (s);
- }
+ s = srcs.erase (s);
+ }
return 0;
}
@@ -2694,17 +2694,17 @@ Session::add_source (boost::shared_ptr<Source> source)
if (result.second) {
- /* yay, new source */
+ /* yay, new source */
set_dirty();
- boost::shared_ptr<AudioFileSource> afs;
+ boost::shared_ptr<AudioFileSource> afs;
- if ((afs = boost::dynamic_pointer_cast<AudioFileSource>(source)) != 0) {
- if (Config->get_auto_analyse_audio()) {
- Analyser::queue_source_for_analysis (source, false);
- }
- }
+ if ((afs = boost::dynamic_pointer_cast<AudioFileSource>(source)) != 0) {
+ if (Config->get_auto_analyse_audio()) {
+ Analyser::queue_source_for_analysis (source, false);
+ }
+ }
}
}
@@ -2722,7 +2722,7 @@ Session::remove_source (boost::weak_ptr<Source> src)
Glib::Mutex::Lock lm (source_lock);
if ((i = sources.find (source->id())) != sources.end()) {
- cerr << "Removing source " << source->name() << endl;
+ cerr << "Removing source " << source->name() << endl;
sources.erase (i);
}
}
@@ -2770,16 +2770,16 @@ Session::source_by_path_and_channel (const string& path, uint16_t chn)
uint32_t
Session::count_sources_by_origin (const string& path)
{
- uint32_t cnt = 0;
+ uint32_t cnt = 0;
Glib::Mutex::Lock lm (source_lock);
for (SourceMap::iterator i = sources.begin(); i != sources.end(); ++i) {
boost::shared_ptr<FileSource> fs
= boost::dynamic_pointer_cast<FileSource>(i->second);
- if (fs && fs->origin() == path) {
- ++cnt;
- }
+ if (fs && fs->origin() == path) {
+ ++cnt;
+ }
}
return cnt;
@@ -2809,7 +2809,7 @@ Session::change_source_path_by_name (string path, string oldname, string newname
string::size_type dash;
dir = Glib::path_get_dirname (path);
- path = Glib::path_get_basename (path);
+ path = Glib::path_get_basename (path);
/* '-' is not a legal character for the NAME part of the path */
@@ -2823,8 +2823,7 @@ Session::change_source_path_by_name (string path, string oldname, string newname
path += '-';
path += new_legalized;
path += native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
-
- path = Glib::build_filename (dir, path);
+ path = Glib::build_filename (dir, path);
} else {
@@ -2841,7 +2840,7 @@ Session::change_source_path_by_name (string path, string oldname, string newname
string::size_type postfix;
dir = Glib::path_get_dirname (path);
- path = Glib::path_get_basename (path);
+ path = Glib::path_get_basename (path);
/* '-' is not a legal character for the NAME part of the path */
@@ -2873,8 +2872,8 @@ Session::change_source_path_by_name (string path, string oldname, string newname
snprintf (buf, sizeof(buf), "%s-%u%s", newname.c_str(), cnt, suffix.c_str());
- if (!matching_unsuffixed_filename_exists_in (dir, buf)) {
- path = Glib::build_filename (dir, buf);
+ if (!matching_unsuffixed_filename_exists_in (dir, buf)) {
+ path = Glib::build_filename (dir, buf);
break;
}
@@ -2883,8 +2882,8 @@ Session::change_source_path_by_name (string path, string oldname, string newname
if (path.empty()) {
fatal << string_compose (_("FATAL ERROR! Could not find a suitable version of %1 for a rename"),
- newname) << endl;
- /*NOTREACHED*/
+ newname) << endl;
+ /*NOTREACHED*/
}
}
@@ -2932,7 +2931,7 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha
char buf[PATH_MAX+1];
const uint32_t limit = 10000;
string legalized;
- string ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
+ string ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
buf[0] = '\0';
legalized = legalize_for_path (base);
@@ -2949,21 +2948,21 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha
if (nchan < 2) {
snprintf (buf, sizeof(buf), "T%04d-%s%s",
- cnt, legalized.c_str(), ext.c_str());
+ cnt, legalized.c_str(), ext.c_str());
} else if (nchan == 2) {
if (chan == 0) {
snprintf (buf, sizeof(buf), "T%04d-%s%%L%s",
- cnt, legalized.c_str(), ext.c_str());
+ cnt, legalized.c_str(), ext.c_str());
} else {
snprintf (buf, sizeof(buf), "T%04d-%s%%R%s",
- cnt, legalized.c_str(), ext.c_str());
+ cnt, legalized.c_str(), ext.c_str());
}
} else if (nchan < 26) {
snprintf (buf, sizeof(buf), "T%04d-%s%%%c%s",
- cnt, legalized.c_str(), 'a' + chan, ext.c_str());
+ cnt, legalized.c_str(), 'a' + chan, ext.c_str());
} else {
snprintf (buf, sizeof(buf), "T%04d-%s%s",
- cnt, legalized.c_str(), ext.c_str());
+ cnt, legalized.c_str(), ext.c_str());
}
} else {
@@ -2988,17 +2987,17 @@ Session::new_audio_source_name (const string& base, uint32_t nchan, uint32_t cha
string spath = sdir.sound_path().to_string();
string spath_stubs = sdir.sound_stub_path().to_string();
- /* note that we search *without* the extension so that
- we don't end up both "Audio 1-1.wav" and "Audio 1-1.caf"
- in the event that this new name is required for
- a file format change.
- */
+ /* note that we search *without* the extension so that
+ we don't end up both "Audio 1-1.wav" and "Audio 1-1.caf"
+ in the event that this new name is required for
+ a file format change.
+ */
- if (matching_unsuffixed_filename_exists_in (spath, buf) ||
- matching_unsuffixed_filename_exists_in (spath_stubs, buf)) {
- existing++;
- break;
- }
+ if (matching_unsuffixed_filename_exists_in (spath, buf) ||
+ matching_unsuffixed_filename_exists_in (spath_stubs, buf)) {
+ existing++;
+ break;
+ }
}
if (existing == 0) {
@@ -3081,28 +3080,28 @@ Session::new_midi_source_name (const string& base)
boost::shared_ptr<MidiSource>
Session::create_midi_source_for_session (Track* track, string const & n, bool as_stub)
{
- /* try to use the existing write source for the track, to keep numbering sane
- */
+ /* try to use the existing write source for the track, to keep numbering sane
+ */
- if (track) {
- /*MidiTrack* mt = dynamic_cast<Track*> (track);
- assert (mt);
- */
+ if (track) {
+ /*MidiTrack* mt = dynamic_cast<Track*> (track);
+ assert (mt);
+ */
- list<boost::shared_ptr<Source> > l = track->steal_write_sources ();
+ list<boost::shared_ptr<Source> > l = track->steal_write_sources ();
- if (!l.empty()) {
- assert (boost::dynamic_pointer_cast<MidiSource> (l.front()));
- return boost::dynamic_pointer_cast<MidiSource> (l.front());
- }
- }
+ if (!l.empty()) {
+ assert (boost::dynamic_pointer_cast<MidiSource> (l.front()));
+ return boost::dynamic_pointer_cast<MidiSource> (l.front());
+ }
+ }
const string name = new_midi_source_name (n);
const string path = new_source_path_from_name (DataType::MIDI, name, as_stub);
return boost::dynamic_pointer_cast<SMFSource> (
- SourceFactory::createWritable (
- DataType::MIDI, *this, path, string(), false, frame_rate()));
+ SourceFactory::createWritable (
+ DataType::MIDI, *this, path, string(), false, frame_rate()));
}
@@ -3188,12 +3187,12 @@ Session::cancel_audition ()
bool
Session::RoutePublicOrderSorter::operator() (boost::shared_ptr<Route> a, boost::shared_ptr<Route> b)
{
- if (a->is_monitor()) {
- return true;
- }
- if (b->is_monitor()) {
- return false;
- }
+ if (a->is_monitor()) {
+ return true;
+ }
+ if (b->is_monitor()) {
+ return false;
+ }
return a->order_key(N_("signal")) < b->order_key(N_("signal"));
}
@@ -3352,7 +3351,7 @@ Session::update_locations_after_tempo_map_change (Locations::LocationList& loc)
void
Session::ensure_buffers (ChanCount howmany)
{
- BufferManager::ensure_buffers (howmany);
+ BufferManager::ensure_buffers (howmany);
}
void
@@ -3463,24 +3462,24 @@ void
Session::unmark_send_id (uint32_t id)
{
if (id < send_bitset.size()) {
- send_bitset[id] = false;
- }
+ send_bitset[id] = false;
+ }
}
void
Session::unmark_return_id (uint32_t id)
{
if (id < return_bitset.size()) {
- return_bitset[id] = false;
- }
+ return_bitset[id] = false;
+ }
}
void
Session::unmark_insert_id (uint32_t id)
{
if (id < insert_bitset.size()) {
- insert_bitset[id] = false;
- }
+ insert_bitset[id] = false;
+ }
}
@@ -3540,12 +3539,12 @@ Session::reset_native_file_format ()
for (RouteList::iterator i = rl->begin(); i != rl->end(); ++i) {
boost::shared_ptr<Track> tr = boost::dynamic_pointer_cast<Track> (*i);
if (tr) {
- /* don't save state as we do this, there's no point
- */
+ /* don't save state as we do this, there's no point
+ */
- _state_of_the_state = StateOfTheState (_state_of_the_state|InCleanup);
+ _state_of_the_state = StateOfTheState (_state_of_the_state|InCleanup);
tr->reset_write_sources (false);
- _state_of_the_state = StateOfTheState (_state_of_the_state & ~InCleanup);
+ _state_of_the_state = StateOfTheState (_state_of_the_state & ~InCleanup);
}
}
}
@@ -3616,8 +3615,8 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
SessionDirectory sdir(get_best_session_directory_for_new_source ());
const string sound_dir = sdir.sound_path().to_string();
framepos_t len = end - start;
- bool need_block_size_reset = false;
- string ext;
+ bool need_block_size_reset = false;
+ string ext;
if (end <= start) {
error << string_compose (_("Cannot write a range where end <= start (e.g. %1 <= %2)"),
@@ -3643,7 +3642,7 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
goto out;
}
- ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
+ ext = native_header_format_extension (config.get_native_file_header_format(), DataType::AUDIO);
for (uint32_t chan_n=0; chan_n < nchans.n_audio(); ++chan_n) {
@@ -3672,10 +3671,10 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
srcs.push_back (fsource);
}
- /* tell redirects that care that we are about to use a much larger blocksize */
+ /* tell redirects that care that we are about to use a much larger blocksize */
- need_block_size_reset = true;
- track.set_block_size (chunk_size);
+ need_block_size_reset = true;
+ track.set_block_size (chunk_size);
/* XXX need to flush all redirects */
@@ -3768,9 +3767,9 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
}
- if (need_block_size_reset) {
- track.set_block_size (get_block_size());
- }
+ if (need_block_size_reset) {
+ track.set_block_size (get_block_size());
+ }
unblock_processing ();
@@ -3780,19 +3779,19 @@ Session::write_one_track (AudioTrack& track, framepos_t start, framepos_t end,
gain_t*
Session::gain_automation_buffer() const
{
- return ProcessThread::gain_automation_buffer ();
+ return ProcessThread::gain_automation_buffer ();
}
pan_t**
Session::pan_automation_buffer() const
{
- return ProcessThread::pan_automation_buffer ();
+ return ProcessThread::pan_automation_buffer ();
}
BufferSet&
Session::get_silent_buffers (ChanCount count)
{
- return ProcessThread::get_silent_buffers (count);
+ return ProcessThread::get_silent_buffers (count);
#if 0
assert(_silent_buffers->available() >= count);
_silent_buffers->set_count(count);
@@ -3810,7 +3809,7 @@ Session::get_silent_buffers (ChanCount count)
BufferSet&
Session::get_scratch_buffers (ChanCount count)
{
- return ProcessThread::get_scratch_buffers (count);
+ return ProcessThread::get_scratch_buffers (count);
#if 0
if (count != ChanCount::ZERO) {
assert(_scratch_buffers->available() >= count);
@@ -3826,7 +3825,7 @@ Session::get_scratch_buffers (ChanCount count)
BufferSet&
Session::get_mix_buffers (ChanCount count)
{
- return ProcessThread::get_mix_buffers (count);
+ return ProcessThread::get_mix_buffers (count);
#if 0
assert(_mix_buffers->available() >= count);
_mix_buffers->set_count(count);
@@ -3954,11 +3953,11 @@ Session::solo_control_mode_changed ()
{
/* cancel all solo or all listen when solo control mode changes */
- if (soloing()) {
- set_solo (get_routes(), false);
- } else if (listening()) {
- set_listen (get_routes(), false);
- }
+ if (soloing()) {
+ set_solo (get_routes(), false);
+ } else if (listening()) {
+ set_listen (get_routes(), false);
+ }
}
/** Called when anything about any of our route groups changes (membership, state etc.) */
@@ -4054,26 +4053,26 @@ Session::route_order_key_changed ()
void
Session::step_edit_status_change (bool yn)
{
- bool send = false;
+ bool send = false;
- bool val = false;
- if (yn) {
- send = (_step_editors == 0);
- val = true;
+ bool val = false;
+ if (yn) {
+ send = (_step_editors == 0);
+ val = true;
- _step_editors++;
- } else {
- send = (_step_editors == 1);
- val = false;
+ _step_editors++;
+ } else {
+ send = (_step_editors == 1);
+ val = false;
- if (_step_editors > 0) {
- _step_editors--;
- }
- }
+ if (_step_editors > 0) {
+ _step_editors--;
+ }
+ }
- if (send) {
- StepEditStatusChange (val);
- }
+ if (send) {
+ StepEditStatusChange (val);
+ }
}
@@ -4110,98 +4109,98 @@ Session::end_time_changed (framepos_t old)
string
Session::source_search_path (DataType type) const
{
- string search_path;
+ string search_path;
if (session_dirs.size() == 1) {
- switch (type) {
- case DataType::AUDIO:
- search_path = _session_dir->sound_path().to_string();
- break;
- case DataType::MIDI:
- search_path = _session_dir->midi_path().to_string();
- break;
- }
+ switch (type) {
+ case DataType::AUDIO:
+ search_path = _session_dir->sound_path().to_string();
+ break;
+ case DataType::MIDI:
+ search_path = _session_dir->midi_path().to_string();
+ break;
+ }
} else {
- for (vector<space_and_path>::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) {
- SessionDirectory sdir (i->path);
- if (!search_path.empty()) {
- search_path += ':';
- }
- switch (type) {
- case DataType::AUDIO:
- search_path += sdir.sound_path().to_string();
- break;
- case DataType::MIDI:
- search_path += sdir.midi_path().to_string();
- break;
- }
- }
- }
+ for (vector<space_and_path>::const_iterator i = session_dirs.begin(); i != session_dirs.end(); ++i) {
+ SessionDirectory sdir (i->path);
+ if (!search_path.empty()) {
+ search_path += ':';
+ }
+ switch (type) {
+ case DataType::AUDIO:
+ search_path += sdir.sound_path().to_string();
+ break;
+ case DataType::MIDI:
+ search_path += sdir.midi_path().to_string();
+ break;
+ }
+ }
+ }
- /* now add user-specified locations
- */
+ /* now add user-specified locations
+ */
- vector<string> dirs;
+ vector<string> dirs;
- switch (type) {
- case DataType::AUDIO:
- split (config.get_audio_search_path (), dirs, ':');
- break;
- case DataType::MIDI:
- split (config.get_midi_search_path (), dirs, ':');
- break;
- }
+ switch (type) {
+ case DataType::AUDIO:
+ split (config.get_audio_search_path (), dirs, ':');
+ break;
+ case DataType::MIDI:
+ split (config.get_midi_search_path (), dirs, ':');
+ break;
+ }
- for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
- search_path += ':';
- search_path += *i;
+ for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
+ search_path += ':';
+ search_path += *i;
- }
+ }
- return search_path;
+ return search_path;
}
void
Session::ensure_search_path_includes (const string& path, DataType type)
{
- string search_path;
- vector<string> dirs;
+ string search_path;
+ vector<string> dirs;
- if (path == ".") {
- return;
- }
+ if (path == ".") {
+ return;
+ }
- switch (type) {
- case DataType::AUDIO:
- search_path = config.get_audio_search_path ();
- break;
- case DataType::MIDI:
- search_path = config.get_midi_search_path ();
- break;
- }
+ switch (type) {
+ case DataType::AUDIO:
+ search_path = config.get_audio_search_path ();
+ break;
+ case DataType::MIDI:
+ search_path = config.get_midi_search_path ();
+ break;
+ }
- split (search_path, dirs, ':');
+ split (search_path, dirs, ':');
- for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
- if (*i == path) {
- return;
- }
- }
+ for (vector<string>::iterator i = dirs.begin(); i != dirs.end(); ++i) {
+ if (*i == path) {
+ return;
+ }
+ }
- if (!search_path.empty()) {
- search_path += ':';
- }
+ if (!search_path.empty()) {
+ search_path += ':';
+ }
- search_path += path;
+ search_path += path;
- switch (type) {
- case DataType::AUDIO:
- config.set_audio_search_path (search_path);
- break;
- case DataType::MIDI:
- config.set_midi_search_path (search_path);
- break;
- }
+ switch (type) {
+ case DataType::AUDIO:
+ config.set_audio_search_path (search_path);
+ break;
+ case DataType::MIDI:
+ config.set_midi_search_path (search_path);
+ break;
+ }
}
Speakers&
diff --git a/libs/ardour/speakers.cc b/libs/ardour/speakers.cc
index c5495f204d..7d0461ff52 100644
--- a/libs/ardour/speakers.cc
+++ b/libs/ardour/speakers.cc
@@ -24,16 +24,16 @@ using namespace PBD;
using namespace std;
Speaker::Speaker (int i, const AngularVector& position)
- : id (i)
+ : id (i)
{
- move (position);
+ move (position);
}
void
Speaker::move (const AngularVector& new_position)
{
- _angles = new_position;
- _angles.cartesian (_coords);
+ _angles = new_position;
+ _angles.cartesian (_coords);
}
Speakers::Speakers ()
@@ -47,62 +47,59 @@ Speakers::~Speakers ()
void
Speakers::dump_speakers (ostream& o)
{
- for (vector<Speaker>::iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
- o << "Speaker " << (*i).id << " @ "
- << (*i).coords().x << ", " << (*i).coords().y << ", " << (*i).coords().z
- << " azimuth " << (*i).angles().azi
- << " elevation " << (*i).angles().ele
- << " distance " << (*i).angles().length
- << endl;
- }
+ for (vector<Speaker>::iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
+ o << "Speaker " << (*i).id << " @ "
+ << (*i).coords().x << ", " << (*i).coords().y << ", " << (*i).coords().z
+ << " azimuth " << (*i).angles().azi
+ << " elevation " << (*i).angles().ele
+ << " distance " << (*i).angles().length
+ << endl;
+ }
}
void
Speakers::clear_speakers ()
{
- _speakers.clear ();
- update ();
+ _speakers.clear ();
+ update ();
}
int
Speakers::add_speaker (const AngularVector& position)
{
- int id = _speakers.size();
+ int id = _speakers.size();
- cerr << "Added speaker " << id << " at " << position.azi << " /= " << position.ele << endl;
+ cerr << "Added speaker " << id << " at " << position.azi << " /= " << position.ele << endl;
- _speakers.push_back (Speaker (id, position));
- update ();
+ _speakers.push_back (Speaker (id, position));
+ update ();
- dump_speakers (cerr);
- Changed ();
+ dump_speakers (cerr);
+ Changed ();
- return id;
+ return id;
}
void
Speakers::remove_speaker (int id)
{
- for (vector<Speaker>::iterator i = _speakers.begin(); i != _speakers.end(); ) {
- if ((*i).id == id) {
- i = _speakers.erase (i);
- update ();
- break;
- }
- }
+ for (vector<Speaker>::iterator i = _speakers.begin(); i != _speakers.end(); ) {
+ if ((*i).id == id) {
+ i = _speakers.erase (i);
+ update ();
+ break;
+ }
+ }
}
void
Speakers::move_speaker (int id, const AngularVector& new_position)
{
- for (vector<Speaker>::iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
- if ((*i).id == id) {
- (*i).move (new_position);
- update ();
- break;
- }
- }
+ for (vector<Speaker>::iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
+ if ((*i).id == id) {
+ (*i).move (new_position);
+ update ();
+ break;
+ }
+ }
}
-
-
-
diff --git a/libs/ardour/vbap.cc b/libs/ardour/vbap.cc
index 7c2b845139..75c18cb7de 100644
--- a/libs/ardour/vbap.cc
+++ b/libs/ardour/vbap.cc
@@ -1,3 +1,4 @@
+
/*
This software is being provided to you, the licensee, by Ville Pulkki,
under the following license. By obtaining, using and/or copying this
@@ -54,9 +55,9 @@ using namespace std;
string VBAPanner::name = X_("VBAP");
VBAPanner::VBAPanner (Panner& parent, Evoral::Parameter param, Speakers& s)
- : StreamPanner (parent, param)
- , _dirty (false)
- , _speakers (VBAPSpeakers::instance (s))
+ : StreamPanner (parent, param)
+ , _dirty (false)
+ , _speakers (VBAPSpeakers::instance (s))
{
}
@@ -67,76 +68,76 @@ VBAPanner::~VBAPanner ()
void
VBAPanner::mark_dirty ()
{
- _dirty = true;
+ _dirty = true;
}
void
VBAPanner::update ()
{
- /* force 2D for now */
- _angles.ele = 0.0;
- _dirty = true;
+ /* force 2D for now */
+ _angles.ele = 0.0;
+ _dirty = true;
- Changed ();
+ Changed ();
}
void
VBAPanner::compute_gains (double gains[3], int speaker_ids[3], int azi, int ele)
{
- /* calculates gain factors using loudspeaker setup and given direction */
- double cartdir[3];
- double power;
- int i,j,k;
- double small_g;
- double big_sm_g, gtmp[3];
+ /* calculates gain factors using loudspeaker setup and given direction */
+ double cartdir[3];
+ double power;
+ int i,j,k;
+ double small_g;
+ double big_sm_g, gtmp[3];
- azi_ele_to_cart (azi,ele, cartdir[0], cartdir[1], cartdir[2]);
- big_sm_g = -100000.0;
+ azi_ele_to_cart (azi,ele, cartdir[0], cartdir[1], cartdir[2]);
+ big_sm_g = -100000.0;
- for (i = 0; i < _speakers.n_tuples(); i++) {
+ for (i = 0; i < _speakers.n_tuples(); i++) {
- small_g = 10000000.0;
+ small_g = 10000000.0;
- for (j = 0; j < _speakers.dimension(); j++) {
+ for (j = 0; j < _speakers.dimension(); j++) {
- gtmp[j]=0.0;
+ gtmp[j]=0.0;
- for (k = 0; k < _speakers.dimension(); k++) {
- gtmp[j] += cartdir[k] * _speakers.matrix(i)[j*_speakers.dimension()+k];
- }
+ for (k = 0; k < _speakers.dimension(); k++) {
+ gtmp[j] += cartdir[k] * _speakers.matrix(i)[j*_speakers.dimension()+k];
+ }
- if (gtmp[j] < small_g) {
- small_g = gtmp[j];
- }
- }
+ if (gtmp[j] < small_g) {
+ small_g = gtmp[j];
+ }
+ }
- if (small_g > big_sm_g) {
+ if (small_g > big_sm_g) {
- big_sm_g = small_g;
+ big_sm_g = small_g;
- gains[0] = gtmp[0];
- gains[1] = gtmp[1];
+ gains[0] = gtmp[0];
+ gains[1] = gtmp[1];
- speaker_ids[0] = _speakers.speaker_for_tuple (i, 0);
- speaker_ids[1] = _speakers.speaker_for_tuple (i, 1);
+ speaker_ids[0] = _speakers.speaker_for_tuple (i, 0);
+ speaker_ids[1] = _speakers.speaker_for_tuple (i, 1);
- if (_speakers.dimension() == 3) {
- gains[2] = gtmp[2];
- speaker_ids[2] = _speakers.speaker_for_tuple (i, 2);
- } else {
- gains[2] = 0.0;
- speaker_ids[2] = -1;
- }
- }
- }
+ if (_speakers.dimension() == 3) {
+ gains[2] = gtmp[2];
+ speaker_ids[2] = _speakers.speaker_for_tuple (i, 2);
+ } else {
+ gains[2] = 0.0;
+ speaker_ids[2] = -1;
+ }
+ }
+ }
- power = sqrt (gains[0]*gains[0] + gains[1]*gains[1] + gains[2]*gains[2]);
+ power = sqrt (gains[0]*gains[0] + gains[1]*gains[1] + gains[2]*gains[2]);
- gains[0] /= power;
- gains[1] /= power;
- gains[2] /= power;
+ gains[0] /= power;
+ gains[1] /= power;
+ gains[2] /= power;
- _dirty = false;
+ _dirty = false;
}
void
@@ -148,62 +149,62 @@ VBAPanner::do_distribute (AudioBuffer& srcbuf, BufferSet& obufs, gain_t gain_coe
Sample* const src = srcbuf.data();
Sample* dst;
- pan_t pan;
- uint32_t n_audio = obufs.count().n_audio();
- bool was_dirty;
-
- if ((was_dirty = _dirty)) {
- compute_gains (desired_gains, desired_outputs, _angles.azi, _angles.ele);
- cerr << " @ " << _angles.azi << " /= " << _angles.ele
- << " Outputs: "
- << desired_outputs[0] + 1 << ' '
- << desired_outputs[1] + 1 << ' '
- << " Gains "
- << desired_gains[0] << ' '
- << desired_gains[1] << ' '
- << endl;
- }
-
- bool todo[n_audio];
+ pan_t pan;
+ uint32_t n_audio = obufs.count().n_audio();
+ bool was_dirty;
+
+ if ((was_dirty = _dirty)) {
+ compute_gains (desired_gains, desired_outputs, _angles.azi, _angles.ele);
+ cerr << " @ " << _angles.azi << " /= " << _angles.ele
+ << " Outputs: "
+ << desired_outputs[0] + 1 << ' '
+ << desired_outputs[1] + 1 << ' '
+ << " Gains "
+ << desired_gains[0] << ' '
+ << desired_gains[1] << ' '
+ << endl;
+ }
+
+ bool todo[n_audio];
- for (uint32_t o = 0; o < n_audio; ++o) {
- todo[o] = true;
- }
+ for (uint32_t o = 0; o < n_audio; ++o) {
+ todo[o] = true;
+ }
- /* VBAP may distribute the signal across up to 3 speakers depending on
- the configuration of the speakers.
- */
+ /* VBAP may distribute the signal across up to 3 speakers depending on
+ the configuration of the speakers.
+ */
- for (int o = 0; o < 3; ++o) {
- if (desired_outputs[o] != -1) {
+ for (int o = 0; o < 3; ++o) {
+ if (desired_outputs[o] != -1) {
- nframes_t n = 0;
+ nframes_t n = 0;
- /* XXX TODO: interpolate across changes in gain and/or outputs
- */
+ /* XXX TODO: interpolate across changes in gain and/or outputs
+ */
- dst = obufs.get_audio(desired_outputs[o]).data();
+ dst = obufs.get_audio(desired_outputs[o]).data();
- pan = gain_coefficient * desired_gains[o];
- mix_buffers_with_gain (dst+n,src+n,nframes-n,pan);
+ pan = gain_coefficient * desired_gains[o];
+ mix_buffers_with_gain (dst+n,src+n,nframes-n,pan);
- todo[o] = false;
- }
- }
+ todo[o] = false;
+ }
+ }
- for (uint32_t o = 0; o < n_audio; ++o) {
- if (todo[o]) {
- /* VBAP decided not to deliver any audio to this output, so we write silence */
- dst = obufs.get_audio(o).data();
- memset (dst, 0, sizeof (Sample) * nframes);
- }
- }
+ for (uint32_t o = 0; o < n_audio; ++o) {
+ if (todo[o]) {
+ /* VBAP decided not to deliver any audio to this output, so we write silence */
+ dst = obufs.get_audio(o).data();
+ memset (dst, 0, sizeof (Sample) * nframes);
+ }
+ }
- if (was_dirty) {
- memcpy (gains, desired_gains, sizeof (gains));
- memcpy (outputs, desired_outputs, sizeof (outputs));
- }
+ if (was_dirty) {
+ memcpy (gains, desired_gains, sizeof (gains));
+ memcpy (outputs, desired_outputs, sizeof (outputs));
+ }
}
void
@@ -215,20 +216,20 @@ VBAPanner::do_distribute_automated (AudioBuffer& src, BufferSet& obufs,
XMLNode&
VBAPanner::get_state ()
{
- return state (true);
+ return state (true);
}
XMLNode&
VBAPanner::state (bool full_state)
{
- XMLNode* node = new XMLNode (X_("VBAPanner"));
- return *node;
+ XMLNode* node = new XMLNode (X_("VBAPanner"));
+ return *node;
}
int
VBAPanner::set_state (const XMLNode& node, int /*version*/)
{
- return 0;
+ return 0;
}
StreamPanner*
diff --git a/libs/ardour/vbap_speakers.cc b/libs/ardour/vbap_speakers.cc
index 308f1beafb..9090ed65e1 100644
--- a/libs/ardour/vbap_speakers.cc
+++ b/libs/ardour/vbap_speakers.cc
@@ -47,18 +47,18 @@ VBAPSpeakers* VBAPSpeakers::_instance = 0;
VBAPSpeakers&
VBAPSpeakers::instance (Speakers& s)
{
- if (_instance == 0) {
- _instance = new VBAPSpeakers (s);
- }
+ if (_instance == 0) {
+ _instance = new VBAPSpeakers (s);
+ }
- return *_instance;
+ return *_instance;
}
VBAPSpeakers::VBAPSpeakers (Speakers& s)
- : _dimension (2)
- , _speakers (s.speakers())
+ : _dimension (2)
+ , _speakers (s.speakers())
{
- s.Changed.connect_same_thread (speaker_connection, boost::bind (&VBAPSpeakers::update, this));
+ s.Changed.connect_same_thread (speaker_connection, boost::bind (&VBAPSpeakers::update, this));
}
VBAPSpeakers::~VBAPSpeakers ()
@@ -68,591 +68,591 @@ VBAPSpeakers::~VBAPSpeakers ()
void
VBAPSpeakers::update ()
{
- int dim = 2;
+ int dim = 2;
- 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";
- dim = 3;
- break;
- }
- }
-
- _dimension = dim;
-
- cerr << "update with dimension = " << dim << " speakers = " << _speakers.size() << endl;
-
- if (_speakers.size() < 2) {
- /* nothing to be done with less than two speakers */
- return;
- }
-
- if (_dimension == 3) {
- ls_triplet_chain *ls_triplets = 0;
- choose_speaker_triplets (&ls_triplets);
- if (ls_triplets) {
- calculate_3x3_matrixes (ls_triplets);
- free (ls_triplets);
- }
- } else {
- choose_speaker_pairs ();
- }
+ 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";
+ dim = 3;
+ break;
+ }
+ }
+
+ _dimension = dim;
+
+ cerr << "update with dimension = " << dim << " speakers = " << _speakers.size() << endl;
+
+ if (_speakers.size() < 2) {
+ /* nothing to be done with less than two speakers */
+ return;
+ }
+
+ if (_dimension == 3) {
+ ls_triplet_chain *ls_triplets = 0;
+ choose_speaker_triplets (&ls_triplets);
+ if (ls_triplets) {
+ calculate_3x3_matrixes (ls_triplets);
+ free (ls_triplets);
+ }
+ } else {
+ choose_speaker_pairs ();
+ }
}
void
VBAPSpeakers::choose_speaker_triplets(struct ls_triplet_chain **ls_triplets)
{
- /* Selects the loudspeaker triplets, and
- calculates the inversion matrices for each selected triplet.
- A line (connection) is drawn between each loudspeaker. The lines
- denote the sides of the triangles. The triangles should not be
- intersecting. All crossing connections are searched and the
- longer connection is erased. This yields non-intesecting triangles,
- which can be used in panning.
- */
-
- int i,j,k,l,table_size;
- int n_speakers = _speakers.size ();
- int connections[n_speakers][n_speakers];
- float distance_table[((n_speakers * (n_speakers - 1)) / 2)];
- int distance_table_i[((n_speakers * (n_speakers - 1)) / 2)];
- int distance_table_j[((n_speakers * (n_speakers - 1)) / 2)];
- float distance;
- struct ls_triplet_chain *trip_ptr, *prev, *tmp_ptr;
-
- if (n_speakers == 0) {
- return;
- }
-
- for (i = 0; i < n_speakers; i++) {
- for (j = i+1; j < n_speakers; j++) {
- for(k=j+1;k<n_speakers;k++) {
- if (vol_p_side_lgth(i,j, k, _speakers) > MIN_VOL_P_SIDE_LGTH){
- connections[i][j]=1;
- connections[j][i]=1;
- connections[i][k]=1;
- connections[k][i]=1;
- connections[j][k]=1;
- connections[k][j]=1;
- add_ldsp_triplet(i,j,k,ls_triplets);
- }
- }
- }
- }
-
- /*calculate distancies between all speakers and sorting them*/
- table_size =(((n_speakers - 1) * (n_speakers)) / 2);
- for (i = 0; i < table_size; i++) {
- distance_table[i] = 100000.0;
- }
-
- for (i = 0;i < n_speakers; i++) {
- for (j = i+1; j < n_speakers; j++) {
- if (connections[i][j] == 1) {
- distance = fabs(vec_angle(_speakers[i].coords(),_speakers[j].coords()));
- k=0;
- while(distance_table[k] < distance) {
- k++;
- }
- for (l = table_size - 1; l > k ; l--) {
- distance_table[l] = distance_table[l-1];
- distance_table_i[l] = distance_table_i[l-1];
- distance_table_j[l] = distance_table_j[l-1];
- }
- distance_table[k] = distance;
- distance_table_i[k] = i;
- distance_table_j[k] = j;
- } else
- table_size--;
- }
- }
-
- /* disconnecting connections which are crossing shorter ones,
- starting from shortest one and removing all that cross it,
- and proceeding to next shortest */
- for (i = 0; i < table_size; i++) {
- int fst_ls = distance_table_i[i];
- int sec_ls = distance_table_j[i];
- if (connections[fst_ls][sec_ls] == 1) {
- for (j = 0; j < n_speakers; j++) {
- for (k = j+1; k < n_speakers; k++) {
- if ((j!=fst_ls) && (k != sec_ls) && (k!=fst_ls) && (j != sec_ls)){
- if (lines_intersect(fst_ls, sec_ls, j,k) == 1){
- connections[j][k] = 0;
- connections[k][j] = 0;
- }
- }
- }
- }
- }
- }
-
- /* remove triangles which had crossing sides
- with smaller triangles or include loudspeakers*/
- trip_ptr = *ls_triplets;
- prev = 0;
- while (trip_ptr != 0){
- i = trip_ptr->ls_nos[0];
- j = trip_ptr->ls_nos[1];
- k = trip_ptr->ls_nos[2];
- if (connections[i][j] == 0 ||
- connections[i][k] == 0 ||
- connections[j][k] == 0 ||
- any_ls_inside_triplet(i,j,k) == 1 ){
- if (prev != 0) {
- prev->next = trip_ptr->next;
- tmp_ptr = trip_ptr;
- trip_ptr = trip_ptr->next;
- free(tmp_ptr);
- } else {
- *ls_triplets = trip_ptr->next;
- tmp_ptr = trip_ptr;
- trip_ptr = trip_ptr->next;
- free(tmp_ptr);
- }
- } else {
- prev = trip_ptr;
- trip_ptr = trip_ptr->next;
-
- }
- }
+ /* Selects the loudspeaker triplets, and
+ calculates the inversion matrices for each selected triplet.
+ A line (connection) is drawn between each loudspeaker. The lines
+ denote the sides of the triangles. The triangles should not be
+ intersecting. All crossing connections are searched and the
+ longer connection is erased. This yields non-intesecting triangles,
+ which can be used in panning.
+ */
+
+ int i,j,k,l,table_size;
+ int n_speakers = _speakers.size ();
+ int connections[n_speakers][n_speakers];
+ float distance_table[((n_speakers * (n_speakers - 1)) / 2)];
+ int distance_table_i[((n_speakers * (n_speakers - 1)) / 2)];
+ int distance_table_j[((n_speakers * (n_speakers - 1)) / 2)];
+ float distance;
+ struct ls_triplet_chain *trip_ptr, *prev, *tmp_ptr;
+
+ if (n_speakers == 0) {
+ return;
+ }
+
+ for (i = 0; i < n_speakers; i++) {
+ for (j = i+1; j < n_speakers; j++) {
+ for(k=j+1;k<n_speakers;k++) {
+ if (vol_p_side_lgth(i,j, k, _speakers) > MIN_VOL_P_SIDE_LGTH){
+ connections[i][j]=1;
+ connections[j][i]=1;
+ connections[i][k]=1;
+ connections[k][i]=1;
+ connections[j][k]=1;
+ connections[k][j]=1;
+ add_ldsp_triplet(i,j,k,ls_triplets);
+ }
+ }
+ }
+ }
+
+ /*calculate distancies between all speakers and sorting them*/
+ table_size =(((n_speakers - 1) * (n_speakers)) / 2);
+ for (i = 0; i < table_size; i++) {
+ distance_table[i] = 100000.0;
+ }
+
+ for (i = 0;i < n_speakers; i++) {
+ for (j = i+1; j < n_speakers; j++) {
+ if (connections[i][j] == 1) {
+ distance = fabs(vec_angle(_speakers[i].coords(),_speakers[j].coords()));
+ k=0;
+ while(distance_table[k] < distance) {
+ k++;
+ }
+ for (l = table_size - 1; l > k ; l--) {
+ distance_table[l] = distance_table[l-1];
+ distance_table_i[l] = distance_table_i[l-1];
+ distance_table_j[l] = distance_table_j[l-1];
+ }
+ distance_table[k] = distance;
+ distance_table_i[k] = i;
+ distance_table_j[k] = j;
+ } else
+ table_size--;
+ }
+ }
+
+ /* disconnecting connections which are crossing shorter ones,
+ starting from shortest one and removing all that cross it,
+ and proceeding to next shortest */
+ for (i = 0; i < table_size; i++) {
+ int fst_ls = distance_table_i[i];
+ int sec_ls = distance_table_j[i];
+ if (connections[fst_ls][sec_ls] == 1) {
+ for (j = 0; j < n_speakers; j++) {
+ for (k = j+1; k < n_speakers; k++) {
+ if ((j!=fst_ls) && (k != sec_ls) && (k!=fst_ls) && (j != sec_ls)){
+ if (lines_intersect(fst_ls, sec_ls, j,k) == 1){
+ connections[j][k] = 0;
+ connections[k][j] = 0;
+ }
+ }
+ }
+ }
+ }
+ }
+
+ /* remove triangles which had crossing sides
+ with smaller triangles or include loudspeakers*/
+ trip_ptr = *ls_triplets;
+ prev = 0;
+ while (trip_ptr != 0){
+ i = trip_ptr->ls_nos[0];
+ j = trip_ptr->ls_nos[1];
+ k = trip_ptr->ls_nos[2];
+ if (connections[i][j] == 0 ||
+ connections[i][k] == 0 ||
+ connections[j][k] == 0 ||
+ any_ls_inside_triplet(i,j,k) == 1 ){
+ if (prev != 0) {
+ prev->next = trip_ptr->next;
+ tmp_ptr = trip_ptr;
+ trip_ptr = trip_ptr->next;
+ free(tmp_ptr);
+ } else {
+ *ls_triplets = trip_ptr->next;
+ tmp_ptr = trip_ptr;
+ trip_ptr = trip_ptr->next;
+ free(tmp_ptr);
+ }
+ } else {
+ prev = trip_ptr;
+ trip_ptr = trip_ptr->next;
+
+ }
+ }
}
int
VBAPSpeakers::any_ls_inside_triplet(int a, int b, int c)
{
- /* returns 1 if there is loudspeaker(s) inside given ls triplet */
- float invdet;
- const CartesianVector* lp1;
- const CartesianVector* lp2;
- const CartesianVector* lp3;
- float invmx[9];
- int i,j;
- float tmp;
- bool any_ls_inside;
- bool this_inside;
- int n_speakers = _speakers.size();
-
- lp1 = &(_speakers[a].coords());
- lp2 = &(_speakers[b].coords());
- lp3 = &(_speakers[c].coords());
+ /* returns 1 if there is loudspeaker(s) inside given ls triplet */
+ float invdet;
+ const CartesianVector* lp1;
+ const CartesianVector* lp2;
+ const CartesianVector* lp3;
+ float invmx[9];
+ int i,j;
+ float tmp;
+ bool any_ls_inside;
+ bool this_inside;
+ int n_speakers = _speakers.size();
+
+ lp1 = &(_speakers[a].coords());
+ lp2 = &(_speakers[b].coords());
+ lp3 = &(_speakers[c].coords());
- /* matrix inversion */
- invdet = 1.0 / ( lp1->x * ((lp2->y * lp3->z) - (lp2->z * lp3->y))
- - lp1->y * ((lp2->x * lp3->z) - (lp2->z * lp3->x))
- + lp1->z * ((lp2->x * lp3->y) - (lp2->y * lp3->x)));
+ /* matrix inversion */
+ invdet = 1.0 / ( lp1->x * ((lp2->y * lp3->z) - (lp2->z * lp3->y))
+ - lp1->y * ((lp2->x * lp3->z) - (lp2->z * lp3->x))
+ + lp1->z * ((lp2->x * lp3->y) - (lp2->y * lp3->x)));
- invmx[0] = ((lp2->y * lp3->z) - (lp2->z * lp3->y)) * invdet;
- invmx[3] = ((lp1->y * lp3->z) - (lp1->z * lp3->y)) * -invdet;
- invmx[6] = ((lp1->y * lp2->z) - (lp1->z * lp2->y)) * invdet;
- invmx[1] = ((lp2->x * lp3->z) - (lp2->z * lp3->x)) * -invdet;
- invmx[4] = ((lp1->x * lp3->z) - (lp1->z * lp3->x)) * invdet;
- invmx[7] = ((lp1->x * lp2->z) - (lp1->z * lp2->x)) * -invdet;
- invmx[2] = ((lp2->x * lp3->y) - (lp2->y * lp3->x)) * invdet;
- invmx[5] = ((lp1->x * lp3->y) - (lp1->y * lp3->x)) * -invdet;
- invmx[8] = ((lp1->x * lp2->y) - (lp1->y * lp2->x)) * invdet;
+ invmx[0] = ((lp2->y * lp3->z) - (lp2->z * lp3->y)) * invdet;
+ invmx[3] = ((lp1->y * lp3->z) - (lp1->z * lp3->y)) * -invdet;
+ invmx[6] = ((lp1->y * lp2->z) - (lp1->z * lp2->y)) * invdet;
+ invmx[1] = ((lp2->x * lp3->z) - (lp2->z * lp3->x)) * -invdet;
+ invmx[4] = ((lp1->x * lp3->z) - (lp1->z * lp3->x)) * invdet;
+ invmx[7] = ((lp1->x * lp2->z) - (lp1->z * lp2->x)) * -invdet;
+ invmx[2] = ((lp2->x * lp3->y) - (lp2->y * lp3->x)) * invdet;
+ invmx[5] = ((lp1->x * lp3->y) - (lp1->y * lp3->x)) * -invdet;
+ invmx[8] = ((lp1->x * lp2->y) - (lp1->y * lp2->x)) * invdet;
- any_ls_inside = false;
- for (i = 0; i < n_speakers; i++) {
- if (i != a && i!=b && i != c) {
- this_inside = true;
- for (j = 0; j < 3; j++) {
- tmp = _speakers[i].coords().x * invmx[0 + j*3];
- tmp += _speakers[i].coords().y * invmx[1 + j*3];
- tmp += _speakers[i].coords().z * invmx[2 + j*3];
- if (tmp < -0.001) {
- this_inside = false;
- }
- }
- if (this_inside) {
- any_ls_inside = true;
- }
- }
- }
-
- return any_ls_inside;
+ any_ls_inside = false;
+ for (i = 0; i < n_speakers; i++) {
+ if (i != a && i!=b && i != c) {
+ this_inside = true;
+ for (j = 0; j < 3; j++) {
+ tmp = _speakers[i].coords().x * invmx[0 + j*3];
+ tmp += _speakers[i].coords().y * invmx[1 + j*3];
+ tmp += _speakers[i].coords().z * invmx[2 + j*3];
+ if (tmp < -0.001) {
+ this_inside = false;
+ }
+ }
+ if (this_inside) {
+ any_ls_inside = true;
+ }
+ }
+ }
+
+ return any_ls_inside;
}
void
VBAPSpeakers::add_ldsp_triplet(int i, int j, int k, struct ls_triplet_chain **ls_triplets)
{
- /* adds i,j,k triplet to triplet chain*/
+ /* adds i,j,k triplet to triplet chain*/
- struct ls_triplet_chain *trip_ptr, *prev;
- trip_ptr = *ls_triplets;
- prev = 0;
+ struct ls_triplet_chain *trip_ptr, *prev;
+ trip_ptr = *ls_triplets;
+ prev = 0;
- while (trip_ptr != 0){
- prev = trip_ptr;
- trip_ptr = trip_ptr->next;
- }
-
- trip_ptr = (struct ls_triplet_chain*) malloc (sizeof (struct ls_triplet_chain));
-
- if (prev == 0) {
- *ls_triplets = trip_ptr;
- } else {
- prev->next = trip_ptr;
- }
-
- trip_ptr->next = 0;
- trip_ptr->ls_nos[0] = i;
- trip_ptr->ls_nos[1] = j;
- trip_ptr->ls_nos[2] = k;
+ while (trip_ptr != 0){
+ prev = trip_ptr;
+ trip_ptr = trip_ptr->next;
+ }
+
+ trip_ptr = (struct ls_triplet_chain*) malloc (sizeof (struct ls_triplet_chain));
+
+ if (prev == 0) {
+ *ls_triplets = trip_ptr;
+ } else {
+ prev->next = trip_ptr;
+ }
+
+ trip_ptr->next = 0;
+ trip_ptr->ls_nos[0] = i;
+ trip_ptr->ls_nos[1] = j;
+ trip_ptr->ls_nos[2] = k;
}
float
VBAPSpeakers::vec_angle(CartesianVector v1, CartesianVector v2)
{
- float inner= ((v1.x*v2.x + v1.y*v2.y + v1.z*v2.z)/
- (vec_length(v1) * vec_length(v2)));
+ float inner= ((v1.x*v2.x + v1.y*v2.y + v1.z*v2.z)/
+ (vec_length(v1) * vec_length(v2)));
- if (inner > 1.0) {
- inner= 1.0;
- }
+ if (inner > 1.0) {
+ inner= 1.0;
+ }
- if (inner < -1.0) {
- inner = -1.0;
- }
+ if (inner < -1.0) {
+ inner = -1.0;
+ }
- return fabsf((float) acos((double) inner));
+ return fabsf((float) acos((double) inner));
}
float
VBAPSpeakers::vec_length(CartesianVector v1)
{
- return (sqrt(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z));
+ return (sqrt(v1.x*v1.x + v1.y*v1.y + v1.z*v1.z));
}
float
VBAPSpeakers::vec_prod(CartesianVector v1, CartesianVector v2)
{
- return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
+ return (v1.x*v2.x + v1.y*v2.y + v1.z*v2.z);
}
float
VBAPSpeakers::vol_p_side_lgth(int i, int j,int k, const vector<Speaker>& speakers)
{
- /* calculate volume of the parallelepiped defined by the loudspeaker
- direction vectors and divide it with total length of the triangle sides.
- This is used when removing too narrow triangles. */
+ /* calculate volume of the parallelepiped defined by the loudspeaker
+ direction vectors and divide it with total length of the triangle sides.
+ This is used when removing too narrow triangles. */
- float volper, lgth;
- CartesianVector xprod;
-
- cross_prod (speakers[i].coords(), speakers[j].coords(), &xprod);
- volper = fabsf (vec_prod(xprod, speakers[k].coords()));
- lgth = (fabsf (vec_angle(speakers[i].coords(), speakers[j].coords()))
- + fabsf (vec_angle(speakers[i].coords(), speakers[k].coords()))
- + fabsf (vec_angle(speakers[j].coords(), speakers[k].coords())));
-
- if (lgth > 0.00001) {
- return volper / lgth;
- } else {
- return 0.0;
- }
+ float volper, lgth;
+ CartesianVector xprod;
+
+ cross_prod (speakers[i].coords(), speakers[j].coords(), &xprod);
+ volper = fabsf (vec_prod(xprod, speakers[k].coords()));
+ lgth = (fabsf (vec_angle(speakers[i].coords(), speakers[j].coords()))
+ + fabsf (vec_angle(speakers[i].coords(), speakers[k].coords()))
+ + fabsf (vec_angle(speakers[j].coords(), speakers[k].coords())));
+
+ if (lgth > 0.00001) {
+ return volper / lgth;
+ } else {
+ return 0.0;
+ }
}
void
VBAPSpeakers::cross_prod(CartesianVector v1,CartesianVector v2, CartesianVector *res)
{
- float length;
+ float length;
- res->x = (v1.y * v2.z ) - (v1.z * v2.y);
- res->y = (v1.z * v2.x ) - (v1.x * v2.z);
- res->z = (v1.x * v2.y ) - (v1.y * v2.x);
+ res->x = (v1.y * v2.z ) - (v1.z * v2.y);
+ res->y = (v1.z * v2.x ) - (v1.x * v2.z);
+ res->z = (v1.x * v2.y ) - (v1.y * v2.x);
- length = vec_length(*res);
- res->x /= length;
- res->y /= length;
- res->z /= length;
+ length = vec_length(*res);
+ res->x /= length;
+ res->y /= length;
+ res->z /= length;
}
int
VBAPSpeakers::lines_intersect (int i, int j, int k, int l)
{
- /* checks if two lines intersect on 3D sphere
- see theory in paper Pulkki, V. Lokki, T. "Creating Auditory Displays
- with Multiple Loudspeakers Using VBAP: A Case Study with
- DIVA Project" in International Conference on
- Auditory Displays -98. E-mail Ville.Pulkki@hut.fi
- if you want to have that paper.
- */
-
- CartesianVector v1;
- CartesianVector v2;
- CartesianVector v3, neg_v3;
- float dist_ij,dist_kl,dist_iv3,dist_jv3,dist_inv3,dist_jnv3;
- float dist_kv3,dist_lv3,dist_knv3,dist_lnv3;
+ /* checks if two lines intersect on 3D sphere
+ see theory in paper Pulkki, V. Lokki, T. "Creating Auditory Displays
+ with Multiple Loudspeakers Using VBAP: A Case Study with
+ DIVA Project" in International Conference on
+ Auditory Displays -98. E-mail Ville.Pulkki@hut.fi
+ if you want to have that paper.
+ */
+
+ CartesianVector v1;
+ CartesianVector v2;
+ CartesianVector v3, neg_v3;
+ float dist_ij,dist_kl,dist_iv3,dist_jv3,dist_inv3,dist_jnv3;
+ float dist_kv3,dist_lv3,dist_knv3,dist_lnv3;
- cross_prod(_speakers[i].coords(),_speakers[j].coords(),&v1);
- cross_prod(_speakers[k].coords(),_speakers[l].coords(),&v2);
- cross_prod(v1,v2,&v3);
+ cross_prod(_speakers[i].coords(),_speakers[j].coords(),&v1);
+ cross_prod(_speakers[k].coords(),_speakers[l].coords(),&v2);
+ cross_prod(v1,v2,&v3);
- neg_v3.x= 0.0 - v3.x;
- neg_v3.y= 0.0 - v3.y;
- neg_v3.z= 0.0 - v3.z;
-
- dist_ij = (vec_angle(_speakers[i].coords(),_speakers[j].coords()));
- dist_kl = (vec_angle(_speakers[k].coords(),_speakers[l].coords()));
- dist_iv3 = (vec_angle(_speakers[i].coords(),v3));
- dist_jv3 = (vec_angle(v3,_speakers[j].coords()));
- dist_inv3 = (vec_angle(_speakers[i].coords(),neg_v3));
- dist_jnv3 = (vec_angle(neg_v3,_speakers[j].coords()));
- dist_kv3 = (vec_angle(_speakers[k].coords(),v3));
- dist_lv3 = (vec_angle(v3,_speakers[l].coords()));
- dist_knv3 = (vec_angle(_speakers[k].coords(),neg_v3));
- dist_lnv3 = (vec_angle(neg_v3,_speakers[l].coords()));
-
- /* if one of loudspeakers is close to crossing point, don't do anything*/
-
-
- if(fabsf(dist_iv3) <= 0.01 || fabsf(dist_jv3) <= 0.01 ||
- fabsf(dist_kv3) <= 0.01 || fabsf(dist_lv3) <= 0.01 ||
- fabsf(dist_inv3) <= 0.01 || fabsf(dist_jnv3) <= 0.01 ||
- fabsf(dist_knv3) <= 0.01 || fabsf(dist_lnv3) <= 0.01 ) {
- return(0);
- }
-
- if (((fabsf(dist_ij - (dist_iv3 + dist_jv3)) <= 0.01 ) &&
- (fabsf(dist_kl - (dist_kv3 + dist_lv3)) <= 0.01)) ||
- ((fabsf(dist_ij - (dist_inv3 + dist_jnv3)) <= 0.01) &&
- (fabsf(dist_kl - (dist_knv3 + dist_lnv3)) <= 0.01 ))) {
- return (1);
- } else {
- return (0);
- }
+ neg_v3.x= 0.0 - v3.x;
+ neg_v3.y= 0.0 - v3.y;
+ neg_v3.z= 0.0 - v3.z;
+
+ dist_ij = (vec_angle(_speakers[i].coords(),_speakers[j].coords()));
+ dist_kl = (vec_angle(_speakers[k].coords(),_speakers[l].coords()));
+ dist_iv3 = (vec_angle(_speakers[i].coords(),v3));
+ dist_jv3 = (vec_angle(v3,_speakers[j].coords()));
+ dist_inv3 = (vec_angle(_speakers[i].coords(),neg_v3));
+ dist_jnv3 = (vec_angle(neg_v3,_speakers[j].coords()));
+ dist_kv3 = (vec_angle(_speakers[k].coords(),v3));
+ dist_lv3 = (vec_angle(v3,_speakers[l].coords()));
+ dist_knv3 = (vec_angle(_speakers[k].coords(),neg_v3));
+ dist_lnv3 = (vec_angle(neg_v3,_speakers[l].coords()));
+
+ /* if one of loudspeakers is close to crossing point, don't do anything*/
+
+
+ if(fabsf(dist_iv3) <= 0.01 || fabsf(dist_jv3) <= 0.01 ||
+ fabsf(dist_kv3) <= 0.01 || fabsf(dist_lv3) <= 0.01 ||
+ fabsf(dist_inv3) <= 0.01 || fabsf(dist_jnv3) <= 0.01 ||
+ fabsf(dist_knv3) <= 0.01 || fabsf(dist_lnv3) <= 0.01 ) {
+ return(0);
+ }
+
+ if (((fabsf(dist_ij - (dist_iv3 + dist_jv3)) <= 0.01 ) &&
+ (fabsf(dist_kl - (dist_kv3 + dist_lv3)) <= 0.01)) ||
+ ((fabsf(dist_ij - (dist_inv3 + dist_jnv3)) <= 0.01) &&
+ (fabsf(dist_kl - (dist_knv3 + dist_lnv3)) <= 0.01 ))) {
+ return (1);
+ } else {
+ return (0);
+ }
}
void
VBAPSpeakers::calculate_3x3_matrixes(struct ls_triplet_chain *ls_triplets)
{
- /* Calculates the inverse matrices for 3D */
- float invdet;
- const CartesianVector* lp1;
- const CartesianVector* lp2;
- const CartesianVector* lp3;
- float *invmx;
- struct ls_triplet_chain *tr_ptr = ls_triplets;
- int triplet_count = 0;
- int triplet;
-
- assert (tr_ptr);
+ /* Calculates the inverse matrices for 3D */
+ float invdet;
+ const CartesianVector* lp1;
+ const CartesianVector* lp2;
+ const CartesianVector* lp3;
+ float *invmx;
+ struct ls_triplet_chain *tr_ptr = ls_triplets;
+ int triplet_count = 0;
+ int triplet;
+
+ assert (tr_ptr);
- /* counting triplet amount */
+ /* counting triplet amount */
- while (tr_ptr != 0) {
- triplet_count++;
- tr_ptr = tr_ptr->next;
- }
+ while (tr_ptr != 0) {
+ triplet_count++;
+ tr_ptr = tr_ptr->next;
+ }
- cerr << "@@@ triplets generate " << triplet_count << " of speaker tuples\n";
+ cerr << "@@@ triplets generate " << triplet_count << " of speaker tuples\n";
- triplet = 0;
+ triplet = 0;
- _matrices.clear ();
- _speaker_tuples.clear ();
+ _matrices.clear ();
+ _speaker_tuples.clear ();
- for (int n = 0; n < triplet_count; ++n) {
- _matrices.push_back (threeDmatrix());
- _speaker_tuples.push_back (tmatrix());
- }
+ for (int n = 0; n < triplet_count; ++n) {
+ _matrices.push_back (threeDmatrix());
+ _speaker_tuples.push_back (tmatrix());
+ }
- while (tr_ptr != 0) {
- lp1 = &(_speakers[tr_ptr->ls_nos[0]].coords());
- lp2 = &(_speakers[tr_ptr->ls_nos[1]].coords());
- lp3 = &(_speakers[tr_ptr->ls_nos[2]].coords());
+ while (tr_ptr != 0) {
+ lp1 = &(_speakers[tr_ptr->ls_nos[0]].coords());
+ lp2 = &(_speakers[tr_ptr->ls_nos[1]].coords());
+ lp3 = &(_speakers[tr_ptr->ls_nos[2]].coords());
- /* matrix inversion */
- invmx = tr_ptr->inv_mx;
- invdet = 1.0 / ( lp1->x * ((lp2->y * lp3->z) - (lp2->z * lp3->y))
- - lp1->y * ((lp2->x * lp3->z) - (lp2->z * lp3->x))
- + lp1->z * ((lp2->x * lp3->y) - (lp2->y * lp3->x)));
+ /* matrix inversion */
+ invmx = tr_ptr->inv_mx;
+ invdet = 1.0 / ( lp1->x * ((lp2->y * lp3->z) - (lp2->z * lp3->y))
+ - lp1->y * ((lp2->x * lp3->z) - (lp2->z * lp3->x))
+ + lp1->z * ((lp2->x * lp3->y) - (lp2->y * lp3->x)));
- invmx[0] = ((lp2->y * lp3->z) - (lp2->z * lp3->y)) * invdet;
- invmx[3] = ((lp1->y * lp3->z) - (lp1->z * lp3->y)) * -invdet;
- invmx[6] = ((lp1->y * lp2->z) - (lp1->z * lp2->y)) * invdet;
- invmx[1] = ((lp2->x * lp3->z) - (lp2->z * lp3->x)) * -invdet;
- invmx[4] = ((lp1->x * lp3->z) - (lp1->z * lp3->x)) * invdet;
- invmx[7] = ((lp1->x * lp2->z) - (lp1->z * lp2->x)) * -invdet;
- invmx[2] = ((lp2->x * lp3->y) - (lp2->y * lp3->x)) * invdet;
- invmx[5] = ((lp1->x * lp3->y) - (lp1->y * lp3->x)) * -invdet;
- invmx[8] = ((lp1->x * lp2->y) - (lp1->y * lp2->x)) * invdet;
+ invmx[0] = ((lp2->y * lp3->z) - (lp2->z * lp3->y)) * invdet;
+ invmx[3] = ((lp1->y * lp3->z) - (lp1->z * lp3->y)) * -invdet;
+ invmx[6] = ((lp1->y * lp2->z) - (lp1->z * lp2->y)) * invdet;
+ invmx[1] = ((lp2->x * lp3->z) - (lp2->z * lp3->x)) * -invdet;
+ invmx[4] = ((lp1->x * lp3->z) - (lp1->z * lp3->x)) * invdet;
+ invmx[7] = ((lp1->x * lp2->z) - (lp1->z * lp2->x)) * -invdet;
+ invmx[2] = ((lp2->x * lp3->y) - (lp2->y * lp3->x)) * invdet;
+ invmx[5] = ((lp1->x * lp3->y) - (lp1->y * lp3->x)) * -invdet;
+ invmx[8] = ((lp1->x * lp2->y) - (lp1->y * lp2->x)) * invdet;
- /* copy the matrix */
-
- _matrices[triplet][0] = invmx[0];
- _matrices[triplet][1] = invmx[1];
- _matrices[triplet][2] = invmx[2];
- _matrices[triplet][3] = invmx[3];
- _matrices[triplet][4] = invmx[4];
- _matrices[triplet][5] = invmx[5];
- _matrices[triplet][6] = invmx[6];
- _matrices[triplet][7] = invmx[7];
- _matrices[triplet][8] = invmx[8];
-
- _speaker_tuples[triplet][0] = tr_ptr->ls_nos[0];
- _speaker_tuples[triplet][1] = tr_ptr->ls_nos[1];
- _speaker_tuples[triplet][2] = tr_ptr->ls_nos[2];
-
- cerr << "Triplet[" << triplet << "] = "
- << tr_ptr->ls_nos[0] << " + "
- << tr_ptr->ls_nos[1] << " + "
- << tr_ptr->ls_nos[2] << endl;
-
- triplet++;
-
- tr_ptr = tr_ptr->next;
- }
+ /* copy the matrix */
+
+ _matrices[triplet][0] = invmx[0];
+ _matrices[triplet][1] = invmx[1];
+ _matrices[triplet][2] = invmx[2];
+ _matrices[triplet][3] = invmx[3];
+ _matrices[triplet][4] = invmx[4];
+ _matrices[triplet][5] = invmx[5];
+ _matrices[triplet][6] = invmx[6];
+ _matrices[triplet][7] = invmx[7];
+ _matrices[triplet][8] = invmx[8];
+
+ _speaker_tuples[triplet][0] = tr_ptr->ls_nos[0];
+ _speaker_tuples[triplet][1] = tr_ptr->ls_nos[1];
+ _speaker_tuples[triplet][2] = tr_ptr->ls_nos[2];
+
+ cerr << "Triplet[" << triplet << "] = "
+ << tr_ptr->ls_nos[0] << " + "
+ << tr_ptr->ls_nos[1] << " + "
+ << tr_ptr->ls_nos[2] << endl;
+
+ triplet++;
+
+ tr_ptr = tr_ptr->next;
+ }
}
void
VBAPSpeakers::choose_speaker_pairs (){
- /* selects the loudspeaker pairs, calculates the inversion
- matrices and stores the data to a global array
- */
- const int n_speakers = _speakers.size();
- const double AZIMUTH_DELTA_THRESHOLD_DEGREES = (180.0/M_PI) * (M_PI - 0.175);
- int sorted_speakers[n_speakers];
- bool exists[n_speakers];
- double inverse_matrix[n_speakers][4];
- int expected_pairs = 0;
- int pair;
- int speaker;
-
- cerr << "CHOOSE PAIRS\n";
-
- if (n_speakers == 0) {
- return;
- }
-
- for (speaker = 0; speaker < n_speakers; ++speaker) {
- exists[speaker] = false;
- }
-
- /* sort loudspeakers according their aximuth angle */
- sort_2D_lss (sorted_speakers);
+ /* selects the loudspeaker pairs, calculates the inversion
+ matrices and stores the data to a global array
+ */
+ const int n_speakers = _speakers.size();
+ const double AZIMUTH_DELTA_THRESHOLD_DEGREES = (180.0/M_PI) * (M_PI - 0.175);
+ int sorted_speakers[n_speakers];
+ bool exists[n_speakers];
+ double inverse_matrix[n_speakers][4];
+ int expected_pairs = 0;
+ int pair;
+ int speaker;
+
+ cerr << "CHOOSE PAIRS\n";
+
+ if (n_speakers == 0) {
+ return;
+ }
+
+ for (speaker = 0; speaker < n_speakers; ++speaker) {
+ exists[speaker] = false;
+ }
+
+ /* sort loudspeakers according their aximuth angle */
+ sort_2D_lss (sorted_speakers);
- /* adjacent loudspeakers are the loudspeaker pairs to be used.*/
- for (speaker = 0; speaker < n_speakers-1; speaker++) {
-
- cerr << "Looking at "
- << _speakers[sorted_speakers[speaker]].id << " @ " << _speakers[sorted_speakers[speaker]].angles().azi
- << " and "
- << _speakers[sorted_speakers[speaker+1]].id << " @ " << _speakers[sorted_speakers[speaker+1]].angles().azi
- << " delta = "
- << _speakers[sorted_speakers[speaker+1]].angles().azi - _speakers[sorted_speakers[speaker]].angles().azi
- << endl;
-
- if ((_speakers[sorted_speakers[speaker+1]].angles().azi -
- _speakers[sorted_speakers[speaker]].angles().azi) <= AZIMUTH_DELTA_THRESHOLD_DEGREES) {
- if (calc_2D_inv_tmatrix( _speakers[sorted_speakers[speaker]].angles().azi,
- _speakers[sorted_speakers[speaker+1]].angles().azi,
- inverse_matrix[speaker]) != 0){
- exists[speaker] = true;
- expected_pairs++;
- }
- }
- }
+ /* adjacent loudspeakers are the loudspeaker pairs to be used.*/
+ for (speaker = 0; speaker < n_speakers-1; speaker++) {
+
+ cerr << "Looking at "
+ << _speakers[sorted_speakers[speaker]].id << " @ " << _speakers[sorted_speakers[speaker]].angles().azi
+ << " and "
+ << _speakers[sorted_speakers[speaker+1]].id << " @ " << _speakers[sorted_speakers[speaker+1]].angles().azi
+ << " delta = "
+ << _speakers[sorted_speakers[speaker+1]].angles().azi - _speakers[sorted_speakers[speaker]].angles().azi
+ << endl;
+
+ if ((_speakers[sorted_speakers[speaker+1]].angles().azi -
+ _speakers[sorted_speakers[speaker]].angles().azi) <= AZIMUTH_DELTA_THRESHOLD_DEGREES) {
+ if (calc_2D_inv_tmatrix( _speakers[sorted_speakers[speaker]].angles().azi,
+ _speakers[sorted_speakers[speaker+1]].angles().azi,
+ inverse_matrix[speaker]) != 0){
+ exists[speaker] = true;
+ expected_pairs++;
+ }
+ }
+ }
- if (((6.283 - _speakers[sorted_speakers[n_speakers-1]].angles().azi)
- +_speakers[sorted_speakers[0]].angles().azi) <= AZIMUTH_DELTA_THRESHOLD_DEGREES) {
- if (calc_2D_inv_tmatrix(_speakers[sorted_speakers[n_speakers-1]].angles().azi,
- _speakers[sorted_speakers[0]].angles().azi,
- inverse_matrix[n_speakers-1]) != 0) {
- exists[n_speakers-1] = true;
- expected_pairs++;
- }
- }
-
- pair = 0;
-
- _matrices.clear ();
- _speaker_tuples.clear ();
-
- for (int n = 0; n < expected_pairs; ++n) {
- _matrices.push_back (twoDmatrix());
- _speaker_tuples.push_back (tmatrix());
- }
-
- for (speaker = 0; speaker < n_speakers - 1; speaker++) {
- if (exists[speaker]) {
- _matrices[pair][0] = inverse_matrix[speaker][0];
- _matrices[pair][1] = inverse_matrix[speaker][1];
- _matrices[pair][2] = inverse_matrix[speaker][2];
- _matrices[pair][3] = inverse_matrix[speaker][3];
-
- _speaker_tuples[pair][0] = sorted_speakers[speaker];
- _speaker_tuples[pair][1] = sorted_speakers[speaker+1];
-
- cerr << "PAIR[" << pair << "] = " << sorted_speakers[speaker] << " + " << sorted_speakers[speaker+1] << endl;
-
- pair++;
- }
- }
+ if (((6.283 - _speakers[sorted_speakers[n_speakers-1]].angles().azi)
+ +_speakers[sorted_speakers[0]].angles().azi) <= AZIMUTH_DELTA_THRESHOLD_DEGREES) {
+ if (calc_2D_inv_tmatrix(_speakers[sorted_speakers[n_speakers-1]].angles().azi,
+ _speakers[sorted_speakers[0]].angles().azi,
+ inverse_matrix[n_speakers-1]) != 0) {
+ exists[n_speakers-1] = true;
+ expected_pairs++;
+ }
+ }
+
+ pair = 0;
+
+ _matrices.clear ();
+ _speaker_tuples.clear ();
+
+ for (int n = 0; n < expected_pairs; ++n) {
+ _matrices.push_back (twoDmatrix());
+ _speaker_tuples.push_back (tmatrix());
+ }
+
+ for (speaker = 0; speaker < n_speakers - 1; speaker++) {
+ if (exists[speaker]) {
+ _matrices[pair][0] = inverse_matrix[speaker][0];
+ _matrices[pair][1] = inverse_matrix[speaker][1];
+ _matrices[pair][2] = inverse_matrix[speaker][2];
+ _matrices[pair][3] = inverse_matrix[speaker][3];
+
+ _speaker_tuples[pair][0] = sorted_speakers[speaker];
+ _speaker_tuples[pair][1] = sorted_speakers[speaker+1];
+
+ cerr << "PAIR[" << pair << "] = " << sorted_speakers[speaker] << " + " << sorted_speakers[speaker+1] << endl;
+
+ pair++;
+ }
+ }
- if (exists[n_speakers-1]) {
- _matrices[pair][0] = inverse_matrix[speaker][0];
- _matrices[pair][1] = inverse_matrix[speaker][1];
- _matrices[pair][2] = inverse_matrix[speaker][2];
- _matrices[pair][3] = inverse_matrix[speaker][3];
+ if (exists[n_speakers-1]) {
+ _matrices[pair][0] = inverse_matrix[speaker][0];
+ _matrices[pair][1] = inverse_matrix[speaker][1];
+ _matrices[pair][2] = inverse_matrix[speaker][2];
+ _matrices[pair][3] = inverse_matrix[speaker][3];
- _speaker_tuples[pair][0] = sorted_speakers[n_speakers-1];
- _speaker_tuples[pair][1] = sorted_speakers[0];
+ _speaker_tuples[pair][0] = sorted_speakers[n_speakers-1];
+ _speaker_tuples[pair][1] = sorted_speakers[0];
- cerr << "PAIR[" << pair << "] = " << sorted_speakers[n_speakers-1] << " + " << sorted_speakers[0] << endl;
+ cerr << "PAIR[" << pair << "] = " << sorted_speakers[n_speakers-1] << " + " << sorted_speakers[0] << endl;
- }
+ }
}
void
VBAPSpeakers::sort_2D_lss (int* sorted_speakers)
{
- vector<Speaker> tmp = _speakers;
- vector<Speaker>::iterator s;
- azimuth_sorter sorter;
- int n;
+ vector<Speaker> tmp = _speakers;
+ vector<Speaker>::iterator s;
+ azimuth_sorter sorter;
+ int n;
- sort (tmp.begin(), tmp.end(), sorter);
+ sort (tmp.begin(), tmp.end(), sorter);
- for (n = 0, s = tmp.begin(); s != tmp.end(); ++s, ++n) {
- sorted_speakers[n] = (*s).id;
- cerr << "Sorted[" << n << "] = " << (*s).id << endl;
- }
+ for (n = 0, s = tmp.begin(); s != tmp.end(); ++s, ++n) {
+ sorted_speakers[n] = (*s).id;
+ cerr << "Sorted[" << n << "] = " << (*s).id << endl;
+ }
}
int
VBAPSpeakers::calc_2D_inv_tmatrix (double azi1, double azi2, double* inverse_matrix)
{
- double x1,x2,x3,x4;
- double det;
+ double x1,x2,x3,x4;
+ double det;
- x1 = cos (azi1);
- x2 = sin (azi1);
- x3 = cos (azi2);
- x4 = sin (azi2);
- det = (x1 * x4) - ( x3 * x2 );
+ x1 = cos (azi1);
+ x2 = sin (azi1);
+ x3 = cos (azi2);
+ x4 = sin (azi2);
+ det = (x1 * x4) - ( x3 * x2 );
- if (fabs(det) <= 0.001) {
+ if (fabs(det) <= 0.001) {
- inverse_matrix[0] = 0.0;
- inverse_matrix[1] = 0.0;
- inverse_matrix[2] = 0.0;
- inverse_matrix[3] = 0.0;
+ inverse_matrix[0] = 0.0;
+ inverse_matrix[1] = 0.0;
+ inverse_matrix[2] = 0.0;
+ inverse_matrix[3] = 0.0;
- return 0;
+ return 0;
- } else {
+ } else {
- inverse_matrix[0] = x4 / det;
- inverse_matrix[1] = -x3 / det;
- inverse_matrix[2] = -x2 / det;
- inverse_matrix[3] = x1 / det;
+ inverse_matrix[0] = x4 / det;
+ inverse_matrix[1] = -x3 / det;
+ inverse_matrix[2] = -x2 / det;
+ inverse_matrix[3] = x1 / det;
- return 1;
- }
+ return 1;
+ }
}
diff --git a/libs/ardour/wscript b/libs/ardour/wscript
index 3ece2d0784..61dadda198 100644
--- a/libs/ardour/wscript
+++ b/libs/ardour/wscript
@@ -308,7 +308,7 @@ def build(bld):
# alltogether.
#
if bld.env['HAVE_SLV2']:
- obj.source += [ 'lv2_plugin.cc', 'lv2_event_buffer.cc', 'uri_map.cc' ]
+ obj.source += [ 'lv2_plugin.cc', 'lv2_event_buffer.cc', 'uri_map.cc', 'lv2_persist_file.c' ]
obj.uselib += ' SLV2 '
if bld.env['VST_SUPPORT']:
diff --git a/libs/pbd/cartesian.cc b/libs/pbd/cartesian.cc
index 8bece8e005..c09e00b189 100644
--- a/libs/pbd/cartesian.cc
+++ b/libs/pbd/cartesian.cc
@@ -26,56 +26,56 @@ using namespace std;
void
PBD::azi_ele_to_cart (double azi, double ele, double& x, double& y, double& z)
{
- /* convert from cylindrical coordinates in degrees to cartesian */
+ /* convert from cylindrical coordinates in degrees to cartesian */
- static const double atorad = 2.0 * M_PI / 360.0 ;
+ static const double atorad = 2.0 * M_PI / 360.0 ;
- x = cos (azi * atorad) * cos (ele * atorad);
- y = sin (azi * atorad) * cos (ele * atorad);
- z = sin (ele * atorad);
+ x = cos (azi * atorad) * cos (ele * atorad);
+ y = sin (azi * atorad) * cos (ele * atorad);
+ z = sin (ele * atorad);
}
void
PBD::cart_to_azi_ele (double x, double y, double z, double& azimuth, double& elevation)
{
- /* converts cartesian coordinates to cylindrical in degrees*/
-
- const double atorad = 2.0 * M_PI / 360.0;
- double atan_y_per_x, atan_x_pl_y_per_z;
- double distance;
-
- if(x == 0.0) {
- atan_y_per_x = M_PI / 2;
- } else {
- atan_y_per_x = atan2 (y,x);
- }
-
- if (y < 0.0) {
- /* below x-axis: atan2 returns 0 .. -PI (negative) so convert to degrees and ADD to 180 */
- azimuth = 180.0 + (atan_y_per_x / (M_PI/180.0) + 180.0);
- } else {
- /* above x-axis: atan2 returns 0 .. +PI so convert to degrees */
- azimuth = atan_y_per_x / atorad;
- }
-
- distance = sqrt (x*x + y*y);
-
- if (z == 0.0) {
- atan_x_pl_y_per_z = 0.0;
- } else {
- atan_x_pl_y_per_z = atan2 (z,distance);
- }
-
- if (distance == 0.0) {
- if (z < 0.0) {
- atan_x_pl_y_per_z = -M_PI/2.0;
- } else if (z > 0.0) {
- atan_x_pl_y_per_z = M_PI/2.0;
- }
- }
-
- elevation = atan_x_pl_y_per_z / atorad;
-
- // distance = sqrtf (x*x + y*y + z*z);
+ /* converts cartesian coordinates to cylindrical in degrees*/
+
+ const double atorad = 2.0 * M_PI / 360.0;
+ double atan_y_per_x, atan_x_pl_y_per_z;
+ double distance;
+
+ if (x == 0.0) {
+ atan_y_per_x = M_PI / 2;
+ } else {
+ atan_y_per_x = atan2 (y,x);
+ }
+
+ if (y < 0.0) {
+ /* below x-axis: atan2 returns 0 .. -PI (negative) so convert to degrees and ADD to 180 */
+ azimuth = 180.0 + (atan_y_per_x / (M_PI/180.0) + 180.0);
+ } else {
+ /* above x-axis: atan2 returns 0 .. +PI so convert to degrees */
+ azimuth = atan_y_per_x / atorad;
+ }
+
+ distance = sqrt (x*x + y*y);
+
+ if (z == 0.0) {
+ atan_x_pl_y_per_z = 0.0;
+ } else {
+ atan_x_pl_y_per_z = atan2 (z,distance);
+ }
+
+ if (distance == 0.0) {
+ if (z < 0.0) {
+ atan_x_pl_y_per_z = -M_PI/2.0;
+ } else if (z > 0.0) {
+ atan_x_pl_y_per_z = M_PI/2.0;
+ }
+ }
+
+ elevation = atan_x_pl_y_per_z / atorad;
+
+ // distance = sqrtf (x*x + y*y + z*z);
}
diff --git a/libs/pbd/pbd/cartesian.h b/libs/pbd/pbd/cartesian.h
index b44a12cd3d..afa4579465 100644
--- a/libs/pbd/pbd/cartesian.h
+++ b/libs/pbd/pbd/cartesian.h
@@ -30,74 +30,73 @@ void cart_to_azi_ele (double x, double y, double z, double& azi, double& ele);
struct AngularVector;
struct CartesianVector {
- double x;
- double y;
- double z;
-
- CartesianVector () : x(0.0), y(0.0), z(0.0) {}
- CartesianVector (double xp, double yp, double zp = 0.0) : x(xp), y(yp), z(zp) {}
-
- CartesianVector& translate (CartesianVector& other, double xtranslate, double ytranslate, double ztranslate = 0.0) {
- other.x += xtranslate;
- other.y += ytranslate;
- other.z += ztranslate;
- return other;
- }
-
- CartesianVector& scale (CartesianVector& other, double xscale, double yscale, double zscale = 1.0) {
- other.x *= xscale;
- other.y *= yscale;
- other.z *= zscale;
- return other;
- }
-
- void angular (AngularVector&) const;
+ double x;
+ double y;
+ double z;
+
+ CartesianVector () : x(0.0), y(0.0), z(0.0) {}
+ CartesianVector (double xp, double yp, double zp = 0.0) : x(xp), y(yp), z(zp) {}
+
+ CartesianVector& translate (CartesianVector& other, double xtranslate, double ytranslate, double ztranslate = 0.0) {
+ other.x += xtranslate;
+ other.y += ytranslate;
+ other.z += ztranslate;
+ return other;
+ }
+
+ CartesianVector& scale (CartesianVector& other, double xscale, double yscale, double zscale = 1.0) {
+ other.x *= xscale;
+ other.y *= yscale;
+ other.z *= zscale;
+ return other;
+ }
+
+ void angular (AngularVector&) const;
};
struct AngularVector {
- double azi;
- double ele;
- double length;
-
- AngularVector () : azi(0.0), ele(0.0), length (0.0) {}
- AngularVector (double a, double e, double l = 1.0) : azi(a), ele(e), length (l) {}
-
- AngularVector operator- (const AngularVector& other) const {
- AngularVector r;
- r.azi = azi - other.azi;
- r.ele = ele - other.ele;
- r.length = length - other.length;
- return r;
- }
-
- AngularVector operator+ (const AngularVector& other) const {
- AngularVector r;
- r.azi = azi + other.azi;
- r.ele = ele + other.ele;
- r.length = length + other.length;
- return r;
- }
-
- bool operator== (const AngularVector& other) const {
- return fabs (azi - other.azi) <= FLT_EPSILON &&
- fabs (ele - other.ele) <= FLT_EPSILON &&
- fabs (length - other.length) <= FLT_EPSILON;
- }
-
- bool operator!= (const AngularVector& other) const {
- return fabs (azi - other.azi) > FLT_EPSILON ||
- fabs (ele - other.ele) > FLT_EPSILON ||
- fabs (length - other.length) > FLT_EPSILON;
- }
-
- void cartesian (CartesianVector& c) const {
- azi_ele_to_cart (azi, ele, c.x, c.y, c.z);
- }
+ double azi;
+ double ele;
+ double length;
+
+ AngularVector () : azi(0.0), ele(0.0), length (0.0) {}
+ AngularVector (double a, double e, double l = 1.0) : azi(a), ele(e), length (l) {}
+
+ AngularVector operator- (const AngularVector& other) const {
+ AngularVector r;
+ r.azi = azi - other.azi;
+ r.ele = ele - other.ele;
+ r.length = length - other.length;
+ return r;
+ }
+
+ AngularVector operator+ (const AngularVector& other) const {
+ AngularVector r;
+ r.azi = azi + other.azi;
+ r.ele = ele + other.ele;
+ r.length = length + other.length;
+ return r;
+ }
+
+ bool operator== (const AngularVector& other) const {
+ return fabs (azi - other.azi) <= FLT_EPSILON &&
+ fabs (ele - other.ele) <= FLT_EPSILON &&
+ fabs (length - other.length) <= FLT_EPSILON;
+ }
+
+ bool operator!= (const AngularVector& other) const {
+ return fabs (azi - other.azi) > FLT_EPSILON ||
+ fabs (ele - other.ele) > FLT_EPSILON ||
+ fabs (length - other.length) > FLT_EPSILON;
+ }
+
+ void cartesian (CartesianVector& c) const {
+ azi_ele_to_cart (azi, ele, c.x, c.y, c.z);
+ }
};
-inline
-void CartesianVector::angular (AngularVector& a) const {
- cart_to_azi_ele (x, y, z, a.azi, a.ele);
+inline void CartesianVector::angular (AngularVector& a) const {
+ cart_to_azi_ele (x, y, z, a.azi, a.ele);
}
}
diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc
index c9c62dcb21..05cbc45f65 100644
--- a/libs/surfaces/mackie/mackie_control_protocol.cc
+++ b/libs/surfaces/mackie/mackie_control_protocol.cc
@@ -840,12 +840,12 @@ MackieControlProtocol::handle_control_event (SurfacePort & port, Control & contr
if (route->panner()->npanners() == 1 || (route->panner()->npanners() == 2 && route->panner()->linked()))
{
// assume pan for now
- AngularVector a = route->panner()->streampanner (0).get_effective_position ();
+ AngularVector a = route->panner()->streampanner (0).get_effective_position ();
// calculate new value, and adjust
a.azi += 180.0 * state.delta * state.sign;
- a.azi = min (180.0, a.azi);
- a.azi = max (0.0, a.azi);
+ a.azi = min (180.0, a.azi);
+ a.azi = max (0.0, a.azi);
route->panner()->streampanner (0).set_position (a);
}
}
@@ -1005,7 +1005,7 @@ MackieControlProtocol::notify_panner_changed (RouteSignal * route_signal, bool f
if ((panner && panner->npanners() == 1) || (panner->npanners() == 2 && panner->linked()))
{
AngularVector pos = route_signal->route()->panner()->streampanner(0).get_effective_position ();
- float fract = 1.0 - (pos.azi / 180.0); /* 1.0 = 0 degrees = right; 0.0 = 180 degrees = left */
+ float fract = 1.0 - (pos.azi / 180.0); /* 1.0 = 0 degrees = right; 0.0 = 180 degrees = left */
// cache the MidiByteArray here, because the mackie led control is much lower
// resolution than the panner control. So we save lots of byte