1 /* 2 * Copyright (C) 2008-2013 Sakari Bergen <sakari.bergen@beatwaves.net> 3 * Copyright (C) 2008-2017 Paul Davis <paul@linuxaudiosystems.com> 4 * Copyright (C) 2009-2010 Carl Hetherington <carl@carlh.net> 5 * Copyright (C) 2009 David Robillard <d@drobilla.net> 6 * Copyright (C) 2013-2014 Colin Fletcher <colin.m.fletcher@googlemail.com> 7 * Copyright (C) 2015-2018 Robin Gareus <robin@gareus.org> 8 * 9 * This program is free software; you can redistribute it and/or modify 10 * it under the terms of the GNU General Public License as published by 11 * the Free Software Foundation; either version 2 of the License, or 12 * (at your option) any later version. 13 * 14 * This program is distributed in the hope that it will be useful, 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 17 * GNU General Public License for more details. 18 * 19 * You should have received a copy of the GNU General Public License along 20 * with this program; if not, write to the Free Software Foundation, Inc., 21 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 */ 23 24 #ifndef __ardour_export_format_specification_h__ 25 #define __ardour_export_format_specification_h__ 26 27 #include <string> 28 29 #include "pbd/uuid.h" 30 31 #include "ardour/libardour_visibility.h" 32 #include "ardour/types.h" 33 #include "ardour/export_format_base.h" 34 35 class XMLNode; 36 37 namespace ARDOUR 38 { 39 40 class ExportFormat; 41 class ExportFormatCompatibility; 42 class Session; 43 44 class LIBARDOUR_API ExportFormatSpecification : public ExportFormatBase { 45 46 private: 47 48 /* Time struct for keeping time formats as close as possible to what was requested */ 49 50 struct Time : public AnyTime { TimeTime51 Time (Session & session) : AnyTime (), session (session) {} 52 Time & operator= (AnyTime const & other); 53 54 samplecnt_t get_samples_at (samplepos_t position, samplecnt_t target_rate) const; 55 56 /* Serialization */ 57 58 XMLNode & get_state (); 59 int set_state (const XMLNode & node); 60 61 private: 62 Session & session; 63 }; 64 65 private: 66 friend class ExportElementFactory; 67 explicit ExportFormatSpecification (Session & s); 68 ExportFormatSpecification (Session & s, XMLNode const & state); 69 70 public: 71 ExportFormatSpecification (ExportFormatSpecification const & other, bool modify_name = true); 72 ~ExportFormatSpecification (); 73 74 /* compatibility */ 75 76 bool is_compatible_with (ExportFormatCompatibility const & compatibility) const; 77 bool is_complete () const; 78 79 /* Modifying functions */ 80 81 void set_format (boost::shared_ptr<ExportFormat> format); 82 set_name(std::string const & name)83 void set_name (std::string const & name) { _name = name; } 84 set_type(Type type)85 void set_type (Type type) { _type = type; } set_format_id(FormatId value)86 void set_format_id (FormatId value) { format_ids.clear(); format_ids.insert (value); } set_endianness(Endianness value)87 void set_endianness (Endianness value) { endiannesses.clear(); endiannesses.insert (value); } set_sample_format(SampleFormat value)88 void set_sample_format (SampleFormat value) { sample_formats.clear(); sample_formats.insert (value); } set_sample_rate(SampleRate value)89 void set_sample_rate (SampleRate value) { sample_rates.clear(); sample_rates.insert (value); } set_quality(Quality value)90 void set_quality (Quality value) { qualities.clear(); qualities.insert (value); } 91 set_dither_type(DitherType value)92 void set_dither_type (DitherType value) { _dither_type = value; } set_src_quality(SRCQuality value)93 void set_src_quality (SRCQuality value) { _src_quality = value; } set_trim_beginning(bool value)94 void set_trim_beginning (bool value) { _trim_beginning = value; } set_trim_end(bool value)95 void set_trim_end (bool value) { _trim_end = value; } set_normalize(bool value)96 void set_normalize (bool value) { _normalize = value; } set_normalize_loudness(bool value)97 void set_normalize_loudness (bool value) { _normalize_loudness = value; } set_use_tp_limiter(bool value)98 void set_use_tp_limiter (bool value) { _use_tp_limiter = value; } set_normalize_dbfs(float value)99 void set_normalize_dbfs (float value) { _normalize_dbfs = value; } set_normalize_lufs(float value)100 void set_normalize_lufs (float value) { _normalize_lufs = value; } set_normalize_dbtp(float value)101 void set_normalize_dbtp (float value) { _normalize_dbtp = value; } 102 set_demo_noise_level(float db)103 void set_demo_noise_level (float db) { _demo_noise_level = db; } set_demo_noise_duration(int msec)104 void set_demo_noise_duration (int msec) { _demo_noise_duration = msec; } set_demo_noise_interval(int msec)105 void set_demo_noise_interval (int msec) { _demo_noise_interval = msec; } 106 set_tag(bool tag_it)107 void set_tag (bool tag_it) { _tag = tag_it; } set_with_cue(bool yn)108 void set_with_cue (bool yn) { _with_cue = yn; } set_with_toc(bool yn)109 void set_with_toc (bool yn) { _with_toc = yn; } set_with_mp4chaps(bool yn)110 void set_with_mp4chaps (bool yn) { _with_mp4chaps = yn; } set_soundcloud_upload(bool yn)111 void set_soundcloud_upload (bool yn) { _soundcloud_upload = yn; } set_command(std::string command)112 void set_command (std::string command) { _command = command; } set_analyse(bool yn)113 void set_analyse (bool yn) { _analyse = yn; } set_codec_quality(int q)114 void set_codec_quality (int q) { _codec_quality = q; } 115 set_silence_beginning(AnyTime const & value)116 void set_silence_beginning (AnyTime const & value) { _silence_beginning = value; } set_silence_end(AnyTime const & value)117 void set_silence_end (AnyTime const & value) { _silence_end = value; } 118 119 /* Accessing functions */ 120 id()121 PBD::UUID const & id () { return _id; } name()122 std::string const & name () const { return _name; } 123 std::string description (bool include_name = true); 124 has_broadcast_info()125 bool has_broadcast_info () const { return _has_broadcast_info; } channel_limit()126 uint32_t channel_limit () const { return _channel_limit; } format_name()127 std::string format_name () const { return _format_name; } 128 type()129 Type type () const { return _type; } 130 format_id()131 FormatId format_id () const { 132 if (!format_ids.empty() ) 133 return *format_ids.begin(); 134 else 135 return FormatId(0); 136 } 137 endianness()138 Endianness endianness () const { 139 if (!endiannesses.empty() ) 140 return *endiannesses.begin(); 141 else 142 return Endianness(0); 143 } 144 sample_format()145 SampleFormat sample_format () const { 146 if (!sample_formats.empty() ) 147 return *sample_formats.begin(); 148 else 149 return SampleFormat(0); 150 } 151 sample_rate()152 SampleRate sample_rate () const { 153 if (!sample_rates.empty() ) 154 return *sample_rates.begin(); 155 else 156 return SampleRate(0); 157 158 } 159 quality()160 Quality quality () const { 161 if (!qualities.empty() ) 162 return *qualities.begin(); 163 else 164 return Quality(0); 165 } 166 dither_type()167 DitherType dither_type () const { return _dither_type; } src_quality()168 SRCQuality src_quality () const { return _src_quality; } trim_beginning()169 bool trim_beginning () const { return _trim_beginning; } trim_end()170 bool trim_end () const { return _trim_end; } normalize()171 bool normalize () const { return _normalize; } normalize_loudness()172 bool normalize_loudness () const { return _normalize_loudness; } use_tp_limiter()173 bool use_tp_limiter () const { return _use_tp_limiter; } normalize_dbfs()174 float normalize_dbfs () const { return _normalize_dbfs; } normalize_lufs()175 float normalize_lufs () const { return _normalize_lufs; } normalize_dbtp()176 float normalize_dbtp () const { return _normalize_dbtp; } with_toc()177 bool with_toc() const { return _with_toc; } with_cue()178 bool with_cue() const { return _with_cue; } with_mp4chaps()179 bool with_mp4chaps() const { return _with_mp4chaps; } 180 demo_noise_level()181 float demo_noise_level () const { return _demo_noise_level; } demo_noise_duration()182 int demo_noise_duration () const { return _demo_noise_duration; } demo_noise_interval()183 int demo_noise_interval () const { return _demo_noise_interval; } 184 soundcloud_upload()185 bool soundcloud_upload() const { return _soundcloud_upload; } command()186 std::string command() const { return _command; } analyse()187 bool analyse() const { return _analyse; } codec_quality()188 int codec_quality() const { return _codec_quality; } 189 tag()190 bool tag () const { return _tag && _supports_tagging; } 191 silence_beginning_at(samplepos_t position,samplecnt_t samplerate)192 samplecnt_t silence_beginning_at (samplepos_t position, samplecnt_t samplerate) const 193 { return _silence_beginning.get_samples_at (position, samplerate); } silence_end_at(samplepos_t position,samplecnt_t samplerate)194 samplecnt_t silence_end_at (samplepos_t position, samplecnt_t samplerate) const 195 { return _silence_end.get_samples_at (position, samplerate); } 196 silence_beginning_time()197 AnyTime silence_beginning_time () const { return _silence_beginning; } silence_end_time()198 AnyTime silence_end_time () const { return _silence_end; } 199 200 /* Serialization */ 201 202 XMLNode & get_state (); 203 int set_state (const XMLNode & root); 204 205 206 private: 207 208 Session & session; 209 210 /* The variables below do not have setters (usually set via set_format) */ 211 212 std::string _format_name; 213 bool _has_sample_format; 214 bool _supports_tagging; 215 bool _has_codec_quality; 216 bool _has_broadcast_info; 217 uint32_t _channel_limit; 218 219 /* The variables below have getters and setters */ 220 221 std::string _name; 222 PBD::UUID _id; 223 224 Type _type; 225 DitherType _dither_type; 226 SRCQuality _src_quality; 227 228 bool _tag; 229 230 bool _trim_beginning; 231 Time _silence_beginning; 232 bool _trim_end; 233 Time _silence_end; 234 235 bool _normalize; 236 bool _normalize_loudness; 237 bool _use_tp_limiter; 238 float _normalize_dbfs; 239 float _normalize_lufs; 240 float _normalize_dbtp; 241 bool _with_toc; 242 bool _with_cue; 243 bool _with_mp4chaps; 244 bool _soundcloud_upload; 245 246 float _demo_noise_level; 247 int _demo_noise_duration; 248 int _demo_noise_interval; 249 250 std::string _command; 251 bool _analyse; 252 int _codec_quality; 253 254 /* serialization helpers */ 255 256 void add_option (XMLNode * node, std::string const & name, std::string const & value); 257 std::string get_option (XMLNode const * node, std::string const & name); 258 259 }; 260 261 } // namespace ARDOUR 262 263 #endif /* __ardour_export_format_specification_h__ */ 264