improve AU Latency PropertyChange Events
[ardour.git] / libs / ardour / ardour / export_graph_builder.h
index 3e9fb58a1556e46090065ca3f6f7229a3711473a..b692b03b3231f2e09b91ee1cabfce48e562f9870 100644 (file)
@@ -22,6 +22,7 @@
 #define __ardour_export_graph_builder_h__
 
 #include "ardour/export_handler.h"
+#include "ardour/export_analysis.h"
 
 #include "audiographer/utils/identity_vertex.h"
 
@@ -31,7 +32,9 @@
 namespace AudioGrapher {
        class SampleRateConverter;
        class PeakReader;
+       class LoudnessReader;
        class Normalizer;
+       class Analyser;
        template <typename T> class Chunker;
        template <typename T> class SampleFormatConverter;
        template <typename T> class Interleaver;
@@ -55,7 +58,9 @@ class LIBARDOUR_API ExportGraphBuilder
 
        typedef boost::shared_ptr<AudioGrapher::Sink<Sample> > FloatSinkPtr;
        typedef boost::shared_ptr<AudioGrapher::IdentityVertex<Sample> > IdentityVertexPtr;
+       typedef boost::shared_ptr<AudioGrapher::Analyser> AnalysisPtr;
        typedef std::map<ExportChannelPtr,  IdentityVertexPtr> ChannelMap;
+       typedef std::map<std::string, AnalysisPtr> AnalysisMap;
 
   public:
 
@@ -64,16 +69,22 @@ class LIBARDOUR_API ExportGraphBuilder
 
        int process (framecnt_t frames, bool last_cycle);
        bool process_normalize (); // returns true when finished
-       bool will_normalize() { return !normalizers.empty(); }
+       bool will_normalize() const { return !normalizers.empty(); }
+       bool realtime() const { return _realtime; }
        unsigned get_normalize_cycle_count() const;
 
        void reset ();
        void cleanup (bool remove_out_files = false);
        void set_current_timespan (boost::shared_ptr<ExportTimespan> span);
-       void add_config (FileSpec const & config);
+       void add_config (FileSpec const & config, bool rt);
+       void get_analysis_results (AnalysisResults& results);
 
   private:
 
+       void add_analyser (const std::string& fn, AnalysisPtr ap) {
+               analysis_map.insert (std::make_pair (fn, ap));
+       }
+
        void add_split_config (FileSpec const & config);
 
        class Encoder {
@@ -115,8 +126,10 @@ class LIBARDOUR_API ExportGraphBuilder
                void add_child (FileSpec const & new_config);
                void remove_children (bool remove_out_files);
                bool operator== (FileSpec const & other_config) const;
+               void set_peak (float);
 
                                                private:
+               typedef boost::shared_ptr<AudioGrapher::Chunker<float> > ChunkerPtr;
                typedef boost::shared_ptr<AudioGrapher::SampleFormatConverter<Sample> > FloatConverterPtr;
                typedef boost::shared_ptr<AudioGrapher::SampleFormatConverter<int> >   IntConverterPtr;
                typedef boost::shared_ptr<AudioGrapher::SampleFormatConverter<short> > ShortConverterPtr;
@@ -125,6 +138,9 @@ class LIBARDOUR_API ExportGraphBuilder
                boost::ptr_list<Encoder> children;
                int                data_width;
 
+               ChunkerPtr      chunker;
+               AnalysisPtr     analyser;
+               bool            _analyse;
                // Only one of these should be available at a time
                FloatConverterPtr float_converter;
                IntConverterPtr int_converter;
@@ -146,26 +162,30 @@ class LIBARDOUR_API ExportGraphBuilder
 
                                                private:
                typedef boost::shared_ptr<AudioGrapher::PeakReader> PeakReaderPtr;
+               typedef boost::shared_ptr<AudioGrapher::LoudnessReader> LoudnessReaderPtr;
                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();
+               void prepare_post_processing ();
+               void start_post_processing ();
 
                ExportGraphBuilder & parent;
 
                FileSpec        config;
                framecnt_t      max_frames_out;
-
+               bool            use_loudness;
+               bool            use_peak;
                BufferPtr       buffer;
                PeakReaderPtr   peak_reader;
                TmpFilePtr      tmp_file;
                NormalizerPtr   normalizer;
                ThreaderPtr     threader;
+               LoudnessReaderPtr    loudness_reader;
                boost::ptr_list<SFC> children;
 
-               PBD::ScopedConnection post_processing_connection;
+               PBD::ScopedConnectionList post_processing_connection;
        };
 
        // sample rate converter
@@ -245,6 +265,10 @@ class LIBARDOUR_API ExportGraphBuilder
 
        std::list<Normalizer *> normalizers;
 
+       AnalysisMap analysis_map;
+
+       bool _realtime;
+
        Glib::ThreadPool thread_pool;
 };