major internal plugin & processor API change:

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.
This commit is contained in:
Robin Gareus 2016-06-25 02:23:56 +02:00
parent 6a12022ccf
commit e9a8ccc7e2
53 changed files with 171 additions and 142 deletions

View file

@ -343,7 +343,7 @@ PluginEqGui::run_impulse_analysis()
ARDOUR::ChanMapping out_map(_plugin->get_info()->n_outputs); ARDOUR::ChanMapping out_map(_plugin->get_info()->n_outputs);
_plugin->set_block_size (_buffer_size); _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 (); framecnt_t f = _plugin->signal_latency ();
// Adding user_latency() could be interesting // Adding user_latency() could be interesting
@ -402,7 +402,7 @@ PluginEqGui::run_impulse_analysis()
in_map = ARDOUR::ChanMapping(_plugin->get_info()->n_inputs); in_map = ARDOUR::ChanMapping(_plugin->get_info()->n_inputs);
out_map = ARDOUR::ChanMapping(_plugin->get_info()->n_outputs); 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); } while ( frames_left > 0);

View file

@ -71,7 +71,7 @@ Amp::configure_io (ChanCount in, ChanCount out)
} }
void 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) { if (!_active && !_pending_active) {
return; return;

View file

@ -47,7 +47,7 @@ public:
bool can_support_io_configuration (const ChanCount& in, ChanCount& out); bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
bool configure_io (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; } bool apply_gain () const { return _apply_gain; }
void apply_gain (bool yn) { _apply_gain = yn; } void apply_gain (bool yn) { _apply_gain = yn; }

View file

@ -171,6 +171,8 @@ class LIBARDOUR_API AUPlugin : public ARDOUR::Plugin
std::vector<std::pair<int,int> > io_configs; std::vector<std::pair<int,int> > io_configs;
pframes_t _current_block_size; pframes_t _current_block_size;
framecnt_t _last_nframes; framecnt_t _last_nframes;
framepos_t _transport_frame;
framepos_t _transport_speed;
bool _requires_fixed_size_buffers; bool _requires_fixed_size_buffers;
AudioBufferList* buffers; AudioBufferList* buffers;
bool _has_midi_input; bool _has_midi_input;
@ -226,7 +228,8 @@ class LIBARDOUR_API AUPlugin : public ARDOUR::Plugin
void discover_factory_presets (); void discover_factory_presets ();
bool last_transport_rolling; framepos_t transport_frame;
float transport_speed;
floa t last_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); static void _parameter_change_listener (void* /*arg*/, void* /*src*/, const AudioUnitEvent* event, UInt64 host_time, Float32 new_value);

View file

@ -36,7 +36,7 @@ class LIBARDOUR_API CapturingProcessor : public Processor
public: // Processor overrides public: // Processor overrides
bool display_to_user() const { return false; } bool display_to_user() const { return false; }
int set_block_size (pframes_t nframes); 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 configure_io (ChanCount in, ChanCount out);
bool can_support_io_configuration (const ChanCount& in, ChanCount& out); bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
virtual XMLNode& state (bool); virtual XMLNode& state (bool);

View file

@ -42,7 +42,7 @@ public:
bool display_to_user() const { return false; } 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); void set_delay(framecnt_t signal_delay);
framecnt_t get_delay() { return _pending_delay; } framecnt_t get_delay() { return _pending_delay; }

View file

@ -71,7 +71,7 @@ public:
bool can_support_io_configuration (const ChanCount& in, ChanCount& out); bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
bool configure_io (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 */ /* supplemental method used with MIDI */

View file

@ -37,7 +37,7 @@ class LIBARDOUR_API InternalReturn : public Return
XMLNode& state (bool full); XMLNode& state (bool full);
XMLNode& get_state (); 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 configure_io (ChanCount, ChanCount);
bool can_support_io_configuration (const ChanCount& in, ChanCount& out); bool can_support_io_configuration (const ChanCount& in, ChanCount& out);

View file

@ -40,7 +40,7 @@ class LIBARDOUR_API InternalSend : public Send
int set_state(const XMLNode& node, int version); int set_state(const XMLNode& node, int version);
void cycle_start (pframes_t); 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 feeds (boost::shared_ptr<Route> other) const;
bool can_support_io_configuration (const ChanCount& in, ChanCount& out); bool can_support_io_configuration (const ChanCount& in, ChanCount& out);
bool configure_io (ChanCount in, ChanCount out); bool configure_io (ChanCount in, ChanCount out);

View 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 */ /* three utility functions - this just seems to be simplest place to put them */
void collect_input (BufferSet& bufs, pframes_t nframes, ChanCount offset); 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); void copy_to_outputs (BufferSet& bufs, DataType type, pframes_t nframes, framecnt_t offset);
/* AudioTrack::deprecated_use_diskstream_connections() needs these */ /* AudioTrack::deprecated_use_diskstream_connections() needs these */

View file

@ -64,7 +64,7 @@ class LIBARDOUR_API IOProcessor : public Processor
void set_input (boost::shared_ptr<IO>); void set_input (boost::shared_ptr<IO>);
void set_output (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 disconnect ();
void increment_port_buffer_offset (pframes_t); void increment_port_buffer_offset (pframes_t);

View file

@ -83,6 +83,7 @@ class LIBARDOUR_API LadspaPlugin : public ARDOUR::Plugin
int set_block_size (pframes_t /*nframes*/) { return 0; } int set_block_size (pframes_t /*nframes*/) { return 0; }
int connect_and_run (BufferSet& bufs, int connect_and_run (BufferSet& bufs,
framepos_t start, framepos_t end, double speed,
ChanMapping in, ChanMapping out, ChanMapping in, ChanMapping out,
pframes_t nframes, framecnt_t offset); pframes_t nframes, framecnt_t offset);

View file

@ -75,6 +75,7 @@ public:
framecnt_t signal_latency() const { return 0; } framecnt_t signal_latency() const { return 0; }
int connect_and_run (BufferSet& bufs, int connect_and_run (BufferSet& bufs,
framepos_t start, framepos_t end, double speed,
ChanMapping in, ChanMapping out, ChanMapping in, ChanMapping out,
pframes_t nframes, framecnt_t offset); pframes_t nframes, framecnt_t offset);

View file

@ -108,6 +108,7 @@ class LIBARDOUR_API LV2Plugin : public ARDOUR::Plugin, public ARDOUR::Workee
bool requires_fixed_sized_buffers () const; bool requires_fixed_sized_buffers () const;
int connect_and_run (BufferSet& bufs, int connect_and_run (BufferSet& bufs,
framepos_t start, framepos_t end, double speed,
ChanMapping in, ChanMapping out, ChanMapping in, ChanMapping out,
pframes_t nframes, framecnt_t offset); pframes_t nframes, framecnt_t offset);

View file

@ -64,7 +64,7 @@ public:
void emit_configuration_changed (); void emit_configuration_changed ();
/** Compute peaks */ /** 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 activate () { }
void deactivate () { } void deactivate () { }

View file

@ -127,7 +127,7 @@ public:
bool display_to_user() const; 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); XMLNode& state (bool full);
int set_state (const XMLNode&, int /* version */); int set_state (const XMLNode&, int /* version */);

View file

@ -99,6 +99,7 @@ class LIBARDOUR_API Plugin : public PBD::StatefulDestructible, public Latent
virtual bool inplace_broken() const { return false; } virtual bool inplace_broken() const { return false; }
virtual int connect_and_run (BufferSet& bufs, virtual int connect_and_run (BufferSet& bufs,
framepos_t start, framepos_t end, double speed,
ChanMapping in, ChanMapping out, ChanMapping in, ChanMapping out,
pframes_t nframes, framecnt_t offset); pframes_t nframes, framecnt_t offset);

View file

@ -61,8 +61,8 @@ class LIBARDOUR_API PluginInsert : public Processor
void update_id (PBD::ID); void update_id (PBD::ID);
void set_state_dir (const std::string& d = ""); 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 run (BufferSet& in, framepos_t start_frame, framepos_t end_frame, double speed, pframes_t nframes, bool);
void silence (framecnt_t nframes); void silence (framecnt_t nframes, framepos_t start_frame);
void activate (); void activate ();
void deactivate (); void deactivate ();
@ -344,8 +344,8 @@ class LIBARDOUR_API PluginInsert : public Processor
PinMappings _out_map; PinMappings _out_map;
ChanMapping _thru_map; // out-idx <= in-idx ChanMapping _thru_map; // out-idx <= in-idx
void automation_run (BufferSet& bufs, framepos_t start, pframes_t nframes); void automation_run (BufferSet& bufs, framepos_t start, framepos_t end, double speed, pframes_t nframes);
void connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t offset, bool with_auto, framepos_t now = 0); 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 bypass (BufferSet& bufs, pframes_t nframes);
void inplace_silence_unconnected (BufferSet&, const PinMappings&, framecnt_t nframes, framecnt_t offset) const; void inplace_silence_unconnected (BufferSet&, const PinMappings&, framecnt_t nframes, framecnt_t offset) const;

View file

@ -52,7 +52,7 @@ class LIBARDOUR_API PortInsert : public IOProcessor
XMLNode& get_state(void); XMLNode& get_state(void);
int set_state (const XMLNode&, int version); 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; framecnt_t signal_latency () const;

View 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; /** @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. * 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 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*/) {} virtual void silence (framecnt_t /*nframes*/, framepos_t /*start_frame*/) {}
virtual void activate () { _pending_active = true; ActiveChanged(); } virtual void activate () { _pending_active = true; ActiveChanged(); }
virtual void deactivate () { _pending_active = false; ActiveChanged(); } virtual void deactivate () { _pending_active = false; ActiveChanged(); }

View file

@ -42,7 +42,7 @@ public:
uint32_t bit_slot() const { return _bitslot; } 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<Amp> amp() const { return _amp; }
boost::shared_ptr<PeakMeter> meter() const { return _meter; } boost::shared_ptr<PeakMeter> meter() const { return _meter; }

View file

@ -61,7 +61,7 @@ class LIBARDOUR_API Send : public Delivery
uint32_t pans_required() const { return _configured_input.n_audio(); } 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 can_support_io_configuration (const ChanCount& in, ChanCount& out);
bool configure_io (ChanCount in, ChanCount out); bool configure_io (ChanCount in, ChanCount out);

View 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)); } 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; } double transport_speed() const { return _transport_speed; }
bool transport_stopped() const { return _transport_speed == 0.0f; } bool transport_stopped() const { return _transport_speed == 0.0; }
bool transport_rolling() const { return _transport_speed != 0.0f; } bool transport_rolling() const { return _transport_speed != 0.0; }
bool silent () { return _silent; } bool silent () { return _silent; }

View file

@ -34,7 +34,7 @@ public:
SideChain (Session&, const std::string&); SideChain (Session&, const std::string&);
virtual ~SideChain (); 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 can_support_io_configuration (const ChanCount& in, ChanCount& out);
bool configure_io (ChanCount in, ChanCount out); bool configure_io (ChanCount in, ChanCount out);

View file

@ -46,7 +46,7 @@ public:
virtual ~UnknownProcessor (); virtual ~UnknownProcessor ();
bool can_support_io_configuration (const ChanCount &, ChanCount &); 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); XMLNode & state (bool);

View file

@ -63,8 +63,9 @@ public:
bool parameter_is_input (uint32_t) const { return true; } bool parameter_is_input (uint32_t) const { return true; }
bool parameter_is_output (uint32_t) const { return false; } bool parameter_is_output (uint32_t) const { return false; }
int connect_and_run ( int connect_and_run (BufferSet&,
BufferSet&, ChanMapping in, ChanMapping out, framepos_t start, framepos_t end, double speed,
ChanMapping in, ChanMapping out,
pframes_t nframes, framecnt_t offset pframes_t nframes, framecnt_t offset
); );
@ -89,6 +90,8 @@ public:
PluginInsert* plugin_insert () const { return _pi; } PluginInsert* plugin_insert () const { return _pi; }
uint32_t plugin_number () const { return _num; } uint32_t plugin_number () const { return _num; }
VstTimeInfo* timeinfo () { return &_timeInfo; } VstTimeInfo* timeinfo () { return &_timeInfo; }
framepos_t transport_frame () const { return _transport_frame; }
float transport_speed () const { return _transport_speed; }
protected: protected:
@ -112,6 +115,9 @@ protected:
MidiBuffer* _midi_out_buf; MidiBuffer* _midi_out_buf;
VstTimeInfo _timeInfo; VstTimeInfo _timeInfo;
framepos_t _transport_frame;
float _transport_speed;
}; };
} }

View 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); fill_buffers_with_input (bufs, _input, nframes);
if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) { 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) { if ((dret = diskstream->process (bufs, transport_frame, nframes, playback_distance, (monitoring_state() == MonitoringDisk))) != 0) {

View file

@ -448,7 +448,8 @@ AUPlugin::AUPlugin (AudioEngine& engine, Session& session, boost::shared_ptr<CAC
, audio_input_cnt (0) , audio_input_cnt (0)
, _parameter_listener (0) , _parameter_listener (0)
, _parameter_listener_arg (0) , _parameter_listener_arg (0)
, last_transport_rolling (false) , transport_frame (false)
, transport_speed (false)
, last_transport_speed (0.0) , last_transport_speed (0.0)
{ {
if (!preset_search_path_initialized) { if (!preset_search_path_initialized) {
@ -1584,9 +1585,15 @@ AUPlugin::render_callback(AudioUnitRenderActionFlags*,
} }
int 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; AudioUnitRenderActionFlags flags = 0;
AudioTimeStamp ts; AudioTimeStamp ts;
@ -1760,8 +1767,8 @@ AUPlugin::get_beat_and_tempo_callback (Float64* outCurrentBeat,
return kAudioUnitErr_CannotDoInCurrentContext; return kAudioUnitErr_CannotDoInCurrentContext;
} }
TempoMetric metric = tmap.metric_at (_session.transport_frame() + input_offset); TempoMetric metric = tmap.metric_at (transport_frame + input_offset);
Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (_session.transport_frame() + input_offset); Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (transport_frame + input_offset);
if (outCurrentBeat) { if (outCurrentBeat) {
const double ppq_scaling = metric.meter().note_divisor() / 4.0; 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; return kAudioUnitErr_CannotDoInCurrentContext;
} }
TempoMetric metric = tmap.metric_at (_session.transport_frame() + input_offset); TempoMetric metric = tmap.metric_at (transport_frame + input_offset);
Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (_session.transport_frame() + input_offset); Timecode::BBT_Time bbt = _session.tempo_map().bbt_at_frame (transport_frame + input_offset);
if (outDeltaSampleOffsetToNextBeat) { if (outDeltaSampleOffsetToNextBeat) {
if (bbt.ticks == 0) { if (bbt.ticks == 0) {
@ -1808,7 +1815,7 @@ AUPlugin::get_musical_time_location_callback (UInt32* outDeltaSampleOffsetToNe
*outDeltaSampleOffsetToNextBeat = 0; *outDeltaSampleOffsetToNextBeat = 0;
} else { } else {
double const beat_frac_to_next = (Timecode::BBT_Time::ticks_per_beat - bbt.ticks) / Timecode::BBT_Time::ticks_per_beat; 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* outCycleStartBeat,
Float64* outCycleEndBeat) Float64* outCycleEndBeat)
{ {
bool rolling; const bool rolling = (transport_speed != 0);
float speed; const bool last_transport_rolling = (last_transport_speed != 0);
DEBUG_TRACE (DEBUG::AudioUnits, "AU calls ardour transport state callback\n"); DEBUG_TRACE (DEBUG::AudioUnits, "AU calls ardour transport state callback\n");
rolling = _session.transport_rolling();
speed = _session.transport_speed ();
if (outIsPlaying) { if (outIsPlaying) {
*outIsPlaying = _session.transport_rolling(); *outIsPlaying = rolling;
} }
if (outTransportStateChanged) { if (outTransportStateChanged) {
if (rolling != last_transport_rolling) { if (rolling != last_transport_rolling) {
*outTransportStateChanged = true; *outTransportStateChanged = true;
} else if (speed != last_transport_speed) { } else if (transport_speed != last_transport_speed) {
*outTransportStateChanged = true; *outTransportStateChanged = true;
} else { } else {
*outTransportStateChanged = false; *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, /* this assumes that the AU can only call this host callback from render context,
where input_offset is valid. where input_offset is valid.
*/ */
*outCurrentSampleInTimeLine = _session.transport_frame() + input_offset; *outCurrentSampleInTimeLine = transport_frame + input_offset;
} }
if (outIsCycling) { if (outIsCycling) {
// TODO check bounce-processing
Location* loc = _session.locations()->auto_loop_location(); 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) { if (*outIsCycling) {
@ -1919,8 +1925,7 @@ AUPlugin::get_transport_state_callback (Boolean* outIsPlaying,
} }
} }
last_transport_rolling = rolling; last_transport_speed = transport_speed;
last_transport_speed = speed;
return noErr; return noErr;
} }

View file

@ -46,7 +46,7 @@ CapturingProcessor::set_block_size (pframes_t nframes)
} }
void 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()) { if (active()) {
capture_buffers.read_from (bufs, nframes); capture_buffers.read_from (bufs, nframes);

View file

@ -50,7 +50,7 @@ DelayLine::~DelayLine ()
#define FADE_LEN (16) #define FADE_LEN (16)
void 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(); const uint32_t chn = _configured_output.n_audio();
pframes_t p0 = 0; pframes_t p0 = 0;

View file

@ -229,7 +229,7 @@ Delivery::configure_io (ChanCount in, ChanCount out)
} }
void 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); assert (_output);

View file

@ -32,7 +32,7 @@ InternalReturn::InternalReturn (Session& s)
} }
void 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) { if (!_active && !_pending_active) {
return; return;

View file

@ -133,7 +133,7 @@ InternalSend::send_to_going_away ()
} }
void 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) { if ((!_active && !_pending_active) || !_send_to) {
_meter->reset (); _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->set_gain_automation_buffer (_session.send_gain_automation_buffer ());
_amp->setup_gain_automation (start_frame, end_frame, nframes); _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 */ /* 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) { if (_amp->gain_control()->get_value() == GAIN_COEFF_ZERO) {
_meter->reset(); _meter->reset();
} else { } else {
_meter->run (mixbufs, start_frame, end_frame, nframes, true); _meter->run (mixbufs, start_frame, end_frame, speed, nframes, true);
} }
} }

View file

@ -1675,7 +1675,7 @@ IO::connected_to (const string& str) const
* Caller must hold process lock. * Caller must hold process lock.
*/ */
void 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 */ /* 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); _buffers.get_backend_port_addresses (_ports, nframes);
if (proc) { if (proc) {
proc->run (_buffers, start_frame, end_frame, nframes, true); proc->run (_buffers, start_frame, end_frame, speed, nframes, true);
} }
} }

View file

@ -240,7 +240,7 @@ IOProcessor::set_state_2X (const XMLNode& node, int version)
} }
void void
IOProcessor::silence (framecnt_t nframes) IOProcessor::silence (framecnt_t nframes, framepos_t /* start_frame */)
{ {
if (_own_output && _output) { if (_own_output && _output) {
_output->silence (nframes); _output->silence (nframes);

View file

@ -566,10 +566,11 @@ LadspaPlugin::automatable () const
int int
LadspaPlugin::connect_and_run (BufferSet& bufs, LadspaPlugin::connect_and_run (BufferSet& bufs,
framepos_t start, framepos_t end, double speed,
ChanMapping in_map, ChanMapping out_map, ChanMapping in_map, ChanMapping out_map,
pframes_t nframes, framecnt_t offset) 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 now;
cycles_t then = get_cycles (); cycles_t then = get_cycles ();

View file

@ -613,6 +613,7 @@ LuaProc::configure_io (ChanCount in, ChanCount out)
int int
LuaProc::connect_and_run (BufferSet& bufs, LuaProc::connect_and_run (BufferSet& bufs,
framepos_t start, framepos_t end, double speed,
ChanMapping in, ChanMapping out, ChanMapping in, ChanMapping out,
pframes_t nframes, framecnt_t offset) pframes_t nframes, framecnt_t offset)
{ {
@ -620,7 +621,7 @@ LuaProc::connect_and_run (BufferSet& bufs,
return 0; 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 :( // This is needed for ARDOUR::Session requests :(
if (! SessionEvent::has_per_thread_pool ()) { if (! SessionEvent::has_per_thread_pool ()) {

View file

@ -2248,17 +2248,18 @@ write_position(LV2_Atom_Forge* forge,
int int
LV2Plugin::connect_and_run(BufferSet& bufs, LV2Plugin::connect_and_run(BufferSet& bufs,
framepos_t start, framepos_t end, double speed,
ChanMapping in_map, ChanMapping out_map, ChanMapping in_map, ChanMapping out_map,
pframes_t nframes, framecnt_t offset) pframes_t nframes, framecnt_t offset)
{ {
DEBUG_TRACE(DEBUG::LV2, string_compose("%1 run %2 offset %3\n", name(), nframes, 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(); cycles_t then = get_cycles();
TempoMap& tmap = _session.tempo_map(); TempoMap& tmap = _session.tempo_map();
Metrics::const_iterator metric_i = tmap.metrics_end(); 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) { if (_freewheel_control_port) {
*_freewheel_control_port = _session.engine().freewheeling() ? 1.f : 0.f; *_freewheel_control_port = _session.engine().freewheeling() ? 1.f : 0.f;
@ -2269,7 +2270,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
} }
#ifdef LV2_EXTENDED #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 // add guard-points after locating
for (AutomationCtrlMap::iterator i = _ctrl_map.begin(); i != _ctrl_map.end(); ++i) { for (AutomationCtrlMap::iterator i = _ctrl_map.begin(); i != _ctrl_map.end(); ++i) {
i->second->guard = true; i->second->guard = true;
@ -2337,13 +2338,12 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
if (valid && (flags & PORT_INPUT)) { if (valid && (flags & PORT_INPUT)) {
Timecode::BBT_Time bbt; Timecode::BBT_Time bbt;
if ((flags & PORT_POSITION)) { if ((flags & PORT_POSITION)) {
if (_session.transport_frame() != _next_cycle_start || if (start != _next_cycle_start ||
_session.transport_speed() != _next_cycle_speed) { speed != _next_cycle_speed) {
// Transport has changed, write position at cycle start // 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], write_position(&_impl->forge, _ev_buffers[port_index],
tmetric, bbt, _session.transport_speed(), tmetric, bbt, speed, start, 0);
_session.transport_frame(), 0);
} }
} }
@ -2357,7 +2357,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
// Now merge MIDI and any transport events into the buffer // Now merge MIDI and any transport events into the buffer
const uint32_t type = _uri_map.urids.midi_MidiEvent; const uint32_t type = _uri_map.urids.midi_MidiEvent;
const framepos_t tend = _session.transport_frame() + nframes; const framepos_t tend = end;
++metric_i; ++metric_i;
while (m != m_end || (metric_i != tmap.metrics_end() && while (m != m_end || (metric_i != tmap.metrics_end() &&
(*metric_i)->frame() < tend)) { (*metric_i)->frame() < tend)) {
@ -2374,9 +2374,9 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
tmetric.set_metric(metric); tmetric.set_metric(metric);
bbt = tmap.bbt_at_pulse (metric->pulse()); bbt = tmap.bbt_at_pulse (metric->pulse());
write_position(&_impl->forge, _ev_buffers[port_index], write_position(&_impl->forge, _ev_buffers[port_index],
tmetric, bbt, _session.transport_speed(), tmetric, bbt, speed,
metric->frame(), metric->frame(),
metric->frame() - _session.transport_frame()); metric->frame() - start);
++metric_i; ++metric_i;
} }
} }
@ -2497,8 +2497,8 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
if (c && if (c &&
(c->ac->automation_state() == Touch || c->ac->automation_state() == Write) (c->ac->automation_state() == Touch || c->ac->automation_state() == Write)
) { ) {
framepos_t when = std::max ((framepos_t) 0, _session.transport_frame() + frames - _current_latency); framepos_t when = std::max ((framepos_t) 0, start + frames - _current_latency);
assert (_session.transport_frame() + frames - _current_latency >= 0); assert (start + frames - _current_latency >= 0);
if (c->guard) { if (c->guard) {
c->guard = false; c->guard = false;
c->ac->list()->add (when, v, true, true); c->ac->list()->add (when, v, true, true);
@ -2560,7 +2560,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
AutomationCtrlPtr c = get_automation_control (p); AutomationCtrlPtr c = get_automation_control (p);
DEBUG_TRACE(DEBUG::LV2Automate, string_compose ("Start Touch p: %1\n", p)); DEBUG_TRACE(DEBUG::LV2Automate, string_compose ("Start Touch p: %1\n", p));
if (c) { 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; c->guard = true;
} }
} }
@ -2575,7 +2575,7 @@ LV2Plugin::connect_and_run(BufferSet& bufs,
AutomationCtrlPtr c = get_automation_control (p); AutomationCtrlPtr c = get_automation_control (p);
DEBUG_TRACE(DEBUG::LV2Automate, string_compose ("End Touch p: %1\n", p)); DEBUG_TRACE(DEBUG::LV2Automate, string_compose ("End Touch p: %1\n", p));
if (c) { 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)); set_cycles((uint32_t)(now - then));
// Update expected transport information for next cycle so we can detect changes // Update expected transport information for next cycle so we can detect changes
_next_cycle_speed = _session.transport_speed(); _next_cycle_speed = speed;
_next_cycle_start = _session.transport_frame() + (nframes * _next_cycle_speed); _next_cycle_start = end;
if (_latency_control_port) { if (_latency_control_port) {
framecnt_t new_latency = signal_latency (); framecnt_t new_latency = signal_latency ();

View file

@ -78,7 +78,7 @@ PeakMeter::~PeakMeter ()
* (runs in jack realtime context) * (runs in jack realtime context)
*/ */
void 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) { if (!_active && !_pending_active) {
return; return;

View file

@ -404,7 +404,7 @@ MidiTrack::roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame
_capture_filter.filter (bufs); _capture_filter.filter (bufs);
if (_meter_point == MeterInput && ((_monitoring_control->monitoring_choice() & MonitorInput) || _diskstream->record_enabled())) { 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);
} }

View file

@ -270,7 +270,7 @@ MonitorProcessor::state (bool full)
} }
void 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; uint32_t chn = 0;
gain_t target_gain; gain_t target_gain;

View file

@ -329,6 +329,7 @@ Plugin::preset_by_uri (const string& uri)
int int
Plugin::connect_and_run (BufferSet& bufs, Plugin::connect_and_run (BufferSet& bufs,
framepos_t /*start*/, framepos_t /*end*/, double /*speed*/,
ChanMapping /*in_map*/, ChanMapping /*out_map*/, ChanMapping /*in_map*/, ChanMapping /*out_map*/,
pframes_t /* nframes */, framecnt_t /*offset*/) pframes_t /* nframes */, framecnt_t /*offset*/)
{ {

View file

@ -593,7 +593,7 @@ PluginInsert::inplace_silence_unconnected (BufferSet& bufs, const PinMappings& o
} }
void 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 // TODO: atomically copy maps & _no_inplace
PinMappings in_map (_in_map); 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()) { if (c->list() && c->automation_playback()) {
bool valid; bool valid;
const float val = c->list()->rt_safe_eval (now, valid); const float val = c->list()->rt_safe_eval (start, valid);
if (valid) { if (valid) {
/* This is the ONLY place where we are /* 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_in_map (ChanCount::min (_configured_in, ChanCount (DataType::AUDIO, 2)));
ChanMapping mb_out_map (ChanCount::min (_configured_out, 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) { for (uint32_t out = _configured_in.n_audio (); out < bufs.count().get (DataType::AUDIO); ++out) {
bufs.get (DataType::AUDIO, out).silence (nframes, offset); 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)); 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 (); deactivate ();
} }
} }
@ -815,7 +815,7 @@ PluginInsert::connect_and_run (BufferSet& bufs, pframes_t nframes, framecnt_t of
/* in-place processing */ /* in-place processing */
uint32_t pc = 0; uint32_t pc = 0;
for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i, ++pc) { 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 (); deactivate ();
} }
} }
@ -962,7 +962,7 @@ PluginInsert::bypass (BufferSet& bufs, pframes_t nframes)
} }
void void
PluginInsert::silence (framecnt_t nframes) PluginInsert::silence (framecnt_t nframes, framepos_t start_frame)
{ {
if (!active ()) { if (!active ()) {
return; return;
@ -976,17 +976,17 @@ PluginInsert::silence (framecnt_t nframes)
#ifdef MIXBUS #ifdef MIXBUS
if (is_channelstrip ()) { if (is_channelstrip ()) {
if (_configured_in.n_audio() > 0) { 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 } else
#endif #endif
for (Plugins::iterator i = _plugins.begin(); i != _plugins.end(); ++i) { 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 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) { if (_pending_active) {
/* run as normal if we are active or moving from inactive to 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) { if (_sidechain) {
// collect sidechain input for complete cycle (!) // collect sidechain input for complete cycle (!)
// TODO we need delaylines here for latency compensation // 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()) { if (_session.transport_rolling() || _session.bounce_processing()) {
automation_run (bufs, start_frame, nframes); automation_run (bufs, start_frame, end_frame, speed, nframes);
} else { } else {
connect_and_run (bufs, nframes, 0, false); connect_and_run (bufs, start_frame, end_frame, speed, nframes, 0, false);
} }
} else { } else {
@ -1016,39 +1016,37 @@ PluginInsert::run (BufferSet& bufs, framepos_t start_frame, framepos_t end_frame
} }
void 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); Evoral::ControlEvent next_event (0, 0.0f);
framepos_t now = start;
framepos_t end = now + nframes;
framecnt_t offset = 0; framecnt_t offset = 0;
Glib::Threads::Mutex::Lock lm (control_lock(), Glib::Threads::TRY_LOCK); Glib::Threads::Mutex::Lock lm (control_lock(), Glib::Threads::TRY_LOCK);
if (!lm.locked()) { if (!lm.locked()) {
connect_and_run (bufs, nframes, offset, false); connect_and_run (bufs, start, end, speed, nframes, offset, false);
return; 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 */ /* 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; return;
} }
while (nframes) { 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; nframes -= cnt;
offset += cnt; offset += cnt;
now += cnt; start += cnt;
if (!find_next_event (now, end, next_event)) { if (!find_next_event (start, end, next_event)) {
break; break;
} }
} }
@ -1056,7 +1054,7 @@ PluginInsert::automation_run (BufferSet& bufs, framepos_t start, pframes_t nfram
/* cleanup anything that is left to do */ /* cleanup anything that is left to do */
if (nframes) { if (nframes) {
connect_and_run (bufs, nframes, offset, true, now); connect_and_run (bufs, start, start + nframes, speed, nframes, offset, true);
} }
} }

View file

@ -107,7 +107,7 @@ PortInsert::latency() const
} }
void 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) { if (_output->n_ports().n_total() == 0) {
return; 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. hear the remnants of whatever MTDM pumped into the pipeline.
*/ */
silence (nframes); silence (nframes, start_frame);
if (_latency_flush_frames > nframes) { if (_latency_flush_frames > nframes) {
_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) { if (!_active && !_pending_active) {
/* deliver silence */ /* deliver silence */
silence (nframes); silence (nframes, start_frame);
goto out; 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); _input->collect_input (bufs, nframes, ChanCount::ZERO);
out: out:

View file

@ -115,7 +115,7 @@ Return::set_state (const XMLNode& node, int version)
} }
void 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) { if ((!_active && !_pending_active) || _input->n_ports() == ChanCount::ZERO) {
return; 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 // 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 // so that we don't overwrite the main automation data for the route amp
// _amp->setup_gain_automation (start_frame, end_frame, nframes); // _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 (_metering) {
if (_amp->gain_control()->get_value() == 0) { if (_amp->gain_control()->get_value() == 0) {
_meter->reset(); _meter->reset();
} else { } else {
_meter->run (bufs, start_frame, end_frame, nframes, true); _meter->run (bufs, start_frame, end_frame, speed, nframes, true);
} }
} }

View file

@ -415,6 +415,7 @@ Route::process_output_buffers (BufferSet& bufs,
bool const meter_already_run = metering_state() == MeteringInput; bool const meter_already_run = metering_state() == MeteringInput;
framecnt_t latency = 0; framecnt_t latency = 0;
const double speed = _session.transport_speed ();
for (ProcessorList::const_iterator i = _processors.begin(); i != _processors.end(); ++i) { 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); _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()); bufs.set_count ((*i)->output_streams());
if ((*i)->active ()) { 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); _trim->setup_gain_automation (start, start + nframes, nframes);
latency = 0; latency = 0;
const double speed = _session.transport_speed ();
for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) { for (ProcessorList::iterator i = _processors.begin(); i != _processors.end(); ++i) {
if (!include_endpoint && (*i) == endpoint) { if (!include_endpoint && (*i) == endpoint) {
@ -500,7 +502,7 @@ Route::bounce_process (BufferSet& buffers, framepos_t start, framecnt_t nframes,
*/ */
if ((*i) == _main_outs) { if ((*i) == _main_outs) {
assert ((*i)->does_routing()); 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()); 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. * Also don't bother with metering.
*/ */
if (!(*i)->does_routing() && !boost::dynamic_pointer_cast<PeakMeter>(*i)) { 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()); buffers.set_count ((*i)->output_streams());
latency += (*i)->signal_latency (); latency += (*i)->signal_latency ();
} }
@ -2890,6 +2892,8 @@ Route::silence_unlocked (framecnt_t nframes)
{ {
/* Must be called with the processor lock held */ /* Must be called with the processor lock held */
const framepos_t now = _session.transport_frame ();
if (!_silent) { if (!_silent) {
_output->silence (nframes); _output->silence (nframes);
@ -2902,7 +2906,7 @@ Route::silence_unlocked (framecnt_t nframes)
continue; continue;
} }
(*i)->silence (nframes); (*i)->silence (nframes, now);
} }
if (nframes == _session.get_block_size()) { 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); fill_buffers_with_input (bufs, _input, nframes);
if (_meter_point == MeterInput) { 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); _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); fill_buffers_with_input (bufs, _input, nframes);
if (_meter_point == MeterInput) { 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); passthru (bufs, start_frame, end_frame, nframes, declick);

View file

@ -159,7 +159,7 @@ Send::set_delay_out(framecnt_t delay)
} }
void 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) { if (_output->n_ports() == ChanCount::ZERO) {
_meter->reset (); _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->set_gain_automation_buffer (_session.send_gain_automation_buffer ());
_amp->setup_gain_automation (start_frame, end_frame, nframes); _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 */ /* deliver to outputs */
Delivery::run (sendbufs, start_frame, end_frame, nframes, true); Delivery::run (sendbufs, start_frame, end_frame, speed, nframes, true);
/* consider metering */ /* 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) { if (_amp->gain_control()->get_value() == 0) {
_meter->reset(); _meter->reset();
} else { } else {
_meter->run (*_output_buffers, start_frame, end_frame, nframes, true); _meter->run (*_output_buffers, start_frame, end_frame, speed, nframes, true);
} }
} }

View 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); _click_io->copy_to_outputs (bufs, DataType::AUDIO, nframes, 0);
} }

View file

@ -200,8 +200,8 @@ intptr_t Session::vst_callback (
timeinfo->nanoSeconds = g_get_monotonic_time () * 1000; timeinfo->nanoSeconds = g_get_monotonic_time () * 1000;
if (session) { if (plug && session) {
framepos_t now = session->transport_frame(); framepos_t now = plug->transport_frame();
timeinfo->samplePos = now; timeinfo->samplePos = now;
timeinfo->sampleRate = session->frame_rate(); timeinfo->sampleRate = session->frame_rate();
@ -280,7 +280,7 @@ intptr_t Session::vst_callback (
newflags |= kVstTransportRecording; newflags |= kVstTransportRecording;
} }
if (session->transport_speed () != 0.0f) { if (plug->transport_speed () != 0.0f) {
newflags |= kVstTransportPlaying; newflags |= kVstTransportPlaying;
} }

View file

@ -61,7 +61,7 @@ SideChain::set_state (const XMLNode& node, int version)
} }
void 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) { if (_input->n_ports () == ChanCount::ZERO) {
// inplace pass-through // inplace pass-through

View file

@ -444,10 +444,10 @@ Track::no_roll (pframes_t nframes, framepos_t start_frame, framepos_t end_frame,
if (no_meter) { if (no_meter) {
BufferSet& bufs (_session.get_silent_buffers (n_process_buffers())); BufferSet& bufs (_session.get_silent_buffers (n_process_buffers()));
_meter->run (bufs, 0, 0, nframes, true); _meter->run (bufs, start_frame, end_frame, 1.0, nframes, true);
_input->process_input (boost::shared_ptr<Processor>(), start_frame, end_frame, nframes); _input->process_input (boost::shared_ptr<Processor>(), start_frame, end_frame, speed(), nframes);
} else { } 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); fill_buffers_with_input (bufs, _input, nframes);
if (_meter_point == MeterInput) { 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); passthru (bufs, start_frame, end_frame, nframes, false);

View file

@ -111,7 +111,7 @@ UnknownProcessor::can_support_io_configuration (const ChanCount &in, ChanCount &
} }
void 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) { if (!have_ioconfig) {
return; return;

View file

@ -46,6 +46,8 @@ VSTPlugin::VSTPlugin (AudioEngine& engine, Session& session, VSTHandle* handle)
, _plugin (0) , _plugin (0)
, _pi (0) , _pi (0)
, _num (0) , _num (0)
, _transport_frame (0)
, _transport_speed (0.f)
{ {
memset (&_timeInfo, 0, sizeof(_timeInfo)); memset (&_timeInfo, 0, sizeof(_timeInfo));
} }
@ -533,10 +535,14 @@ VSTPlugin::automatable () const
int int
VSTPlugin::connect_and_run (BufferSet& bufs, VSTPlugin::connect_and_run (BufferSet& bufs,
framepos_t start, framepos_t end, double speed,
ChanMapping in_map, ChanMapping out_map, ChanMapping in_map, ChanMapping out_map,
pframes_t nframes, framecnt_t offset) 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; ChanCount bufs_count;
bufs_count.set(DataType::AUDIO, 1); bufs_count.set(DataType::AUDIO, 1);