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_format_base_h__
22 #define __ardour_export_format_base_h__
27 #include <boost/shared_ptr.hpp>
30 #include <samplerate.h>
32 #include "pbd/signals.h"
33 #include "ardour/libardour_visibility.h"
34 #include "ardour/types.h"
36 #include "audiographer/general/sample_format_converter.h"
41 class LIBARDOUR_API ExportFormatBase {
51 F_WAV = SF_FORMAT_WAV,
52 F_W64 = SF_FORMAT_W64,
53 F_CAF = SF_FORMAT_CAF,
54 F_AIFF = SF_FORMAT_AIFF,
56 F_IRCAM = SF_FORMAT_IRCAM,
57 F_RAW = SF_FORMAT_RAW,
58 F_FLAC = SF_FORMAT_FLAC,
63 E_FileDefault = SF_ENDIAN_FILE, /* Default file endian-ness. */
64 E_Little = SF_ENDIAN_LITTLE, /* Force little endian-ness. */
65 E_Big = SF_ENDIAN_BIG, /* Force big endian-ness. */
66 E_Cpu = SF_ENDIAN_CPU /* Force CPU endian-ness. */
71 SF_8 = SF_FORMAT_PCM_S8,
72 SF_16 = SF_FORMAT_PCM_16,
73 SF_24 = SF_FORMAT_PCM_24,
74 SF_32 = SF_FORMAT_PCM_32,
75 SF_U8 = SF_FORMAT_PCM_U8,
76 SF_Float = SF_FORMAT_FLOAT,
77 SF_Double = SF_FORMAT_DOUBLE,
78 SF_Vorbis = SF_FORMAT_VORBIS
82 D_None = AudioGrapher::D_None,
83 D_Rect = AudioGrapher::D_Rect,
84 D_Tri = AudioGrapher::D_Tri,
85 D_Shaped = AudioGrapher::D_Shaped
92 Q_LosslessCompression,
110 SRC_SincBest = SRC_SINC_BEST_QUALITY,
111 SRC_SincMedium = SRC_SINC_MEDIUM_QUALITY,
112 SRC_SincFast = SRC_SINC_FASTEST,
113 SRC_ZeroOrderHold = SRC_ZERO_ORDER_HOLD,
114 SRC_Linear = SRC_LINEAR
117 /// Class for managing selection and compatibility states
118 class LIBARDOUR_API SelectableCompatible {
120 SelectableCompatible ()
121 : _selected (false), _compatible (true) { }
122 ~SelectableCompatible () {}
124 PBD::Signal1<void,bool> SelectChanged;
125 PBD::Signal1<void,bool> CompatibleChanged;
127 bool selected () const { return _selected; }
128 bool compatible () const { return _compatible; }
129 std::string name () const { return _name; }
131 void set_selected (bool value);
132 void set_compatible (bool value);
135 void set_name (std::string name) { _name = name; }
147 ExportFormatBase (ExportFormatBase const & other);
149 virtual ~ExportFormatBase ();
151 boost::shared_ptr<ExportFormatBase> get_intersection (ExportFormatBase const & other) const;
152 boost::shared_ptr<ExportFormatBase> get_union (ExportFormatBase const & other) const;
154 bool endiannesses_empty () const { return endiannesses.empty (); }
155 bool sample_formats_empty () const { return sample_formats.empty (); }
156 bool sample_rates_empty () const { return sample_rates.empty (); }
157 bool formats_empty () const { return format_ids.empty (); }
158 bool qualities_empty () const { return qualities.empty (); }
160 bool has_endianness (Endianness endianness) const { return endiannesses.find (endianness) != endiannesses.end() ; }
161 bool has_sample_format (SampleFormat format) const { return sample_formats.find (format) != sample_formats.end(); }
162 bool has_sample_rate (SampleRate rate) const { return sample_rates.find (rate) != sample_rates.end(); }
163 bool has_format (FormatId format) const { return format_ids.find (format) != format_ids.end(); }
164 bool has_quality (Quality quality) const { return qualities.find (quality) != qualities.end(); }
166 void set_extension (std::string const & extension) { _extension = extension; }
167 std::string const & extension () const { return _extension; }
169 static SampleRate nearest_sample_rate (samplecnt_t sample_rate);
173 friend class HasSampleFormat;
174 typedef std::set<SampleFormat> SampleFormatSet;
175 SampleFormatSet sample_formats;
178 typedef std::set<Endianness> EndianSet;
179 typedef std::set<SampleRate> SampleRateSet;
180 typedef std::set<FormatId> FormatSet;
181 typedef std::set<Quality> QualitySet;
183 EndianSet endiannesses;
184 SampleRateSet sample_rates;
185 FormatSet format_ids;
186 QualitySet qualities;
190 std::string _extension;
197 boost::shared_ptr<ExportFormatBase> do_set_operation (ExportFormatBase const & other, SetOperation operation) const;
200 } // namespace ARDOUR
202 #endif /* __ardour_export_format_base_h__ */