#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/utils/identity_vertex.h"
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;
template <typename T> class SndfileWriter;
namespace ARDOUR
{
-class ExportGraphBuilder
+class ExportTimespan;
+class Session;
+
+class LIBARDOUR_API ExportGraphBuilder
{
private:
typedef ExportHandler::FileSpec FileSpec;
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:
ExportGraphBuilder (Session const & session);
~ExportGraphBuilder ();
- int process (framecnt_t frames, bool last_cycle);
- bool process_normalize (); // returns true when finished
- bool will_normalize() { return !normalizers.empty(); }
+ int process (samplecnt_t samples, 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 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 {
- public:
+ public:
template <typename T> boost::shared_ptr<AudioGrapher::Sink<T> > 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<AudioGrapher::SndfileWriter<Sample> > FloatWriterPtr;
typedef boost::shared_ptr<AudioGrapher::SndfileWriter<int> > IntWriterPtr;
typedef boost::shared_ptr<AudioGrapher::SndfileWriter<short> > ShortWriterPtr;
std::list<ExportFilenamePtr> 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;
// sample format converter
class SFC {
- public:
+ public:
// This constructor so that this can be constructed like a Normalizer
- SFC (ExportGraphBuilder &, FileSpec const & new_config, framecnt_t max_frames);
+ SFC (ExportGraphBuilder &, FileSpec const & new_config, samplecnt_t max_samples);
FloatSinkPtr sink ();
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:
+ 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;
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;
ShortConverterPtr short_converter;
};
- class Normalizer {
- public:
- Normalizer (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
+ class Intermediate {
+ public:
+ Intermediate (ExportGraphBuilder & parent, FileSpec const & new_config, samplecnt_t max_samples);
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<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;
-
+ samplecnt_t max_samples_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
class SRC {
- public:
- SRC (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
+ public:
+ SRC (ExportGraphBuilder & parent, FileSpec const & new_config, samplecnt_t max_samples);
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<AudioGrapher::SampleRateConverter> SRConverterPtr;
template<typename T>
ExportGraphBuilder & parent;
FileSpec config;
boost::ptr_list<SFC> children;
- boost::ptr_list<Normalizer> normalized_children;
+ boost::ptr_list<Intermediate> intermediate_children;
SRConverterPtr converter;
- framecnt_t max_frames_out;
+ samplecnt_t max_samples_out;
};
// Silence trimmer + adder
class SilenceHandler {
- public:
- SilenceHandler (ExportGraphBuilder & parent, FileSpec const & new_config, framecnt_t max_frames);
+ public:
+ SilenceHandler (ExportGraphBuilder & parent, FileSpec const & new_config, samplecnt_t max_samples);
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<AudioGrapher::SilenceTrimmer<Sample> > SilenceTrimmerPtr;
ExportGraphBuilder & parent;
FileSpec config;
boost::ptr_list<SRC> children;
SilenceTrimmerPtr silence_trimmer;
- framecnt_t max_frames_in;
+ samplecnt_t max_samples_in;
};
// channel configuration
class ChannelConfig {
- public:
+ 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<AudioGrapher::Interleaver<Sample> > InterleaverPtr;
+ typedef boost::shared_ptr<AudioGrapher::Chunker<Sample> > ChunkerPtr;
ExportGraphBuilder & parent;
FileSpec config;
boost::ptr_list<SilenceHandler> children;
InterleaverPtr interleaver;
- framecnt_t max_frames;
+ ChunkerPtr chunker;
+ samplecnt_t max_samples_out;
};
Session const & session;
// The sources of all data, each channel is read only once
ChannelMap channels;
- framecnt_t process_buffer_frames;
+ samplecnt_t process_buffer_samples;
+
+ std::list<Intermediate *> intermediates;
+
+ AnalysisMap analysis_map;
- std::list<Normalizer *> normalizers;
+ bool _realtime;
Glib::ThreadPool thread_pool;
};