Ardour  9.0-pre0-582-g084a23a80d
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 #pragma once
25 
26 #include <string>
27 
28 #include "pbd/uuid.h"
29 
31 #include "ardour/types.h"
33 
34 class XMLNode;
35 
36 namespace ARDOUR
37 {
38 
39 class ExportFormat;
40 class ExportFormatCompatibility;
41 class Session;
42 
44 
45  private:
46 
47  /* Time struct for keeping time formats as close as possible to what was requested */
48 
49  struct Time : public AnyTime {
51  Time & operator= (AnyTime const & other);
52 
54 
55  /* Serialization */
56 
57  XMLNode & get_state () const;
58  int set_state (const XMLNode & node);
59 
60  private:
62  };
63 
64  private:
65  friend class ExportElementFactory;
68 
69  public:
70  ExportFormatSpecification (ExportFormatSpecification const & other, bool modify_name = true);
72 
73  /* compatibility */
74 
75  bool is_compatible_with (ExportFormatCompatibility const & compatibility) const;
76  bool is_complete () const;
77 
78  /* Modifying functions */
79 
80  void set_format (std::shared_ptr<ExportFormat> format);
81  bool is_format (std::shared_ptr<ExportFormat> format) const;
83 
84  void set_name (std::string const & name) { _name = name; }
85 
86  void set_type (Type type) { _type = type; }
87  void set_format_id (FormatId value) { format_ids.clear(); format_ids.insert (value); }
88  void set_endianness (Endianness value) { endiannesses.clear(); endiannesses.insert (value); }
89  void set_sample_format (SampleFormat value) { sample_formats.clear(); sample_formats.insert (value); }
90  void set_sample_rate (SampleRate value) { sample_rates.clear(); sample_rates.insert (value); }
91  void set_quality (Quality value) { qualities.clear(); qualities.insert (value); }
92 
93  void set_dither_type (DitherType value) { _dither_type = value; }
94  void set_src_quality (SRCQuality value) { _src_quality = value; }
95  void set_trim_beginning (bool value) { _trim_beginning = value; }
96  void set_trim_end (bool value) { _trim_end = value; }
97  void set_normalize (bool value) { _normalize = value; }
98  void set_normalize_loudness (bool value) { _normalize_loudness = value; }
99  void set_use_tp_limiter (bool value) { _use_tp_limiter = value; }
100  void set_normalize_dbfs (float value) { _normalize_dbfs = value; }
101  void set_normalize_lufs (float value) { _normalize_lufs = value; }
102  void set_normalize_dbtp (float value) { _normalize_dbtp = value; }
103 
104  void set_demo_noise_level (float db) { _demo_noise_level = db; }
105  void set_demo_noise_duration (int msec) { _demo_noise_duration = msec; }
106  void set_demo_noise_interval (int msec) { _demo_noise_interval = msec; }
107 
108  void set_tag (bool tag_it) { _tag = tag_it; }
109  void set_with_cue (bool yn) { _with_cue = yn; }
110  void set_with_toc (bool yn) { _with_toc = yn; }
111  void set_with_mp4chaps (bool yn) { _with_mp4chaps = yn; }
112  void set_soundcloud_upload (bool yn) { _soundcloud_upload = yn; }
113  void set_command (std::string command) { _command = command; }
114  void set_analyse (bool yn) { _analyse = yn; }
115  void set_reimport (bool yn) { _reimport = yn; }
116  void set_codec_quality (int q) { _codec_quality = q; }
117 
118  void set_silence_beginning (AnyTime const & value) { _silence_beginning = value; }
119  void set_silence_end (AnyTime const & value) { _silence_end = value; }
120 
121  /* Accessing functions */
122 
123  PBD::UUID const & id () { return _id; }
124  std::string const & name () const { return _name; }
125  std::string description (bool include_name = true);
126 
127  bool has_broadcast_info () const { return _has_broadcast_info; }
128  uint32_t channel_limit () const { return _channel_limit; }
129  std::string format_name () const { return _format_name; }
130 
131  Type type () const { return _type; }
132 
133  FormatId format_id () const {
134  if (!format_ids.empty() )
135  return *format_ids.begin();
136  else
137  return FormatId(0);
138  }
139 
141  if (!endiannesses.empty() )
142  return *endiannesses.begin();
143  else
144  return Endianness(0);
145  }
146 
148  if (!sample_formats.empty() )
149  return *sample_formats.begin();
150  else
151  return SampleFormat(0);
152  }
153 
155  if (!sample_rates.empty() )
156  return *sample_rates.begin();
157  else
158  return SampleRate(0);
159 
160  }
161 
162  Quality quality () const {
163  if (!qualities.empty() )
164  return *qualities.begin();
165  else
166  return Quality(0);
167  }
168 
169  DitherType dither_type () const { return _dither_type; }
170  SRCQuality src_quality () const { return _src_quality; }
171  bool trim_beginning () const { return _trim_beginning; }
172  bool trim_end () const { return _trim_end; }
173  bool normalize () const { return _normalize; }
174  bool normalize_loudness () const { return _normalize_loudness; }
175  bool use_tp_limiter () const { return _use_tp_limiter; }
176  float normalize_dbfs () const { return _normalize_dbfs; }
177  float normalize_lufs () const { return _normalize_lufs; }
178  float normalize_dbtp () const { return _normalize_dbtp; }
179  bool with_toc() const { return _with_toc; }
180  bool with_cue() const { return _with_cue; }
181  bool with_mp4chaps() const { return _with_mp4chaps; }
182 
183  float demo_noise_level () const { return _demo_noise_level; }
184  int demo_noise_duration () const { return _demo_noise_duration; }
185  int demo_noise_interval () const { return _demo_noise_interval; }
186 
187  bool soundcloud_upload() const { return _soundcloud_upload; }
188  std::string command() const { return _command; }
189  bool analyse() const { return _analyse; }
190  bool reimport() const { return _reimport; }
191  int codec_quality() const { return _codec_quality; }
192 
193  bool tag () const { return _tag && _supports_tagging; }
194 
196  { return _silence_beginning.get_samples_at (position, samplerate); }
198  { return _silence_end.get_samples_at (position, samplerate); }
199 
200  AnyTime silence_beginning_time () const { return _silence_beginning; }
201  AnyTime silence_end_time () const { return _silence_end; }
202 
203  /* Serialization */
204 
205  XMLNode & get_state () const;
206  int set_state (const XMLNode & root);
207 
208 
209  private:
210 
212 
213  /* The variables below do not have setters (usually set via set_format) */
214 
215  std::string _format_name;
220  uint32_t _channel_limit;
221 
222  /* The variables below have getters and setters */
223 
224  std::string _name;
226 
230 
231  bool _tag;
232 
235  bool _trim_end;
237 
244  bool _with_toc;
245  bool _with_cue;
248 
252 
253  std::string _command;
254  bool _analyse;
255  bool _reimport;
257 
258  /* serialization helpers */
259 
260  static void add_option (XMLNode * node, std::string const & name, std::string const & value);
261  static std::string get_option (XMLNode const * node, std::string const & name);
262 
263 };
264 
265 } // namespace ARDOUR
266 
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:31
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