X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fexport_graph_builder.h;h=c9671d729bbb6388a9821a6a01ae640a9e2b7a81;hb=11da4a83e499db74e75d5b59973b0e52b0c1277a;hp=f98ffeb8eb67e7dfa9a4c69e70542e4745c7ea61;hpb=650c6d5824222a8879df5c5ba9645c264ed3b84f;p=ardour.git diff --git a/libs/ardour/ardour/export_graph_builder.h b/libs/ardour/ardour/export_graph_builder.h index f98ffeb8eb..c9671d729b 100644 --- a/libs/ardour/ardour/export_graph_builder.h +++ b/libs/ardour/ardour/export_graph_builder.h @@ -21,19 +21,21 @@ #ifndef __ardour_export_graph_builder_h__ #define __ardour_export_graph_builder_h__ -#include "ardour/ardour.h" #include "ardour/export_handler.h" -#include "ardour/export_channel.h" -#include "ardour/export_format_base.h" +#include "ardour/export_analysis.h" -#include "audiographer/identity_vertex.h" +#include "audiographer/utils/identity_vertex.h" +#include #include namespace AudioGrapher { class SampleRateConverter; class PeakReader; + class LoudnessReader; class Normalizer; + class Analyser; + template class Chunker; template class SampleFormatConverter; template class Interleaver; template class SndfileWriter; @@ -46,182 +48,227 @@ namespace AudioGrapher { namespace ARDOUR { -class ExportGraphBuilder +class ExportTimespan; +class Session; + +class LIBARDOUR_API ExportGraphBuilder { private: typedef ExportHandler::FileSpec FileSpec; - typedef ExportElementFactory::FilenamePtr FilenamePtr; typedef boost::shared_ptr > FloatSinkPtr; typedef boost::shared_ptr > IdentityVertexPtr; + typedef boost::shared_ptr AnalysisPtr; typedef std::map ChannelMap; + typedef std::map AnalysisMap; public: - + ExportGraphBuilder (Session const & session); ~ExportGraphBuilder (); - - int process (nframes_t frames, bool last_cycle); - bool process_normalize (); // returns true when finished - + + int process (framecnt_t frames, bool last_cycle); + bool post_process (); // returns true when finished + bool need_postprocessing () const { return !intermediates.empty(); } + bool realtime() const { return _realtime; } + unsigned get_postprocessing_cycle_count() const; + void reset (); - void add_config (FileSpec const & config); - + void cleanup (bool remove_out_files = false); + void set_current_timespan (boost::shared_ptr span); + void add_config (FileSpec const & config, bool rt); + void get_analysis_results (AnalysisResults& results); + private: - - class Encoder : public sigc::trackable { - public: + + 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 { + public: template boost::shared_ptr > init (FileSpec const & new_config); void add_child (FileSpec const & new_config); + void remove_children (); + void destroy_writer (bool delete_out_file); bool operator== (FileSpec const & other_config) const; - + static int get_real_format (FileSpec const & config); - - private: + + private: typedef boost::shared_ptr > FloatWriterPtr; typedef boost::shared_ptr > IntWriterPtr; typedef boost::shared_ptr > ShortWriterPtr; - + template void init_writer (boost::shared_ptr > & writer); void copy_files (std::string orig_path); - + FileSpec config; - std::list filenames; - + std::list filenames; + PBD::ScopedConnection copy_files_connection; + + std::string writer_filename; + // 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: + public: // This constructor so that this can be constructed like a Normalizer - SFC (ExportGraphBuilder &) : data_width(0) {} - 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); + void remove_children (bool remove_out_files); bool operator== (FileSpec const & other_config) const; - - private: + void set_peak (float); + + private: + typedef boost::shared_ptr > ChunkerPtr; typedef boost::shared_ptr > FloatConverterPtr; typedef boost::shared_ptr > IntConverterPtr; typedef boost::shared_ptr > ShortConverterPtr; - + FileSpec config; - std::list children; + boost::ptr_list 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; + IntConverterPtr int_converter; ShortConverterPtr short_converter; }; - - class Normalizer : public sigc::trackable { - public: - Normalizer (ExportGraphBuilder & parent) : parent (parent) {} - FloatSinkPtr init (FileSpec const & new_config, nframes_t max_frames); + + class Intermediate { + public: + Intermediate (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames); + FloatSinkPtr sink (); void add_child (FileSpec const & new_config); + void remove_children (bool remove_out_files); bool operator== (FileSpec const & other_config) const; - + + unsigned get_postprocessing_cycle_count() const; + /// Returns true when finished bool process (); - - private: + + private: typedef boost::shared_ptr PeakReaderPtr; + typedef boost::shared_ptr LoudnessReaderPtr; typedef boost::shared_ptr NormalizerPtr; typedef boost::shared_ptr > TmpFilePtr; typedef boost::shared_ptr > ThreaderPtr; typedef boost::shared_ptr > BufferPtr; - - void start_post_processing(); - + + void prepare_post_processing (); + void start_post_processing (); + ExportGraphBuilder & parent; - + FileSpec config; - nframes_t max_frames_out; - + framecnt_t max_frames_out; + bool use_loudness; + bool use_peak; BufferPtr buffer; PeakReaderPtr peak_reader; TmpFilePtr tmp_file; NormalizerPtr normalizer; ThreaderPtr threader; - std::list children; + LoudnessReaderPtr loudness_reader; + boost::ptr_list children; + + PBD::ScopedConnectionList post_processing_connection; }; - + // sample rate converter class SRC { - public: - SRC (ExportGraphBuilder & parent) : parent (parent) {} - FloatSinkPtr init (FileSpec const & new_config, nframes_t max_frames); + public: + SRC (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames); + FloatSinkPtr sink (); void add_child (FileSpec const & new_config); + void remove_children (bool remove_out_files); + bool operator== (FileSpec const & other_config) const; - - private: + + private: typedef boost::shared_ptr SRConverterPtr; - + template - void add_child_to_list (FileSpec const & new_config, std::list & list); - + void add_child_to_list (FileSpec const & new_config, boost::ptr_list & list); + ExportGraphBuilder & parent; FileSpec config; - std::list children; - std::list normalized_children; + boost::ptr_list children; + boost::ptr_list intermediate_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); + public: + SilenceHandler (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames); + FloatSinkPtr sink (); void add_child (FileSpec const & new_config); + void remove_children (bool remove_out_files); bool operator== (FileSpec const & other_config) const; - - private: + + private: typedef boost::shared_ptr > SilenceTrimmerPtr; - + ExportGraphBuilder & parent; FileSpec config; - std::list children; + boost::ptr_list 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); + public: + ChannelConfig (ExportGraphBuilder & parent, FileSpec const & new_config, ChannelMap & channel_map); void add_child (FileSpec const & new_config); + void remove_children (bool remove_out_files); bool operator== (FileSpec const & other_config) const; - - private: + + private: typedef boost::shared_ptr > InterleaverPtr; - + typedef boost::shared_ptr > ChunkerPtr; + ExportGraphBuilder & parent; FileSpec config; - std::list children; + boost::ptr_list children; InterleaverPtr interleaver; - nframes_t max_frames; + ChunkerPtr chunker; + framecnt_t max_frames_out; }; Session const & session; - + boost::shared_ptr timespan; + // Roots for export processor trees - typedef std::list ChannelConfigList; + typedef boost::ptr_list 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; - - std::list normalizers; - + + framecnt_t process_buffer_frames; + + std::list intermediates; + + AnalysisMap analysis_map; + + bool _realtime; + Glib::ThreadPool thread_pool; };