X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fardour%2Fio.h;h=0b86eb408858af4217b606258c35670bcc3a53c2;hb=4b95621853072c44b1df698df8a96d7d9167319f;hp=a4b50618bbda6cb30098e63079b21a2d6b5c3b1d;hpb=cbdf686e391bc2e7b93f37a5d3fa9197cb178078;p=ardour.git diff --git a/libs/ardour/ardour/io.h b/libs/ardour/ardour/io.h index a4b50618bb..0b86eb4088 100644 --- a/libs/ardour/ardour/io.h +++ b/libs/ardour/ardour/io.h @@ -15,7 +15,6 @@ along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - $Id$ */ #ifndef __ardour_io_h__ @@ -31,12 +30,11 @@ #include #include -#include +#include #include #include #include -#include #include #include #include @@ -52,18 +50,20 @@ namespace ARDOUR { class Session; class AudioEngine; -class Connection; +class Bundle; class Panner; +class PeakMeter; class Port; class AudioPort; class MidiPort; +class BufferSet; /** A collection of input and output ports with connections. * * An IO can contain ports of varying types, making routes/inserts/etc with * varied combinations of types (eg MIDI and audio) possible. */ -class IO : public Stateful, public ARDOUR::StateManager +class IO : public PBD::StatefulDestructible { public: @@ -72,7 +72,9 @@ class IO : public Stateful, public ARDOUR::StateManager IO (Session&, string name, int input_min = -1, int input_max = -1, int output_min = -1, int output_max = -1, - DataType default_type = DataType::AUDIO); + DataType default_type = DataType::AUDIO); + + IO (Session&, const XMLNode&, DataType default_type = DataType::AUDIO); virtual ~IO(); @@ -80,52 +82,48 @@ class IO : public Stateful, public ARDOUR::StateManager ChanCount input_maximum() const { return _input_maximum; } ChanCount output_minimum() const { return _output_minimum; } ChanCount output_maximum() const { return _output_maximum; } - + void set_input_minimum (ChanCount n); void set_input_maximum (ChanCount n); void set_output_minimum (ChanCount n); void set_output_maximum (ChanCount n); - // Do not write any new code using these - void set_input_minimum (int n); - void set_input_maximum (int n); - void set_output_minimum (int n); - void set_output_maximum (int n); - - DataType default_type() const { return _default_type; } + DataType default_type() const { return _default_type; } + void set_default_type(DataType t) { _default_type = t; } const string& name() const { return _name; } virtual int set_name (string str, void *src); - virtual void silence (jack_nframes_t, jack_nframes_t offset); - - // These should be moved in to a separate object that manipulates an IO - - void pan (vector& bufs, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset, gain_t gain_coeff); - void pan_automated (vector& bufs, uint32_t nbufs, jack_nframes_t start_frame, jack_nframes_t end_frame, - jack_nframes_t nframes, jack_nframes_t offset); - void collect_input (vector&, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset); - void deliver_output (vector&, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset); - void deliver_output_no_pan (vector&, uint32_t nbufs, jack_nframes_t nframes, jack_nframes_t offset); - void just_meter_input (jack_nframes_t start_frame, jack_nframes_t end_frame, - jack_nframes_t nframes, jack_nframes_t offset); + virtual void silence (nframes_t, nframes_t offset); - virtual uint32_t n_process_buffers () { return 0; } + void collect_input (BufferSet& bufs, nframes_t nframes, nframes_t offset); + void deliver_output (BufferSet& bufs, nframes_t start_frame, nframes_t end_frame, + nframes_t nframes, nframes_t offset); + void just_meter_input (nframes_t start_frame, nframes_t end_frame, + nframes_t nframes, nframes_t offset); virtual void set_gain (gain_t g, void *src); void inc_gain (gain_t delta, void *src); gain_t gain () const { return _desired_gain; } virtual gain_t effective_gain () const; + + void set_denormal_protection (bool yn, void *src); + bool denormal_protection() const { return _denormal_protection; } + + void set_phase_invert (bool yn, void *src); + bool phase_invert() const { return _phase_invert; } - Panner& panner() { return *_panner; } - - int ensure_io (uint32_t, uint32_t, bool clear, void *src); + Panner& panner() { return *_panner; } + PeakMeter& peak_meter() { return *_meter; } + const Panner& panner() const { return *_panner; } + + int ensure_io (ChanCount in, ChanCount out, bool clear, void *src); - int use_input_connection (Connection&, void *src); - int use_output_connection (Connection&, void *src); + int use_input_bundle (Bundle&, void *src); + int use_output_bundle (Bundle&, void *src); - Connection *input_connection() const { return _input_connection; } - Connection *output_connection() const { return _output_connection; } + Bundle *input_bundle() const { return _input_bundle; } + Bundle *output_bundle() const { return _output_bundle; } int add_input_port (string source, void *src, DataType type = DataType::NIL); int add_output_port (string destination, void *src, DataType type = DataType::NIL); @@ -144,9 +142,12 @@ class IO : public Stateful, public ARDOUR::StateManager int disconnect_inputs (void *src); int disconnect_outputs (void *src); - jack_nframes_t output_latency() const; - jack_nframes_t input_latency() const; - void set_port_latency (jack_nframes_t); + nframes_t output_latency() const; + nframes_t input_latency() const; + void set_port_latency (nframes_t); + + const PortSet& inputs() const { return _inputs; } + const PortSet& outputs() const { return _outputs; } Port *output (uint32_t n) const { if (n < _outputs.num_ports()) { @@ -169,8 +170,10 @@ class IO : public Stateful, public ARDOUR::StateManager MidiPort* midi_input(uint32_t n) const; MidiPort* midi_output(uint32_t n) const; - const ChanCount& n_inputs () const { return _inputs.chan_count(); } - const ChanCount& n_outputs () const { return _outputs.chan_count(); } + const ChanCount& n_inputs () const { return _inputs.count(); } + const ChanCount& n_outputs () const { return _outputs.count(); } + + void attach_buffers(ChanCount ignored); sigc::signal input_changed; sigc::signal output_changed; @@ -182,9 +185,6 @@ class IO : public Stateful, public ARDOUR::StateManager XMLNode& get_state (void); int set_state (const XMLNode&); - virtual UndoAction get_memento() const; - - static int disable_connecting (void); static int enable_connecting (void); @@ -197,39 +197,36 @@ class IO : public Stateful, public ARDOUR::StateManager static int reset_panners (void); - static sigc::signal PortsLegal; - static sigc::signal PannersLegal; - static sigc::signal ConnectingLegal; - static sigc::signal MoreOutputs; - static sigc::signal PortsCreated; + static sigc::signal PortsLegal; + static sigc::signal PannersLegal; + static sigc::signal ConnectingLegal; + static sigc::signal MoreChannels; + static sigc::signal PortsCreated; PBD::Controllable& gain_control() { return _gain_control; } - - /* Peak metering */ - - float peak_input_power (uint32_t n) { - if (n < std::max (_inputs.chan_count().get(DataType::AUDIO), - _outputs.chan_count().get(DataType::AUDIO))) { - return _visible_peak_power[n]; - } else { - return minus_infinity(); - } - } - + static void update_meters(); -private: + private: static sigc::signal Meter; static Glib::StaticMutex m_meter_signal_lock; sigc::connection m_meter_connection; -public: + public: /* automation */ + static void set_automation_interval (nframes_t frames) { + _automation_interval = frames; + } + + static nframes_t automation_interval() { + return _automation_interval; + } + void clear_automation (); bool gain_automation_recording() const { @@ -250,16 +247,8 @@ public: AutoStyle gain_automation_style () const { return _gain_automation_curve.automation_style(); } sigc::signal gain_automation_style_changed; - static void set_automation_interval (jack_nframes_t frames) { - _automation_interval = frames; - } - - static jack_nframes_t automation_interval() { - return _automation_interval; - } - - virtual void transport_stopped (jack_nframes_t now); - virtual void automation_snapshot (jack_nframes_t now); + virtual void transport_stopped (nframes_t now); + void automation_snapshot (nframes_t now); ARDOUR::Curve& gain_automation_curve () { return _gain_automation_curve; } @@ -269,8 +258,6 @@ public: void start_pan_touch (uint32_t which); void end_pan_touch (uint32_t which); - const PBD::ID& id() const { return _id; } - void defer_pan_reset (); void allow_pan_reset (); @@ -285,37 +272,34 @@ public: mutable Glib::Mutex io_lock; protected: - Session& _session; - Panner* _panner; - gain_t _gain; - gain_t _effective_gain; - gain_t _desired_gain; - Glib::Mutex declick_lock; - PortSet _outputs; - PortSet _inputs; - vector _peak_power; - vector _visible_peak_power; - string _name; - Connection* _input_connection; - Connection* _output_connection; - PBD::ID _id; - bool no_panner_reset; - XMLNode* deferred_state; - DataType _default_type; - + Session& _session; + Panner* _panner; + BufferSet* _output_buffers; //< Set directly to output port buffers + gain_t _gain; + gain_t _effective_gain; + gain_t _desired_gain; + Glib::Mutex declick_lock; + PortSet _outputs; + PortSet _inputs; + PeakMeter* _meter; + string _name; + Bundle* _input_bundle; + Bundle* _output_bundle; + bool no_panner_reset; + bool _phase_invert; + bool _denormal_protection; + XMLNode* deferred_state; + DataType _default_type; + virtual void set_deferred_state() {} - void reset_peak_meters(); void reset_panner (); virtual uint32_t pans_required() const - { return _inputs.chan_count().get(DataType::AUDIO); } - - static void apply_declick (vector&, uint32_t nbufs, jack_nframes_t nframes, - gain_t initial, gain_t target, bool invert_polarity); + { return _inputs.count().n_audio(); } struct GainControllable : public PBD::Controllable { - GainControllable (IO& i) : io (i) {} + GainControllable (std::string name, IO& i) : Controllable (name), io (i) {} void set_value (float val); float get_value (void) const; @@ -325,27 +309,21 @@ public: GainControllable _gain_control; - /* state management */ - - Change restore_state (State&); - StateManager::State* state_factory (std::string why) const; - - /* automation */ + nframes_t last_automation_snapshot; + static nframes_t _automation_interval; - jack_nframes_t last_automation_snapshot; - static jack_nframes_t _automation_interval; - - AutoState _gain_automation_state; + AutoState _gain_automation_state; AutoStyle _gain_automation_style; bool apply_gain_automation; Curve _gain_automation_curve; - int save_automation (const string&); - int load_automation (const string&); - Glib::Mutex automation_lock; + virtual int set_automation_state (const XMLNode&); + virtual XMLNode& get_automation_state (); + virtual int load_automation (std::string path); + /* AudioTrack::deprecated_use_diskstream_connections() needs these */ int set_inputs (const string& str); @@ -354,15 +332,16 @@ public: static bool connecting_legal; static bool ports_legal; - private: + BufferSet& output_buffers() { return *_output_buffers; } + private: /* are these the best variable names ever, or what? */ - sigc::connection input_connection_configuration_connection; - sigc::connection output_connection_configuration_connection; - sigc::connection input_connection_connection_connection; - sigc::connection output_connection_connection_connection; + sigc::connection input_bundle_configuration_connection; + sigc::connection output_bundle_configuration_connection; + sigc::connection input_bundle_connection_connection; + sigc::connection output_bundle_connection_connection; static bool panners_legal; @@ -385,16 +364,16 @@ public: int set_sources (vector&, void *src, bool add); int set_destinations (vector&, void *src, bool add); - int ensure_inputs (uint32_t, bool clear, bool lockit, void *src); - int ensure_outputs (uint32_t, bool clear, bool lockit, void *src); + int ensure_inputs (ChanCount, bool clear, bool lockit, void *src); + int ensure_outputs (ChanCount, bool clear, bool lockit, void *src); - void drop_input_connection (); - void drop_output_connection (); + void drop_input_bundle (); + void drop_output_bundle (); - void input_connection_configuration_changed (); - void input_connection_connection_changed (int); - void output_connection_configuration_changed (); - void output_connection_connection_changed (int); + void input_bundle_configuration_changed (); + void input_bundle_connection_changed (int); + void output_bundle_configuration_changed (); + void output_bundle_connection_changed (int); int create_ports (const XMLNode&); int make_connections (const XMLNode&); @@ -402,8 +381,8 @@ public: void setup_peak_meters (); void meter (); - bool ensure_inputs_locked (uint32_t, bool clear, void *src); - bool ensure_outputs_locked (uint32_t, bool clear, void *src); + bool ensure_inputs_locked (ChanCount, bool clear, void *src); + bool ensure_outputs_locked (ChanCount, bool clear, void *src); int32_t find_input_port_hole (); int32_t find_output_port_hole ();