major internal plugin & processor API change:
authorRobin Gareus <robin@gareus.org>
Sat, 25 Jun 2016 00:23:56 +0000 (02:23 +0200)
committerRobin Gareus <robin@gareus.org>
Sat, 25 Jun 2016 00:23:56 +0000 (02:23 +0200)
Pass current (latency compensated) cycle times to plugin.
This fixes time-reporting to plugins and also fixes automation
and when bouncing (the session->transport* is not valid) etc.

53 files changed:
gtk2_ardour/plugin_eq_gui.cc
libs/ardour/amp.cc
libs/ardour/ardour/amp.h
libs/ardour/ardour/audio_unit.h
libs/ardour/ardour/capturing_processor.h
libs/ardour/ardour/delayline.h
libs/ardour/ardour/delivery.h
libs/ardour/ardour/internal_return.h
libs/ardour/ardour/internal_send.h
libs/ardour/ardour/io.h
libs/ardour/ardour/io_processor.h
libs/ardour/ardour/ladspa_plugin.h
libs/ardour/ardour/luaproc.h
libs/ardour/ardour/lv2_plugin.h
libs/ardour/ardour/meter.h
libs/ardour/ardour/monitor_processor.h
libs/ardour/ardour/plugin.h
libs/ardour/ardour/plugin_insert.h
libs/ardour/ardour/port_insert.h
libs/ardour/ardour/processor.h
libs/ardour/ardour/return.h
libs/ardour/ardour/send.h
libs/ardour/ardour/session.h
libs/ardour/ardour/sidechain.h
libs/ardour/ardour/unknown_processor.h
libs/ardour/ardour/vst_plugin.h
libs/ardour/audio_track.cc
libs/ardour/audio_unit.cc
libs/ardour/capturing_processor.cc
libs/ardour/delayline.cc
libs/ardour/delivery.cc
libs/ardour/internal_return.cc
libs/ardour/internal_send.cc
libs/ardour/io.cc
libs/ardour/io_processor.cc
libs/ardour/ladspa_plugin.cc
libs/ardour/luaproc.cc
libs/ardour/lv2_plugin.cc
libs/ardour/meter.cc
libs/ardour/midi_track.cc
libs/ardour/monitor_processor.cc
libs/ardour/plugin.cc
libs/ardour/plugin_insert.cc
libs/ardour/port_insert.cc
libs/ardour/return.cc
libs/ardour/route.cc
libs/ardour/send.cc
libs/ardour/session_click.cc
libs/ardour/session_vst.cc
libs/ardour/sidechain.cc
libs/ardour/track.cc
libs/ardour/unknown_processor.cc
libs/ardour/vst_plugin.cc

index 1fa5d2d598e6250216233baf5b937ebf7833cd52..e2606afc906cfea5697cddd264efc8b22711238d 100644 (file)
@@ -343,7 +343,7 @@ PluginEqGui::run_impulse_analysis()
        ARDOUR::ChanMapping out_map(_plugin->get_info()->n_outputs);
 
        _plugin->set_block_size (_buffer_size);
-       _plugin->connect_and_run(_bufferset, in_map, out_map, _buffer_size, 0);
+       _plugin->connect_and_run(_bufferset, 0, _buffer_size, 1.0, in_map, out_map, _buffer_size, 0);
        framecnt_t f = _plugin->signal_latency ();
        // Adding user_latency() could be interesting
 
@@ -402,7 +402,7 @@ PluginEqGui::run_impulse_analysis()
 
                                in_map  = ARDOUR::ChanMapping(_plugin->get_info()->n_inputs);
                                out_map = ARDOUR::ChanMapping(_plugin->get_info()->n_outputs);
-                               _plugin->connect_and_run(_bufferset, in_map, out_map, _buffer_size, 0);
+                               _plugin->connect_and_run (_bufferset, target_offset, target_offset + _buffer_size, 1.0, in_map, out_map, _buffer_size, 0);
                        }
                } while ( frames_left > 0);
 
index 273acc77f9a16ed3da3be1a7daf5e9bbaccbc5a6..e4223e458613f36f4a3b0297264f79c35d596539 100644 (file)
@@ -71,7 +71,7 @@ Amp::configure_io (ChanCount in, ChanCount out)
 }
 
 void
-Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool)
+Amp::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double /*speed*/, pframes_t nframes, bool)
 {
        if (!_active && !_pending_active) {
                return;
index a85963babebcb04b028879aeab91ac204acdaa25..820e2a85e1e9e80f1ce4468900f8a278e0d8e463 100644 (file)
@@ -47,7 +47,7 @@ public:
        bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
        bool configure_io (ChanCount in, ChanCount out);
 
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
 
        bool apply_gain () const  { return _apply_gain; }
        void apply_gain (bool yn) { _apply_gain = yn; }
index 448584251c31f010efa9a69b8cbcd64eab918829..b02a0d3b806fa5455c60e63e7f38a9752ec82392 100644 (file)
@@ -171,6 +171,8 @@ class LIBARDOUR_API AUPlugin : public ARDOUR::Plugin
        std::vector<std::pair<int,int> > io_configs;
        pframes_t _current_block_size;
        framecnt_t _last_nframes;
+       framepos_t _transport_frame;
+       framepos_t _transport_speed;
        bool _requires_fixed_size_buffers;
        AudioBufferList* buffers;
        bool _has_midi_input;
@@ -226,8 +228,9 @@ class LIBARDOUR_API AUPlugin : public ARDOUR::Plugin
 
        void discover_factory_presets ();
 
-       bool      last_transport_rolling;
-       float     last_transport_speed;
+       framepos_t transport_frame;
+       float      transport_speed;
+       floa t     last_transport_speed;
 
        static void _parameter_change_listener (void* /*arg*/, void* /*src*/, const AudioUnitEvent* event, UInt64 host_time, Float32 new_value);
        void parameter_change_listener (void* /*arg*/, void* /*src*/, const AudioUnitEvent* event, UInt64 host_time, Float32 new_value);
index 9a91e6d02fba0e8f7de67bde7b2e5bc2d6050801..b5cdc8739cbbdc62288256089dd39d4f734bb6e4 100644 (file)
@@ -36,7 +36,7 @@ class LIBARDOUR_API CapturingProcessor : public Processor
   public: // Processor overrides
        bool display_to_user() const { return false; }
        int set_block_size (pframes_t nframes);
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool result_required);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool result_required);
        bool configure_io (ChanCount in, ChanCount out);
        bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
        virtual XMLNode& state (bool);
index 2e970ecd9fb6fad9303e66341ef57faa0a23bdcd..93097df6b23ba11bae841501a959395f942968f1 100644 (file)
@@ -42,7 +42,7 @@ public:
 
        bool display_to_user() const { return false; }
 
-       void run (BufferSet&, framepos_t, framepos_t, pframes_t, bool);
+       void run (BufferSet&, framepos_t, framepos_t, double, pframes_t, bool);
        void set_delay(framecnt_t signal_delay);
        framecnt_t get_delay() { return _pending_delay; }
 
index 13e1cdcda3902bcd899b5e92bde0804a163b91ae..80b8431737bdfd2046e2cf94f6d6b63ad5d418a0 100644 (file)
@@ -71,7 +71,7 @@ public:
        bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
        bool configure_io (ChanCount in, ChanCount out);
 
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
 
        /* supplemental method used with MIDI */
 
index d12b330e37d9a6bc5c3bd2037ba968f8bc03138d..48fcab151e32e26d24479bb86e08a7cd74015eae 100644 (file)
@@ -37,7 +37,7 @@ class LIBARDOUR_API InternalReturn : public Return
        XMLNode& state (bool full);
        XMLNode& get_state ();
 
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
        bool configure_io (ChanCount, ChanCount);
        bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
 
index 71d8049cae2e8830e3ce92af7c3d34feb1f6e487..263c40b90b86a278135a5aa2d581bae1afefe3b2 100644 (file)
@@ -40,7 +40,7 @@ class LIBARDOUR_API InternalSend : public Send
        int set_state(const XMLNode& node, int version);
 
        void cycle_start (pframes_t);
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
        bool feeds (boost::shared_ptr<Route> other) const;
        bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
        bool configure_io (ChanCount in, ChanCount out);
index 5511f64dd683b3becf62f58ac146134ab12135f4..db0f2c3cf8ca9907e5a0033f589da65b29245418 100644 (file)
@@ -194,7 +194,7 @@ class LIBARDOUR_API IO : public SessionObject, public Latent
        /* three utility functions - this just seems to be simplest place to put them */
 
        void collect_input (BufferSet& bufs, pframes_t nframes, ChanCount offset);
-       void process_input (boost::shared_ptr<Processor>, framepos_t start_frame, framepos_t end_frame, pframes_t nframes);
+       void process_input (boost::shared_ptr<Processor>, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes);
        void copy_to_outputs (BufferSet& bufs, DataType type, pframes_t nframes, framecnt_t offset);
 
        /* AudioTrack::deprecated_use_diskstream_connections() needs these */
index a2735453a76db1154a6f4dc74c2df54a5a0f0adf..15bd74d122b35ed6d9cc0cc867b2416a42e0be0a 100644 (file)
@@ -64,7 +64,7 @@ class LIBARDOUR_API IOProcessor : public Processor
        void set_input (boost::shared_ptr<IO>);
        void set_output (boost::shared_ptr<IO>);
 
-       void silence (framecnt_t nframes);
+       void silence (framecnt_t nframes, framepos_t start_frame);
        void disconnect ();
 
        void increment_port_buffer_offset (pframes_t);
index 6fd214db6888d9df3e51473d2aad82efa6133bc9..dbb635fd91132fe3e80a1e36501a090c5b9d6ea5 100644 (file)
@@ -83,6 +83,7 @@ class LIBARDOUR_API LadspaPlugin : public ARDOUR::Plugin
        int set_block_size (pframes_t /*nframes*/) { return 0; }
 
        int connect_and_run (BufferSet& bufs,
+                       framepos_t start, framepos_t end, double speed,
                        ChanMapping in, ChanMapping out,
                        pframes_t nframes, framecnt_t offset);
 
index 67c4432087b91cba0cc44ebb75af5e44ac46cf38..a92bcdf2f62c073e728fa72d0591a77675613b7e 100644 (file)
@@ -75,6 +75,7 @@ public:
        framecnt_t  signal_latency() const { return 0; }
 
        int connect_and_run (BufferSet& bufs,
+                       framepos_t start, framepos_t end, double speed,
                        ChanMapping in, ChanMapping out,
                        pframes_t nframes, framecnt_t offset);
 
index 54a1611cb6d12bf0b4a6174f07cd4918216eb33a..9d4e2d1f68719ad308b31fcd20971b7732604ec6 100644 (file)
@@ -108,6 +108,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
        bool requires_fixed_sized_buffers () const;
 
        int connect_and_run (BufferSet& bufs,
+                            framepos_t start, framepos_t end, double speed,
                             ChanMapping in, ChanMapping out,
                             pframes_t nframes, framecnt_t offset);
 
index a3bd34e1b78bbfc3e79298444ac1bbae50bd6d31..ddc1e5e48f1c83507199b545ee1944ace94b94ba 100644 (file)
@@ -64,7 +64,7 @@ public:
        void emit_configuration_changed ();
 
        /** Compute peaks */
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
 
        void activate ()   { }
        void deactivate () { }
index cef12b33d93def01959bc55695d82285022f1769..d369cb9c282002b8330d02330260dea509bce53b 100644 (file)
@@ -127,7 +127,7 @@ public:
 
        bool display_to_user() const;
 
-       void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t /*nframes*/, bool /*result_required*/);
+       void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double /*speed*/, pframes_t /*nframes*/, bool /*result_required*/);
 
        XMLNode& state (bool full);
        int set_state (const XMLNode&, int /* version */);
index d284c2620d75f3580388cac74d102a71b31b7a3e..935b75faead0719bdb869998413e79d5a30710f2 100644 (file)
@@ -99,8 +99,9 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent
        virtual bool inplace_broken() const { return false; }
 
        virtual int connect_and_run (BufferSet& bufs,
-                                    ChanMapping in, ChanMapping out,
-                                    pframes_t nframes, framecnt_t offset);
+                       framepos_t start, framepos_t end, double speed,
+                       ChanMapping in, ChanMapping out,
+                       pframes_t nframes, framecnt_t offset);
 
        virtual std::set<Evoral::Parameter> automatable() const = 0;
        virtual std::string describe_parameter (Evoral::Parameter) = 0;
index 2905f012bfd2b95a0ebd70d1b081f958301c8210..5ec35d0589a961c96b2d7439715d868bbf943099 100644 (file)
@@ -61,8 +61,8 @@ class LIBARDOUR_API PluginInsert : public Processor
        void update_id (PBD::ID);
        void set_state_dir (const std::string& d = "");
 
-       void run (BufferSet& in, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
-       void silence (framecnt_t nframes);
+       void run (BufferSet& in, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
+       void silence (framecnt_t nframes, framepos_t start_frame);
 
        void activate ();
        void deactivate ();
@@ -344,8 +344,8 @@ class LIBARDOUR_API PluginInsert : public Processor
        PinMappings _out_map;
        ChanMapping _thru_map; // out-idx <=  in-idx
 
-       void automation_run (BufferSet& bufs, framepos_t start, pframes_t nframes);
-       void connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t offset, bool with_auto, framepos_t now = 0);
+       void automation_run (BufferSet& bufs, framepos_t start, framepos_t end, double speed, pframes_t nframes);
+       void connect_and_run (BufferSet& bufs, framepos_t start, framecnt_t end, double speed, pframes_t nframes, framecnt_t offset, bool with_auto);
        void bypass (BufferSet& bufs, pframes_t nframes);
        void inplace_silence_unconnected (BufferSet&, const PinMappings&, framecnt_t nframes, framecnt_t offset) const;
 
index 54d8583d9abf99b9ee0f1f3ad5f289c7f709393f..fee1f4694c7e2463d6ca1ae5257a710428f5d2fa 100644 (file)
@@ -52,7 +52,7 @@ class LIBARDOUR_API PortInsert : public IOProcessor
        XMLNode& get_state(void);
        int set_state (const XMLNode&, int version);
 
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
 
        framecnt_t signal_latency () const;
 
index 914ddb904fca0f24bda07fc4c2c2430e152701c9..c86827c13b196af1f0ba3b638b8cf1330c7e8665 100644 (file)
@@ -74,8 +74,8 @@ class LIBARDOUR_API Processor : public SessionObject, public Automatable, public
        /** @param result_required true if, on return from this method, @a bufs is required to contain valid data;
         *  if false, the method need not bother writing to @a bufs if it doesn't want to.
         */
-       virtual void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t /*nframes*/, bool /*result_required*/) {}
-       virtual void silence (framecnt_t /*nframes*/) {}
+       virtual void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double speed, pframes_t /*nframes*/, bool /*result_required*/) {}
+       virtual void silence (framecnt_t /*nframes*/, framepos_t /*start_frame*/) {}
 
        virtual void activate ()   { _pending_active = true; ActiveChanged(); }
        virtual void deactivate () { _pending_active = false; ActiveChanged(); }
index 1d60a43d38e750fd50c4eaff38de8ddb4f7848c3..d42a280ffb03914964d97f67c1e10ab059e8d5c3 100644 (file)
@@ -42,7 +42,7 @@ public:
 
        uint32_t bit_slot() const { return _bitslot; }
 
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
 
        boost::shared_ptr<Amp> amp() const { return _amp; }
        boost::shared_ptr<PeakMeter> meter() const { return _meter; }
index 2d6b8ee1b8b5c60d15aa40ef556489425b3589b8..f70f09b6ead3af518c376366aa2da867c180d2ba 100644 (file)
@@ -61,7 +61,7 @@ class LIBARDOUR_API Send : public Delivery
 
        uint32_t pans_required() const { return _configured_input.n_audio(); }
 
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
 
        bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
        bool configure_io (ChanCount in, ChanCount out);
index 0d96777f8c11a376bf8f4b9d8b7f818e77a2dfc7..5ec7e99cea0c84e476229db2b52b0fe5b94c404f 100644 (file)
@@ -676,8 +676,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        bool   synced_to_ltc () const { return config.get_external_sync() && Config->get_sync_source() == LTC && g_atomic_int_get (const_cast<gint*>(&_ltc_active)); }
 
        double transport_speed() const { return _transport_speed; }
-       bool   transport_stopped() const { return _transport_speed == 0.0f; }
-       bool   transport_rolling() const { return _transport_speed != 0.0f; }
+       bool   transport_stopped() const { return _transport_speed == 0.0; }
+       bool   transport_rolling() const { return _transport_speed != 0.0; }
 
        bool silent () { return _silent; }
 
index ad92137cea437eb5b8514f4dffa0ce2767b631ed..9d44c3efa269c24927b540219b21e9bbbf886667 100644 (file)
@@ -34,7 +34,7 @@ public:
        SideChain (Session&, const std::string&);
        virtual ~SideChain ();
 
-       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool);
+       void run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
 
        bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
        bool configure_io (ChanCount in, ChanCount out);
index b9743c959938fbdcf261e4fd2f11905605c60788..170be3804252bdf2d0d4299f9fb708c2938801ce 100644 (file)
@@ -46,7 +46,7 @@ public:
        virtual ~UnknownProcessor ();
 
        bool can_support_io_configuration (const ChanCount &, ChanCount &);
-       void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t /*nframes*/, bool /*result_required*/);
+       void run (BufferSet& /*bufs*/, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double /*speed*/, pframes_t /*nframes*/, bool /*result_required*/);
 
        XMLNode & state (bool);
 
index 3440534eb992f4a501c62cfd6908c5b65323a530..2f2bcaae837e0476562e97fbe6a6f4d57b689910 100644 (file)
@@ -63,10 +63,11 @@ public:
        bool parameter_is_input (uint32_t) const { return true; }
        bool parameter_is_output (uint32_t) const { return false; }
 
-       int connect_and_run (
-               BufferSet&, ChanMapping in, ChanMapping out,
-               pframes_t nframes, framecnt_t offset
-               );
+       int connect_and_run (BufferSet&,
+                       framepos_t start, framepos_t end, double speed,
+                       ChanMapping in, ChanMapping out,
+                       pframes_t nframes, framecnt_t offset
+                       );
 
        std::string unique_id () const;
        const char * label () const;
@@ -89,6 +90,8 @@ public:
        PluginInsert* plugin_insert () const { return _pi; }
        uint32_t plugin_number () const { return _num; }
        VstTimeInfo* timeinfo () { return &_timeInfo; }
+       framepos_t transport_frame () const { return _transport_frame; }
+       float transport_speed () const { return _transport_speed; }
 
 
 protected:
@@ -112,6 +115,9 @@ protected:
 
        MidiBuffer* _midi_out_buf;
        VstTimeInfo _timeInfo;
+
+       framepos_t _transport_frame;
+       float      _transport_speed;
 };
 
 }
index 742eb9c7788a8a6b3259bc9fe76432fa176ac78a..8c56f90afbe1d52c9c3903efd29715f3a37d648f 100644 (file)
@@ -383,7 +383,7 @@ AudioTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_fram
        fill_buffers_with_input (bufs, _input, nframes);
 
        if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) {
-               _meter->run (bufs, start_frame, end_frame, nframes, true);
+               _meter->run (bufs, start_frame, end_frame, 1.0 /*speed()*/, nframes, true);
        }
 
        if ((dret = diskstream->process (bufs, transport_frame, nframes, playback_distance, (monitoring_state() == MonitoringDisk))) != 0) {
index 70d2853f8c15ad5942d5b2d8b766496613dad569..c31d77256eda6f2fc826f51ca21f522f08f32b05 100644 (file)
@@ -448,7 +448,8 @@ AUPlugin::AUPlugin (AudioEngine& engine, Session& session, boost::shared_ptr<CAC
        , audio_input_cnt (0)
        , _parameter_listener (0)
        , _parameter_listener_arg (0)
-       , last_transport_rolling (false)
+       , transport_frame (false)
+       , transport_speed (false)
        , last_transport_speed (0.0)
 {
        if (!preset_search_path_initialized) {
@@ -1584,9 +1585,15 @@ AUPlugin::render_callback(AudioUnitRenderActionFlags*,
 }
 
 int
-AUPlugin::connect_and_run (BufferSet& bufs, ChanMapping in_map, ChanMapping out_map, pframes_t nframes, framecnt_t offset)
+AUPlugin::connect_and_run (BufferSet& bufs,
+               framepos_t start, framepos_t end, double speed,
+               ChanMapping in_map, ChanMapping out_map,
+               pframes_t nframes, framecnt_t offset)
 {
-       Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
+       Plugin::connect_and_run(bufs, start, end, speed, in_map, out_map, nframes, offset);
+
+       transport_frame = start;
+       transport_speed = speed;
 
        AudioUnitRenderActionFlags flags = 0;
        AudioTimeStamp ts;
@@ -1760,8 +1767,8 @@ AUPlugin::get_beat_and_tempo_callback (Float64* outCurrentBeat,
                return kAudioUnitErr_CannotDoInCurrentContext;
        }
 
-       TempoMetric metric = tmap.metric_at (_session.transport_frame() + input_offset);
-       Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (_session.transport_frame() + input_offset);
+       TempoMetric metric = tmap.metric_at (transport_frame + input_offset);
+       Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (transport_frame + input_offset);
 
        if (outCurrentBeat) {
                const double ppq_scaling = metric.meter().note_divisor() / 4.0;
@@ -1799,8 +1806,8 @@ AUPlugin::get_musical_time_location_callback (UInt32*   outDeltaSampleOffsetToNe
                return kAudioUnitErr_CannotDoInCurrentContext;
        }
 
-       TempoMetric metric = tmap.metric_at (_session.transport_frame() + input_offset);
-       Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (_session.transport_frame() + input_offset);
+       TempoMetric metric = tmap.metric_at (transport_frame + input_offset);
+       Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (transport_frame + input_offset);
 
        if (outDeltaSampleOffsetToNextBeat) {
                if (bbt.ticks == 0) {
@@ -1808,7 +1815,7 @@ AUPlugin::get_musical_time_location_callback (UInt32*   outDeltaSampleOffsetToNe
                        *outDeltaSampleOffsetToNextBeat = 0;
                } else {
                        double const beat_frac_to_next = (Timecode::BBT_Time::ticks_per_beat - bbt.ticks) / Timecode::BBT_Time::ticks_per_beat;
-                       *outDeltaSampleOffsetToNextBeat = tmap.frame_at_beat (tmap.beat_at_frame (_session.transport_frame() + input_offset) + beat_frac_to_next);
+                       *outDeltaSampleOffsetToNextBeat = tmap.frame_at_beat (tmap.beat_at_frame (transport_frame + input_offset) + beat_frac_to_next);
                }
        }
 
@@ -1842,22 +1849,20 @@ AUPlugin::get_transport_state_callback (Boolean*  outIsPlaying,
                                        Float64*  outCycleStartBeat,
                                        Float64*  outCycleEndBeat)
 {
-       bool rolling;
-       float speed;
+       const bool rolling = (transport_speed != 0);
+       const bool last_transport_rolling = (last_transport_speed != 0);
 
        DEBUG_TRACE (DEBUG::AudioUnits, "AU calls ardour transport state callback\n");
 
-       rolling = _session.transport_rolling();
-       speed = _session.transport_speed ();
 
        if (outIsPlaying) {
-               *outIsPlaying = _session.transport_rolling();
+               *outIsPlaying = rolling;
        }
 
        if (outTransportStateChanged) {
                if (rolling != last_transport_rolling) {
                        *outTransportStateChanged = true;
-               } else if (speed != last_transport_speed) {
+               } else if (transport_speed != last_transport_speed) {
                        *outTransportStateChanged = true;
                } else {
                        *outTransportStateChanged = false;
@@ -1868,13 +1873,14 @@ AUPlugin::get_transport_state_callback (Boolean*  outIsPlaying,
                /* this assumes that the AU can only call this host callback from render context,
                   where input_offset is valid.
                */
-               *outCurrentSampleInTimeLine = _session.transport_frame() + input_offset;
+               *outCurrentSampleInTimeLine = transport_frame + input_offset;
        }
 
        if (outIsCycling) {
+               // TODO check bounce-processing
                Location* loc = _session.locations()->auto_loop_location();
 
-               *outIsCycling = (loc && _session.transport_rolling() && _session.get_play_loop());
+               *outIsCycling = (loc && rolling && _session.get_play_loop());
 
                if (*outIsCycling) {
 
@@ -1919,8 +1925,7 @@ AUPlugin::get_transport_state_callback (Boolean*  outIsPlaying,
                }
        }
 
-       last_transport_rolling = rolling;
-       last_transport_speed = speed;
+       last_transport_speed = transport_speed;
 
        return noErr;
 }
index ce4a546fb417f8503465d5cc2aef3151bcc85f44..755a00c4c4565c69da82929c8c7e928fc12baf35 100644 (file)
@@ -46,7 +46,7 @@ CapturingProcessor::set_block_size (pframes_t nframes)
 }
 
 void
-CapturingProcessor::run (BufferSet& bufs, framepos_t, framepos_t, pframes_t nframes, bool)
+CapturingProcessor::run (BufferSet& bufs, framepos_t, framepos_t, double, pframes_t nframes, bool)
 {
        if (active()) {
                capture_buffers.read_from (bufs, nframes);
index 26b6ce619eb14f2a799e14c46b9cf979ca6f963e..eda85f0dfd138eaff255a354c014aceef25a08c2 100644 (file)
@@ -50,7 +50,7 @@ DelayLine::~DelayLine ()
 
 #define FADE_LEN (16)
 void
-DelayLine::run (BufferSet& bufs, framepos_t /* start_frame */, framepos_t /* end_frame */, pframes_t nsamples, bool)
+DelayLine::run (BufferSet& bufs, framepos_t /* start_frame */, framepos_t /* end_frame */, double /* speed */, pframes_t nsamples, bool)
 {
        const uint32_t chn = _configured_output.n_audio();
        pframes_t p0 = 0;
index ed1c89a3e262dbf9fab670c07343b49254f7de5a..565a6740fd193e8b862f9a9990b70a9cc4f26971 100644 (file)
@@ -229,7 +229,7 @@ Delivery::configure_io (ChanCount in, ChanCount out)
 }
 
 void
-Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool result_required)
+Delivery::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double /*speed*/, pframes_t nframes, bool result_required)
 {
        assert (_output);
 
index 4947231c84717b9836a405c7d5dfc09eaa7aa6f3..e42c067454823d7bc1341df08123f3c48e131424 100644 (file)
@@ -32,7 +32,7 @@ InternalReturn::InternalReturn (Session& s)
 }
 
 void
-InternalReturn::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool)
+InternalReturn::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double /*speed*/, pframes_t nframes, bool)
 {
        if (!_active && !_pending_active) {
                return;
index 1c42993d4fa91247b2cce263507c4f4a58c939d0..0f7d633ba048be4f9e00cc94a8b63ffa49694ee3 100644 (file)
@@ -133,7 +133,7 @@ InternalSend::send_to_going_away ()
 }
 
 void
-InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
+InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool)
 {
        if ((!_active && !_pending_active) || !_send_to) {
                _meter->reset ();
@@ -213,9 +213,9 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
 
        _amp->set_gain_automation_buffer (_session.send_gain_automation_buffer ());
        _amp->setup_gain_automation (start_frame, end_frame, nframes);
-       _amp->run (mixbufs, start_frame, end_frame, nframes, true);
+       _amp->run (mixbufs, start_frame, end_frame, speed, nframes, true);
 
-       _delayline->run (mixbufs, start_frame, end_frame, nframes, true);
+       _delayline->run (mixbufs, start_frame, end_frame, speed, nframes, true);
 
        /* consider metering */
 
@@ -223,7 +223,7 @@ InternalSend::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
                if (_amp->gain_control()->get_value() == GAIN_COEFF_ZERO) {
                        _meter->reset();
                } else {
-                       _meter->run (mixbufs, start_frame, end_frame, nframes, true);
+                       _meter->run (mixbufs, start_frame, end_frame, speed, nframes, true);
                }
        }
 
index 9f880c5b91c6a849ee4792f0e42e405f181a7659..6d15d5847874acb0e42e8ae4efb3d56e2d716829 100644 (file)
@@ -1675,7 +1675,7 @@ IO::connected_to (const string& str) const
  *  Caller must hold process lock.
  */
 void
-IO::process_input (boost::shared_ptr<Processor> proc, framepos_t start_frame, framepos_t end_frame, pframes_t nframes)
+IO::process_input (boost::shared_ptr<Processor> proc, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes)
 {
        /* don't read the data into new buffers - just use the port buffers directly */
 
@@ -1686,7 +1686,7 @@ IO::process_input (boost::shared_ptr<Processor> proc, framepos_t start_frame, fr
 
        _buffers.get_backend_port_addresses (_ports, nframes);
        if (proc) {
-               proc->run (_buffers, start_frame, end_frame, nframes, true);
+               proc->run (_buffers, start_frame, end_frame, speed, nframes, true);
        }
 }
 
index 955447a3869f67390994088f7e50350278e6282a..3af3d67de4b36a3a69279dbbf52022f67aaa2586 100644 (file)
@@ -240,7 +240,7 @@ IOProcessor::set_state_2X (const XMLNode& node, int version)
 }
 
 void
-IOProcessor::silence (framecnt_t nframes)
+IOProcessor::silence (framecnt_t nframes, framepos_t /* start_frame */)
 {
        if (_own_output && _output) {
                _output->silence (nframes);
index 787079198f6e88272b014d0e65dfb38fae68afb6..cfff3a5ee66dba53be5cfa6b9bf8c1b534cdc736 100644 (file)
@@ -566,10 +566,11 @@ LadspaPlugin::automatable () const
 
 int
 LadspaPlugin::connect_and_run (BufferSet& bufs,
+               framepos_t start, framepos_t end, double speed,
                ChanMapping in_map, ChanMapping out_map,
                pframes_t nframes, framecnt_t offset)
 {
-       Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
+       Plugin::connect_and_run (bufs, start, end, speed, in_map, out_map, nframes, offset);
 
        cycles_t now;
        cycles_t then = get_cycles ();
index fc899ba4add1cb5e2720cc575a1a0b4ffa1b92c6..da7be47d21c4f83c2f41baecb632865f4f949d3b 100644 (file)
@@ -613,6 +613,7 @@ LuaProc::configure_io (ChanCount in, ChanCount out)
 
 int
 LuaProc::connect_and_run (BufferSet& bufs,
+               framepos_t start, framepos_t end, double speed,
                ChanMapping in, ChanMapping out,
                pframes_t nframes, framecnt_t offset)
 {
@@ -620,7 +621,7 @@ LuaProc::connect_and_run (BufferSet& bufs,
                return 0;
        }
 
-       Plugin::connect_and_run (bufs, in, out, nframes, offset);
+       Plugin::connect_and_run (bufs, start, end, speed, in, out, nframes, offset);
 
        // This is needed for ARDOUR::Session requests :(
        if (! SessionEvent::has_per_thread_pool ()) {
index ce090a79a40adbaa0d59f426dd2b0375d07a160e..cd0f9a94678ef12cd47a28e944702553800b6878 100644 (file)
@@ -2248,17 +2248,18 @@ write_position(LV2_Atom_Forge*     forge,
 
 int
 LV2Plugin::connect_and_run(BufferSet& bufs,
-       ChanMapping in_map, ChanMapping out_map,
-       pframes_t nframes, framecnt_t offset)
+               framepos_t start, framepos_t end, double speed,
+               ChanMapping in_map, ChanMapping out_map,
+               pframes_t nframes, framecnt_t offset)
 {
        DEBUG_TRACE(DEBUG::LV2, string_compose("%1 run %2 offset %3\n", name(), nframes, offset));
-       Plugin::connect_and_run(bufs, in_map, out_map, nframes, offset);
+       Plugin::connect_and_run(bufs, start, end, speed, in_map, out_map, nframes, offset);
 
        cycles_t then = get_cycles();
 
        TempoMap&               tmap     = _session.tempo_map();
        Metrics::const_iterator metric_i = tmap.metrics_end();
-       TempoMetric             tmetric  = tmap.metric_at(_session.transport_frame(), &metric_i);
+       TempoMetric             tmetric  = tmap.metric_at(start, &metric_i);
 
        if (_freewheel_control_port) {
                *_freewheel_control_port = _session.engine().freewheeling() ? 1.f : 0.f;
@@ -2269,7 +2270,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
        }
 
 #ifdef LV2_EXTENDED
-       if (_can_write_automation && _session.transport_frame() != _next_cycle_start) {
+       if (_can_write_automation && start != _next_cycle_start) {
                // add guard-points after locating
                for (AutomationCtrlMap::iterator i = _ctrl_map.begin(); i != _ctrl_map.end(); ++i) {
                        i->second->guard = true;
@@ -2337,13 +2338,12 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                        if (valid && (flags & PORT_INPUT)) {
                                Timecode::BBT_Time bbt;
                                if ((flags & PORT_POSITION)) {
-                                       if (_session.transport_frame() != _next_cycle_start ||
-                                           _session.transport_speed() != _next_cycle_speed) {
+                                       if (start != _next_cycle_start ||
+                                           speed != _next_cycle_speed) {
                                                // Transport has changed, write position at cycle start
-                                               bbt = tmap.bbt_at_frame (_session.transport_frame());
+                                               bbt = tmap.bbt_at_frame (start);
                                                write_position(&_impl->forge, _ev_buffers[port_index],
-                                                              tmetric, bbt, _session.transport_speed(),
-                                                              _session.transport_frame(), 0);
+                                                              tmetric, bbt, speed, start, 0);
                                        }
                                }
 
@@ -2357,7 +2357,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
 
                                // Now merge MIDI and any transport events into the buffer
                                const uint32_t     type = _uri_map.urids.midi_MidiEvent;
-                               const framepos_t   tend = _session.transport_frame() + nframes;
+                               const framepos_t   tend = end;
                                ++metric_i;
                                while (m != m_end || (metric_i != tmap.metrics_end() &&
                                                      (*metric_i)->frame() < tend)) {
@@ -2374,9 +2374,9 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                                                tmetric.set_metric(metric);
                                                bbt = tmap.bbt_at_pulse (metric->pulse());
                                                write_position(&_impl->forge, _ev_buffers[port_index],
-                                                              tmetric, bbt, _session.transport_speed(),
+                                                              tmetric, bbt, speed,
                                                               metric->frame(),
-                                                              metric->frame() - _session.transport_frame());
+                                                              metric->frame() - start);
                                                ++metric_i;
                                        }
                                }
@@ -2497,8 +2497,8 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                                                                if (c &&
                                                                     (c->ac->automation_state() == Touch || c->ac->automation_state() == Write)
                                                                   ) {
-                                                                       framepos_t when = std::max ((framepos_t) 0, _session.transport_frame() + frames - _current_latency);
-                                                                       assert (_session.transport_frame() + frames - _current_latency >= 0);
+                                                                       framepos_t when = std::max ((framepos_t) 0, start + frames - _current_latency);
+                                                                       assert (start + frames - _current_latency >= 0);
                                                                        if (c->guard) {
                                                                                c->guard = false;
                                                                                c->ac->list()->add (when, v, true, true);
@@ -2560,7 +2560,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                                                                AutomationCtrlPtr c = get_automation_control (p);
                                                                DEBUG_TRACE(DEBUG::LV2Automate, string_compose ("Start Touch p: %1\n", p));
                                                                if (c) {
-                                                                       c->ac->start_touch (std::max ((framepos_t)0, _session.transport_frame() - _current_latency));
+                                                                       c->ac->start_touch (std::max ((framepos_t)0, start - _current_latency));
                                                                        c->guard = true;
                                                                }
                                                        }
@@ -2575,7 +2575,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
                                                                AutomationCtrlPtr c = get_automation_control (p);
                                                                DEBUG_TRACE(DEBUG::LV2Automate, string_compose ("End Touch p: %1\n", p));
                                                                if (c) {
-                                                                       c->ac->stop_touch (true, std::max ((framepos_t)0, _session.transport_frame() - _current_latency));
+                                                                       c->ac->stop_touch (true, std::max ((framepos_t)0, start - _current_latency));
                                                                }
                                                        }
                                                }
@@ -2625,8 +2625,8 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
        set_cycles((uint32_t)(now - then));
 
        // Update expected transport information for next cycle so we can detect changes
-       _next_cycle_speed = _session.transport_speed();
-       _next_cycle_start = _session.transport_frame() + (nframes * _next_cycle_speed);
+       _next_cycle_speed = speed;
+       _next_cycle_start = end;
 
        if (_latency_control_port) {
                framecnt_t new_latency = signal_latency ();
index 72a2f82cb1f49f4ef7580db5ecd348989aa32596..bb6e3eb29ce67356c1e6982f7fb3e50ca8335d42 100644 (file)
@@ -78,7 +78,7 @@ PeakMeter::~PeakMeter ()
  * (runs in jack realtime context)
  */
 void
-PeakMeter::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool)
+PeakMeter::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double /*speed*/, pframes_t nframes, bool)
 {
        if (!_active && !_pending_active) {
                return;
index 97ddb43f6f257d490f8853d80a0a8d52d82de0fd..e9efb2fc17d992f688534e8149715594ef51fd21 100644 (file)
@@ -404,7 +404,7 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
        _capture_filter.filter (bufs);
 
        if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) {
-               _meter->run (bufs, start_frame, end_frame, nframes, true);
+               _meter->run (bufs, start_frame, end_frame, 1.0 /*speed()*/, nframes, true);
        }
 
 
index e5c58009af764fccd9b0f6e3302039ca8e8b4779..f9bff99c19bb5797fdb6f0a22571fdcc8c8775e2 100644 (file)
@@ -270,7 +270,7 @@ MonitorProcessor::state (bool full)
 }
 
 void
-MonitorProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool /*result_required*/)
+MonitorProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double /*speed*/, pframes_t nframes, bool /*result_required*/)
 {
         uint32_t chn = 0;
         gain_t target_gain;
index 8c1dd81d26d37b6f62d3ca617d8a95955822c8e5..81982c156d6baf2f47c2113e7615a8ec6934bff4 100644 (file)
@@ -329,8 +329,9 @@ Plugin::preset_by_uri (const string& uri)
 
 int
 Plugin::connect_and_run (BufferSet& bufs,
-                        ChanMapping /*in_map*/, ChanMapping /*out_map*/,
-                        pframes_t /* nframes */, framecnt_t /*offset*/)
+               framepos_t /*start*/, framepos_t /*end*/, double /*speed*/,
+               ChanMapping /*in_map*/, ChanMapping /*out_map*/,
+               pframes_t /* nframes */, framecnt_t /*offset*/)
 {
        if (bufs.count().n_midi() > 0) {
 
index 38c3b684eda9e898ac2f92eac28025f019959a90..fd595c0d23471320600cd9941d85c366360421d9 100644 (file)
@@ -593,7 +593,7 @@ PluginInsert::inplace_silence_unconnected (BufferSet& bufs, const PinMappings& o
 }
 
 void
-PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t offset, bool with_auto, framepos_t now)
+PluginInsert::connect_and_run (BufferSet& bufs, framepos_t start, framepos_t end, double speed, pframes_t nframes, framecnt_t offset, bool with_auto)
 {
        // TODO: atomically copy maps & _no_inplace
        PinMappings in_map (_in_map);
@@ -661,7 +661,7 @@ PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t of
                        if (c->list() && c->automation_playback()) {
                                bool valid;
 
-                               const float val = c->list()->rt_safe_eval (now, valid);
+                               const float val = c->list()->rt_safe_eval (start, valid);
 
                                if (valid) {
                                        /* This is the ONLY place where we are
@@ -709,7 +709,7 @@ PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t of
                        ChanMapping mb_in_map (ChanCount::min (_configured_in, ChanCount (DataType::AUDIO, 2)));
                        ChanMapping mb_out_map (ChanCount::min (_configured_out, ChanCount (DataType::AUDIO, 2)));
 
-                       _plugins.front()->connect_and_run (bufs, mb_in_map, mb_out_map, nframes, offset);
+                       _plugins.front()->connect_and_run (bufs, start, end, speed, mb_in_map, mb_out_map, nframes, offset);
 
                        for (uint32_t out = _configured_in.n_audio (); out < bufs.count().get (DataType::AUDIO); ++out) {
                                bufs.get (DataType::AUDIO, out).silence (nframes, offset);
@@ -785,7 +785,7 @@ PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t of
                                i_out_map.offset_to (*t, natural_input_streams ().get (*t));
                        }
 
-                       if ((*i)->connect_and_run (inplace_bufs, i_in_map, i_out_map, nframes, offset)) {
+                       if ((*i)->connect_and_run (inplace_bufs, start, end, speed, i_in_map, i_out_map, nframes, offset)) {
                                deactivate ();
                        }
                }
@@ -815,7 +815,7 @@ PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t of
                /* in-place processing */
                uint32_t pc = 0;
                for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i, ++pc) {
-                       if ((*i)->connect_and_run(bufs, in_map[pc], out_map[pc], nframes, offset)) {
+                       if ((*i)->connect_and_run(bufs, start, end, speed, in_map[pc], out_map[pc], nframes, offset)) {
                                deactivate ();
                        }
                }
@@ -962,7 +962,7 @@ PluginInsert::bypass (BufferSet& bufs, pframes_t nframes)
 }
 
 void
-PluginInsert::silence (framecnt_t nframes)
+PluginInsert::silence (framecnt_t nframes, framepos_t start_frame)
 {
        if (!active ()) {
                return;
@@ -976,17 +976,17 @@ PluginInsert::silence (framecnt_t nframes)
 #ifdef MIXBUS
        if (is_channelstrip ()) {
                if (_configured_in.n_audio() > 0) {
-                       _plugins.front()->connect_and_run (_session.get_scratch_buffers (maxbuf, true), in_map, out_map, nframes, 0);
+                       _plugins.front()->connect_and_run (_session.get_scratch_buffers (maxbuf, true), start_frame, start_frame + nframes, 1.0 in_map, out_map, nframes);
                }
        } else
 #endif
        for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) {
-               (*i)->connect_and_run (_session.get_scratch_buffers (maxbuf, true), in_map, out_map, nframes, 0);
+               (*i)->connect_and_run (_session.get_scratch_buffers (maxbuf, true), start_frame, start_frame + nframes, 1.0, in_map, out_map, nframes, 0);
        }
 }
 
 void
-PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
+PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool)
 {
        if (_pending_active) {
                /* run as normal if we are active or moving from inactive to active */
@@ -994,13 +994,13 @@ PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
                if (_sidechain) {
                        // collect sidechain input for complete cycle (!)
                        // TODO we need delaylines here for latency compensation
-                       _sidechain->run (bufs, start_frame, end_frame, nframes, true);
+                       _sidechain->run (bufs, start_frame, end_frame, speed, nframes, true);
                }
 
                if (_session.transport_rolling() || _session.bounce_processing()) {
-                       automation_run (bufs, start_frame, nframes);
+                       automation_run (bufs, start_frame, end_frame, speed, nframes);
                } else {
-                       connect_and_run (bufs, nframes, 0, false);
+                       connect_and_run (bufs, start_frame, end_frame, speed, nframes, 0, false);
                }
 
        } else {
@@ -1016,39 +1016,37 @@ PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
 }
 
 void
-PluginInsert::automation_run (BufferSet& bufs, framepos_t start, pframes_t nframes)
+PluginInsert::automation_run (BufferSet& bufs, framepos_t start, framepos_t end, double speed, pframes_t nframes)
 {
        Evoral::ControlEvent next_event (0, 0.0f);
-       framepos_t now = start;
-       framepos_t end = now + nframes;
        framecnt_t offset = 0;
 
        Glib::Threads::Mutex::Lock lm (control_lock(), Glib::Threads::TRY_LOCK);
 
        if (!lm.locked()) {
-               connect_and_run (bufs, nframes, offset, false);
+               connect_and_run (bufs, start, end, speed, nframes, offset, false);
                return;
        }
 
-       if (!find_next_event (now, end, next_event) || _plugins.front()->requires_fixed_sized_buffers()) {
+       if (!find_next_event (start, end, next_event) || _plugins.front()->requires_fixed_sized_buffers()) {
 
                /* no events have a time within the relevant range */
 
-               connect_and_run (bufs, nframes, offset, true, now);
+               connect_and_run (bufs, start, end, speed, nframes, offset, true);
                return;
        }
 
        while (nframes) {
 
-               framecnt_t cnt = min (((framecnt_t) ceil (next_event.when) - now), (framecnt_t) nframes);
+               framecnt_t cnt = min (((framecnt_t) ceil (next_event.when) - start), (framecnt_t) nframes);
 
-               connect_and_run (bufs, cnt, offset, true, now);
+               connect_and_run (bufs, start, start + cnt, speed, cnt, offset, true); // XXX (start + cnt) * speed
 
                nframes -= cnt;
                offset += cnt;
-               now += cnt;
+               start += cnt;
 
-               if (!find_next_event (now, end, next_event)) {
+               if (!find_next_event (start, end, next_event)) {
                        break;
                }
        }
@@ -1056,7 +1054,7 @@ PluginInsert::automation_run (BufferSet& bufs, framepos_t start, pframes_t nfram
        /* cleanup anything that is left to do */
 
        if (nframes) {
-               connect_and_run (bufs, nframes, offset, true, now);
+               connect_and_run (bufs, start, start + nframes, speed, nframes, offset, true);
        }
 }
 
index 8ec5ead530b66da5b1e41b83dc7854db58e91178..d38279c08c44858be43b6e9a4d6655bc585d3c8f 100644 (file)
@@ -107,7 +107,7 @@ PortInsert::latency() const
 }
 
 void
-PortInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
+PortInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool)
 {
        if (_output->n_ports().n_total() == 0) {
                return;
@@ -134,7 +134,7 @@ PortInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
                    hear the remnants of whatever MTDM pumped into the pipeline.
                 */
 
-                silence (nframes);
+                silence (nframes, start_frame);
 
                 if (_latency_flush_frames > nframes) {
                         _latency_flush_frames -= nframes;
@@ -147,11 +147,11 @@ PortInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame,
 
        if (!_active && !_pending_active) {
                /* deliver silence */
-               silence (nframes);
+               silence (nframes, start_frame);
                goto out;
        }
 
-       _out->run (bufs, start_frame, end_frame, nframes, true);
+       _out->run (bufs, start_frame, end_frame, speed, nframes, true);
        _input->collect_input (bufs, nframes, ChanCount::ZERO);
 
   out:
index 9c0f19ab03f37081d39979295b8a767cec0674a1..cb61b0767aa025a2d2e569de509b79db6f58bea5 100644 (file)
@@ -115,7 +115,7 @@ Return::set_state (const XMLNode& node, int version)
 }
 
 void
-Return::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
+Return::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool)
 {
        if ((!_active && !_pending_active) || _input->n_ports() == ChanCount::ZERO) {
                return;
@@ -127,13 +127,13 @@ Return::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pfra
        // Can't automate gain for sends or returns yet because we need different buffers
        // so that we don't overwrite the main automation data for the route amp
        // _amp->setup_gain_automation (start_frame, end_frame, nframes);
-       _amp->run (bufs, start_frame, end_frame, nframes, true);
+       _amp->run (bufs, start_frame, end_frame, speed, nframes, true);
 
        if (_metering) {
                if (_amp->gain_control()->get_value() == 0) {
                        _meter->reset();
                } else {
-                       _meter->run (bufs, start_frame, end_frame, nframes, true);
+                       _meter->run (bufs, start_frame, end_frame, speed, nframes, true);
                }
        }
 
index 6209b9f91159a11507e14b31c7dfeee9a1109fcd..15848df31e5ca73b4856f44353c233e5b090b47d 100644 (file)
@@ -415,6 +415,7 @@ Route::process_output_buffers (BufferSet& bufs,
        bool const meter_already_run = metering_state() == MeteringInput;
 
        framecnt_t latency = 0;
+       const double speed = _session.transport_speed ();
 
        for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) {
 
@@ -450,7 +451,7 @@ Route::process_output_buffers (BufferSet& bufs,
                                        _initial_delay + latency, longest_session_latency - latency);
                }
 
-               (*i)->run (bufs, start_frame - latency, end_frame - latency, nframes, *i != _processors.back());
+               (*i)->run (bufs, start_frame - latency, end_frame - latency, speed, nframes, *i != _processors.back());
                bufs.set_count ((*i)->output_streams());
 
                if ((*i)->active ()) {
@@ -478,6 +479,7 @@ Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
        _trim->setup_gain_automation (start, start + nframes, nframes);
 
        latency = 0;
+       const double speed = _session.transport_speed ();
        for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
 
                if (!include_endpoint && (*i) == endpoint) {
@@ -500,7 +502,7 @@ Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
                 */
                if ((*i) == _main_outs) {
                        assert ((*i)->does_routing());
-                       (*i)->run (buffers, start - latency, start - latency + nframes, nframes, true);
+                       (*i)->run (buffers, start - latency, start - latency + nframes, speed, nframes, true);
                        buffers.set_count ((*i)->output_streams());
                }
 
@@ -508,7 +510,7 @@ Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
                 * Also don't bother with metering.
                 */
                if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) {
-                       (*i)->run (buffers, start - latency, start - latency + nframes, nframes, true);
+                       (*i)->run (buffers, start - latency, start - latency + nframes, 1.0, nframes, true);
                        buffers.set_count ((*i)->output_streams());
                        latency += (*i)->signal_latency ();
                }
@@ -2890,6 +2892,8 @@ Route::silence_unlocked (framecnt_t nframes)
 {
        /* Must be called with the processor lock held */
 
+       const framepos_t now = _session.transport_frame ();
+
        if (!_silent) {
 
                _output->silence (nframes);
@@ -2902,7 +2906,7 @@ Route::silence_unlocked (framecnt_t nframes)
                                continue;
                        }
 
-                       (*i)->silence (nframes);
+                       (*i)->silence (nframes, now);
                }
 
                if (nframes == _session.get_block_size()) {
@@ -3432,7 +3436,7 @@ Route::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
        fill_buffers_with_input (bufs, _input, nframes);
 
        if (_meter_point == MeterInput) {
-               _meter->run (bufs, start_frame, end_frame, nframes, true);
+               _meter->run (bufs, start_frame, end_frame, 0.0, nframes, true);
        }
 
        _amp->apply_gain_automation (false);
@@ -3472,7 +3476,7 @@ Route::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame, in
        fill_buffers_with_input (bufs, _input, nframes);
 
        if (_meter_point == MeterInput) {
-               _meter->run (bufs, start_frame, end_frame, nframes, true);
+               _meter->run (bufs, start_frame, end_frame, 1.0, nframes, true);
        }
 
        passthru (bufs, start_frame, end_frame, nframes, declick);
index 8f7afc7c8fc4d5ab7e5cf5865e721fee86703fd1..2ad08736dfa1d0c26035a70029442e5bf8b64f2c 100644 (file)
@@ -159,7 +159,7 @@ Send::set_delay_out(framecnt_t delay)
 }
 
 void
-Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
+Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool)
 {
        if (_output->n_ports() == ChanCount::ZERO) {
                _meter->reset ();
@@ -185,13 +185,13 @@ Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframe
 
        _amp->set_gain_automation_buffer (_session.send_gain_automation_buffer ());
        _amp->setup_gain_automation (start_frame, end_frame, nframes);
-       _amp->run (sendbufs, start_frame, end_frame, nframes, true);
+       _amp->run (sendbufs, start_frame, end_frame, speed, nframes, true);
 
-       _delayline->run (sendbufs, start_frame, end_frame, nframes, true);
+       _delayline->run (sendbufs, start_frame, end_frame, speed, nframes, true);
 
        /* deliver to outputs */
 
-       Delivery::run (sendbufs, start_frame, end_frame, nframes, true);
+       Delivery::run (sendbufs, start_frame, end_frame, speed, nframes, true);
 
        /* consider metering */
 
@@ -199,7 +199,7 @@ Send::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframe
                if (_amp->gain_control()->get_value() == 0) {
                        _meter->reset();
                } else {
-                       _meter->run (*_output_buffers, start_frame, end_frame, nframes, true);
+                       _meter->run (*_output_buffers, start_frame, end_frame, speed, nframes, true);
                }
        }
 
index 872828e57ecf64df2e481f2f31865508d0dfa9ae..969fdabb825dc3a7370f16c9a0c41654e98a888f 100644 (file)
@@ -133,7 +133,7 @@ Session::click (framepos_t start, framecnt_t nframes)
                }
        }
 
-       _click_gain->run (bufs, 0, 0, nframes, false);
+       _click_gain->run (bufs, 0, 0, 1.0, nframes, false);
        _click_io->copy_to_outputs (bufs, DataType::AUDIO, nframes, 0);
 }
 
index 3ee5d5889cdd1dec6c57055ed1be652b1c80acbc..4cce5219ac11248a95e7ba637170764752dcdc61 100644 (file)
@@ -200,8 +200,8 @@ intptr_t Session::vst_callback (
 
                timeinfo->nanoSeconds = g_get_monotonic_time () * 1000;
 
-               if (session) {
-                       framepos_t now = session->transport_frame();
+               if (plug && session) {
+                       framepos_t now = plug->transport_frame();
 
                        timeinfo->samplePos = now;
                        timeinfo->sampleRate = session->frame_rate();
@@ -280,7 +280,7 @@ intptr_t Session::vst_callback (
                                newflags |= kVstTransportRecording;
                        }
 
-                       if (session->transport_speed () != 0.0f) {
+                       if (plug->transport_speed () != 0.0f) {
                                newflags |= kVstTransportPlaying;
                        }
 
index badbd63edf666784b7407a4831cc260c0060cc4b..0ac1e3227b56c5cc0b6415cdde69b2522b8d811b 100644 (file)
@@ -61,7 +61,7 @@ SideChain::set_state (const XMLNode& node, int version)
 }
 
 void
-SideChain::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, pframes_t nframes, bool)
+SideChain::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame, double /*speed*/, pframes_t nframes, bool)
 {
        if (_input->n_ports () == ChanCount::ZERO) {
                // inplace pass-through
index 75cb689441efc2a8063bd5351ef87bf924f89f1b..0c586e4a0e0603c4c5a3000d586a5d36233dc808 100644 (file)
@@ -444,10 +444,10 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
 
                        if (no_meter) {
                                BufferSet& bufs (_session.get_silent_buffers (n_process_buffers()));
-                               _meter->run (bufs, 0, 0, nframes, true);
-                               _input->process_input (boost::shared_ptr<Processor>(), start_frame, end_frame, nframes);
+                               _meter->run (bufs, start_frame, end_frame, 1.0, nframes, true);
+                               _input->process_input (boost::shared_ptr<Processor>(), start_frame, end_frame, speed(), nframes);
                        } else {
-                               _input->process_input (_meter, start_frame, end_frame, nframes);
+                               _input->process_input (_meter, start_frame, end_frame, speed(), nframes);
                        }
                }
 
@@ -460,7 +460,7 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
                fill_buffers_with_input (bufs, _input, nframes);
 
                if (_meter_point == MeterInput) {
-                       _meter->run (bufs, start_frame, end_frame, nframes, true);
+                       _meter->run (bufs, start_frame, end_frame, 1.0 /*speed()*/, nframes, true);
                }
 
                passthru (bufs, start_frame, end_frame, nframes, false);
index e7f738507dcacee814cfd4ab4e6fcdcb1d747214..1f710d4c4c6f69fe34e1757d412698f6effa79b2 100644 (file)
@@ -111,7 +111,7 @@ UnknownProcessor::can_support_io_configuration (const ChanCount &in, ChanCount &
 }
 
 void
-UnknownProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, pframes_t nframes, bool)
+UnknownProcessor::run (BufferSet& bufs, framepos_t /*start_frame*/, framepos_t /*end_frame*/, double /*speed*/, pframes_t nframes, bool)
 {
        if (!have_ioconfig) {
                return;
index 3b7f9776d0abb4563419df28c759e7e4f65cf937..b517b480b6f4a504a95a0b60b07c91583723daa8 100644 (file)
@@ -46,6 +46,8 @@ VSTPlugin::VSTPlugin (AudioEngine& engine, Session& session, VSTHandle* handle)
        , _plugin (0)
        , _pi (0)
        , _num (0)
+       , _transport_frame (0)
+       , _transport_speed (0.f)
 {
        memset (&_timeInfo, 0, sizeof(_timeInfo));
 }
@@ -533,10 +535,14 @@ VSTPlugin::automatable () const
 
 int
 VSTPlugin::connect_and_run (BufferSet& bufs,
+               framepos_t start, framepos_t end, double speed,
                ChanMapping in_map, ChanMapping out_map,
                pframes_t nframes, framecnt_t offset)
 {
-       Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
+       Plugin::connect_and_run(bufs, start, end, speed, in_map, out_map, nframes, offset);
+
+       _transport_frame = start;
+       _transport_speed = speed;
 
        ChanCount bufs_count;
        bufs_count.set(DataType::AUDIO, 1);