ardour
export_formats.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2008 Paul Davis
3  Author: Sakari Bergen
4 
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.
9 
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.
14 
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.
18 
19 */
20 
21 #ifndef __ardour_export_formats_h__
22 #define __ardour_export_formats_h__
23 
24 #include <list>
25 #include <boost/weak_ptr.hpp>
26 
27 #include "pbd/failed_constructor.h"
28 #include "pbd/signals.h"
29 
32 
33 namespace ARDOUR
34 {
35 
37  public:
38  virtual const char *what() const throw() { return "Export format constructor failed: Format incompatible with system"; }
39 };
40 
43 
44  public:
45  ExportFormat () {};
47 
48  virtual bool set_compatibility_state (ExportFormatCompatibility const & compatibility) = 0;
49  virtual Type get_type () const = 0;
50 
51  FormatId get_format_id () const { return *format_ids.begin(); }
52  Quality get_quality () const { return *qualities.begin(); }
53 
54  bool has_sample_format ();
55  bool sample_format_is_compatible (SampleFormat format) const;
56 
57  /* If the format has a specific sample format, this function should be overriden
58  * if the format has a selectable sample format, do not override this!
59  */
60 
61  virtual SampleFormat get_explicit_sample_format () const { return SF_None; }
62 
63  /* If the above is not overriden, this one should be */
64 
65  virtual ExportFormat::SampleFormat default_sample_format () const { return SF_None; }
66 
67  /* If the format has a channel count limit, override this */
68 
69  virtual uint32_t get_channel_limit () const { return 256; }
70 
71  /* If the format can be tagged with metadata override this */
72 
73  virtual bool supports_tagging () const { return false; }
74 
75  /* If the format contains broadcast info override this */
76 
77  virtual bool has_broadcast_info () const { return false; }
78 
79  protected:
80 
81  void add_sample_rate (SampleRate rate) { sample_rates.insert (rate); }
82  void add_endianness (Endianness endianness) { endiannesses.insert (endianness); }
83 
84  void set_format_id (FormatId id) { format_ids.clear (); format_ids.insert (id); }
85  void set_quality (Quality value) { qualities.clear(); qualities.insert (value); }
86 };
87 
90  public:
91 
93  public:
95  : format (format)
96  {
97  set_name (name);
98  }
99 
101  };
102 
104  public:
106  type (type) { set_name (name); }
107 
109  };
110 
113  typedef std::list<SampleFormatPtr> SampleFormatList;
114 
117  typedef std::list<DitherTypePtr> DitherTypeList;
118 
119  public:
120 
122  virtual ~HasSampleFormat () {};
123 
124  void add_sample_format (ExportFormatBase::SampleFormat format);
125 
126  SampleFormatList const & get_sample_formats () const { return sample_format_states; }
127  DitherTypeList const & get_dither_types () const { return dither_type_states; }
128 
129  SampleFormatPtr get_selected_sample_format ();
130  DitherTypePtr get_selected_dither_type ();
131 
132  /* Proxies for signals from sample formats and dither types */
133 
134  PBD::Signal2<void,bool, WeakSampleFormatPtr> SampleFormatSelectChanged;
135  PBD::Signal2<void,bool, WeakSampleFormatPtr> SampleFormatCompatibleChanged;
136 
137  PBD::Signal2<void,bool, WeakDitherTypePtr> DitherTypeSelectChanged;
138  PBD::Signal2<void,bool, WeakDitherTypePtr> DitherTypeCompatibleChanged;
139 
140  static std::string get_sample_format_name (ExportFormatBase::SampleFormat format);
141 
142  protected:
143  /* State lists */
144 
145  DitherTypeList dither_type_states;
146  SampleFormatList sample_format_states;
147 
148  private:
149  /* Connected to signals */
150 
151  void add_dither_type (ExportFormatBase::DitherType type, std::string name);
152  void update_sample_format_selection (bool);
153  void update_dither_type_selection (bool);
154 
155  /* Reference to ExportFormatBase::sample_formats */
157 };
158 
160  public:
161 
162  ExportFormatLinear (std::string name, FormatId format_id);
164 
165  bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
166  Type get_type () const { return T_Sndfile; }
167 
168  void add_endianness (Endianness endianness) { endiannesses.insert (endianness); }
169 
170  void set_default_sample_format (SampleFormat sf) { _default_sample_format = sf; }
171  SampleFormat default_sample_format () const { return _default_sample_format; }
172 
173  protected:
175 };
176 
178  public:
181 
182  bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
183  Type get_type () const { return T_Sndfile; }
184  SampleFormat get_explicit_sample_format () const { return SF_Vorbis; }
185  virtual bool supports_tagging () const { return true; }
186 };
187 
189  public:
190  ExportFormatFLAC ();
192 
193  bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
194  Type get_type () const { return T_Sndfile; }
195 
196  uint32_t get_channel_limit () const { return 8; }
197  SampleFormat default_sample_format () const { return SF_16; }
198  virtual bool supports_tagging () const { return true; }
199 };
200 
202  public:
203  ExportFormatBWF ();
205 
206  bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
207  Type get_type () const { return T_Sndfile; }
208 
209  SampleFormat default_sample_format () const { return SF_16; }
210  virtual bool has_broadcast_info () const { return true; }
211 };
212 
213 } // namespace ARDOUR
214 
215 #endif /* __ardour_export_formats__ */
virtual uint32_t get_channel_limit() const
SampleFormat default_sample_format() const
void set_format_id(FormatId id)
PBD::Signal2< void, bool, WeakSampleFormatPtr > SampleFormatSelectChanged
std::list< SampleFormatPtr > SampleFormatList
boost::shared_ptr< DitherTypeState > DitherTypePtr
boost::weak_ptr< SampleFormatState > WeakSampleFormatPtr
SampleFormat get_explicit_sample_format() const
SampleFormatList sample_format_states
PBD::Signal2< void, bool, WeakDitherTypePtr > DitherTypeSelectChanged
void set_quality(Quality value)
uint32_t get_channel_limit() const
virtual bool supports_tagging() const
virtual bool has_broadcast_info() const
std::list< DitherTypePtr > DitherTypeList
Definition: amp.h:29
virtual bool has_broadcast_info() const
ExportFormatBase::SampleFormat format
Class to be inherited by export formats that have a selectable sample format.
PBD::Signal2< void, bool, WeakDitherTypePtr > DitherTypeCompatibleChanged
SampleFormat default_sample_format() const
boost::weak_ptr< DitherTypeState > WeakDitherTypePtr
virtual ExportFormat::SampleFormat default_sample_format() const
DitherTypeList const & get_dither_types() const
Class for managing selection and compatibility states.
ExportFormatBase::DitherType type
#define LIBARDOUR_API
Base class for formats.
virtual const char * what() const
const char * name
ExportFormatBase::SampleFormatSet & _sample_formats
SampleFormat
Definition: types.h:460
FormatId get_format_id() const
void add_endianness(Endianness endianness)
PBD::Signal2< void, bool, WeakSampleFormatPtr > SampleFormatCompatibleChanged
Quality get_quality() const
SampleFormatList const & get_sample_formats() const
DitherTypeState(ExportFormatBase::DitherType type, Glib::ustring name)
SampleFormat default_sample_format() const
Allows adding to all sets. A format should be able to test if it is compatible with this...
void add_sample_rate(SampleRate rate)
SampleFormatState(ExportFormatBase::SampleFormat format, std::string name)
void set_default_sample_format(SampleFormat sf)
virtual bool supports_tagging() const
virtual SampleFormat get_explicit_sample_format() const
boost::shared_ptr< SampleFormatState > SampleFormatPtr
SampleFormat _default_sample_format
void add_endianness(Endianness endianness)
virtual bool supports_tagging() const
DitherTypeList dither_type_states
std::set< SampleFormat > SampleFormatSet