2 Copyright (C) 2008 Paul Davis
5 This program is free software; you can redistribute it and/or modify
6 it under the terms of the GNU General Public License as published by
7 the Free Software Foundation; either version 2 of the License, or
8 (at your option) any later version.
10 This program is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 GNU General Public License for more details.
15 You should have received a copy of the GNU General Public License
16 along with this program; if not, write to the Free Software
17 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #ifndef __ardour_export_format_specification_h__
22 #define __ardour_export_format_specification_h__
28 #include "ardour/libardour_visibility.h"
29 #include "ardour/types.h"
30 #include "ardour/export_format_base.h"
38 class ExportFormatCompatibility;
41 class LIBARDOUR_API ExportFormatSpecification : public ExportFormatBase {
45 /* Time struct for keeping time formats as close as possible to what was requested */
47 struct Time : public AnyTime {
48 Time (Session & session) : AnyTime (), session (session) {}
49 Time & operator= (AnyTime const & other);
51 samplecnt_t get_samples_at (samplepos_t position, samplecnt_t target_rate) const;
55 XMLNode & get_state ();
56 int set_state (const XMLNode & node);
63 friend class ExportElementFactory;
64 explicit ExportFormatSpecification (Session & s);
65 ExportFormatSpecification (Session & s, XMLNode const & state);
68 ExportFormatSpecification (ExportFormatSpecification const & other, bool modify_name = true);
69 ~ExportFormatSpecification ();
73 bool is_compatible_with (ExportFormatCompatibility const & compatibility) const;
74 bool is_complete () const;
76 /* Modifying functions */
78 void set_format (boost::shared_ptr<ExportFormat> format);
80 void set_name (std::string const & name) { _name = name; }
82 void set_type (Type type) { _type = type; }
83 void set_format_id (FormatId value) { format_ids.clear(); format_ids.insert (value); }
84 void set_endianness (Endianness value) { endiannesses.clear(); endiannesses.insert (value); }
85 void set_sample_format (SampleFormat value) { sample_formats.clear(); sample_formats.insert (value); }
86 void set_sample_rate (SampleRate value) { sample_rates.clear(); sample_rates.insert (value); }
87 void set_quality (Quality value) { qualities.clear(); qualities.insert (value); }
89 void set_dither_type (DitherType value) { _dither_type = value; }
90 void set_src_quality (SRCQuality value) { _src_quality = value; }
91 void set_trim_beginning (bool value) { _trim_beginning = value; }
92 void set_trim_end (bool value) { _trim_end = value; }
93 void set_normalize (bool value) { _normalize = value; }
94 void set_normalize_loudness (bool value) { _normalize_loudness = value; }
95 void set_normalize_dbfs (float value) { _normalize_dbfs = value; }
96 void set_normalize_lufs (float value) { _normalize_lufs = value; }
97 void set_normalize_dbtp (float value) { _normalize_dbtp = value; }
99 void set_tag (bool tag_it) { _tag = tag_it; }
100 void set_with_cue (bool yn) { _with_cue = yn; }
101 void set_with_toc (bool yn) { _with_toc = yn; }
102 void set_with_mp4chaps (bool yn) { _with_mp4chaps = yn; }
103 void set_soundcloud_upload (bool yn) { _soundcloud_upload = yn; }
104 void set_command (std::string command) { _command = command; }
105 void set_analyse (bool yn) { _analyse = yn; }
107 void set_silence_beginning (AnyTime const & value) { _silence_beginning = value; }
108 void set_silence_end (AnyTime const & value) { _silence_end = value; }
110 /* Accessing functions */
112 PBD::UUID const & id () { return _id; }
113 std::string const & name () const { return _name; }
114 std::string description (bool include_name = true);
116 bool has_broadcast_info () const { return _has_broadcast_info; }
117 uint32_t channel_limit () const { return _channel_limit; }
118 std::string format_name () const { return _format_name; }
120 Type type () const { return _type; }
122 FormatId format_id () const {
123 if (!format_ids.empty() )
124 return *format_ids.begin();
129 Endianness endianness () const {
130 if (!endiannesses.empty() )
131 return *endiannesses.begin();
133 return Endianness(0);
136 SampleFormat sample_format () const {
137 if (!sample_formats.empty() )
138 return *sample_formats.begin();
140 return SampleFormat(0);
143 SampleRate sample_rate () const {
144 if (!sample_rates.empty() )
145 return *sample_rates.begin();
147 return SampleRate(0);
151 Quality quality () const {
152 if (!qualities.empty() )
153 return *qualities.begin();
158 DitherType dither_type () const { return _dither_type; }
159 SRCQuality src_quality () const { return _src_quality; }
160 bool trim_beginning () const { return _trim_beginning; }
161 bool trim_end () const { return _trim_end; }
162 bool normalize () const { return _normalize; }
163 bool normalize_loudness () const { return _normalize_loudness; }
164 float normalize_dbfs () const { return _normalize_dbfs; }
165 float normalize_lufs () const { return _normalize_lufs; }
166 float normalize_dbtp () const { return _normalize_dbtp; }
167 bool with_toc() const { return _with_toc; }
168 bool with_cue() const { return _with_cue; }
169 bool with_mp4chaps() const { return _with_mp4chaps; }
171 bool soundcloud_upload() const { return _soundcloud_upload; }
172 std::string command() const { return _command; }
173 bool analyse() const { return _analyse; }
175 bool tag () const { return _tag && supports_tagging; }
177 samplecnt_t silence_beginning_at (samplepos_t position, samplecnt_t samplerate) const
178 { return _silence_beginning.get_samples_at (position, samplerate); }
179 samplecnt_t silence_end_at (samplepos_t position, samplecnt_t samplerate) const
180 { return _silence_end.get_samples_at (position, samplerate); }
182 AnyTime silence_beginning_time () const { return _silence_beginning; }
183 AnyTime silence_end_time () const { return _silence_end; }
187 XMLNode & get_state ();
188 int set_state (const XMLNode & root);
195 /* The variables below do not have setters (usually set via set_format) */
197 std::string _format_name;
198 bool has_sample_format;
199 bool supports_tagging;
200 bool _has_broadcast_info;
201 uint32_t _channel_limit;
203 /* The variables below have getters and setters */
209 DitherType _dither_type;
210 SRCQuality _src_quality;
214 bool _trim_beginning;
215 Time _silence_beginning;
220 bool _normalize_loudness;
221 float _normalize_dbfs;
222 float _normalize_lufs;
223 float _normalize_dbtp;
227 bool _soundcloud_upload;
229 std::string _command;
232 /* serialization helpers */
234 void add_option (XMLNode * node, std::string const & name, std::string const & value);
235 std::string get_option (XMLNode const * node, std::string const & name);
239 } // namespace ARDOUR
241 #endif /* __ardour_export_format_specification_h__ */