X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fexport_channel.h;h=8f4d8fc27cf3e47dd8bfe459c9af8d247ed125aa;hb=e5a181c323243a03338f5a9934a5df254986370d;hp=dd351bfd70bdf57c56ee1215cb05cf4c2af82b49;hpb=98389f7da420ee205f6827b7df4db3ea0802f751;p=ardour.git diff --git a/libs/ardour/ardour/export_channel.h b/libs/ardour/ardour/export_channel.h index dd351bfd70..8f4d8fc27c 100644 --- a/libs/ardour/ardour/export_channel.h +++ b/libs/ardour/ardour/export_channel.h @@ -21,124 +21,184 @@ #ifndef __ardour_export_channel_h__ #define __ardour_export_channel_h__ -#include -#include -#include - #include +#include +#include #include -#include + +#include "pbd/signals.h" +#include "pbd/ringbuffer.h" + +#include "ardour/buffer_set.h" +#include "ardour/export_pointers.h" namespace ARDOUR { class Session; +class AudioTrack; +class AudioPort; +class AudioRegion; +class CapturingProcessor; /// Export channel base class interface for different source types -class ExportChannel +class LIBARDOUR_API ExportChannel : public boost::less_than_comparable { public: - virtual void read (Sample * data, nframes_t frames) const = 0; + + virtual ~ExportChannel () {} + + virtual void set_max_buffer_size(samplecnt_t) { } + + virtual void read (Sample const *& data, samplecnt_t samples) const = 0; virtual bool empty () const = 0; - + /// Adds state to node passed virtual void get_state (XMLNode * node) const = 0; - + /// Sets state from node passed virtual void set_state (XMLNode * node, Session & session) = 0; - + // Operator< must be defined for usage in e.g. std::map or std::set to disallow duplicates when necessary virtual bool operator< (ExportChannel const & other) const = 0; }; -/// Safe pointer for storing ExportChannels in ordered STL containers -class ExportChannelPtr : public boost::shared_ptr +/// Basic export channel that reads from AudioPorts +class LIBARDOUR_API PortExportChannel : public ExportChannel { public: - ExportChannelPtr () {} - template explicit ExportChannelPtr (Y * ptr) : boost::shared_ptr (ptr) {} + typedef std::set > PortSet; - bool operator< (ExportChannelPtr const & other) const { return **this < *other; } -}; + PortExportChannel (); + ~PortExportChannel (); -/// Basic export channel that reads from AudioPorts -class PortExportChannel : public ExportChannel -{ - public: - typedef std::set PortSet; - - PortExportChannel () {} - - virtual void read (Sample * data, nframes_t frames) const; - virtual bool empty () const { return ports.empty(); } - - virtual void get_state (XMLNode * node) const; - virtual void set_state (XMLNode * node, Session & session); - - virtual bool operator< (ExportChannel const & other) const; - - void add_port (AudioPort * port) { ports.insert (port); } + void set_max_buffer_size(samplecnt_t samples); + + void read (Sample const *& data, samplecnt_t samples) const; + bool empty () const { return ports.empty(); } + + void get_state (XMLNode * node) const; + void set_state (XMLNode * node, Session & session); + + bool operator< (ExportChannel const & other) const; + + void add_port (boost::weak_ptr port) { ports.insert (port); } PortSet const & get_ports () { return ports; } private: PortSet ports; + samplecnt_t _buffer_size; + boost::scoped_array _buffer; + std::list > > _delaylines; }; + /// Handles RegionExportChannels and does actual reading from region -class RegionExportChannelFactory : public sigc::trackable +class LIBARDOUR_API RegionExportChannelFactory { public: enum Type { + None, Raw, + Fades, Processed }; - + RegionExportChannelFactory (Session * session, AudioRegion const & region, AudioTrack & track, Type type); + ~RegionExportChannelFactory (); ExportChannelPtr create (uint32_t channel); - void read (uint32_t channel, Sample * data, nframes_t frames_to_read); - + void read (uint32_t channel, Sample const *& data, samplecnt_t samples_to_read); + private: - int new_cycle_started () { buffers_up_to_date = false; return 0; } - void update_buffers (nframes_t frames); + int new_cycle_started (samplecnt_t) { buffers_up_to_date = false; return 0; } + void update_buffers (samplecnt_t samples); AudioRegion const & region; AudioTrack & track; Type type; - nframes_t frames_per_cycle; + samplecnt_t samples_per_cycle; size_t n_channels; BufferSet buffers; bool buffers_up_to_date; - nframes_t region_start; - nframes_t position; + samplecnt_t region_start; + samplecnt_t position; + + boost::scoped_array mixdown_buffer; + boost::scoped_array gain_buffer; + + PBD::ScopedConnection export_connection; }; /// Export channel that reads from region channel -class RegionExportChannel : public ExportChannel +class LIBARDOUR_API RegionExportChannel : public ExportChannel { friend class RegionExportChannelFactory; public: - virtual void read (Sample * data, nframes_t frames_to_read) const { factory.read (channel, data, frames_to_read); } - virtual void get_state (XMLNode * node) const {}; - virtual void set_state (XMLNode * node, Session & session) {}; - virtual bool empty () const { return false; } + void read (Sample const *& data, samplecnt_t samples_to_read) const { factory.read (channel, data, samples_to_read); } + void get_state (XMLNode * /*node*/) const {}; + void set_state (XMLNode * /*node*/, Session & /*session*/) {}; + bool empty () const { return false; } // Region export should never have duplicate channels, so there need not be any semantics here - virtual bool operator< (ExportChannel const & other) const { return this < &other; } + bool operator< (ExportChannel const & other) const { return this < &other; } private: - RegionExportChannel (RegionExportChannelFactory & factory, uint32_t channel) : - factory (factory), - channel (channel) + RegionExportChannel (RegionExportChannelFactory & factory, uint32_t channel) + : factory (factory) + , channel (channel) {} - + RegionExportChannelFactory & factory; uint32_t channel; }; +/// Export channel for exporting from different positions in a route +class LIBARDOUR_API RouteExportChannel : public ExportChannel +{ + class ProcessorRemover; // fwd declaration + + public: + RouteExportChannel(boost::shared_ptr processor, size_t channel, + boost::shared_ptr remover); + ~RouteExportChannel(); + + static void create_from_route(std::list & result, boost::shared_ptr route); + + public: // ExportChannel interface + void set_max_buffer_size(samplecnt_t samples); + + void read (Sample const *& data, samplecnt_t samples) const; + bool empty () const { return false; } + + void get_state (XMLNode * node) const; + void set_state (XMLNode * node, Session & session); + + bool operator< (ExportChannel const & other) const; + + private: + + // Removes the processor from the track when deleted + class ProcessorRemover { + public: + ProcessorRemover (boost::shared_ptr route, boost::shared_ptr processor) + : route (route), processor (processor) {} + ~ProcessorRemover(); + private: + boost::shared_ptr route; + boost::shared_ptr processor; + }; + + boost::shared_ptr processor; + size_t channel; + // Each channel keeps a ref to the remover. Last one alive + // will cause the processor to be removed on deletion. + boost::shared_ptr remover; +}; + } // namespace ARDOUR #endif