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_specification_h__
22 #define __ardour_export_format_specification_h__
24 #include <glibmm/ustring.h>
28 #include "ardour/types.h"
29 #include "ardour/export_format_base.h"
37 class ExportFormatCompatibility
;
40 class ExportFormatSpecification
: public ExportFormatBase
{
44 /* Time struct for keeping time formats as close as possible to what was requested */
46 struct Time
: public AnyTime
{
47 Time (Session
& session
) : AnyTime (), session (session
) {}
48 Time
& operator= (AnyTime
const & other
);
50 nframes_t
get_frames (nframes_t target_rate
) const;
54 XMLNode
& get_state ();
55 int set_state (const XMLNode
& node
);
62 friend class ExportElementFactory
;
63 explicit ExportFormatSpecification (Session
& s
);
64 ExportFormatSpecification (Session
& s
, XMLNode
const & state
);
67 ExportFormatSpecification (ExportFormatSpecification
const & other
);
68 ~ExportFormatSpecification ();
72 bool is_compatible_with (ExportFormatCompatibility
const & compatibility
) const;
73 bool is_complete () const;
75 /* Modifying functions */
77 void set_format (boost::shared_ptr
<ExportFormat
> format
);
79 void set_name (Glib::ustring
const & name
) { _name
= name
; }
81 void set_type (Type type
) { _type
= type
; }
82 void set_format_id (FormatId value
) { format_ids
.clear(); format_ids
.insert (value
); }
83 void set_endianness (Endianness value
) { endiannesses
.clear(); endiannesses
.insert (value
); }
84 void set_sample_format (SampleFormat value
) { sample_formats
.clear(); sample_formats
.insert (value
); }
85 void set_sample_rate (SampleRate value
) { sample_rates
.clear(); sample_rates
.insert (value
); }
86 void set_quality (Quality value
) { qualities
.clear(); qualities
.insert (value
); }
88 void set_dither_type (DitherType value
) { _dither_type
= value
; }
89 void set_src_quality (SRCQuality value
) { _src_quality
= value
; }
90 void set_trim_beginning (bool value
) { _trim_beginning
= value
; }
91 void set_trim_end (bool value
) { _trim_end
= value
; }
92 void set_normalize (bool value
) { _normalize
= value
; }
93 void set_normalize_target (float value
) { _normalize_target
= value
; }
95 void set_tag (bool tag_it
) { _tag
= tag_it
; }
97 void set_silence_beginning (AnyTime
const & value
) { _silence_beginning
= value
; }
98 void set_silence_end (AnyTime
const & value
) { _silence_end
= value
; }
100 /* Accessing functions */
102 PBD::UUID
const & id () { return _id
; }
103 Glib::ustring
const & name () const { return _name
; }
104 Glib::ustring
description ();
106 bool has_broadcast_info () const { return _has_broadcast_info
; }
107 uint32_t channel_limit () const { return _channel_limit
; }
108 Glib::ustring
format_name () const { return _format_name
; }
110 Type
type () const { return _type
; }
111 FormatId
format_id () const { return *format_ids
.begin(); }
112 Endianness
endianness () const { return *endiannesses
.begin(); }
113 SampleFormat
sample_format () const { return *sample_formats
.begin(); }
114 SampleRate
sample_rate () const { return *sample_rates
.begin(); }
115 Quality
quality () const { return *qualities
.begin(); }
117 DitherType
dither_type () const { return _dither_type
; }
118 SRCQuality
src_quality () const { return _src_quality
; }
119 bool trim_beginning () const { return _trim_beginning
; }
120 bool trim_end () const { return _trim_end
; }
121 bool normalize () const { return _normalize
; }
122 float normalize_target () const { return _normalize_target
; }
124 bool tag () const { return _tag
&& supports_tagging
; }
126 nframes_t
silence_beginning () const { return _silence_beginning
.get_frames (sample_rate()); }
127 nframes_t
silence_end () const { return _silence_end
.get_frames (sample_rate()); }
129 nframes_t
silence_beginning (nframes_t samplerate
) const { return _silence_beginning
.get_frames (samplerate
); }
130 nframes_t
silence_end (nframes_t samplerate
) const { return _silence_end
.get_frames (samplerate
); }
132 AnyTime
silence_beginning_time () const { return _silence_beginning
; }
133 AnyTime
silence_end_time () const { return _silence_end
; }
137 XMLNode
& get_state ();
138 int set_state (const XMLNode
& root
);
145 /* The variables below do not have setters (usually set via set_format) */
147 Glib::ustring _format_name
;
148 bool has_sample_format
;
149 bool supports_tagging
;
150 bool _has_broadcast_info
;
151 uint32_t _channel_limit
;
153 /* The variables below have getters and setters */
159 DitherType _dither_type
;
160 SRCQuality _src_quality
;
164 bool _trim_beginning
;
165 Time _silence_beginning
;
170 float _normalize_target
;
172 /* serialization helpers */
174 void add_option (XMLNode
* node
, std::string
const & name
, std::string
const & value
);
175 std::string
get_option (XMLNode
const * node
, std::string
const & name
);
179 } // namespace ARDOUR
181 #endif /* __ardour_export_format_specification_h__ */