summaryrefslogtreecommitdiff
path: root/libs/ardour/ardour
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2008-09-17 12:58:33 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2008-09-17 12:58:33 +0000
commitf2b007195cd75b195e38a4cd7757debac73e7792 (patch)
tree90474413776806f02794602bbb495663e07a81ea /libs/ardour/ardour
parent6ba5125e991e08a9d117b39a4c337cf453fd015d (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')
-rw-r--r--libs/ardour/ardour/audiofile_tagger.h56
-rw-r--r--libs/ardour/ardour/broadcast_info.h95
-rw-r--r--libs/ardour/ardour/export_channel_configuration.h138
-rw-r--r--libs/ardour/ardour/export_failed.h61
-rw-r--r--libs/ardour/ardour/export_file_io.h144
-rw-r--r--libs/ardour/ardour/export_filename.h140
-rw-r--r--libs/ardour/ardour/export_format_base.h199
-rw-r--r--libs/ardour/ardour/export_format_compatibility.h57
-rw-r--r--libs/ardour/ardour/export_format_manager.h176
-rw-r--r--libs/ardour/ardour/export_format_specification.h185
-rw-r--r--libs/ardour/ardour/export_formats.h206
-rw-r--r--libs/ardour/ardour/export_handler.h182
-rw-r--r--libs/ardour/ardour/export_multiplication.h189
-rw-r--r--libs/ardour/ardour/export_processor.h139
-rw-r--r--libs/ardour/ardour/export_profile_manager.h316
-rw-r--r--libs/ardour/ardour/export_status.h72
-rw-r--r--libs/ardour/ardour/export_timespan.h97
-rw-r--r--libs/ardour/ardour/export_utilities.h146
-rw-r--r--libs/ardour/ardour/graph.h101
-rw-r--r--libs/ardour/ardour/session_metadata.h132
20 files changed, 2831 insertions, 0 deletions
diff --git a/libs/ardour/ardour/audiofile_tagger.h b/libs/ardour/ardour/audiofile_tagger.h
new file mode 100644
index 0000000000..1f2cbf223c
--- /dev/null
+++ b/libs/ardour/ardour/audiofile_tagger.h
@@ -0,0 +1,56 @@
+/*
+ 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_audiofile_tagger_h__
+#define __ardour_audiofile_tagger_h__
+
+#include <string>
+
+#include <taglib/taglib.h>
+#include <taglib/tag.h>
+#include <taglib/xiphcomment.h>
+
+using std::string;
+
+namespace ARDOUR
+{
+
+class SessionMetadata;
+
+/// Clas with static functions for tagging audiofiles
+class AudiofileTagger
+{
+ public:
+
+ /* Tags file with metadata, return true on success */
+
+ static bool tag_file (string const & filename, SessionMetadata const & metadata);
+
+ private:
+
+ static bool tag_generic (TagLib::Tag & tag, SessionMetadata const & metadata);
+ static bool tag_vorbis_comment (TagLib::Ogg::XiphComment & tag, SessionMetadata const & metadata);
+};
+
+
+
+} // namespace ARDOUR
+
+#endif /* __ardour_audiofile_tagger_h__ */
diff --git a/libs/ardour/ardour/broadcast_info.h b/libs/ardour/ardour/broadcast_info.h
new file mode 100644
index 0000000000..07522839fa
--- /dev/null
+++ b/libs/ardour/ardour/broadcast_info.h
@@ -0,0 +1,95 @@
+/*
+ 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_broadcast_info_h__
+#define __ardour_broadcast_info_h__
+
+#include <string>
+#include <ctime>
+
+#include <sndfile.h>
+
+#include <ardour/types.h>
+
+using std::string;
+
+namespace ARDOUR
+{
+
+class Session;
+
+class BroadcastInfo
+{
+ public:
+
+ /// Construct empty broadcast info
+ BroadcastInfo ();
+ ~BroadcastInfo ();
+
+ /// Returns last error sring from libsndfile
+ string get_error () const { return error; }
+
+ /* Convenience functions */
+
+ void set_from_session (Session const & session, int64_t time);
+
+ /* Reading */
+
+ bool load_from_file (string const & filename);
+ bool load_from_file (SNDFILE* sf);
+
+ string get_description () const;
+ int64_t get_time_reference () const;
+ struct tm get_origination_time () const;
+ string get_originator () const;
+ string get_originator_ref () const;
+
+ /* Writing */
+
+ bool write_to_file (string const & filename);
+ bool write_to_file (SNDFILE* sf);
+
+ void set_description (string const & desc);
+ void set_time_reference (int64_t when);
+ void set_origination_time (struct tm * now = 0); // if 0, use time generated at construction
+ void set_originator (string const & str = "");
+ void set_originator_ref (string const & str = "");
+
+ /* State info */
+
+ /// Returns true if a info has been succesfully loaded or anything has been manually set
+ bool has_info () const { return _has_info; }
+
+ private:
+
+ SF_BROADCAST_INFO * info;
+ struct tm _time;
+
+ void update_error ();
+ string error;
+
+ bool _has_info;
+};
+
+
+
+} // namespace ARDOUR
+
+#endif /* __ardour_broadcast_info_h__ */
diff --git a/libs/ardour/ardour/export_channel_configuration.h b/libs/ardour/ardour/export_channel_configuration.h
new file mode 100644
index 0000000000..8f2fcdbd28
--- /dev/null
+++ b/libs/ardour/ardour/export_channel_configuration.h
@@ -0,0 +1,138 @@
+/*
+ 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_channel_configuration_h__
+#define __ardour_export_channel_configuration_h__
+
+#include <set>
+#include <list>
+
+#include <glibmm/ustring.h>
+#include <sigc++/signal.h>
+
+#include <ardour/export_status.h>
+#include <ardour/ardour.h>
+
+using Glib::ustring;
+
+namespace ARDOUR
+{
+
+class ExportHandler;
+class AudioPort;
+class ExportChannel;
+class ExportFormatSpecification;
+class ExportFilename;
+class ExportProcessor;
+class ExportTimespan;
+
+class ExportChannel : public std::set<AudioPort *>
+{
+ public:
+ ExportChannel ();
+ ~ExportChannel ();
+
+ void add_port (AudioPort * port) { if (port) { insert (port); } }
+ void read_ports (float * data, nframes_t frames) const;
+};
+
+class ExportChannelConfiguration
+{
+ private:
+ typedef boost::shared_ptr<ExportProcessor> ProcessorPtr;
+ typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
+ typedef boost::shared_ptr<ExportFormatSpecification const> FormatPtr;
+ typedef boost::shared_ptr<ExportFilename> FilenamePtr;
+
+ typedef std::pair<FormatPtr, FilenamePtr> FileConfig;
+ typedef std::list<FileConfig> FileConfigList;
+
+ /// Struct for threading, acts like a pointer to a ExportChannelConfiguration
+ struct WriterThread {
+ WriterThread (ExportChannelConfiguration & channel_config) :
+ channel_config (channel_config), running (false) {}
+
+ ExportChannelConfiguration * operator-> () { return &channel_config; }
+ ExportChannelConfiguration & operator* () { return channel_config; }
+
+ ExportChannelConfiguration & channel_config;
+
+ pthread_t thread;
+ bool running;
+ };
+
+ private:
+ friend class ExportElementFactory;
+ ExportChannelConfiguration (ExportStatus & status);
+
+ public:
+ ~ExportChannelConfiguration ();
+
+ typedef boost::shared_ptr<ExportChannel const> ChannelPtr;
+ typedef std::list<ChannelPtr> ChannelList;
+
+ ChannelList const & get_channels () { return channels; }
+ bool all_channels_have_ports ();
+
+ ustring name () const { return _name; }
+ void set_name (ustring name) { _name = name; }
+ void set_split (bool value) { split = value; }
+
+ bool get_split () { return split; }
+ uint32_t get_n_chans () { return channels.size(); }
+
+ void register_channel (ChannelPtr channel) { channels.push_back (channel); }
+ void register_file_config (FormatPtr format, FilenamePtr filename) { file_configs.push_back (FileConfig (format, filename)); }
+
+ void clear_channels () { channels.clear (); }
+
+ /// Writes all files for this channel config @return true if a new thread was spawned
+ bool write_files (boost::shared_ptr<ExportProcessor> new_processor);
+ sigc::signal<void> FilesWritten;
+
+ // Tells the handler the necessary information for it to handle tempfiles
+ void register_with_timespan (TimespanPtr timespan);
+
+ void unregister_all ();
+
+ private:
+
+ // processor has to be prepared before doing this.
+ void write_file ();
+
+ /// The actual write files, needed for threading
+ static void * _write_files (void *arg);
+ WriterThread writer_thread;
+ ProcessorPtr processor;
+ ExportStatus & status;
+
+ bool files_written;
+
+ TimespanPtr timespan;
+ ChannelList channels;
+ FileConfigList file_configs;
+
+ bool split; // Split to mono files
+ ustring _name;
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_channel_configuration_h__ */
diff --git a/libs/ardour/ardour/export_failed.h b/libs/ardour/ardour/export_failed.h
new file mode 100644
index 0000000000..de00fba87e
--- /dev/null
+++ b/libs/ardour/ardour/export_failed.h
@@ -0,0 +1,61 @@
+/*
+ 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_failed_h__
+#define __ardour_export_failed_h__
+
+#include <exception>
+#include <string>
+#include <pbd/error.h>
+
+#include "i18n.h"
+
+using namespace PBD;
+
+namespace ARDOUR
+{
+
+class ExportFailed : public std::exception
+{
+ public:
+ ExportFailed (std::string const & reason, std::string const & description) :
+ reason (reason.c_str()),
+ description (description.c_str())
+ {
+ error << string_compose (_("Export failed: %1"), reason) << endmsg;
+ }
+
+ ~ExportFailed () throw() { }
+
+ const char* what() const throw()
+ {
+ return description;
+ }
+
+ private:
+
+ const char * reason;
+ const char * description;
+
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_failed_h__ */
diff --git a/libs/ardour/ardour/export_file_io.h b/libs/ardour/ardour/export_file_io.h
new file mode 100644
index 0000000000..e0b1c95323
--- /dev/null
+++ b/libs/ardour/ardour/export_file_io.h
@@ -0,0 +1,144 @@
+/*
+ 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_file_io_h__
+#define __ardour_export_file_io_h__
+
+#include <sndfile.h>
+
+#include <ardour/graph.h>
+#include <ardour/types.h>
+#include <ardour/ardour.h>
+
+namespace ARDOUR
+{
+
+/// Common part for all export file writers
+class ExportFileWriter
+{
+ public:
+ ExportFileWriter (string filename) : _filename (filename) {}
+ virtual ~ExportFileWriter () {}
+
+ string filename () const { return _filename; }
+ nframes_t position () const { return _position; }
+
+ void set_position (nframes_t position) { _position = position; }
+
+ protected:
+ string _filename;
+ nframes_t _position;
+};
+
+/// Common interface for templated libsndfile writers
+class SndfileWriterBase : public ExportFileWriter
+{
+ public:
+ SndfileWriterBase (int channels, nframes_t samplerate, int format, string const & path);
+ virtual ~SndfileWriterBase ();
+
+ SNDFILE * get_sndfile () const { return sndfile; }
+
+ protected:
+ SF_INFO sf_info;
+ SNDFILE * sndfile;
+};
+
+
+/// Template parameter specific parts of sndfile writer
+template <typename T>
+class SndfileWriter : public SndfileWriterBase, public GraphSink<T>
+{
+ public:
+ SndfileWriter (int channels, nframes_t samplerate, int format, string const & path);
+ virtual ~SndfileWriter () {}
+
+ nframes_t write (T * data, nframes_t frames);
+
+ protected:
+ sf_count_t (*write_func)(SNDFILE *, const T *, sf_count_t);
+
+ private:
+ void init (); // Inits write function
+};
+
+/// Writes and reads a RAW tempfile (file aquired with tmpfile())
+class ExportTempFile : public SndfileWriter<float>, public GraphSource<float>
+{
+ public:
+ ExportTempFile (uint32_t channels, nframes_t samplerate);
+ ~ExportTempFile () {}
+
+ /// Causes the file to be read from the beginning again
+ void reset_read () { reading = false; }
+ nframes_t read (float * data, nframes_t frames);
+
+ /* Silence management */
+
+ nframes_t trim_beginning (bool yn = true);
+ nframes_t trim_end (bool yn = true);
+
+ void set_silence_beginning (nframes_t frames);
+ void set_silence_end (nframes_t frames);
+
+ private:
+ /* File access */
+
+ sf_count_t get_length ();
+ sf_count_t get_position ();
+ sf_count_t get_read_position (); // get position seems to default to the write pointer
+ sf_count_t locate_to (nframes_t frames);
+ sf_count_t _read (float * data, nframes_t frames);
+
+ uint32_t channels;
+ bool reading;
+
+ /* Silence related */
+
+ /* start and end are used by read() */
+
+ nframes_t start;
+ nframes_t end;
+
+ /* these are the silence processing results and state */
+
+ void process_beginning ();
+ void process_end ();
+
+ bool beginning_processed;
+ bool end_processed;
+
+ nframes_t silent_frames_beginning;
+ nframes_t silent_frames_end;
+
+ /* Silence to add to start and end */
+
+ nframes_t silence_beginning;
+ nframes_t silence_end;
+
+ /* Takes care that the end postion gets set at some stage */
+
+ bool end_set;
+
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_file_io_h__ */
diff --git a/libs/ardour/ardour/export_filename.h b/libs/ardour/ardour/export_filename.h
new file mode 100644
index 0000000000..e44c50f394
--- /dev/null
+++ b/libs/ardour/ardour/export_filename.h
@@ -0,0 +1,140 @@
+/*
+ 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_filename_h__
+#define __ardour_export_filename_h__
+
+#include <glibmm/ustring.h>
+#include <pbd/statefuldestructible.h>
+
+#include <ardour/session.h>
+
+using Glib::ustring;
+
+namespace ARDOUR
+{
+
+class Session;
+class ExportTimespan;
+class ExportChannelConfiguration;
+class ExportFormatSpecification;
+
+class ExportFilename {
+ private:
+
+ typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
+ typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
+ typedef boost::shared_ptr<ExportFormatSpecification const> FormatPtr;
+
+ public:
+
+ enum DateFormat {
+ D_None,
+ D_ISO, // ISO 8601 full date
+ D_ISOShortY, // Like ISO 8601, but short year representation
+ D_BE, // big endian (no deliminator)
+ D_BEShortY // big endian short year representation
+ };
+
+ enum TimeFormat {
+ T_None,
+ T_NoDelim,
+ T_Delim
+ };
+
+ private:
+ friend class ExportElementFactory;
+ ExportFilename (Session & session);
+
+ public:
+ /* Serialization */
+
+ XMLNode & get_state ();
+ int set_state (const XMLNode &);
+
+ /* data access */
+
+ ustring get_path (FormatPtr format) const;
+ ustring get_folder () const { return folder; }
+
+ TimeFormat get_time_format () const { return time_format; }
+ DateFormat get_date_format () const { return date_format; }
+ ustring get_time_format_str (TimeFormat format) const;
+ ustring get_date_format_str (DateFormat format) const;
+
+ ustring get_label () const { return label; }
+ uint32_t get_revision () const { return revision; }
+
+ /* data modification */
+
+ void set_time_format (TimeFormat format);
+ void set_date_format (DateFormat format);
+ void set_label (ustring value);
+ void set_revision (uint32_t value) { revision = value; }
+ void set_channel (uint32_t value) { channel = value; }
+ bool set_folder (ustring path);
+
+ void set_timespan (TimespanPtr ts) { timespan = ts; }
+ void set_channel_config (ChannelConfigPtr cc) { channel_config = cc; }
+
+ /* public members */
+
+ bool include_label;
+ bool include_session;
+ bool include_revision;
+ bool include_channel_config;
+ bool include_channel;
+ bool include_timespan;
+ bool include_time;
+ bool include_date;
+
+ private:
+
+ Session & session;
+
+ ustring label;
+ uint32_t revision;
+ uint32_t channel;
+
+ ustring folder;
+
+ DateFormat date_format;
+ TimeFormat time_format;
+
+ ustring get_formatted_time (ustring const & format) const;
+ struct tm * time_struct; // Due to static allocation no destructor or copy-ctor is needed because of this
+
+ TimespanPtr timespan;
+ ChannelConfigPtr channel_config;
+
+ /* Serialization helpers */
+
+ typedef std::pair<bool, ustring> FieldPair;
+
+ void add_field (XMLNode * node, ustring const & name, bool enabled, ustring const & value = "");
+ FieldPair get_field (XMLNode const & node, ustring const & name);
+ FieldPair analyse_folder ();
+
+};
+
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_filename_h__ */
diff --git a/libs/ardour/ardour/export_format_base.h b/libs/ardour/ardour/export_format_base.h
new file mode 100644
index 0000000000..210452add2
--- /dev/null
+++ b/libs/ardour/ardour/export_format_base.h
@@ -0,0 +1,199 @@
+/*
+ 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_base_h__
+#define __ardour_export_format_base_h__
+
+#include <set>
+#include <string>
+#include <algorithm>
+#include <boost/shared_ptr.hpp>
+#include <glibmm/ustring.h>
+
+#include <sndfile.h>
+#include <samplerate.h>
+#include <ardour/gdither_types.h>
+#include <ardour/ardour.h>
+
+using std::string;
+
+namespace ARDOUR
+{
+
+class HasSampleFormat;
+
+class ExportFormatBase {
+ public:
+
+ enum Type {
+ T_None = 0,
+ T_Sndfile
+ };
+
+ enum FormatId {
+ F_None = 0,
+ F_WAV = SF_FORMAT_WAV,
+ F_W64 = SF_FORMAT_W64,
+ F_AIFF = SF_FORMAT_AIFF,
+ F_AU = SF_FORMAT_AU,
+ F_IRCAM = SF_FORMAT_IRCAM,
+ F_RAW = SF_FORMAT_RAW,
+ F_FLAC = SF_FORMAT_FLAC,
+ F_Ogg = SF_FORMAT_OGG
+ };
+
+ enum Endianness {
+ E_FileDefault = SF_ENDIAN_FILE, /* Default file endian-ness. */
+ E_Little = SF_ENDIAN_LITTLE, /* Force little endian-ness. */
+ E_Big = SF_ENDIAN_BIG, /* Force big endian-ness. */
+ E_Cpu = SF_ENDIAN_CPU /* Force CPU endian-ness. */
+ };
+
+ enum SampleFormat {
+ SF_None = 0,
+ SF_8 = SF_FORMAT_PCM_S8,
+ SF_16 = SF_FORMAT_PCM_16,
+ SF_24 = SF_FORMAT_PCM_24,
+ SF_32 = SF_FORMAT_PCM_32,
+ SF_U8 = SF_FORMAT_PCM_U8,
+ SF_Float = SF_FORMAT_FLOAT,
+ SF_Double = SF_FORMAT_DOUBLE,
+ SF_Vorbis = SF_FORMAT_VORBIS
+ };
+
+ enum DitherType {
+ D_None = GDitherNone,
+ D_Rect = GDitherRect,
+ D_Tri = GDitherTri,
+ D_Shaped = GDitherShaped
+ };
+
+ enum Quality {
+ Q_None = 0,
+ Q_Any,
+ Q_LosslessLinear,
+ Q_LosslessCompression,
+ Q_LossyCompression
+ };
+
+ enum SampleRate {
+ SR_None = 0,
+ SR_22_05 = 220500,
+ SR_44_1 = 44100,
+ SR_48 = 48000,
+ SR_88_2 = 88200,
+ SR_96 = 96000,
+ SR_192 = 192000
+ };
+
+ enum SRCQuality {
+ SRC_SincBest = SRC_SINC_BEST_QUALITY,
+ SRC_SincMedium = SRC_SINC_MEDIUM_QUALITY,
+ SRC_SincFast = SRC_SINC_FASTEST,
+ SRC_ZeroOrderHold = SRC_ZERO_ORDER_HOLD,
+ SRC_Linear = SRC_LINEAR
+ };
+
+ /// Class for managing selection and compatibility states
+ class SelectableCompatible {
+ public:
+ SelectableCompatible () :
+ _selected (false), _compatible (true) { }
+ ~SelectableCompatible () {}
+
+ sigc::signal<void, bool> SelectChanged;
+ sigc::signal<void, bool> CompatibleChanged;
+
+ bool selected () const { return _selected; }
+ bool compatible () const { return _compatible; }
+ Glib::ustring name () const { return _name; }
+
+ void set_selected (bool value);
+ void set_compatible (bool value);
+
+ protected:
+ void set_name (Glib::ustring name) { _name = name; }
+
+ private:
+ bool _selected;
+ bool _compatible;
+
+ Glib::ustring _name;
+ };
+
+ public:
+
+ ExportFormatBase ();
+ ExportFormatBase (ExportFormatBase const & other);
+
+ virtual ~ExportFormatBase ();
+
+ boost::shared_ptr<ExportFormatBase> get_intersection (ExportFormatBase const & other) const;
+ boost::shared_ptr<ExportFormatBase> get_difference (ExportFormatBase const & other) const;
+ boost::shared_ptr<ExportFormatBase> get_union (ExportFormatBase const & other) const;
+
+ bool endiannesses_empty () const { return endiannesses.empty (); }
+ bool sample_formats_empty () const { return sample_formats.empty (); }
+ bool sample_rates_empty () const { return sample_rates.empty (); }
+ bool formats_empty () const { return format_ids.empty (); }
+ bool qualities_empty () const { return qualities.empty (); }
+
+ bool has_endianness (Endianness endianness) const { return endiannesses.find (endianness) != endiannesses.end() ; }
+ bool has_sample_format (SampleFormat format) const { return sample_formats.find (format) != sample_formats.end(); }
+ bool has_sample_rate (SampleRate rate) const { return sample_rates.find (rate) != sample_rates.end(); }
+ bool has_format (FormatId format) const { return format_ids.find (format) != format_ids.end(); }
+ bool has_quality (Quality quality) const { return qualities.find (quality) != qualities.end(); }
+
+ void set_extension (Glib::ustring const & extension) { _extension = extension; }
+ Glib::ustring const & extension () const { return _extension; }
+
+ protected:
+
+ friend class HasSampleFormat;
+ typedef std::set<SampleFormat> SampleFormatSet;
+ SampleFormatSet sample_formats;
+
+ protected:
+ typedef std::set<Endianness> EndianSet;
+ typedef std::set<SampleRate> SampleRateSet;
+ typedef std::set<FormatId> FormatSet;
+ typedef std::set<Quality> QualitySet;
+
+ EndianSet endiannesses;
+ SampleRateSet sample_rates;
+ FormatSet format_ids;
+ QualitySet qualities;
+
+ private:
+
+ Glib::ustring _extension;
+
+ enum SetOperation {
+ SetUnion,
+ SetDifference,
+ SetIntersection
+ };
+
+ boost::shared_ptr<ExportFormatBase> do_set_operation (ExportFormatBase const & other, SetOperation operation) const;
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_format_base_h__ */
diff --git a/libs/ardour/ardour/export_format_compatibility.h b/libs/ardour/ardour/export_format_compatibility.h
new file mode 100644
index 0000000000..617b5ee1d0
--- /dev/null
+++ b/libs/ardour/ardour/export_format_compatibility.h
@@ -0,0 +1,57 @@
+/*
+ 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_compatibility_h__
+#define __ardour_export_format_compatibility_h__
+
+#include <ardour/export_format_base.h>
+
+namespace ARDOUR
+{
+
+/// Allows adding to all sets. A format should be able to test if it is compatible with this
+class ExportFormatCompatibility : public ExportFormatBase, public ExportFormatBase::SelectableCompatible {
+ private:
+
+ public:
+ ExportFormatCompatibility (Glib::ustring name)
+ {
+ set_name (name);
+ sample_formats.insert (SF_None);
+ sample_rates.insert (SR_None);
+ format_ids.insert (F_None);
+ qualities.insert (Q_None);
+ }
+
+ ~ExportFormatCompatibility () {};
+
+ ExportFormatCompatibility (ExportFormatBase const & other) :
+ ExportFormatBase (other) {}
+
+ void add_endianness (Endianness endianness) { endiannesses.insert (endianness); }
+ void add_sample_format (SampleFormat format) { sample_formats.insert (format); }
+ void add_sample_rate (SampleRate rate) { sample_rates.insert (rate); }
+ void add_format_id (FormatId id) { format_ids.insert (id); }
+ void add_quality (Quality quality) { qualities.insert (quality); }
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_format_compatibility_h__ */
diff --git a/libs/ardour/ardour/export_format_manager.h b/libs/ardour/ardour/export_format_manager.h
new file mode 100644
index 0000000000..8c54c9cd45
--- /dev/null
+++ b/libs/ardour/ardour/export_format_manager.h
@@ -0,0 +1,176 @@
+/*
+ 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_manager_h__
+#define __ardour_export_format_manager_h__
+
+#include <list>
+#include <string>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <sigc++/signal.h>
+#include <sigc++/trackable.h>
+
+#include <ardour/export_formats.h>
+
+using std::string;
+
+namespace ARDOUR
+{
+
+class ExportFormat;
+class ExportFormatCompatibility;
+class ExportFormatSpecification;
+class AnyTime;
+
+class ExportFormatManager : public sigc::trackable
+{
+ public:
+
+ typedef boost::shared_ptr<ExportFormatCompatibility> CompatPtr;
+ typedef boost::weak_ptr<ExportFormatCompatibility> WeakCompatPtr;
+ typedef std::list<CompatPtr> CompatList;
+
+ typedef boost::shared_ptr<ExportFormat> FormatPtr;
+ typedef boost::weak_ptr<ExportFormat> WeakFormatPtr;
+ typedef std::list<FormatPtr> FormatList;
+
+ typedef HasSampleFormat::SampleFormatPtr SampleFormatPtr;
+ typedef HasSampleFormat::SampleFormatList SampleFormatList;
+ typedef HasSampleFormat::WeakSampleFormatPtr WeakSampleFormatPtr;
+
+ typedef HasSampleFormat::DitherTypePtr DitherTypePtr;
+ typedef HasSampleFormat::WeakDitherTypePtr WeakDitherTypePtr;
+
+ typedef boost::shared_ptr<ExportFormatSpecification> SpecPtr;
+ typedef boost::shared_ptr<ExportFormatBase> FormatBasePtr;
+
+ /* Quality states */
+
+ class QualityState : public ExportFormatBase::SelectableCompatible {
+ public:
+ QualityState (ExportFormatBase::Quality quality, Glib::ustring name) :
+ quality (quality) { set_name (name); }
+ ExportFormatBase::Quality quality;
+ };
+ typedef boost::shared_ptr<QualityState> QualityPtr;
+ typedef boost::weak_ptr<QualityState> WeakQualityPtr;
+ typedef std::list<QualityPtr> QualityList;
+
+ /* Sample rate states */
+
+ class SampleRateState : public ExportFormatBase::SelectableCompatible {
+ public:
+ SampleRateState (ExportFormatBase::SampleRate rate, Glib::ustring name) :
+ rate (rate) { set_name (name); }
+ ExportFormatBase::SampleRate rate;
+ };
+ typedef boost::shared_ptr<SampleRateState> SampleRatePtr;
+ typedef boost::weak_ptr<SampleRateState> WeakSampleRatePtr;
+ typedef std::list<SampleRatePtr> SampleRateList;
+
+ public:
+
+ explicit ExportFormatManager (SpecPtr specification);
+ ~ExportFormatManager ();
+
+ /* Signals */
+
+ sigc::signal<void, bool> CompleteChanged;
+
+ /* Access to lists */
+
+ CompatList const & get_compatibilities () { return compatibilities; }
+ QualityList const & get_qualities () { return qualities; }
+ FormatList const & get_formats () { return formats; }
+ SampleRateList const & get_sample_rates () { return sample_rates; }
+
+ /* Non interactive selections */
+
+ void set_name (Glib::ustring name);
+
+ void select_src_quality (ExportFormatBase::SRCQuality value);
+ void select_trim_beginning (bool value);
+ void select_silence_beginning (AnyTime const & time);
+ void select_trim_end (bool value);
+ void select_silence_end (AnyTime const & time);
+ void select_normalize (bool value);
+ void select_normalize_target (float value);
+ void select_tagging (bool tag);
+
+ private:
+
+ void init_compatibilities ();
+ void init_qualities ();
+ void init_formats ();
+ void init_sample_rates ();
+
+ void add_compatibility (CompatPtr ptr);
+ void add_quality (QualityPtr ptr);
+ void add_format (FormatPtr ptr);
+ void add_sample_rate (SampleRatePtr ptr);
+
+ /* Connected to signals */
+
+ void change_compatibility_selection (bool select, WeakCompatPtr const & compat);
+ void change_quality_selection (bool select, WeakQualityPtr const & quality);
+ void change_format_selection (bool select, WeakFormatPtr const & format);
+ void change_sample_rate_selection (bool select, WeakSampleRatePtr const & rate);
+
+ void change_sample_format_selection (bool select, WeakSampleFormatPtr const & format);
+ void change_dither_type_selection (bool select, WeakDitherTypePtr const & type);
+
+ /* Do actual selection */
+
+ void select_compatibility (WeakCompatPtr const & compat);
+ void select_quality (QualityPtr const & quality);
+ void select_format (FormatPtr const & format);
+ void select_sample_rate (SampleRatePtr const & rate);
+
+ void select_sample_format (SampleFormatPtr const & format);
+ void select_dither_type (DitherTypePtr const & type);
+
+ bool pending_selection_change;
+ void selection_changed ();
+
+ /* Formats and compatibilities */
+
+ QualityPtr get_selected_quality ();
+ FormatPtr get_selected_format ();
+ SampleRatePtr get_selected_sample_rate ();
+
+ SampleFormatPtr get_selected_sample_format ();
+
+ FormatBasePtr get_compatibility_intersection ();
+
+ FormatBasePtr universal_set;
+ SpecPtr current_selection;
+
+ CompatList compatibilities;
+ QualityList qualities;
+ FormatList formats;
+ SampleRateList sample_rates;
+
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_format_manager_h__ */
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__ */
diff --git a/libs/ardour/ardour/export_formats.h b/libs/ardour/ardour/export_formats.h
new file mode 100644
index 0000000000..558223d75a
--- /dev/null
+++ b/libs/ardour/ardour/export_formats.h
@@ -0,0 +1,206 @@
+/*
+ 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_formats_h__
+#define __ardour_export_formats_h__
+
+#include <ardour/export_format_base.h>
+#include <ardour/export_format_compatibility.h>
+
+#include <list>
+#include <boost/weak_ptr.hpp>
+
+namespace ARDOUR
+{
+
+class HasSampleFormat;
+
+/// Base class for formats
+class ExportFormat : public ExportFormatBase, public ExportFormatBase::SelectableCompatible {
+
+ public:
+ ExportFormat () {};
+ ~ExportFormat () {};
+
+ virtual bool set_compatibility_state (ExportFormatCompatibility const & compatibility) = 0;
+ virtual Type get_type () const = 0;
+
+ FormatId get_format_id () const { return *format_ids.begin(); }
+ Quality get_quality () const { return *qualities.begin(); }
+
+ bool has_sample_format ();
+ bool sample_format_is_compatible (SampleFormat format) const;
+
+ /* If the format has a specific sample format, this function should be overriden
+ * if the format has a selectable sample format, do not override this!
+ */
+
+ virtual SampleFormat get_explicit_sample_format () const { return SF_None; }
+
+ /* If the above is not overriden, this one should be */
+
+ virtual ExportFormat::SampleFormat default_sample_format () const { return SF_None; }
+
+ /* If the format has a channel count limit, override this */
+
+ virtual uint32_t get_channel_limit () const { return 256; }
+
+ /* If the format can be tagged with metadata override this */
+
+ virtual bool supports_tagging () const { return false; }
+
+ /* If the format contains broadcast info override this */
+
+ virtual bool has_broadcast_info () const { return false; }
+
+ protected:
+
+ void add_sample_rate (SampleRate rate) { sample_rates.insert (rate); }
+ void add_endianness (Endianness endianness) { endiannesses.insert (endianness); }
+
+ void set_format_id (FormatId id) { format_ids.clear (); format_ids.insert (id); }
+ void set_quality (Quality value) { qualities.clear(); qualities.insert (value); }
+};
+
+/// Class to be inherited by export formats that have a selectable sample format
+class HasSampleFormat {
+ public:
+
+ class SampleFormatState : public ExportFormatBase::SelectableCompatible {
+ public:
+ SampleFormatState (ExportFormatBase::SampleFormat format, Glib::ustring name) :
+ format (format) { set_name (name); }
+
+ ExportFormatBase::SampleFormat format;
+ };
+
+ class DitherTypeState : public ExportFormatBase::SelectableCompatible {
+ public:
+ DitherTypeState (ExportFormatBase::DitherType type, Glib::ustring name) :
+ type (type) { set_name (name); }
+
+ ExportFormatBase::DitherType type;
+ };
+
+ typedef boost::shared_ptr<SampleFormatState> SampleFormatPtr;
+ typedef boost::weak_ptr<SampleFormatState> WeakSampleFormatPtr;
+ typedef std::list<SampleFormatPtr> SampleFormatList;
+
+ typedef boost::shared_ptr<DitherTypeState> DitherTypePtr;
+ typedef boost::weak_ptr<DitherTypeState> WeakDitherTypePtr;
+ typedef std::list<DitherTypePtr> DitherTypeList;
+
+ public:
+
+ HasSampleFormat (ExportFormatBase::SampleFormatSet & sample_formats);
+ virtual ~HasSampleFormat () {};
+
+ void add_sample_format (ExportFormatBase::SampleFormat format);
+
+ SampleFormatList const & get_sample_formats () const { return sample_format_states; }
+ DitherTypeList const & get_dither_types () const { return dither_type_states; }
+
+ SampleFormatPtr get_selected_sample_format ();
+ DitherTypePtr get_selected_dither_type ();
+
+ /* Proxies for signals from sample formats and dither types */
+
+ sigc::signal<void, bool, WeakSampleFormatPtr> SampleFormatSelectChanged;
+ sigc::signal<void, bool, WeakSampleFormatPtr> SampleFormatCompatibleChanged;
+
+ sigc::signal<void, bool, WeakDitherTypePtr> DitherTypeSelectChanged;
+ sigc::signal<void, bool, WeakDitherTypePtr> DitherTypeCompatibleChanged;
+
+ static string get_sample_format_name (ExportFormatBase::SampleFormat format);
+
+ protected:
+ /* State lists */
+
+ DitherTypeList dither_type_states;
+ SampleFormatList sample_format_states;
+
+ private:
+ /* Connected to signals */
+
+ void add_dither_type (ExportFormatBase::DitherType type, Glib::ustring name);
+ void update_sample_format_selection (bool);
+ void update_dither_type_selection (bool);
+
+ /* Reference to ExportFormatBase::sample_formats */
+ ExportFormatBase::SampleFormatSet & _sample_formats;
+};
+
+class ExportFormatLinear : public ExportFormat, public HasSampleFormat {
+ public:
+
+ ExportFormatLinear (Glib::ustring name, FormatId format_id);
+ ~ExportFormatLinear () {};
+
+ bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
+ Type get_type () const { return T_Sndfile; }
+
+ void add_endianness (Endianness endianness) { endiannesses.insert (endianness); }
+
+ void set_default_sample_format (SampleFormat sf) { _default_sample_format = sf; }
+ SampleFormat default_sample_format () const { return _default_sample_format; }
+
+ protected:
+ SampleFormat _default_sample_format;
+};
+
+class ExportFormatOggVorbis : public ExportFormat {
+ public:
+ ExportFormatOggVorbis ();
+ ~ExportFormatOggVorbis () {};
+
+ bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
+ Type get_type () const { return T_Sndfile; }
+ SampleFormat get_explicit_sample_format () const { return SF_Vorbis; }
+ virtual bool supports_tagging () const { return true; }
+};
+
+class ExportFormatFLAC : public ExportFormat, public HasSampleFormat {
+ public:
+ ExportFormatFLAC ();
+ ~ExportFormatFLAC () {};
+
+ bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
+ Type get_type () const { return T_Sndfile; }
+
+ uint32_t get_channel_limit () const { return 8; }
+ SampleFormat default_sample_format () const { return SF_16; }
+ virtual bool supports_tagging () const { return true; }
+};
+
+class ExportFormatBWF : public ExportFormat, public HasSampleFormat {
+ public:
+ ExportFormatBWF ();
+ ~ExportFormatBWF () {};
+
+ bool set_compatibility_state (ExportFormatCompatibility const & compatibility);
+ Type get_type () const { return T_Sndfile; }
+
+ SampleFormat default_sample_format () const { return SF_16; }
+ virtual bool has_broadcast_info () const { return true; }
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_formats__ */
diff --git a/libs/ardour/ardour/export_handler.h b/libs/ardour/ardour/export_handler.h
new file mode 100644
index 0000000000..99de563fa9
--- /dev/null
+++ b/libs/ardour/ardour/export_handler.h
@@ -0,0 +1,182 @@
+/*
+ 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_handler_h__
+#define __ardour_export_handler_h__
+
+#include <map>
+#include <list>
+#include <fstream>
+
+#include <boost/shared_ptr.hpp>
+
+#include <ardour/ardour.h>
+#include <ardour/session.h>
+#include <ardour/types.h>
+
+namespace ARDOUR
+{
+
+class ExportTimespan;
+class ExportChannelConfiguration;
+class ExportFormatSpecification;
+class ExportFilename;
+class ExportProcessor;
+
+class ExportElementFactory
+{
+ protected:
+ typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
+ typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
+ typedef boost::shared_ptr<ExportFormatSpecification> FormatPtr;
+ typedef boost::shared_ptr<ExportFilename> FilenamePtr;
+
+ public:
+
+ ExportElementFactory (Session & session);
+ ~ExportElementFactory ();
+
+ TimespanPtr add_timespan ();
+
+ ChannelConfigPtr add_channel_config ();
+
+ FormatPtr add_format ();
+ FormatPtr add_format (XMLNode const & state);
+ FormatPtr add_format_copy (FormatPtr other);
+
+ FilenamePtr add_filename ();
+ FilenamePtr add_filename_copy (FilenamePtr other);
+
+ private:
+ Session & session;
+};
+
+class ExportHandler : public ExportElementFactory, public sigc::trackable
+{
+ private:
+
+ /* Stuff for export configs
+ * The multimap maps timespans to file specifications
+ */
+
+ struct FileSpec {
+
+ FileSpec (ChannelConfigPtr channel_config, FormatPtr format, FilenamePtr filename) :
+ channel_config (channel_config),
+ format (format),
+ filename (filename)
+ {}
+
+ ChannelConfigPtr channel_config;
+ FormatPtr format;
+ FilenamePtr filename;
+ };
+
+ typedef std::pair<TimespanPtr, FileSpec> ConfigPair;
+ typedef std::multimap<TimespanPtr, FileSpec> ConfigMap;
+
+ typedef boost::shared_ptr<ExportProcessor> ProcessorPtr;
+
+ private:
+ /* Session::get_export_handler() should be used to obtain an export handler
+ * This ensures that it doesn't go out of scope before finalize_audio_export is called
+ */
+
+ friend boost::shared_ptr<ExportHandler> Session::get_export_handler();
+ ExportHandler (Session & session);
+
+ public:
+ ~ExportHandler ();
+
+ bool add_export_config (TimespanPtr timespan, ChannelConfigPtr channel_config, FormatPtr format, FilenamePtr filename);
+ void do_export (bool rt = false);
+
+ private:
+
+ Session & session;
+ ProcessorPtr processor;
+ ConfigMap config_map;
+
+ bool realtime;
+
+ sigc::connection files_written_connection;
+ std::list<Glib::ustring> files_written;
+
+ /* CD Marker stuff */
+
+ struct CDMarkerStatus {
+ CDMarkerStatus (string out_file, TimespanPtr timespan, FormatPtr format, string filename) :
+ out (out_file.c_str()), timespan (timespan), format (format), filename (filename),
+ track_number (1), track_position (0), track_duration (0), track_start_frame (0),
+ index_number (1), index_position (0)
+ {}
+
+ /* General info */
+ std::ofstream out;
+ TimespanPtr timespan;
+ FormatPtr format;
+ string filename;
+ Location * marker;
+
+ /* Track info */
+ uint32_t track_number;
+ nframes_t track_position;
+ nframes_t track_duration;
+ nframes_t track_start_frame;
+
+ /* Index info */
+ uint32_t index_number;
+ nframes_t index_position;
+ };
+
+
+ void export_cd_marker_file (TimespanPtr timespan, FormatPtr file_format, std::string filename, CDMarkerFormat format);
+
+ void write_cue_header (CDMarkerStatus & status);
+ void write_toc_header (CDMarkerStatus & status);
+
+ void write_track_info_cue (CDMarkerStatus & status);
+ void write_track_info_toc (CDMarkerStatus & status);
+
+ void write_index_info_cue (CDMarkerStatus & status);
+ void write_index_info_toc (CDMarkerStatus & status);
+
+ void frames_to_cd_frames_string (char* buf, nframes_t when);
+
+ int cue_tracknum;
+ int cue_indexnum;
+
+ /* Timespan management */
+
+ void start_timespan ();
+ void finish_timespan ();
+ void timespan_thread_finished ();
+
+ typedef std::pair<ConfigMap::iterator, ConfigMap::iterator> TimespanBounds;
+ TimespanPtr current_timespan;
+ ConfigMap::iterator current_map_it;
+ TimespanBounds timespan_bounds;
+ sigc::connection channel_config_connection;
+
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_handler_h__ */
diff --git a/libs/ardour/ardour/export_multiplication.h b/libs/ardour/ardour/export_multiplication.h
new file mode 100644
index 0000000000..c8fd20c60e
--- /dev/null
+++ b/libs/ardour/ardour/export_multiplication.h
@@ -0,0 +1,189 @@
+/* This file is not used at the moment. It includes code related to export a
+ * multiplication graph system that can be used together with the ExportMultiplicator
+ * class in the gtk2_ardour folder.
+ * - Sakari Bergen 6.8.2008 -
+ */
+
+/*** Graph classes ***/
+ public:
+
+ /// A node in the hierarchical graph that represents a multiplicatable export item
+ class GraphNode {
+ public:
+ GraphNode ();
+ virtual ~GraphNode ();
+
+ uint32_t id() const { return _id; }
+
+ /* Children and parents. Note: only children are kept in order! */
+
+ list<GraphNode *> const & get_parents () const { return parents; }
+
+ void add_child (GraphNode * child, GraphNode * left_sibling);
+ void remove_child (GraphNode * child);
+ GraphNode * first_child () const { return children.front(); }
+ GraphNode * last_child () const { return children.back(); }
+ list<GraphNode *> const & get_children () const { return children; }
+
+ /* Relation functions */
+
+ bool is_ancestor_of (GraphNode const * node) const;
+ bool is_descendant_of (GraphNode const * node) const;
+ bool equals (GraphNode const * node) const { return node == this; }
+
+ /* Selection functions */
+
+ bool selected () const { return _selected; }
+ void select (bool value);
+
+ sigc::signal<void, bool> SelectChanged;
+
+ protected:
+
+ /* Parent manipulation functions should be used only from child manipulation functions! */
+
+ void add_parent (GraphNode * parent);
+ void remove_parent (GraphNode * parent);
+
+ list<GraphNode *> parents;
+ list<GraphNode *> children;
+
+ bool _selected;
+ uint32_t _id;
+ static uint32_t id_counter;
+ };
+
+ /// A graph node that contains data
+ template <typename T>
+ class DataNode : public GraphNode {
+ private:
+ typedef boost::shared_ptr<T> DataPtr;
+ typedef boost::shared_ptr<DataNode<T> > SelfPtr;
+ typedef boost::weak_ptr<DataNode<T> > WeakSelfPtr;
+
+ DataNode (DataPtr data) : _data (data) {}
+ void set_self_ptr (boost::shared_ptr<DataNode<T> > ptr) { _self_ptr = ptr; }
+
+ public:
+ static SelfPtr create (T * data)
+ {
+ SelfPtr ptr = SelfPtr (new DataNode<T> (DataPtr (data)));
+ ptr->set_self_ptr (ptr);
+ return ptr;
+ }
+
+ static SelfPtr create (DataPtr data)
+ {
+ SelfPtr ptr = SelfPtr (new DataNode<T> (data));
+ ptr->set_self_ptr (ptr);
+ return ptr;
+ }
+
+ DataPtr data() { return _data; }
+ SelfPtr self_ptr () { return _self_ptr.lock(); }
+
+ template<typename P> // Parent's data type
+ void sort_parents (list<boost::shared_ptr<DataNode<P> > > const & sort_list)
+ {
+ parents.sort (NodeSorter<P> (sort_list));
+ }
+
+ private:
+ DataPtr _data;
+ WeakSelfPtr _self_ptr;
+ };
+
+ private:
+ /* Sorts GraphNodes according to a list of DataNodes */
+
+ template<typename T>
+ class NodeSorter {
+ public:
+ typedef list<boost::shared_ptr<DataNode<T> > > ListType;
+
+ NodeSorter (ListType const & list) : list (list) {}
+
+ bool operator() (GraphNode * one, GraphNode * other) // '<' operator
+ {
+ if (one == other) { return false; } // Strict weak ordering
+ for (typename ListType::const_iterator it = list.begin(); it != list.end(); ++it) {
+ if (it->get() == one) {
+ return true;
+ }
+ if (it->get() == other) {
+ return false;
+ }
+ }
+
+ std::cerr << "Invalid comparison list given to NodeSorter" << std::endl;
+
+ abort();
+ }
+
+ private:
+ ListType const & list;
+ };
+
+/*** Multiplication management ***/
+ public:
+
+ typedef DataNode<TimespanState> TimespanNode;
+ typedef boost::shared_ptr<TimespanNode> TimespanNodePtr;
+
+ typedef DataNode<ChannelConfigState> ChannelConfigNode;
+ typedef boost::shared_ptr<ChannelConfigNode> ChannelConfigNodePtr;
+
+ typedef DataNode<FormatState> FormatNode;
+ typedef boost::shared_ptr<FormatNode> FormatNodePtr;
+
+ typedef DataNode<FilenameState> FilenameNode;
+ typedef boost::shared_ptr<FilenameNode> FilenameNodePtr;
+
+ struct MultiplicationGraph {
+ list<TimespanNodePtr> timespans;
+ list<ChannelConfigNodePtr> channel_configs;
+ list<FormatNodePtr> formats;
+ list<FilenameNodePtr> filenames;
+ };
+
+ MultiplicationGraph const & get_graph () { return graph; }
+
+ void split_node (GraphNode * node, float position);
+ void remove_node (GraphNode * node);
+
+ sigc::signal<void> GraphChanged;
+
+ private:
+
+ void purge_graph ();
+
+ template<typename T>
+ static void insert_after (list<T> & the_list, T const & position, T const & element);
+
+ template<typename T>
+ static void remove_by_element (list<T> & the_list, T const & element);
+
+ bool nodes_have_one_common_child (list<GraphNode *> const & the_list);
+ list<GraphNode *>::const_iterator end_of_common_child_range (list<GraphNode *> const & the_list, list<GraphNode *>::const_iterator beginning);
+ void split_node_at_position (GraphNode * old_node, GraphNode * new_node, float position);
+
+ void split_timespan (TimespanNodePtr node, float position = 0.5);
+ void split_channel_config (ChannelConfigNodePtr node, float position = 0.5);
+ void split_format (FormatNodePtr node, float position = 0.5);
+ void split_filename (FilenameNodePtr node, float position = 0.5);
+
+ void duplicate_timespan_children (TimespanNodePtr source, TimespanNodePtr target, GraphNode * insertion_point = 0);
+ void duplicate_channel_config_children (ChannelConfigNodePtr source, ChannelConfigNodePtr target, GraphNode * insertion_point = 0);
+ void duplicate_format_children (FormatNodePtr source, FormatNodePtr target, GraphNode * insertion_point = 0);
+
+ TimespanNodePtr duplicate_timespan_node (TimespanNodePtr node);
+ ChannelConfigNodePtr duplicate_channel_config_node (ChannelConfigNodePtr node);
+ FormatNodePtr duplicate_format_node (FormatNodePtr node);
+ FilenameNodePtr duplicate_filename_node (FilenameNodePtr node);
+
+ void remove_timespan (TimespanNodePtr node);
+ void remove_channel_config (ChannelConfigNodePtr node);
+ void remove_format (FormatNodePtr node);
+ void remove_filename (FilenameNodePtr node);
+
+ MultiplicationGraph graph; \ No newline at end of file
diff --git a/libs/ardour/ardour/export_processor.h b/libs/ardour/ardour/export_processor.h
new file mode 100644
index 0000000000..fdb8213c68
--- /dev/null
+++ b/libs/ardour/ardour/export_processor.h
@@ -0,0 +1,139 @@
+/*
+ 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_processor_h__
+#define __ardour_export_processor_h__
+
+#include <vector>
+
+#include <boost/smart_ptr.hpp>
+#include <glibmm/ustring.h>
+
+#include <ardour/graph.h>
+#include <ardour/export_file_io.h>
+#include <ardour/export_utilities.h>
+
+using Glib::ustring;
+using std::list;
+
+namespace ARDOUR
+{
+
+class Session;
+class ExportStatus;
+class ExportFilename;
+class ExportFormatSpecification;
+
+/// Sets up components for export post processing
+class ExportProcessor
+{
+ private:
+ /* Typedefs for utility processors */
+
+ typedef boost::shared_ptr<SampleRateConverter> SRConverterPtr;
+ typedef boost::shared_ptr<PeakReader> PReaderPtr;
+ typedef boost::shared_ptr<Normalizer> NormalizerPtr;
+ typedef boost::shared_ptr<ExportTempFile> TempFilePtr;
+
+ typedef boost::shared_ptr<SampleFormatConverter<short> > ShortConverterPtr;
+ typedef boost::shared_ptr<SampleFormatConverter<int> > IntConverterPtr;
+ typedef boost::shared_ptr<SampleFormatConverter<float> > FloatConverterPtr;
+
+ typedef boost::shared_ptr<SndfileWriter<short> > ShortWriterPtr;
+ typedef boost::shared_ptr<SndfileWriter<int> > IntWriterPtr;
+ typedef boost::shared_ptr<SndfileWriter<float> > FloatWriterPtr;
+
+ typedef GraphSink<float> FloatSink;
+ typedef boost::shared_ptr<FloatSink> FloatSinkPtr;
+ typedef std::vector<FloatSinkPtr> FloatSinkVect;
+
+ typedef boost::shared_ptr<ExportFilename> FilenamePtr;
+ typedef boost::shared_ptr<ExportFormatSpecification const> FormatPtr;
+
+ typedef boost::shared_ptr<ExportFileWriter> FileWriterPtr;
+ typedef std::list<FileWriterPtr> FileWriterList;
+
+ public:
+
+ ExportProcessor (Session & session);
+ ~ExportProcessor ();
+ ExportProcessor * copy() { return new ExportProcessor (session); }
+
+ /// Do preparations for exporting
+ /** Should be called before process
+ * @return 0 on success
+ */
+ int prepare (FormatPtr format, FilenamePtr fname, uint32_t chans, bool split = false, nframes_t start = 0);
+
+ /// Process data
+ /** @param frames frames to process @return frames written **/
+ nframes_t process (float * data, nframes_t frames);
+
+ /** should be called after all data is given to process **/
+ void prepare_post_processors ();
+
+ void write_files ();
+
+ static sigc::signal<void, Glib::ustring> WritingFile;
+
+ private:
+
+ void reset ();
+ FloatSinkPtr prepare_sndfile_writer (FormatPtr format, uint32_t channels, ustring const & filename);
+
+ Session & session;
+ ExportStatus & status;
+
+ /* these are initalized in prepare() */
+
+ FilenamePtr filename;
+ NormalizerPtr normalizer;
+ SRConverterPtr src;
+ PReaderPtr peak_reader;
+ TempFilePtr temp_file;
+ FloatSinkVect file_sinks;
+ FileWriterList writer_list;
+
+ /* general info */
+
+ uint32_t channels;
+ nframes_t blocksize;
+ nframes_t frame_rate;
+
+ /* Processing */
+
+ bool tag;
+ bool broadcast_info;
+ bool split_files;
+ bool normalize;
+ bool trim_beginning;
+ bool trim_end;
+ nframes_t silence_beginning;
+ nframes_t silence_end;
+
+ /* Progress info */
+
+ nframes_t temp_file_position;
+ nframes_t temp_file_length;
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_processor_h__ */
diff --git a/libs/ardour/ardour/export_profile_manager.h b/libs/ardour/ardour/export_profile_manager.h
new file mode 100644
index 0000000000..1a855d6868
--- /dev/null
+++ b/libs/ardour/ardour/export_profile_manager.h
@@ -0,0 +1,316 @@
+/*
+ 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_profile_manager_h__
+#define __ardour_export_profile_manager_h__
+
+#include <list>
+#include <vector>
+#include <map>
+#include <set>
+
+#include <boost/shared_ptr.hpp>
+#include <boost/weak_ptr.hpp>
+#include <sigc++/signal.h>
+#include <glibmm/ustring.h>
+
+#include <pbd/file_utils.h>
+#include <pbd/xml++.h>
+
+#include <ardour/filesystem_paths.h>
+#include <ardour/location.h>
+#include <ardour/types.h>
+
+using std::string;
+using std::list;
+using std::set;
+
+namespace ARDOUR
+{
+
+class ExportHandler;
+class ExportTimespan;
+class ExportChannelConfiguration;
+class ExportFormatSpecification;
+class ExportFilename;
+class Location;
+class Session;
+
+/// Manages (de)serialization of export profiles and related classes
+class ExportProfileManager
+{
+ public:
+ class Preset {
+ public:
+ Preset (string filename, Session & s);
+ ~Preset ();
+
+ uint32_t id () const { return _id; }
+ string name () const { return _name; }
+
+ void set_name (string name);
+ void set_id (uint32_t id);
+
+ // Note: The set_..._state functions take ownership of the XMLNode
+ void set_global_state (XMLNode & state);
+ void set_local_state (XMLNode & state);
+
+ XMLNode const * get_global_state () const { return global.root(); }
+ XMLNode const * get_local_state () const { return local; }
+
+ void save () const;
+ void remove_local () const;
+
+ private:
+
+ XMLNode * get_instant_xml () const;
+ void save_instant_xml () const;
+ void remove_instant_xml () const;
+
+ uint32_t _id;
+ string _name;
+
+ Session & session;
+ XMLTree global;
+ XMLNode * local;
+
+ };
+
+ typedef boost::shared_ptr<Preset> PresetPtr;
+ typedef std::list<PresetPtr> PresetList;
+
+ public:
+
+ ExportProfileManager (Session & s);
+ ~ExportProfileManager ();
+
+ void load_profile ();
+ void prepare_for_export ();
+
+ PresetList const & get_presets () { return preset_list; }
+ void load_preset (PresetPtr preset);
+ PresetPtr save_preset (string const & name);
+ void remove_preset ();
+
+ private:
+ typedef boost::shared_ptr<ExportHandler> HandlerPtr;
+
+ typedef std::pair<uint32_t, PBD::sys::path> FilePair;
+ typedef std::map<uint32_t, PBD::sys::path> FileMap;
+
+ HandlerPtr handler;
+ Session & session;
+
+ void load_presets ();
+ uint32_t load_preset_from_disk (PBD::sys::path const & path); // Returns preset id
+
+ void set_state (XMLNode const & root);
+ void set_global_state (XMLNode const & root);
+ void set_local_state (XMLNode const & root);
+
+ void serialize_profile (XMLNode & root);
+ void serialize_global_profile (XMLNode & root);
+ void serialize_local_profile (XMLNode & root);
+
+ PresetList preset_list;
+ PresetPtr current_preset;
+ uint32_t preset_id_counter;
+ FileMap preset_file_map;
+
+ std::vector<PBD::sys::path> find_file (std::string const & pattern);
+
+ PBD::sys::path export_config_dir;
+ PBD::SearchPath search_path;
+
+/* Timespans */
+ public:
+
+ typedef boost::shared_ptr<ExportTimespan> TimespanPtr;
+ typedef std::list<TimespanPtr> TimespanList;
+ typedef boost::shared_ptr<TimespanList> TimespanListPtr;
+ typedef std::list<Location *> LocationList;
+
+ enum TimeFormat {
+ SMPTE,
+ BBT,
+ MinSec,
+ Frames,
+ Off
+ };
+
+ struct TimespanState {
+ TimespanListPtr timespans;
+ TimeFormat time_format;
+
+ boost::shared_ptr<Location> session_range;
+ boost::shared_ptr<Location> selection_range;
+ boost::shared_ptr<LocationList> ranges;
+
+ TimespanState (boost::shared_ptr<Location> session_range,
+ boost::shared_ptr<Location> selection_range,
+ boost::shared_ptr<LocationList> ranges) :
+ timespans (new TimespanList ()),
+ time_format (SMPTE),
+
+ session_range (session_range),
+ selection_range (selection_range),
+ ranges (ranges)
+ {}
+ };
+
+ typedef boost::shared_ptr<TimespanState> TimespanStatePtr;
+ typedef std::list<TimespanStatePtr> TimespanStateList;
+
+ void set_selection_range (nframes_t start = 0, nframes_t end = 0);
+ TimespanStateList const & get_timespans () { return timespans; }
+
+ private:
+
+ TimespanStateList timespans;
+
+ void init_timespans (XMLNodeList nodes);
+
+ TimespanStatePtr deserialize_timespan (XMLNode & root);
+ XMLNode & serialize_timespan (TimespanStatePtr state);
+
+ /* Locations */
+
+ void update_ranges ();
+
+ boost::shared_ptr<Location> session_range;
+ boost::shared_ptr<Location> selection_range;
+ boost::shared_ptr<LocationList> ranges;
+
+/* Channel Configs */
+ public:
+
+ typedef boost::shared_ptr<ExportChannelConfiguration> ChannelConfigPtr;
+
+ struct ChannelConfigState {
+ ChannelConfigPtr config;
+
+ ChannelConfigState (ChannelConfigPtr ptr) : config (ptr) {}
+ };
+ typedef boost::shared_ptr<ChannelConfigState> ChannelConfigStatePtr;
+ typedef std::list<ChannelConfigStatePtr> ChannelConfigStateList;
+
+ ChannelConfigStateList const & get_channel_configs () { return channel_configs; }
+
+ private:
+
+ ChannelConfigStateList channel_configs;
+
+ void init_channel_configs (XMLNodeList nodes);
+
+ ChannelConfigStatePtr deserialize_channel_config (XMLNode & root);
+ XMLNode & serialize_channel_config (ChannelConfigStatePtr state);
+
+/* Formats */
+ public:
+
+ typedef boost::shared_ptr<ExportFormatSpecification> FormatPtr;
+ typedef std::list<FormatPtr> FormatList;
+
+ struct FormatState {
+ boost::shared_ptr<FormatList const> list;
+ FormatPtr format;
+
+ FormatState (boost::shared_ptr<FormatList const> list, FormatPtr format) :
+ list (list), format (format) {}
+ };
+ typedef boost::shared_ptr<FormatState> FormatStatePtr;
+ typedef std::list<FormatStatePtr> FormatStateList;
+
+ FormatStateList const & get_formats () { return formats; }
+ FormatStatePtr duplicate_format_state (FormatStatePtr state);
+ void remove_format_state (FormatStatePtr state);
+
+ PBD::sys::path save_format_to_disk (FormatPtr format);
+ void remove_format_profile (FormatPtr format);
+ FormatPtr get_new_format (FormatPtr original);
+
+ sigc::signal<void> FormatListChanged;
+
+ private:
+
+ FormatStateList formats;
+
+ void init_formats (XMLNodeList nodes);
+ FormatStatePtr deserialize_format (XMLNode & root);
+ XMLNode & serialize_format (FormatStatePtr state);
+
+ void load_formats ();
+
+ FormatPtr load_format (XMLNode & node);
+ void load_format_from_disk (PBD::sys::path const & path);
+
+ boost::shared_ptr<FormatList> format_list;
+ FileMap format_file_map;
+
+/* Filenames */
+ public:
+
+ typedef boost::shared_ptr<ExportFilename> FilenamePtr;
+
+ struct FilenameState {
+ FilenamePtr filename;
+
+ FilenameState (FilenamePtr ptr) : filename (ptr) {}
+ };
+ typedef boost::shared_ptr<FilenameState> FilenameStatePtr;
+ typedef std::list<FilenameStatePtr> FilenameStateList;
+
+ FilenameStateList const & get_filenames () { return filenames; }
+ FilenameStatePtr duplicate_filename_state (FilenameStatePtr state);
+ void remove_filename_state (FilenameStatePtr state);
+
+ private:
+
+ FilenameStateList filenames;
+
+ void init_filenames (XMLNodeList nodes);
+
+ FilenameStatePtr deserialize_filename (XMLNode & root);
+ XMLNode & serialize_filename (FilenameStatePtr state);
+
+ FilenamePtr load_filename (XMLNode & node);
+
+/* Warnings */
+ public:
+ struct Warnings {
+ std::list<Glib::ustring> errors;
+ std::list<Glib::ustring> warnings;
+ std::list<Glib::ustring> conflicting_filenames;
+ };
+
+ boost::shared_ptr<Warnings> get_warnings ();
+
+ private:
+ void check_config (boost::shared_ptr<Warnings> warnings,
+ TimespanStatePtr timespan_state,
+ ChannelConfigStatePtr channel_config_state,
+ FormatStatePtr format_state,
+ FilenameStatePtr filename_state);
+};
+
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_profile_manager_h__ */
diff --git a/libs/ardour/ardour/export_status.h b/libs/ardour/ardour/export_status.h
new file mode 100644
index 0000000000..be4bd25b9d
--- /dev/null
+++ b/libs/ardour/ardour/export_status.h
@@ -0,0 +1,72 @@
+/*
+ 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_status_h__
+#define __ardour_export_status_h__
+
+#include <list>
+
+#include <sigc++/signal.h>
+
+namespace ARDOUR
+{
+
+enum ExportStage {
+ export_None,
+ export_ReadTimespan,
+ export_PostProcess,
+ export_Write
+};
+
+struct ExportStatus {
+
+ ExportStatus ();
+ void init ();
+
+ /* Status info */
+
+ volatile bool stop;
+ volatile bool running;
+
+ sigc::signal<void> Aborting;
+ void abort () { _aborted = true; Aborting(); }
+ bool aborted () const { return _aborted; }
+
+ /* Progress info */
+
+ volatile ExportStage stage;
+ volatile float progress;
+
+ volatile uint32_t total_timespans;
+ volatile uint32_t timespan;
+
+ volatile uint32_t total_channel_configs;
+ volatile uint32_t channel_config;
+
+ volatile uint32_t total_formats;
+ volatile uint32_t format;
+
+ private:
+ volatile bool _aborted;
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_status_h__ */
diff --git a/libs/ardour/ardour/export_timespan.h b/libs/ardour/ardour/export_timespan.h
new file mode 100644
index 0000000000..7995da36d2
--- /dev/null
+++ b/libs/ardour/ardour/export_timespan.h
@@ -0,0 +1,97 @@
+/*
+ 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_timespan_h__
+#define __ardour_export_timespan_h__
+
+#include <map>
+#include <list>
+
+#include <glibmm/ustring.h>
+
+#include <ardour/export_status.h>
+#include <ardour/ardour.h>
+
+using Glib::ustring;
+
+namespace ARDOUR
+{
+
+class ExportChannel;
+class ExportTempFile;
+
+class ExportTimespan : public sigc::trackable
+{
+ private:
+ typedef boost::shared_ptr<ExportTempFile> TempFilePtr;
+ typedef std::pair<ExportChannel const, TempFilePtr> ChannelFilePair;
+ typedef std::map<ExportChannel const, TempFilePtr> TempFileMap;
+
+ private:
+ friend class ExportElementFactory;
+ ExportTimespan (ExportStatus & status, nframes_t frame_rate);
+
+ public:
+ ~ExportTimespan ();
+
+ ustring name () const { return _name; }
+ void set_name (ustring name) { _name = name; }
+
+ ustring range_id () const { return _range_id; }
+ void set_range_id (ustring range_id) { _range_id = range_id; }
+
+ /// Registers a channel to be read when export starts rolling
+ void register_channel (ExportChannel const & channel);
+
+ /// "Rewinds" the tempfiles to start reading the beginnings again
+ void rewind ();
+
+ /// Reads data from the tempfile belonging to channel into data
+ nframes_t get_data (float * data, nframes_t frames, ExportChannel const & channel);
+
+ /// Reads data from each channel and writes to tempfile
+ int process (nframes_t frames);
+
+ sigc::connection process_connection;
+
+ void set_range (nframes_t start, nframes_t end);
+ nframes_t get_length () const { return end_frame - start_frame; }
+ nframes_t get_start () const { return start_frame; }
+ nframes_t get_end () const { return end_frame; }
+
+ private:
+
+ ExportStatus & status;
+
+ nframes_t start_frame;
+ nframes_t end_frame;
+ nframes_t position;
+ nframes_t frame_rate;
+
+ TempFileMap filemap;
+
+ ustring _name;
+ ustring _range_id;
+
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_timespan_h__ */
diff --git a/libs/ardour/ardour/export_utilities.h b/libs/ardour/ardour/export_utilities.h
new file mode 100644
index 0000000000..e5660e3b75
--- /dev/null
+++ b/libs/ardour/ardour/export_utilities.h
@@ -0,0 +1,146 @@
+/*
+ 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_utilities_h__
+#define __ardour_export_utilities_h__
+
+#include <samplerate.h>
+
+#include <ardour/graph.h>
+#include <ardour/types.h>
+#include <ardour/ardour.h>
+#include <ardour/export_format_base.h>
+#include <ardour/runtime_functions.h>
+
+namespace ARDOUR
+{
+
+/* Processors */
+
+/* Sample rate converter */
+
+class SampleRateConverter : public GraphSinkVertex<float, float>
+{
+ public:
+ SampleRateConverter (uint32_t channels, nframes_t in_rate, nframes_t out_rate, int quality);
+ ~SampleRateConverter ();
+
+ protected:
+ nframes_t process (float * data, nframes_t frames);
+
+ private:
+ bool active;
+ uint32_t channels;
+
+ nframes_t leftover_frames;
+ nframes_t max_leftover_frames;
+ nframes_t frames_in;
+ nframes_t frames_out;
+
+ float * data_in;
+ float * leftover_data;
+
+ float * data_out;
+ nframes_t data_out_size;
+
+ SRC_DATA src_data;
+ SRC_STATE* src_state;
+};
+
+/* Sample format converter */
+
+template <typename TOut>
+class SampleFormatConverter : public GraphSinkVertex<float, TOut>
+{
+ public:
+ SampleFormatConverter (uint32_t channels, ExportFormatBase::DitherType type = ExportFormatBase::D_None, int data_width_ = 0);
+ ~SampleFormatConverter ();
+
+ void set_clip_floats (bool yn) { clip_floats = yn; }
+
+ protected:
+ nframes_t process (float * data, nframes_t frames);
+
+ private:
+ uint32_t channels;
+ int data_width;
+ GDither dither;
+ nframes_t data_out_size;
+ TOut * data_out;
+
+ bool clip_floats;
+
+};
+
+/* Peak reader */
+
+class PeakReader : public GraphSinkVertex<float, float>
+{
+ public:
+ PeakReader (uint32_t channels) : channels (channels), peak (0) {}
+ ~PeakReader () {}
+
+ float get_peak () { return peak; }
+
+ protected:
+ nframes_t process (float * data, nframes_t frames)
+ {
+ peak = compute_peak (data, channels * frames, peak);
+ return piped_to->write (data, frames);
+ }
+
+ private:
+ uint32_t channels;
+ float peak;
+};
+
+/* Normalizer */
+
+class Normalizer : public GraphSinkVertex<float, float>
+{
+ public:
+ Normalizer (uint32_t channels, float target_dB);
+ ~Normalizer ();
+
+ void set_peak (float peak);
+
+ protected:
+ nframes_t process (float * data, nframes_t frames);
+
+ private:
+ uint32_t channels;
+
+ bool enabled;
+ gain_t target;
+ gain_t gain;
+};
+
+/* Other */
+
+class NullSink : public GraphSink<float>
+{
+ public:
+ nframes_t write (float * data, nframes_t frames) { return frames; }
+};
+
+
+} // namespace ARDOUR
+
+#endif /* __ardour_export_utilities_h__ */
diff --git a/libs/ardour/ardour/graph.h b/libs/ardour/ardour/graph.h
new file mode 100644
index 0000000000..80b5a9fe11
--- /dev/null
+++ b/libs/ardour/ardour/graph.h
@@ -0,0 +1,101 @@
+/*
+ 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_graph_h__
+#define __ardour_graph_h__
+
+#include <boost/shared_ptr.hpp>
+
+#include <ardour/types.h>
+
+namespace ARDOUR
+{
+
+/// Takes data in
+template <typename T>
+class GraphSink {
+ public:
+ GraphSink () : end_of_input (false) {}
+ virtual ~GraphSink () { end_of_input = false; }
+
+ // writes data and return number of frames written
+ virtual nframes_t write (T * data, nframes_t frames) = 0;
+
+ // Notifies end of input. All left over data must be written at this stage
+ virtual void set_end_of_input (bool state = true)
+ {
+ end_of_input = state;
+ }
+
+ protected:
+ bool end_of_input;
+};
+
+/// is a source for data
+template <typename T>
+class GraphSource {
+ public:
+ GraphSource () {}
+ virtual ~GraphSource () {}
+
+ virtual nframes_t read (T * data, nframes_t frames) = 0;
+};
+
+/// Takes data in, processes it and passes it on to another sink
+template <typename TIn, typename TOut>
+class GraphSinkVertex : public GraphSink<TIn> {
+ public:
+ GraphSinkVertex () {}
+ virtual ~GraphSinkVertex () {}
+
+ void pipe_to (boost::shared_ptr<GraphSink<TOut> > dest) {
+ piped_to = dest;
+ }
+
+ nframes_t write (TIn * data, nframes_t frames)
+ {
+ if (!piped_to) {
+ return -1;
+ }
+ return process (data, frames);
+ }
+
+ virtual void set_end_of_input (bool state = true)
+ {
+ if (!piped_to) {
+ return;
+ }
+ piped_to->set_end_of_input (state);
+ GraphSink<TIn>::end_of_input = state;
+ }
+
+ protected:
+ boost::shared_ptr<GraphSink<TOut> > piped_to;
+
+ /* process must process data,
+ use piped_to->write to write the data
+ and return number of frames written */
+ virtual nframes_t process (TIn * data, nframes_t frames) = 0;
+};
+
+} // namespace ARDOUR
+
+#endif /* __ardour_graph_h__ */
+
diff --git a/libs/ardour/ardour/session_metadata.h b/libs/ardour/ardour/session_metadata.h
new file mode 100644
index 0000000000..2163a3dfef
--- /dev/null
+++ b/libs/ardour/ardour/session_metadata.h
@@ -0,0 +1,132 @@
+/*
+ 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_session_metadata_h__
+#define __ardour_session_metadata_h__
+
+#include <string>
+#include <glibmm/ustring.h>
+
+#include <map>
+#include <utility>
+
+#include <pbd/statefuldestructible.h>
+#include <pbd/xml++.h>
+
+namespace ARDOUR {
+
+using std::string;
+using Glib::ustring;
+
+/** Represents metadata associated to a Session
+ * Metadata can be accessed and edited via this class.
+ * Exported files can also be tagged with this data.
+ */
+class SessionMetadata : public PBD::StatefulDestructible
+{
+ public:
+ SessionMetadata ();
+ ~SessionMetadata ();
+
+ /*** Accessing ***/
+ ustring comment () const;
+ ustring copyright () const;
+ ustring isrc () const;
+ uint32_t year () const;
+
+ ustring grouping () const;
+ ustring title () const;
+ ustring subtitle () const;
+
+ ustring artist () const;
+ ustring album_artist () const;
+ ustring lyricist () const;
+ ustring composer () const;
+ ustring conductor () const;
+ ustring remixer () const;
+ ustring arranger () const;
+ ustring engineer () const;
+ ustring producer () const;
+ ustring dj_mixer () const;
+ ustring mixer () const;
+
+ ustring album () const;
+ ustring compilation () const;
+ ustring disc_subtitle () const;
+ uint32_t disc_number () const;
+ uint32_t total_discs () const;
+ uint32_t track_number () const;
+ uint32_t total_tracks () const;
+
+ ustring genre () const;
+
+ /*** Editing ***/
+ void set_comment (const ustring &);
+ void set_copyright (const ustring &);
+ void set_isrc (const ustring &);
+ void set_year (uint32_t);
+
+ void set_grouping (const ustring &);
+ void set_title (const ustring &);
+ void set_subtitle (const ustring &);
+
+ void set_artist (const ustring &);
+ void set_album_artist (const ustring &);
+ void set_lyricist (const ustring &);
+ void set_composer (const ustring &);
+ void set_conductor (const ustring &);
+ void set_remixer (const ustring &);
+ void set_arranger (const ustring &);
+ void set_engineer (const ustring &);
+ void set_producer (const ustring &);
+ void set_dj_mixer (const ustring &);
+ void set_mixer (const ustring &);
+
+ void set_album (const ustring &);
+ void set_compilation (const ustring &);
+ void set_disc_subtitle (const ustring &);
+ void set_disc_number (uint32_t);
+ void set_total_discs (uint32_t);
+ void set_track_number (uint32_t);
+ void set_total_tracks (uint32_t);
+
+ void set_genre (const ustring &);
+
+ /*** Serialization ***/
+ XMLNode & get_state ();
+ int set_state (const XMLNode &);
+
+ private:
+
+ typedef std::pair<ustring, ustring> Property;
+ typedef std::map<ustring, ustring> PropertyMap;
+ PropertyMap map;
+
+ XMLNode * get_xml (const ustring & name);
+
+ ustring get_value (const ustring & name) const;
+ uint32_t get_uint_value (const ustring & name) const;
+
+ void set_value (const ustring & name, const ustring & value);
+ void set_value (const ustring & name, uint32_t value);
+};
+
+} // namespace ARDOUR
+
+#endif // __ardour_session_metadata_h__