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_manager_h__
22 #define __ardour_export_format_manager_h__
27 #include <boost/shared_ptr.hpp>
28 #include <boost/weak_ptr.hpp>
30 #include "pbd/signals.h"
32 #include "ardour/export_formats.h"
38 class ExportFormatCompatibility;
39 class ExportFormatSpecification;
42 class ExportFormatManager : public PBD::ScopedConnectionList
46 typedef boost::shared_ptr<ExportFormatCompatibility> CompatPtr;
47 typedef boost::weak_ptr<ExportFormatCompatibility> WeakCompatPtr;
48 typedef std::list<CompatPtr> CompatList;
50 typedef boost::shared_ptr<ExportFormat> FormatPtr;
51 typedef boost::weak_ptr<ExportFormat> WeakFormatPtr;
52 typedef std::list<FormatPtr> FormatList;
54 typedef HasSampleFormat::SampleFormatPtr SampleFormatPtr;
55 typedef HasSampleFormat::SampleFormatList SampleFormatList;
56 typedef HasSampleFormat::WeakSampleFormatPtr WeakSampleFormatPtr;
58 typedef HasSampleFormat::DitherTypePtr DitherTypePtr;
59 typedef HasSampleFormat::WeakDitherTypePtr WeakDitherTypePtr;
61 typedef boost::shared_ptr<ExportFormatSpecification> SpecPtr;
62 typedef boost::shared_ptr<ExportFormatBase> FormatBasePtr;
66 class QualityState : public ExportFormatBase::SelectableCompatible {
68 QualityState (ExportFormatBase::Quality quality, Glib::ustring name) :
69 quality (quality) { set_name (name); }
70 ExportFormatBase::Quality quality;
72 typedef boost::shared_ptr<QualityState> QualityPtr;
73 typedef boost::weak_ptr<QualityState> WeakQualityPtr;
74 typedef std::list<QualityPtr> QualityList;
76 /* Sample rate states */
78 class SampleRateState : public ExportFormatBase::SelectableCompatible {
80 SampleRateState (ExportFormatBase::SampleRate rate, Glib::ustring name)
81 : rate (rate) { set_name (name); }
82 ExportFormatBase::SampleRate rate;
84 typedef boost::shared_ptr<SampleRateState> SampleRatePtr;
85 typedef boost::weak_ptr<SampleRateState> WeakSampleRatePtr;
86 typedef std::list<SampleRatePtr> SampleRateList;
90 explicit ExportFormatManager (SpecPtr specification);
91 ~ExportFormatManager ();
95 PBD::Signal1<void,bool> CompleteChanged;
99 CompatList const & get_compatibilities () { return compatibilities; }
100 QualityList const & get_qualities () { return qualities; }
101 FormatList const & get_formats () { return formats; }
102 SampleRateList const & get_sample_rates () { return sample_rates; }
104 /* Non interactive selections */
106 void set_name (Glib::ustring name);
108 void select_src_quality (ExportFormatBase::SRCQuality value);
109 void select_trim_beginning (bool value);
110 void select_silence_beginning (AnyTime const & time);
111 void select_trim_end (bool value);
112 void select_silence_end (AnyTime const & time);
113 void select_normalize (bool value);
114 void select_normalize_target (float value);
115 void select_tagging (bool tag);
119 void init_compatibilities ();
120 void init_qualities ();
121 void init_formats ();
122 void init_sample_rates ();
124 void add_compatibility (CompatPtr ptr);
125 void add_quality (QualityPtr ptr);
126 void add_format (FormatPtr ptr);
127 void add_sample_rate (SampleRatePtr ptr);
129 /* Connected to signals */
131 void change_compatibility_selection (bool select, WeakCompatPtr const & compat);
132 void change_quality_selection (bool select, WeakQualityPtr const & quality);
133 void change_format_selection (bool select, WeakFormatPtr const & format);
134 void change_sample_rate_selection (bool select, WeakSampleRatePtr const & rate);
136 void change_sample_format_selection (bool select, WeakSampleFormatPtr const & format);
137 void change_dither_type_selection (bool select, WeakDitherTypePtr const & type);
139 /* Do actual selection */
141 void select_compatibility (WeakCompatPtr const & compat);
142 void select_quality (QualityPtr const & quality);
143 void select_format (FormatPtr const & format);
144 void select_sample_rate (SampleRatePtr const & rate);
146 void select_sample_format (SampleFormatPtr const & format);
147 void select_dither_type (DitherTypePtr const & type);
149 bool pending_selection_change;
150 void selection_changed ();
152 /* Formats and compatibilities */
154 QualityPtr get_selected_quality ();
155 FormatPtr get_selected_format ();
156 SampleRatePtr get_selected_sample_rate ();
158 SampleFormatPtr get_selected_sample_format ();
160 FormatBasePtr get_compatibility_intersection ();
162 FormatBasePtr universal_set;
163 SpecPtr current_selection;
165 CompatList compatibilities;
166 QualityList qualities;
168 SampleRateList sample_rates;
172 } // namespace ARDOUR
174 #endif /* __ardour_export_format_manager_h__ */