provide link-editor-and-mixer-selection option. gui implementation is slightly hacky...
[ardour.git] / libs / ardour / ardour / export_graph_builder.h
index 2f57aaf5834d6130fdcdb6e6c2199667087429d1..b4ef0a1d94a6f95d5bb16169485fcfd030b9ba90 100644 (file)
@@ -26,8 +26,9 @@
 #include "ardour/export_channel.h"
 #include "ardour/export_format_base.h"
 
-#include "audiographer/identity_vertex.h"
+#include "audiographer/utils/identity_vertex.h"
 
+#include <boost/ptr_container/ptr_list.hpp>
 #include <glibmm/threadpool.h>
 
 namespace AudioGrapher {
@@ -50,178 +51,183 @@ class ExportGraphBuilder
 {
   private:
        typedef ExportHandler::FileSpec FileSpec;
-       typedef ExportElementFactory::FilenamePtr FilenamePtr;
 
        typedef boost::shared_ptr<AudioGrapher::Sink<Sample> > FloatSinkPtr;
        typedef boost::shared_ptr<AudioGrapher::IdentityVertex<Sample> > IdentityVertexPtr;
        typedef std::map<ExportChannelPtr,  IdentityVertexPtr> ChannelMap;
 
   public:
-       
+
        ExportGraphBuilder (Session const & session);
        ~ExportGraphBuilder ();
-       
-       int process (nframes_t frames, bool last_cycle);
+
+       int process (framecnt_t frames, bool last_cycle);
        bool process_normalize (); // returns true when finished
-       
+       bool will_normalize() { return !normalizers.empty(); }
+
        void reset ();
+       void set_current_timespan (boost::shared_ptr<ExportTimespan> span);
        void add_config (FileSpec const & config);
-       
+
   private:
-       
-       class Encoder : public sigc::trackable {
+
+       void add_split_config (FileSpec const & config);
+
+       class Encoder {
          public:
                template <typename T> boost::shared_ptr<AudioGrapher::Sink<T> > init (FileSpec const & new_config);
                void add_child (FileSpec const & new_config);
                bool operator== (FileSpec const & other_config) const;
-       
+
                static int get_real_format (FileSpec const & config);
-       
+
          private:
                typedef boost::shared_ptr<AudioGrapher::SndfileWriter<Sample> > FloatWriterPtr;
                typedef boost::shared_ptr<AudioGrapher::SndfileWriter<int> >    IntWriterPtr;
                typedef boost::shared_ptr<AudioGrapher::SndfileWriter<short> >  ShortWriterPtr;
-                 
+
                template<typename T> void init_writer (boost::shared_ptr<AudioGrapher::SndfileWriter<T> > & writer);
                void copy_files (std::string orig_path);
-               
+
                FileSpec               config;
-               std::list<FilenamePtr> filenames;
-               
+               std::list<ExportFilenamePtr> filenames;
+               PBD::ScopedConnection  copy_files_connection;
+
                // Only one of these should be available at a time
                FloatWriterPtr float_writer;
                IntWriterPtr   int_writer;
                ShortWriterPtr short_writer;
        };
-       
+
        // sample format converter
        class SFC {
          public:
                // This constructor so that this can be constructed like a Normalizer
-               SFC (ExportGraphBuilder &) {}
-               FloatSinkPtr init (FileSpec const & new_config, nframes_t max_frames);
+               SFC (ExportGraphBuilder &, FileSpec const & new_config, framecnt_t max_frames);
+               FloatSinkPtr sink ();
                void add_child (FileSpec const & new_config);
                bool operator== (FileSpec const & other_config) const;
-               
+
          private:
                typedef boost::shared_ptr<AudioGrapher::SampleFormatConverter<Sample> > FloatConverterPtr;
                typedef boost::shared_ptr<AudioGrapher::SampleFormatConverter<int> >   IntConverterPtr;
                typedef boost::shared_ptr<AudioGrapher::SampleFormatConverter<short> > ShortConverterPtr;
-               
+
                FileSpec           config;
-               std::list<Encoder> children;
+               boost::ptr_list<Encoder> children;
                int                data_width;
-               
+
                // Only one of these should be available at a time
                FloatConverterPtr float_converter;
-               IntConverterPtr   int_converter;
+               IntConverterPtr int_converter;
                ShortConverterPtr short_converter;
        };
-       
-       class Normalizer : public sigc::trackable {
+
+       class Normalizer {
          public:
-               Normalizer (ExportGraphBuilder & parent) : parent (parent) {}
-               FloatSinkPtr init (FileSpec const & new_config, nframes_t max_frames);
+               Normalizer (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
+               FloatSinkPtr sink ();
                void add_child (FileSpec const & new_config);
                bool operator== (FileSpec const & other_config) const;
-               
+
                /// Returns true when finished
                bool process ();
-               
+
          private:
                typedef boost::shared_ptr<AudioGrapher::PeakReader> PeakReaderPtr;
                typedef boost::shared_ptr<AudioGrapher::Normalizer> NormalizerPtr;
                typedef boost::shared_ptr<AudioGrapher::TmpFile<Sample> > TmpFilePtr;
                typedef boost::shared_ptr<AudioGrapher::Threader<Sample> > ThreaderPtr;
                typedef boost::shared_ptr<AudioGrapher::AllocatingProcessContext<Sample> > BufferPtr;
-               
+
                void start_post_processing();
-               
+
                ExportGraphBuilder & parent;
-               
+
                FileSpec        config;
-               nframes_t       max_frames_out;
-               
+               framecnt_t      max_frames_out;
+
                BufferPtr       buffer;
                PeakReaderPtr   peak_reader;
                TmpFilePtr      tmp_file;
                NormalizerPtr   normalizer;
                ThreaderPtr     threader;
-               std::list<SFC>  children;
+               boost::ptr_list<SFC> children;
+
+               PBD::ScopedConnection post_processing_connection;
        };
-       
+
        // sample rate converter
        class SRC {
          public:
-               SRC (ExportGraphBuilder & parent) : parent (parent) {}
-               FloatSinkPtr init (FileSpec const & new_config, nframes_t max_frames);
+               SRC (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
+               FloatSinkPtr sink ();
                void add_child (FileSpec const & new_config);
                bool operator== (FileSpec const & other_config) const;
-               
+
          private:
                typedef boost::shared_ptr<AudioGrapher::SampleRateConverter> SRConverterPtr;
-               
+
                template<typename T>
-               void add_child_to_list (FileSpec const & new_config, std::list<T> & list);
-  
+               void add_child_to_list (FileSpec const & new_config, boost::ptr_list<T> & list);
+
                ExportGraphBuilder &  parent;
                FileSpec              config;
-               std::list<SFC>        children;
-               std::list<Normalizer> normalized_children;
+               boost::ptr_list<SFC>  children;
+               boost::ptr_list<Normalizer> normalized_children;
                SRConverterPtr        converter;
-               nframes_t             max_frames_out;
+               framecnt_t            max_frames_out;
        };
-       
+
        // Silence trimmer + adder
        class SilenceHandler {
          public:
-               SilenceHandler (ExportGraphBuilder & parent) : parent (parent) {}
-               FloatSinkPtr init (FileSpec const & new_config, nframes_t max_frames);
+               SilenceHandler (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
+               FloatSinkPtr sink ();
                void add_child (FileSpec const & new_config);
                bool operator== (FileSpec const & other_config) const;
-               
+
          private:
                typedef boost::shared_ptr<AudioGrapher::SilenceTrimmer<Sample> > SilenceTrimmerPtr;
-               
+
                ExportGraphBuilder & parent;
                FileSpec             config;
-               std::list<SRC>       children;
+               boost::ptr_list<SRC> children;
                SilenceTrimmerPtr    silence_trimmer;
-               nframes_t            max_frames_in;
+               framecnt_t           max_frames_in;
        };
-       
+
        // channel configuration
        class ChannelConfig {
          public:
-               ChannelConfig (ExportGraphBuilder & parent) : parent (parent) {}
-               void init (FileSpec const & new_config, ChannelMap & channel_map);
+               ChannelConfig (ExportGraphBuilder & parent, FileSpec const & new_config, ChannelMap & channel_map);
                void add_child (FileSpec const & new_config);
                bool operator== (FileSpec const & other_config) const;
-               
+
          private:
                typedef boost::shared_ptr<AudioGrapher::Interleaver<Sample> > InterleaverPtr;
-               
+
                ExportGraphBuilder &      parent;
                FileSpec                  config;
-               std::list<SilenceHandler> children;
+               boost::ptr_list<SilenceHandler> children;
                InterleaverPtr            interleaver;
-               nframes_t                 max_frames;
+               framecnt_t                max_frames;
        };
 
        Session const & session;
-       
+       boost::shared_ptr<ExportTimespan> timespan;
+
        // Roots for export processor trees
-       typedef std::list<ChannelConfig> ChannelConfigList;
+       typedef boost::ptr_list<ChannelConfig> ChannelConfigList;
        ChannelConfigList channel_configs;
-       
+
        // The sources of all data, each channel is read only once
        ChannelMap channels;
-       
-       Sample *  process_buffer;
-       nframes_t process_buffer_frames;
-       
+
+       framecnt_t process_buffer_frames;
+
        std::list<Normalizer *> normalizers;
-       
+
        Glib::ThreadPool thread_pool;
 };