2 Copyright (C) 2010 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 #include "ardour/speaker.h"
20 #include "ardour/speakers.h"
22 using namespace ARDOUR;
26 Speaker::Speaker (int i, const AngularVector& position)
33 Speaker::move (const AngularVector& new_position)
35 _angles = new_position;
36 _angles.cartesian (_coords);
43 Speakers::~Speakers ()
48 Speakers::dump_speakers (ostream& o)
50 for (vector<Speaker>::iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
51 o << "Speaker " << (*i).id << " @ "
52 << (*i).coords().x << ", " << (*i).coords().y << ", " << (*i).coords().z
53 << " azimuth " << (*i).angles().azi
54 << " elevation " << (*i).angles().ele
55 << " distance " << (*i).angles().length
61 Speakers::clear_speakers ()
68 Speakers::add_speaker (const AngularVector& position)
70 int id = _speakers.size();
72 cerr << "Added speaker " << id << " at " << position.azi << " /= " << position.ele << endl;
74 _speakers.push_back (Speaker (id, position));
84 Speakers::remove_speaker (int id)
86 for (vector<Speaker>::iterator i = _speakers.begin(); i != _speakers.end(); ) {
88 i = _speakers.erase (i);
96 Speakers::move_speaker (int id, const AngularVector& new_position)
98 for (vector<Speaker>::iterator i = _speakers.begin(); i != _speakers.end(); ++i) {
100 (*i).move (new_position);