diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2008-09-17 12:58:33 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2008-09-17 12:58:33 +0000 |
commit | f2b007195cd75b195e38a4cd7757debac73e7792 (patch) | |
tree | 90474413776806f02794602bbb495663e07a81ea /libs/ardour/ardour/export_format_specification.h | |
parent | 6ba5125e991e08a9d117b39a4c337cf453fd015d (diff) |
new files from sakari, missed last time
git-svn-id: svn://localhost/ardour2/branches/3.0@3740 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/ardour/export_format_specification.h')
-rw-r--r-- | libs/ardour/ardour/export_format_specification.h | 185 |
1 files changed, 185 insertions, 0 deletions
diff --git a/libs/ardour/ardour/export_format_specification.h b/libs/ardour/ardour/export_format_specification.h new file mode 100644 index 0000000000..41f71e8275 --- /dev/null +++ b/libs/ardour/ardour/export_format_specification.h @@ -0,0 +1,185 @@ +/* + Copyright (C) 2008 Paul Davis + Author: Sakari Bergen + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_export_format_specification_h__ +#define __ardour_export_format_specification_h__ + +#include <glibmm/ustring.h> + +#include <ardour/types.h> +#include <ardour/export_format_base.h> + +using std::string; + +class XMLNode; + +namespace ARDOUR +{ + +class ExportFormat; +class ExportFormatCompatibility; +class Session; + +class ExportFormatSpecification : public ExportFormatBase { + + private: + + /* Time struct for keeping time formats as close as possible to what was requested */ + + struct Time : public AnyTime { + Time (Session & session) : AnyTime (), session (session) {} + Time & operator= (AnyTime const & other); + + nframes_t get_frames (nframes_t target_rate) const; + + /* Serialization */ + + XMLNode & get_state (); + int set_state (const XMLNode & node); + + private: + Session & session; + }; + + private: + friend class ExportElementFactory; + explicit ExportFormatSpecification (Session & s); + ExportFormatSpecification (Session & s, XMLNode const & state); + + public: + ExportFormatSpecification (ExportFormatSpecification const & other); + ~ExportFormatSpecification (); + + /* compatibility */ + + bool is_compatible_with (ExportFormatCompatibility const & compatibility) const; + bool is_complete () const; + + /* Modifying functions */ + + void set_format (boost::shared_ptr<ExportFormat> format); + + void set_name (Glib::ustring const & name) { _name = name; } + + void set_type (Type type) { _type = type; } + void set_format_id (FormatId value) { format_ids.clear(); format_ids.insert (value); } + void set_endianness (Endianness value) { endiannesses.clear(); endiannesses.insert (value); } + void set_sample_format (SampleFormat value) { sample_formats.clear(); sample_formats.insert (value); } + void set_sample_rate (SampleRate value) { sample_rates.clear(); sample_rates.insert (value); } + void set_quality (Quality value) { qualities.clear(); qualities.insert (value); } + + void set_dither_type (DitherType value) { _dither_type = value; } + void set_src_quality (SRCQuality value) { _src_quality = value; } + void set_trim_beginning (bool value) { _trim_beginning = value; } + void set_trim_end (bool value) { _trim_end = value; } + void set_normalize (bool value) { _normalize = value; } + void set_normalize_target (float value) { _normalize_target = value; } + + void set_tag (bool tag_it) { _tag = tag_it; } + + void set_silence_beginning (AnyTime const & value) { _silence_beginning = value; } + void set_silence_end (AnyTime const & value) { _silence_end = value; } + + /* Accessing functions */ + + uint32_t id () { return _id; } + Glib::ustring const & name () const { return _name; } + Glib::ustring description (); + + bool has_broadcast_info () const { return _has_broadcast_info; } + uint32_t channel_limit () const { return _channel_limit; } + Glib::ustring format_name () const { return _format_name; } + + Type type () const { return _type; } + FormatId format_id () const { return *format_ids.begin(); } + Endianness endianness () const { return *endiannesses.begin(); } + SampleFormat sample_format () const { return *sample_formats.begin(); } + SampleRate sample_rate () const { return *sample_rates.begin(); } + Quality quality () const { return *qualities.begin(); } + + DitherType dither_type () const { return _dither_type; } + SRCQuality src_quality () const { return _src_quality; } + bool trim_beginning () const { return _trim_beginning; } + bool trim_end () const { return _trim_end; } + bool normalize () const { return _normalize; } + float normalize_target () const { return _normalize_target; } + + bool tag () const { return _tag && supports_tagging; } + + nframes_t silence_beginning () const { return _silence_beginning.get_frames (sample_rate()); } + nframes_t silence_end () const { return _silence_end.get_frames (sample_rate()); } + + AnyTime silence_beginning_time () const { return _silence_beginning; } + AnyTime silence_end_time () const { return _silence_end; } + + /* Serialization */ + + XMLNode & get_state (); + int set_state (const XMLNode & root); + + + private: + + Session & session; + + /* The variables below do not have setters (usually set via set_format) */ + + Glib::ustring _format_name; + bool has_sample_format; + bool supports_tagging; + bool _has_broadcast_info; + uint32_t _channel_limit; + + /* The variables below have getters and setters */ + + Glib::ustring _name; + uint32_t _id; + + Type _type; + DitherType _dither_type; + SRCQuality _src_quality; + + bool _tag; + + bool _trim_beginning; + Time _silence_beginning; + bool _trim_end; + Time _silence_end; + + bool _normalize; + float _normalize_target; + + /* serialization helpers */ + + void add_option (XMLNode * node, std::string const & name, std::string const & value); + std::string get_option (XMLNode const * node, std::string const & name); + + /*** Static stuff for id management, ExportElementFactory will have access to these ***/ + + static void init_counter (uint32_t val) { if (val > _counter) { _counter = val; } } + static uint32_t counter () { return _counter; } + + static uint32_t _counter; + +}; + +} // namespace ARDOUR + +#endif /* __ardour_export_format_specification_h__ */ |