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>
29 #include <sigc++/signal.h>
30 #include <sigc++/trackable.h>
32 #include <ardour/export_formats.h>
40 class ExportFormatCompatibility;
41 class ExportFormatSpecification;
44 class ExportFormatManager : public sigc::trackable
48 typedef boost::shared_ptr<ExportFormatCompatibility> CompatPtr;
49 typedef boost::weak_ptr<ExportFormatCompatibility> WeakCompatPtr;
50 typedef std::list<CompatPtr> CompatList;
52 typedef boost::shared_ptr<ExportFormat> FormatPtr;
53 typedef boost::weak_ptr<ExportFormat> WeakFormatPtr;
54 typedef std::list<FormatPtr> FormatList;
56 typedef HasSampleFormat::SampleFormatPtr SampleFormatPtr;
57 typedef HasSampleFormat::SampleFormatList SampleFormatList;
58 typedef HasSampleFormat::WeakSampleFormatPtr WeakSampleFormatPtr;
60 typedef HasSampleFormat::DitherTypePtr DitherTypePtr;
61 typedef HasSampleFormat::WeakDitherTypePtr WeakDitherTypePtr;
63 typedef boost::shared_ptr<ExportFormatSpecification> SpecPtr;
64 typedef boost::shared_ptr<ExportFormatBase> FormatBasePtr;
68 class QualityState : public ExportFormatBase::SelectableCompatible {
70 QualityState (ExportFormatBase::Quality quality, Glib::ustring name) :
71 quality (quality) { set_name (name); }
72 ExportFormatBase::Quality quality;
74 typedef boost::shared_ptr<QualityState> QualityPtr;
75 typedef boost::weak_ptr<QualityState> WeakQualityPtr;
76 typedef std::list<QualityPtr> QualityList;
78 /* Sample rate states */
80 class SampleRateState : public ExportFormatBase::SelectableCompatible {
82 SampleRateState (ExportFormatBase::SampleRate rate, Glib::ustring name) :
83 rate (rate) { set_name (name); }
84 ExportFormatBase::SampleRate rate;
86 typedef boost::shared_ptr<SampleRateState> SampleRatePtr;
87 typedef boost::weak_ptr<SampleRateState> WeakSampleRatePtr;
88 typedef std::list<SampleRatePtr> SampleRateList;
92 explicit ExportFormatManager (SpecPtr specification);
93 ~ExportFormatManager ();
97 sigc::signal<void, bool> CompleteChanged;
101 CompatList const & get_compatibilities () { return compatibilities; }
102 QualityList const & get_qualities () { return qualities; }
103 FormatList const & get_formats () { return formats; }
104 SampleRateList const & get_sample_rates () { return sample_rates; }
106 /* Non interactive selections */
108 void set_name (Glib::ustring name);
110 void select_src_quality (ExportFormatBase::SRCQuality value);
111 void select_trim_beginning (bool value);
112 void select_silence_beginning (AnyTime const & time);
113 void select_trim_end (bool value);
114 void select_silence_end (AnyTime const & time);
115 void select_normalize (bool value);
116 void select_normalize_target (float value);
117 void select_tagging (bool tag);
121 void init_compatibilities ();
122 void init_qualities ();
123 void init_formats ();
124 void init_sample_rates ();
126 void add_compatibility (CompatPtr ptr);
127 void add_quality (QualityPtr ptr);
128 void add_format (FormatPtr ptr);
129 void add_sample_rate (SampleRatePtr ptr);
131 /* Connected to signals */
133 void change_compatibility_selection (bool select, WeakCompatPtr const & compat);
134 void change_quality_selection (bool select, WeakQualityPtr const & quality);
135 void change_format_selection (bool select, WeakFormatPtr const & format);
136 void change_sample_rate_selection (bool select, WeakSampleRatePtr const & rate);
138 void change_sample_format_selection (bool select, WeakSampleFormatPtr const & format);
139 void change_dither_type_selection (bool select, WeakDitherTypePtr const & type);
141 /* Do actual selection */
143 void select_compatibility (WeakCompatPtr const & compat);
144 void select_quality (QualityPtr const & quality);
145 void select_format (FormatPtr const & format);
146 void select_sample_rate (SampleRatePtr const & rate);
148 void select_sample_format (SampleFormatPtr const & format);
149 void select_dither_type (DitherTypePtr const & type);
151 bool pending_selection_change;
152 void selection_changed ();
154 /* Formats and compatibilities */
156 QualityPtr get_selected_quality ();
157 FormatPtr get_selected_format ();
158 SampleRatePtr get_selected_sample_rate ();
160 SampleFormatPtr get_selected_sample_format ();
162 FormatBasePtr get_compatibility_intersection ();
164 FormatBasePtr universal_set;
165 SpecPtr current_selection;
167 CompatList compatibilities;
168 QualityList qualities;
170 SampleRateList sample_rates;
174 } // namespace ARDOUR
176 #endif /* __ardour_export_format_manager_h__ */