Put plugin-note-off code in the right place.
git-svn-id: svn://localhost/ardour2/branches/3.0@8207 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -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);
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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 ();
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user