summaryrefslogtreecommitdiff
path: root/libs/ardour/speakers.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2010-11-26 17:43:03 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2010-11-26 17:43:03 +0000
commit553cf2982c4905c5a08f305ce2772beaa8c50324 (patch)
treed23a7bad787a2d5bc1a909a14e9869fcfb405ae8 /libs/ardour/speakers.cc
parent1539ac1b9661f0c0bb313d8f0d9a72b6dc95aaf1 (diff)
one step closer to working vbap panning
git-svn-id: svn://localhost/ardour2/branches/3.0@8091 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/speakers.cc')
-rw-r--r--libs/ardour/speakers.cc108
1 files changed, 108 insertions, 0 deletions
diff --git a/libs/ardour/speakers.cc b/libs/ardour/speakers.cc
new file mode 100644
index 0000000000..c5495f204d
--- /dev/null
+++ b/libs/ardour/speakers.cc
@@ -0,0 +1,108 @@
+/*
+ Copyright (C) 2010 Paul Davis
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#include "ardour/speaker.h"
+#include "ardour/speakers.h"
+
+using namespace ARDOUR;
+using namespace PBD;
+using namespace std;
+
+Speaker::Speaker (int i, const AngularVector& position)
+ : id (i)
+{
+ move (position);
+}
+
+void
+Speaker::move (const AngularVector& new_position)
+{
+ _angles = new_position;
+ _angles.cartesian (_coords);
+}
+
+Speakers::Speakers ()
+{
+}
+
+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;
+ }
+}
+
+void
+Speakers::clear_speakers ()
+{
+ _speakers.clear ();
+ update ();
+}
+
+int
+Speakers::add_speaker (const AngularVector& position)
+{
+ int id = _speakers.size();
+
+ cerr << "Added speaker " << id << " at " << position.azi << " /= " << position.ele << endl;
+
+ _speakers.push_back (Speaker (id, position));
+ update ();
+
+ dump_speakers (cerr);
+ Changed ();
+
+ 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;
+ }
+ }
+}
+
+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;
+ }
+ }
+}
+
+
+