194c9bf0e63d46b523ff0917ed3f21408e4365a5
[dcpomatic.git] / src / lib / audio_processor.h
1 /*
2     Copyright (C) 2014-2015 Carl Hetherington <cth@carlh.net>
3
4     This file is part of DCP-o-matic.
5
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.
10
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.
15
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/>.
18
19 */
20
21 /** @file  src/lib/audio_processor.h
22  *  @brief AudioProcessor class.
23  */
24
25 #ifndef DCPOMATIC_AUDIO_PROCESSOR_H
26 #define DCPOMATIC_AUDIO_PROCESSOR_H
27
28 #include "types.h"
29 #include <boost/shared_ptr.hpp>
30 #include <list>
31 #include <string>
32 #include <vector>
33
34 class AudioBuffers;
35 class AudioMapping;
36
37 /** @class AudioProcessor
38  *  @brief A parent class for processors of audio data.
39  *
40  *  These are used to process data before it goes into the DCP, for things like
41  *  stereo -> 5.1 upmixing.
42  */
43 class AudioProcessor
44 {
45 public:
46         virtual ~AudioProcessor () {}
47
48         /** @return User-visible (translated) name */
49         virtual std::string name () const = 0;
50         /** @return An internal identifier */
51         virtual std::string id () const = 0;
52         /** @return Number of output channels */
53         virtual int out_channels () const = 0;
54         /** @return A clone of this AudioProcessor for operation at the specified sampling rate */
55         virtual boost::shared_ptr<AudioProcessor> clone (int sampling_rate) const = 0;
56         /** Process some data, returning the processed result truncated or padded to `channels' */
57         virtual boost::shared_ptr<AudioBuffers> run (boost::shared_ptr<const AudioBuffers>, int channels) = 0;
58         virtual void flush () {}
59         /** Make the supplied audio mapping into a sensible default for this processor */
60         virtual void make_audio_mapping_default (AudioMapping& mapping) const = 0;
61         /** @return the user-visible (translated) names of each of our inputs, in order */
62         virtual std::vector<NamedChannel> input_names () const = 0;
63
64         static std::list<AudioProcessor const *> all ();
65         static std::list<AudioProcessor const *> visible ();
66         static void setup_audio_processors ();
67         static AudioProcessor const * from_id (std::string);
68
69 private:
70         static std::list<AudioProcessor const *> _all;
71         static std::list<AudioProcessor const *> _non_experimental;
72 };
73
74 #endif