summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCarl Hetherington <carl@carlh.net>2010-12-07 15:00:19 +0000
committerCarl Hetherington <carl@carlh.net>2010-12-07 15:00:19 +0000
commita9275f997b131e96191cdb32542074e655a116cb (patch)
tree1db249394c5db54b38ae4f4944b4bc9cbcd26a3b
parente621d704ac16f7da143a1c7ab3d6864c803ec8c9 (diff)
Put plugin-note-off code in the right place.
git-svn-id: svn://localhost/ardour2/branches/3.0@8207 d708f5d6-7413-0410-9779-e7cbd77b26cf
-rw-r--r--libs/ardour/ardour/plugin.h13
-rw-r--r--libs/ardour/ardour/vst_plugin.h6
-rw-r--r--libs/ardour/audio_unit.cc4
-rw-r--r--libs/ardour/ladspa_plugin.cc2
-rw-r--r--libs/ardour/lv2_plugin.cc2
-rw-r--r--libs/ardour/plugin.cc37
-rw-r--r--libs/ardour/vst_plugin.cc29
7 files changed, 56 insertions, 37 deletions
diff --git a/libs/ardour/ardour/plugin.h b/libs/ardour/ardour/plugin.h
index d917ef85af..d35f7611a5 100644
--- a/libs/ardour/ardour/plugin.h
+++ b/libs/ardour/ardour/plugin.h
@@ -33,6 +33,7 @@
#include "ardour/latent.h"
#include "ardour/plugin_insert.h"
#include "ardour/types.h"
+#include "ardour/midi_state_tracker.h"
#include <vector>
#include <set>
@@ -115,8 +116,8 @@ class Plugin : public PBD::StatefulDestructible, public Latent
virtual int set_block_size (pframes_t nframes) = 0;
virtual int connect_and_run (BufferSet& bufs,
- ChanMapping in, ChanMapping out,
- pframes_t nframes, framecnt_t offset) = 0;
+ 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;
@@ -128,7 +129,7 @@ class Plugin : public PBD::StatefulDestructible, public Latent
virtual bool parameter_is_input(uint32_t) const = 0;
virtual bool parameter_is_output(uint32_t) const = 0;
- virtual void realtime_handle_transport_stopped () {}
+ void realtime_handle_transport_stopped ();
bool save_preset (std::string);
void remove_preset (std::string);
@@ -208,6 +209,12 @@ protected:
PluginInfoPtr _info;
uint32_t _cycles;
std::map<std::string, PresetRecord> _presets;
+
+private:
+
+ MidiStateTracker _tracker;
+ BufferSet _pending_stop_events;
+ bool _have_pending_stop_events;
};
PluginPtr find_plugin(ARDOUR::Session&, std::string unique_id, ARDOUR::PluginType);
diff --git a/libs/ardour/ardour/vst_plugin.h b/libs/ardour/ardour/vst_plugin.h
index 24af13c053..b6e2a02756 100644
--- a/libs/ardour/ardour/vst_plugin.h
+++ b/libs/ardour/ardour/vst_plugin.h
@@ -29,7 +29,6 @@
#include "pbd/stateful.h"
#include "ardour/plugin.h"
-#include "ardour/midi_state_tracker.h"
struct _FSTHandle;
struct _FST;
@@ -79,8 +78,6 @@ class VSTPlugin : public ARDOUR::Plugin
bool parameter_is_input(uint32_t i) const { return true; }
bool parameter_is_output(uint32_t i) const { return false; }
- void realtime_handle_transport_stopped ();
-
bool load_preset (const std::string& preset_label);
virtual std::vector<PresetRecord> get_presets ();
int first_user_preset_index () const;
@@ -105,9 +102,6 @@ private:
FST* _fst;
AEffect* _plugin;
bool been_resumed;
- MidiStateTracker _tracker;
- BufferSet _pending_stop_events;
- bool _have_pending_stop_events;
};
class VSTPluginInfo : public PluginInfo
diff --git a/libs/ardour/audio_unit.cc b/libs/ardour/audio_unit.cc
index daace03de1..6746845f67 100644
--- a/libs/ardour/audio_unit.cc
+++ b/libs/ardour/audio_unit.cc
@@ -1252,8 +1252,10 @@ AUPlugin::render_callback(AudioUnitRenderActionFlags*,
}
int
-AUPlugin::connect_and_run (BufferSet& bufs, ChanMapping, ChanMapping, pframes_t nframes, framecnt_t offset)
+AUPlugin::connect_and_run (BufferSet& bufs, ChanMapping in_map, ChanMapping out_map, pframes_t nframes, framecnt_t offset)
{
+ Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
+
AudioUnitRenderActionFlags flags = 0;
AudioTimeStamp ts;
OSErr err;
diff --git a/libs/ardour/ladspa_plugin.cc b/libs/ardour/ladspa_plugin.cc
index 54722488f6..8214475065 100644
--- a/libs/ardour/ladspa_plugin.cc
+++ b/libs/ardour/ladspa_plugin.cc
@@ -559,6 +559,8 @@ LadspaPlugin::connect_and_run (BufferSet& bufs,
ChanMapping in_map, ChanMapping out_map,
pframes_t nframes, framecnt_t offset)
{
+ Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
+
cycles_t now;
cycles_t then = get_cycles ();
diff --git a/libs/ardour/lv2_plugin.cc b/libs/ardour/lv2_plugin.cc
index 35cd9f4d1a..0549bac761 100644
--- a/libs/ardour/lv2_plugin.cc
+++ b/libs/ardour/lv2_plugin.cc
@@ -536,6 +536,8 @@ LV2Plugin::connect_and_run (BufferSet& bufs,
ChanMapping in_map, ChanMapping out_map,
pframes_t nframes, framecnt_t offset)
{
+ Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
+
cycles_t then = get_cycles ();
uint32_t audio_in_index = 0;
diff --git a/libs/ardour/plugin.cc b/libs/ardour/plugin.cc
index 98bc5f35ad..1a711b5250 100644
--- a/libs/ardour/plugin.cc
+++ b/libs/ardour/plugin.cc
@@ -68,6 +68,7 @@ Plugin::Plugin (AudioEngine& e, Session& s)
: _engine (e)
, _session (s)
, _cycles (0)
+ , _have_pending_stop_events (false)
{
}
@@ -78,6 +79,7 @@ Plugin::Plugin (const Plugin& other)
, _session (other._session)
, _info (other._info)
, _cycles (0)
+ , _have_pending_stop_events (false)
{
}
@@ -206,3 +208,38 @@ Plugin::preset_by_uri (const string& uri)
return 0;
}
}
+
+int
+Plugin::connect_and_run (BufferSet& bufs,
+ ChanMapping in_map, ChanMapping out_map,
+ pframes_t nframes, framecnt_t offset)
+{
+ if (bufs.count().n_midi() > 0) {
+
+ /* Track notes that we are sending to the plugin */
+ MidiBuffer& b = bufs.get_midi (0);
+ bool looped;
+ _tracker.track (b.begin(), b.end(), looped);
+
+ if (_have_pending_stop_events) {
+ /* Transmit note-offs that are pending from the last transport stop */
+ bufs.merge_from (_pending_stop_events, 0);
+ _have_pending_stop_events = false;
+ }
+ }
+
+ return 0;
+}
+
+void
+Plugin::realtime_handle_transport_stopped ()
+{
+ /* Create note-offs for any active notes and put them in _pending_stop_events, to be picked
+ up on the next call to connect_and_run ().
+ */
+
+ _pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
+ _pending_stop_events.get_midi(0).clear ();
+ _tracker.resolve_notes (_pending_stop_events.get_midi (0), 0);
+ _have_pending_stop_events = true;
+}
diff --git a/libs/ardour/vst_plugin.cc b/libs/ardour/vst_plugin.cc
index 8f30ff98e9..edcb665435 100644
--- a/libs/ardour/vst_plugin.cc
+++ b/libs/ardour/vst_plugin.cc
@@ -63,7 +63,6 @@ using std::max;
VSTPlugin::VSTPlugin (AudioEngine& e, Session& session, FSTHandle* h)
: Plugin (e, session)
- , _have_pending_stop_events (false)
{
handle = h;
@@ -90,7 +89,6 @@ VSTPlugin::VSTPlugin (AudioEngine& e, Session& session, FSTHandle* h)
VSTPlugin::VSTPlugin (const VSTPlugin &other)
: Plugin (other)
- , _have_pending_stop_events (false)
{
handle = other.handle;
@@ -489,6 +487,8 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
ChanMapping in_map, ChanMapping out_map,
pframes_t nframes, framecnt_t offset)
{
+ Plugin::connect_and_run (bufs, in_map, out_map, nframes, offset);
+
float *ins[_plugin->numInputs];
float *outs[_plugin->numOutputs];
int32_t i;
@@ -516,18 +516,6 @@ VSTPlugin::connect_and_run (BufferSet& bufs,
if (bufs.count().n_midi() > 0) {
-
- /* Track notes that we are sending to the plugin */
- MidiBuffer& b = bufs.get_midi (0);
- bool looped;
- _tracker.track (b.begin(), b.end(), looped);
-
- if (_have_pending_stop_events) {
- /* Transmit note-offs that are pending from the last transport stop */
- bufs.merge_from (_pending_stop_events, 0);
- _have_pending_stop_events = false;
- }
-
VstEvents* v = bufs.get_vst_midi (0);
_plugin->dispatcher (_plugin, effProcessEvents, 0, 0, v, 0);
}
@@ -735,19 +723,6 @@ VSTPlugin::first_user_preset_index () const
return _plugin->numPrograms;
}
-void
-VSTPlugin::realtime_handle_transport_stopped ()
-{
- /* Create note-offs for any active notes and put them in _pending_stop_events, to be picked
- up on the next call to connect_and_run ().
- */
-
- _pending_stop_events.ensure_buffers (DataType::MIDI, 1, 4096);
- _pending_stop_events.get_midi(0).clear ();
- _tracker.resolve_notes (_pending_stop_events.get_midi (0), 0);
- _have_pending_stop_events = true;
-}
-
VSTPluginInfo::VSTPluginInfo()
{
type = ARDOUR::VST;