2 Copyright (C) 2012-2014 Carl Hetherington <cth@carlh.net>
4 This file is part of DCP-o-matic.
6 DCP-o-matic is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
11 DCP-o-matic is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 GNU General Public License for more details.
16 You should have received a copy of the GNU General Public License
17 along with DCP-o-matic. If not, see <http://www.gnu.org/licenses/>.
21 /** @file src/sound_processor.cc
22 * @brief CinemaSoundProcessor class.
25 #include "cinema_sound_processor.h"
26 #include "dolby_cp750.h"
27 #include "dcpomatic_assert.h"
33 vector<CinemaSoundProcessor const *> CinemaSoundProcessor::_cinema_sound_processors;
36 * @param n User-visible name.
38 CinemaSoundProcessor::CinemaSoundProcessor (string i, string n)
45 /** @return All available sound processors */
46 vector<CinemaSoundProcessor const *>
47 CinemaSoundProcessor::all ()
49 return _cinema_sound_processors;
52 /** Set up the static _sound_processors vector; must be called before from_*
56 CinemaSoundProcessor::setup_cinema_sound_processors ()
58 _cinema_sound_processors.push_back (new DolbyCP750);
61 /** @param id One of our ids.
62 * @return Corresponding sound processor, or 0.
64 CinemaSoundProcessor const *
65 CinemaSoundProcessor::from_id (string id)
67 vector<CinemaSoundProcessor const *>::iterator i = _cinema_sound_processors.begin ();
68 while (i != _cinema_sound_processors.end() && (*i)->id() != id) {
72 if (i == _cinema_sound_processors.end ()) {
79 /** @param s A sound processor from our static list.
80 * @return Index of the sound processor with the list, or -1.
83 CinemaSoundProcessor::as_index (CinemaSoundProcessor const * s)
85 vector<CinemaSoundProcessor*>::size_type i = 0;
86 while (i < _cinema_sound_processors.size() && _cinema_sound_processors[i] != s) {
90 if (i == _cinema_sound_processors.size ()) {
97 /** @param i An index returned from as_index().
98 * @return Corresponding sound processor.
100 CinemaSoundProcessor const *
101 CinemaSoundProcessor::from_index (int i)
103 DCPOMATIC_ASSERT (i <= int(_cinema_sound_processors.size ()));
104 return _cinema_sound_processors[i];