Ardour  8.12
export_format_specification.h
Go to the documentation of this file.
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 
32 #include "ardour/types.h"
34 
35 class XMLNode;
36 
37 namespace ARDOUR
38 {
39 
40 class ExportFormat;
41 class ExportFormatCompatibility;
42 class Session;
43 
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 {
52  Time & operator= (AnyTime const & other);
53 
55 
56  /* Serialization */
57 
58  XMLNode & get_state () const;
59  int set_state (const XMLNode & node);
60 
61  private:
63  };
64 
65  private:
66  friend class ExportElementFactory;
69 
70  public:
71  ExportFormatSpecification (ExportFormatSpecification const & other, bool modify_name = true);
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 (std::shared_ptr<ExportFormat> format);
82  bool is_format (std::shared_ptr<ExportFormat> format) const;
84 
85  void set_name (std::string const & name) { _name = name; }
86 
87  void set_type (Type type) { _type = type; }
88  void set_format_id (FormatId value) { format_ids.clear(); format_ids.insert (value); }
89  void set_endianness (Endianness value) { endiannesses.clear(); endiannesses.insert (value); }
90  void set_sample_format (SampleFormat value) { sample_formats.clear(); sample_formats.insert (value); }
91  void set_sample_rate (SampleRate value) { sample_rates.clear(); sample_rates.insert (value); }
92  void set_quality (Quality value) { qualities.clear(); qualities.insert (value); }
93 
94  void set_dither_type (DitherType value) { _dither_type = value; }
95  void set_src_quality (SRCQuality value) { _src_quality = value; }
96  void set_trim_beginning (bool value) { _trim_beginning = value; }
97  void set_trim_end (bool value) { _trim_end = value; }
98  void set_normalize (bool value) { _normalize = value; }
99  void set_normalize_loudness (bool value) { _normalize_loudness = value; }
100  void set_use_tp_limiter (bool value) { _use_tp_limiter = value; }
101  void set_normalize_dbfs (float value) { _normalize_dbfs = value; }
102  void set_normalize_lufs (float value) { _normalize_lufs = value; }
103  void set_normalize_dbtp (float value) { _normalize_dbtp = value; }
104 
105  void set_demo_noise_level (float db) { _demo_noise_level = db; }
106  void set_demo_noise_duration (int msec) { _demo_noise_duration = msec; }
107  void set_demo_noise_interval (int msec) { _demo_noise_interval = msec; }
108 
109  void set_tag (bool tag_it) { _tag = tag_it; }
110  void set_with_cue (bool yn) { _with_cue = yn; }
111  void set_with_toc (bool yn) { _with_toc = yn; }
112  void set_with_mp4chaps (bool yn) { _with_mp4chaps = yn; }
113  void set_soundcloud_upload (bool yn) { _soundcloud_upload = yn; }
114  void set_command (std::string command) { _command = command; }
115  void set_analyse (bool yn) { _analyse = yn; }
116  void set_reimport (bool yn) { _reimport = yn; }
117  void set_codec_quality (int q) { _codec_quality = q; }
118 
119  void set_silence_beginning (AnyTime const & value) { _silence_beginning = value; }
120  void set_silence_end (AnyTime const & value) { _silence_end = value; }
121 
122  /* Accessing functions */
123 
124  PBD::UUID const & id () { return _id; }
125  std::string const & name () const { return _name; }
126  std::string description (bool include_name = true);
127 
128  bool has_broadcast_info () const { return _has_broadcast_info; }
129  uint32_t channel_limit () const { return _channel_limit; }
130  std::string format_name () const { return _format_name; }
131 
132  Type type () const { return _type; }
133 
134  FormatId format_id () const {
135  if (!format_ids.empty() )
136  return *format_ids.begin();
137  else
138  return FormatId(0);
139  }
140 
142  if (!endiannesses.empty() )
143  return *endiannesses.begin();
144  else
145  return Endianness(0);
146  }
147 
149  if (!sample_formats.empty() )
150  return *sample_formats.begin();
151  else
152  return SampleFormat(0);
153  }
154 
156  if (!sample_rates.empty() )
157  return *sample_rates.begin();
158  else
159  return SampleRate(0);
160 
161  }
162 
163  Quality quality () const {
164  if (!qualities.empty() )
165  return *qualities.begin();
166  else
167  return Quality(0);
168  }
169 
170  DitherType dither_type () const { return _dither_type; }
171  SRCQuality src_quality () const { return _src_quality; }
172  bool trim_beginning () const { return _trim_beginning; }
173  bool trim_end () const { return _trim_end; }
174  bool normalize () const { return _normalize; }
175  bool normalize_loudness () const { return _normalize_loudness; }
176  bool use_tp_limiter () const { return _use_tp_limiter; }
177  float normalize_dbfs () const { return _normalize_dbfs; }
178  float normalize_lufs () const { return _normalize_lufs; }
179  float normalize_dbtp () const { return _normalize_dbtp; }
180  bool with_toc() const { return _with_toc; }
181  bool with_cue() const { return _with_cue; }
182  bool with_mp4chaps() const { return _with_mp4chaps; }
183 
184  float demo_noise_level () const { return _demo_noise_level; }
185  int demo_noise_duration () const { return _demo_noise_duration; }
186  int demo_noise_interval () const { return _demo_noise_interval; }
187 
188  bool soundcloud_upload() const { return _soundcloud_upload; }
189  std::string command() const { return _command; }
190  bool analyse() const { return _analyse; }
191  bool reimport() const { return _reimport; }
192  int codec_quality() const { return _codec_quality; }
193 
194  bool tag () const { return _tag && _supports_tagging; }
195 
197  { return _silence_beginning.get_samples_at (position, samplerate); }
199  { return _silence_end.get_samples_at (position, samplerate); }
200 
201  AnyTime silence_beginning_time () const { return _silence_beginning; }
202  AnyTime silence_end_time () const { return _silence_end; }
203 
204  /* Serialization */
205 
206  XMLNode & get_state () const;
207  int set_state (const XMLNode & root);
208 
209 
210  private:
211 
213 
214  /* The variables below do not have setters (usually set via set_format) */
215 
216  std::string _format_name;
221  uint32_t _channel_limit;
222 
223  /* The variables below have getters and setters */
224 
225  std::string _name;
227 
231 
232  bool _tag;
233 
236  bool _trim_end;
238 
245  bool _with_toc;
246  bool _with_cue;
249 
253 
254  std::string _command;
255  bool _analyse;
256  bool _reimport;
258 
259  /* serialization helpers */
260 
261  static void add_option (XMLNode * node, std::string const & name, std::string const & value);
262  static std::string get_option (XMLNode const * node, std::string const & name);
263 
264 };
265 
266 } // namespace ARDOUR
267 
268 #endif /* __ardour_export_format_specification_h__ */
Allows adding to all sets. A format should be able to test if it is compatible with this.
void set_silence_beginning(AnyTime const &value)
int set_state(const XMLNode &root)
void set_format(std::shared_ptr< ExportFormat > format)
static void add_option(XMLNode *node, std::string const &name, std::string const &value)
samplecnt_t silence_beginning_at(samplepos_t position, samplecnt_t samplerate) const
ExportFormatSpecification(ExportFormatSpecification const &other, bool modify_name=true)
samplecnt_t silence_end_at(samplepos_t position, samplecnt_t samplerate) const
bool is_compatible_with(ExportFormatCompatibility const &compatibility) const
void set_name(std::string const &name)
std::string description(bool include_name=true)
bool is_format(std::shared_ptr< ExportFormat > format) const
static std::string get_option(XMLNode const *node, std::string const &name)
ExportFormatSpecification(Session &s, XMLNode const &state)
Definition: uuid.h:32
Definition: xml++.h:114
GtkImageIconNameData name
Definition: gtkimage.h:6
#define LIBARDOUR_API
void session(lua_State *L)
Temporal::samplecnt_t samplecnt_t
Temporal::samplepos_t samplepos_t
bool operator==(const ProcessorSelection &a, const ProcessorSelection &b)
int set_state(const XMLNode &node)
samplecnt_t get_samples_at(samplepos_t position, samplecnt_t target_rate) const