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_formats_h__
22 #define __ardour_export_formats_h__
24 #include <ardour/export_format_base.h>
25 #include <ardour/export_format_compatibility.h>
28 #include <boost/weak_ptr.hpp>
33 class HasSampleFormat;
35 /// Base class for formats
36 class ExportFormat : public ExportFormatBase, public ExportFormatBase::SelectableCompatible {
42 virtual bool set_compatibility_state (ExportFormatCompatibility const & compatibility) = 0;
43 virtual Type get_type () const = 0;
45 FormatId get_format_id () const { return *format_ids.begin(); }
46 Quality get_quality () const { return *qualities.begin(); }
48 bool has_sample_format ();
49 bool sample_format_is_compatible (SampleFormat format) const;
51 /* If the format has a specific sample format, this function should be overriden
52 * if the format has a selectable sample format, do not override this!
55 virtual SampleFormat get_explicit_sample_format () const { return SF_None; }
57 /* If the above is not overriden, this one should be */
59 virtual ExportFormat::SampleFormat default_sample_format () const { return SF_None; }
61 /* If the format has a channel count limit, override this */
63 virtual uint32_t get_channel_limit () const { return 256; }
65 /* If the format can be tagged with metadata override this */
67 virtual bool supports_tagging () const { return false; }
69 /* If the format contains broadcast info override this */
71 virtual bool has_broadcast_info () const { return false; }
75 void add_sample_rate (SampleRate rate) { sample_rates.insert (rate); }
76 void add_endianness (Endianness endianness) { endiannesses.insert (endianness); }
78 void set_format_id (FormatId id) { format_ids.clear (); format_ids.insert (id); }
79 void set_quality (Quality value) { qualities.clear(); qualities.insert (value); }
82 /// Class to be inherited by export formats that have a selectable sample format
83 class HasSampleFormat {
86 class SampleFormatState : public ExportFormatBase::SelectableCompatible {
88 SampleFormatState (ExportFormatBase::SampleFormat format, Glib::ustring name) :
89 format (format) { set_name (name); }
91 ExportFormatBase::SampleFormat format;
94 class DitherTypeState : public ExportFormatBase::SelectableCompatible {
96 DitherTypeState (ExportFormatBase::DitherType type, Glib::ustring name) :
97 type (type) { set_name (name); }
99 ExportFormatBase::DitherType type;
102 typedef boost::shared_ptr<SampleFormatState> SampleFormatPtr;
103 typedef boost::weak_ptr<SampleFormatState> WeakSampleFormatPtr;
104 typedef std::list<SampleFormatPtr> SampleFormatList;
106 typedef boost::shared_ptr<DitherTypeState> DitherTypePtr;
107 typedef boost::weak_ptr<DitherTypeState> WeakDitherTypePtr;
108 typedef std::list<DitherTypePtr> DitherTypeList;
112 HasSampleFormat (ExportFormatBase::SampleFormatSet & sample_formats);
113 virtual ~HasSampleFormat () {};
115 void add_sample_format (ExportFormatBase::SampleFormat format);
117 SampleFormatList const & get_sample_formats () const { return sample_format_states; }
118 DitherTypeList const & get_dither_types () const { return dither_type_states; }
120 SampleFormatPtr get_selected_sample_format ();
121 DitherTypePtr get_selected_dither_type ();
123 /* Proxies for signals from sample formats and dither types */
125 sigc::signal<void, bool, WeakSampleFormatPtr> SampleFormatSelectChanged;
126 sigc::signal<void, bool, WeakSampleFormatPtr> SampleFormatCompatibleChanged;
128 sigc::signal<void, bool, WeakDitherTypePtr> DitherTypeSelectChanged;
129 sigc::signal<void, bool, WeakDitherTypePtr> DitherTypeCompatibleChanged;
131 static string get_sample_format_name (ExportFormatBase::SampleFormat format);
136 DitherTypeList dither_type_states;
137 SampleFormatList sample_format_states;
140 /* Connected to signals */
142 void add_dither_type (ExportFormatBase::DitherType type, Glib::ustring name);
143 void update_sample_format_selection (bool);
144 void update_dither_type_selection (bool);
146 /* Reference to ExportFormatBase::sample_formats */
147 ExportFormatBase::SampleFormatSet & _sample_formats;
150 class ExportFormatLinear : public ExportFormat, public HasSampleFormat {
153 ExportFormatLinear (Glib::ustring name, FormatId format_id);
154 ~ExportFormatLinear () {};
156 bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
157 Type get_type () const { return T_Sndfile; }
159 void add_endianness (Endianness endianness) { endiannesses.insert (endianness); }
161 void set_default_sample_format (SampleFormat sf) { _default_sample_format = sf; }
162 SampleFormat default_sample_format () const { return _default_sample_format; }
165 SampleFormat _default_sample_format;
168 class ExportFormatOggVorbis : public ExportFormat {
170 ExportFormatOggVorbis ();
171 ~ExportFormatOggVorbis () {};
173 bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
174 Type get_type () const { return T_Sndfile; }
175 SampleFormat get_explicit_sample_format () const { return SF_Vorbis; }
176 virtual bool supports_tagging () const { return true; }
179 class ExportFormatFLAC : public ExportFormat, public HasSampleFormat {
182 ~ExportFormatFLAC () {};
184 bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
185 Type get_type () const { return T_Sndfile; }
187 uint32_t get_channel_limit () const { return 8; }
188 SampleFormat default_sample_format () const { return SF_16; }
189 virtual bool supports_tagging () const { return true; }
192 class ExportFormatBWF : public ExportFormat, public HasSampleFormat {
195 ~ExportFormatBWF () {};
197 bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
198 Type get_type () const { return T_Sndfile; }
200 SampleFormat default_sample_format () const { return SF_16; }
201 virtual bool has_broadcast_info () const { return true; }
204 } // namespace ARDOUR
206 #endif /* __ardour_export_formats__ */