ee5a7db7ad10766dd8062fa64636688e87e921ad
[dcpomatic.git] / src / lib / audio_content.h
1 /*
2     Copyright (C) 2013-2014 Carl Hetherington <cth@carlh.net>
3
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.
8
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.
13
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.
17
18 */
19
20 /** @file  src/lib/audio_content.h
21  *  @brief AudioContent and AudioContentProperty classes.
22  */
23
24 #ifndef DCPOMATIC_AUDIO_CONTENT_H
25 #define DCPOMATIC_AUDIO_CONTENT_H
26
27 #include "content.h"
28 #include "audio_mapping.h"
29
30 namespace cxml {
31         class Node;
32 }
33
34 class AudioProcessor;
35
36 /** @class AudioContentProperty
37  *  @brief Names for properties of AudioContent.
38  */
39 class AudioContentProperty
40 {
41 public:
42         static int const AUDIO_CHANNELS;
43         static int const AUDIO_LENGTH;
44         static int const AUDIO_FRAME_RATE;
45         static int const AUDIO_GAIN;
46         static int const AUDIO_DELAY;
47         static int const AUDIO_MAPPING;
48         static int const AUDIO_PROCESSOR;
49 };
50
51 /** @class AudioContent
52  *  @brief Parent class for content which may contain audio data.
53  */
54 class AudioContent : public virtual Content
55 {
56 public:
57         AudioContent (boost::shared_ptr<const Film>);
58         AudioContent (boost::shared_ptr<const Film>, DCPTime);
59         AudioContent (boost::shared_ptr<const Film>, boost::filesystem::path);
60         AudioContent (boost::shared_ptr<const Film>, cxml::ConstNodePtr);
61         AudioContent (boost::shared_ptr<const Film>, std::vector<boost::shared_ptr<Content> >);
62
63         void as_xml (xmlpp::Node *) const;
64         std::string technical_summary () const;
65
66         /** @return number of audio channels in the content */
67         virtual int audio_channels () const = 0;
68         /** @return the length of the audio in the content */
69         virtual Frame audio_length () const = 0;
70         /** @return the frame rate of the content */
71         virtual int audio_frame_rate () const = 0;
72         virtual AudioMapping audio_mapping () const = 0;
73         virtual void set_audio_mapping (AudioMapping);
74         virtual boost::filesystem::path audio_analysis_path () const;
75
76         int resampled_audio_frame_rate () const;
77         int processed_audio_channels () const;
78
79         boost::signals2::connection analyse_audio (boost::function<void()>);
80
81         void set_audio_gain (double);
82         void set_audio_delay (int);
83         void set_audio_processor (AudioProcessor const *);
84         
85         double audio_gain () const {
86                 boost::mutex::scoped_lock lm (_mutex);
87                 return _audio_gain;
88         }
89
90         int audio_delay () const {
91                 boost::mutex::scoped_lock lm (_mutex);
92                 return _audio_delay;
93         }
94
95         AudioProcessor const * audio_processor () const {
96                 boost::mutex::scoped_lock lm (_mutex);
97                 return _audio_processor;
98         }
99
100         std::string processing_description () const;
101         
102 private:
103         /** Gain to apply to audio in dB */
104         double _audio_gain;
105         /** Delay to apply to audio (positive moves audio later) in milliseconds */
106         int _audio_delay;
107         AudioProcessor const * _audio_processor;
108 };
109
110 #endif