Another not-quite-there-but-better commit.
Brought plugin automation into the fold of new automation system. Fixed plugin automation, broke panner automation :] (pending Panner work). Made AutomationController better at automatically following it's controller value (mimic what gain meter does). Fixed some visible automation track bugs (but still broken WRT serialization). git-svn-id: svn://localhost/ardour2/trunk@2092 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
@@ -48,10 +48,14 @@ public:
|
||||
|
||||
virtual boost::shared_ptr<AutomationControl> control(ParamID id, bool create_if_missing=false);
|
||||
virtual boost::shared_ptr<const AutomationControl> control(ParamID id) const;
|
||||
|
||||
typedef std::map<ParamID,boost::shared_ptr<AutomationControl> > Controls;
|
||||
Controls controls() { return _controls; }
|
||||
|
||||
virtual void add_control(boost::shared_ptr<AutomationControl>);
|
||||
|
||||
virtual void automation_snapshot(nframes_t now);
|
||||
virtual void transport_stopped(nframes_t now);
|
||||
|
||||
virtual bool find_next_event(nframes_t start, nframes_t end, ControlEvent& ev) const;
|
||||
|
||||
@@ -60,7 +64,7 @@ public:
|
||||
|
||||
virtual void clear_automation();
|
||||
|
||||
AutoState get_parameter_automation_state (ParamID param);
|
||||
AutoState get_parameter_automation_state (ParamID param, bool lock = true);
|
||||
virtual void set_parameter_automation_state (ParamID param, AutoState);
|
||||
|
||||
AutoStyle get_parameter_automation_style (ParamID param);
|
||||
@@ -88,8 +92,6 @@ protected:
|
||||
|
||||
mutable Glib::Mutex _automation_lock;
|
||||
|
||||
typedef std::map<ParamID,boost::shared_ptr<AutomationControl> > Controls;
|
||||
|
||||
Controls _controls;
|
||||
std::set<ParamID> _visible_controls;
|
||||
std::set<ParamID> _can_automate_list;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
|
||||
#include <ardour/types.h>
|
||||
#include <ardour/curve.h>
|
||||
#include <ardour/automation_control.h>
|
||||
|
||||
using std::istream;
|
||||
using std::ostream;
|
||||
@@ -69,22 +70,8 @@ class StreamPanner : public sigc::trackable, public PBD::Stateful
|
||||
virtual void distribute_automated (AudioBuffer& src, BufferSet& obufs,
|
||||
nframes_t start, nframes_t end, nframes_t nframes, pan_t** buffers) = 0;
|
||||
|
||||
/* automation */
|
||||
|
||||
virtual void snapshot (nframes_t now) = 0;
|
||||
virtual void transport_stopped (nframes_t frame) = 0;
|
||||
virtual void set_automation_state (AutoState) = 0;
|
||||
virtual void set_automation_style (AutoStyle) = 0;
|
||||
boost::shared_ptr<AutomationControl> pan_control() { return _control; }
|
||||
|
||||
boost::shared_ptr<PBD::Controllable> control() { return _control; }
|
||||
|
||||
/* XXX this is wrong. for multi-dimensional panners, there
|
||||
must surely be more than 1 automation curve.
|
||||
*/
|
||||
/* TODO: Panner is-a Automation solves this */
|
||||
|
||||
virtual boost::shared_ptr<AutomationList> automation() = 0;
|
||||
|
||||
sigc::signal<void> Changed; /* for position */
|
||||
sigc::signal<void> StateChanged; /* for mute */
|
||||
|
||||
@@ -115,8 +102,11 @@ class StreamPanner : public sigc::trackable, public PBD::Stateful
|
||||
|
||||
bool _muted;
|
||||
|
||||
struct PanControllable : public PBD::Controllable {
|
||||
PanControllable (std::string name, StreamPanner& p) : Controllable (name), panner (p) {}
|
||||
struct PanControllable : public AutomationControl {
|
||||
PanControllable (Session& s, std::string name, StreamPanner& p)
|
||||
: AutomationControl (s, boost::shared_ptr<AutomationList>(new AutomationList(
|
||||
ParamID(PanAutomation), 0.0, 1.0, 0.5)), name)
|
||||
, panner (p) {}
|
||||
|
||||
StreamPanner& panner;
|
||||
|
||||
@@ -145,14 +135,6 @@ class BaseStereoPanner : public StreamPanner
|
||||
|
||||
void distribute (AudioBuffer& src, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes);
|
||||
|
||||
void snapshot (nframes_t now);
|
||||
void transport_stopped (nframes_t frame);
|
||||
void set_automation_state (AutoState);
|
||||
void set_automation_style (AutoStyle);
|
||||
|
||||
/* TODO: StreamPanner is-a Automatable? */
|
||||
boost::shared_ptr<AutomationList> automation() { return _automation; }
|
||||
|
||||
/* old school automation loading */
|
||||
|
||||
int load (istream&, string path, uint32_t&);
|
||||
@@ -164,8 +146,6 @@ class BaseStereoPanner : public StreamPanner
|
||||
float desired_right;
|
||||
float left_interp;
|
||||
float right_interp;
|
||||
|
||||
boost::shared_ptr<AutomationList> _automation;
|
||||
};
|
||||
|
||||
class EqualPowerStereoPanner : public BaseStereoPanner
|
||||
@@ -197,19 +177,6 @@ class Multi2dPanner : public StreamPanner
|
||||
Multi2dPanner (Panner& parent);
|
||||
~Multi2dPanner ();
|
||||
|
||||
void snapshot (nframes_t now);
|
||||
void transport_stopped (nframes_t frame);
|
||||
void set_automation_state (AutoState);
|
||||
void set_automation_style (AutoStyle);
|
||||
|
||||
/* XXX this is wrong. for multi-dimensional panners, there
|
||||
must surely be more than 1 automation curve.
|
||||
*/
|
||||
|
||||
/* TODO: StreamPanner is-a Automatable? */
|
||||
|
||||
boost::shared_ptr<AutomationList> automation() { return _automation; }
|
||||
|
||||
void distribute (AudioBuffer& src, BufferSet& obufs, gain_t gain_coeff, nframes_t nframes);
|
||||
void distribute_automated (AudioBuffer& src, BufferSet& obufs,
|
||||
nframes_t start, nframes_t end, nframes_t nframes, pan_t** buffers);
|
||||
@@ -226,7 +193,6 @@ class Multi2dPanner : public StreamPanner
|
||||
int load (istream&, string path, uint32_t&);
|
||||
|
||||
private:
|
||||
boost::shared_ptr<AutomationList> _automation;
|
||||
void update ();
|
||||
};
|
||||
|
||||
|
||||
@@ -111,7 +111,6 @@ class Plugin : public PBD::StatefulDestructible, public Latent
|
||||
virtual const char * maker() const = 0;
|
||||
virtual uint32_t parameter_count () const = 0;
|
||||
virtual float default_value (uint32_t port) = 0;
|
||||
virtual void set_parameter (uint32_t which, float val) = 0;
|
||||
virtual float get_parameter(uint32_t which) const = 0;
|
||||
|
||||
virtual int get_parameter_descriptor (uint32_t which, ParameterDescriptor&) const = 0;
|
||||
@@ -140,10 +139,6 @@ class Plugin : public PBD::StatefulDestructible, public Latent
|
||||
|
||||
virtual bool has_editor() const = 0;
|
||||
|
||||
sigc::signal<void,ParamID,float> ParameterChanged;
|
||||
|
||||
PBD::Controllable *get_nth_control (uint32_t);
|
||||
|
||||
PluginInfoPtr get_info() { return _info; }
|
||||
void set_info (const PluginInfoPtr inf) { _info = inf; }
|
||||
|
||||
@@ -154,32 +149,15 @@ class Plugin : public PBD::StatefulDestructible, public Latent
|
||||
cycles_t cycles() const { return _cycles; }
|
||||
|
||||
protected:
|
||||
friend class PluginInsert;
|
||||
virtual void set_parameter (uint32_t which, float val) = 0;
|
||||
|
||||
ARDOUR::AudioEngine& _engine;
|
||||
ARDOUR::Session& _session;
|
||||
PluginInfoPtr _info;
|
||||
uint32_t _cycles;
|
||||
map<string,string> presets;
|
||||
bool save_preset(string name, string domain /* vst, ladspa etc. */);
|
||||
|
||||
void setup_controls ();
|
||||
|
||||
struct PortControllable : public PBD::Controllable {
|
||||
PortControllable (std::string name, Plugin&, uint32_t abs_port_id,
|
||||
float lower, float upper, bool toggled, bool logarithmic);
|
||||
|
||||
void set_value (float);
|
||||
float get_value () const;
|
||||
|
||||
Plugin& plugin;
|
||||
uint32_t absolute_port;
|
||||
float upper;
|
||||
float lower;
|
||||
float range;
|
||||
bool toggled;
|
||||
bool logarithmic;
|
||||
};
|
||||
|
||||
vector<PortControllable*> controls;
|
||||
};
|
||||
|
||||
PluginPtr find_plugin(ARDOUR::Session&, string name, long unique_id, ARDOUR::PluginType);
|
||||
|
||||
@@ -77,8 +77,22 @@ class PluginInsert : public Processor
|
||||
bool is_generator() const;
|
||||
|
||||
void set_parameter (ParamID param, float val);
|
||||
float get_parameter (ParamID param);
|
||||
|
||||
float default_parameter_value (ParamID param);
|
||||
|
||||
struct PluginControl : public AutomationControl {
|
||||
PluginControl (PluginInsert& p, boost::shared_ptr<AutomationList> list);
|
||||
|
||||
void set_value (float val);
|
||||
float get_value (void) const;
|
||||
|
||||
private:
|
||||
PluginInsert& _plugin;
|
||||
boost::shared_ptr<AutomationList> _list;
|
||||
bool _logarithmic;
|
||||
bool _toggled;
|
||||
};
|
||||
|
||||
boost::shared_ptr<Plugin> plugin(uint32_t num=0) const {
|
||||
if (num < _plugins.size()) {
|
||||
@@ -94,9 +108,6 @@ class PluginInsert : public Processor
|
||||
|
||||
nframes_t signal_latency() const;
|
||||
|
||||
void transport_stopped (nframes_t now);
|
||||
void automation_snapshot (nframes_t now);
|
||||
|
||||
private:
|
||||
|
||||
void parameter_changed (ParamID, float);
|
||||
|
||||
@@ -127,8 +127,6 @@ Automatable::add_control(boost::shared_ptr<AutomationControl> ac)
|
||||
|
||||
cerr << _name << ": added parameter " << param.to_string() << endl;
|
||||
|
||||
// FIXME: sane default behaviour?
|
||||
_visible_controls.insert(param);
|
||||
_can_automate_list.insert(param);
|
||||
|
||||
// Sync everything (derived classes) up to initial values
|
||||
@@ -355,17 +353,22 @@ Automatable::set_parameter_automation_state (ParamID param, AutoState s)
|
||||
}
|
||||
|
||||
AutoState
|
||||
Automatable::get_parameter_automation_state (ParamID param)
|
||||
Automatable::get_parameter_automation_state (ParamID param, bool lock)
|
||||
{
|
||||
Glib::Mutex::Lock lm (_automation_lock);
|
||||
AutoState result = Off;
|
||||
|
||||
if (lock)
|
||||
_automation_lock.lock();
|
||||
|
||||
boost::shared_ptr<AutomationControl> c = control(param);
|
||||
|
||||
if (c) {
|
||||
return c->list()->automation_state();
|
||||
} else {
|
||||
return Off;
|
||||
}
|
||||
if (c)
|
||||
result = c->list()->automation_state();
|
||||
|
||||
if (lock)
|
||||
_automation_lock.unlock();
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
void
|
||||
@@ -434,3 +437,18 @@ Automatable::automation_snapshot (nframes_t now)
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Automatable::transport_stopped (nframes_t now)
|
||||
{
|
||||
for (Controls::iterator li = _controls.begin(); li != _controls.end(); ++li) {
|
||||
|
||||
boost::shared_ptr<AutomationControl> c = li->second;
|
||||
|
||||
c->list()->reposition_for_rt_add (now);
|
||||
|
||||
if (c->list()->automation_state() != Off) {
|
||||
c->set_value(c->list()->eval(now));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -98,6 +98,7 @@ BufferSet::ensure_buffers(DataType type, size_t num_buffers, size_t buffer_capac
|
||||
{
|
||||
assert(type != DataType::NIL);
|
||||
assert(type < _buffers.size());
|
||||
assert(buffer_capacity > 0);
|
||||
|
||||
if (num_buffers == 0)
|
||||
return;
|
||||
|
||||
@@ -2271,7 +2271,7 @@ void
|
||||
IO::start_pan_touch (uint32_t which)
|
||||
{
|
||||
if (which < _panner->size()) {
|
||||
(*_panner)[which]->automation()->start_touch();
|
||||
(*_panner)[which]->pan_control()->list()->start_touch();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2279,7 +2279,7 @@ void
|
||||
IO::end_pan_touch (uint32_t which)
|
||||
{
|
||||
if (which < _panner->size()) {
|
||||
(*_panner)[which]->automation()->stop_touch();
|
||||
(*_panner)[which]->pan_control()->list()->stop_touch();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -136,8 +136,6 @@ LadspaPlugin::init (void *mod, uint32_t index, nframes_t rate)
|
||||
}
|
||||
}
|
||||
|
||||
Plugin::setup_controls ();
|
||||
|
||||
latency_compute_run ();
|
||||
}
|
||||
|
||||
@@ -318,11 +316,13 @@ LadspaPlugin::set_parameter (uint32_t which, float val)
|
||||
{
|
||||
if (which < descriptor->PortCount) {
|
||||
shadow_data[which] = (LADSPA_Data) val;
|
||||
#if 0
|
||||
ParameterChanged (ParamID(PluginAutomation, which), val); /* EMIT SIGNAL */
|
||||
|
||||
if (which < parameter_count() && controls[which]) {
|
||||
controls[which]->Changed ();
|
||||
}
|
||||
#endif
|
||||
|
||||
} else {
|
||||
warning << string_compose (_("illegal parameter number used with plugin \"%1\". This may"
|
||||
|
||||
@@ -71,7 +71,7 @@ static double direct_pan_to_control (pan_t val) {
|
||||
|
||||
StreamPanner::StreamPanner (Panner& p)
|
||||
: parent (p),
|
||||
_control (new PanControllable(X_("panner"), *this))
|
||||
_control (new PanControllable(p.session(), X_("panner"), *this))
|
||||
{
|
||||
_muted = false;
|
||||
|
||||
@@ -190,7 +190,7 @@ StreamPanner::add_state (XMLNode& node)
|
||||
/*---------------------------------------------------------------------- */
|
||||
|
||||
BaseStereoPanner::BaseStereoPanner (Panner& p)
|
||||
: StreamPanner (p), _automation (new AutomationList(ParamID(PanAutomation), 0.0, 1.0, 0.5))
|
||||
: StreamPanner (p)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -198,50 +198,13 @@ BaseStereoPanner::~BaseStereoPanner ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
BaseStereoPanner::snapshot (nframes_t now)
|
||||
{
|
||||
if (_automation->automation_state() == Write || _automation->automation_state() == Touch) {
|
||||
_automation->rt_add (now, x);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BaseStereoPanner::transport_stopped (nframes_t frame)
|
||||
{
|
||||
_automation->reposition_for_rt_add (frame);
|
||||
|
||||
if (_automation->automation_state() != Off) {
|
||||
set_position (_automation->eval (frame));
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
BaseStereoPanner::set_automation_style (AutoStyle style)
|
||||
{
|
||||
_automation->set_automation_style (style);
|
||||
}
|
||||
|
||||
void
|
||||
BaseStereoPanner::set_automation_state (AutoState state)
|
||||
{
|
||||
if (state != _automation->automation_state()) {
|
||||
|
||||
_automation->set_automation_state (state);
|
||||
|
||||
if (state != Off) {
|
||||
set_position (_automation->eval (parent.session().transport_frame()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int
|
||||
BaseStereoPanner::load (istream& in, string path, uint32_t& linecnt)
|
||||
{
|
||||
char line[128];
|
||||
LocaleGuard lg (X_("POSIX"));
|
||||
|
||||
_automation->clear ();
|
||||
_control->list()->clear ();
|
||||
|
||||
while (in.getline (line, sizeof (line), '\n')) {
|
||||
nframes_t when;
|
||||
@@ -258,12 +221,12 @@ BaseStereoPanner::load (istream& in, string path, uint32_t& linecnt)
|
||||
continue;
|
||||
}
|
||||
|
||||
_automation->fast_simple_add (when, value);
|
||||
_control->list()->fast_simple_add (when, value);
|
||||
}
|
||||
|
||||
/* now that we are done loading */
|
||||
|
||||
_automation->StateChanged ();
|
||||
_control->list()->StateChanged ();
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -438,7 +401,7 @@ EqualPowerStereoPanner::distribute_automated (AudioBuffer& srcbuf, BufferSet& ob
|
||||
|
||||
/* fetch positional data */
|
||||
|
||||
if (!_automation->curve().rt_safe_get_vector (start, end, buffers[0], nframes)) {
|
||||
if (!_control->list()->curve().rt_safe_get_vector (start, end, buffers[0], nframes)) {
|
||||
/* fallback */
|
||||
if (!_muted) {
|
||||
distribute (srcbuf, obufs, 1.0, nframes);
|
||||
@@ -518,7 +481,7 @@ EqualPowerStereoPanner::state (bool full_state)
|
||||
root->add_property (X_("type"), EqualPowerStereoPanner::name);
|
||||
|
||||
XMLNode* autonode = new XMLNode (X_("Automation"));
|
||||
autonode->add_child_nocopy (_automation->state (full_state));
|
||||
autonode->add_child_nocopy (_control->list()->state (full_state));
|
||||
root->add_child_nocopy (*autonode);
|
||||
|
||||
StreamPanner::add_state (*root);
|
||||
@@ -551,10 +514,10 @@ EqualPowerStereoPanner::set_state (const XMLNode& node)
|
||||
|
||||
} else if ((*iter)->name() == X_("Automation")) {
|
||||
|
||||
_automation->set_state (*((*iter)->children().front()));
|
||||
_control->list()->set_state (*((*iter)->children().front()));
|
||||
|
||||
if (_automation->automation_state() != Off) {
|
||||
set_position (_automation->eval (parent.session().transport_frame()));
|
||||
if (_control->list()->automation_state() != Off) {
|
||||
set_position (_control->list()->eval (parent.session().transport_frame()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -565,7 +528,7 @@ EqualPowerStereoPanner::set_state (const XMLNode& node)
|
||||
/*----------------------------------------------------------------------*/
|
||||
|
||||
Multi2dPanner::Multi2dPanner (Panner& p)
|
||||
: StreamPanner (p), _automation (new AutomationList(ParamID(PanAutomation), 0.0, 1.0, 0.5)) // XXX useless
|
||||
: StreamPanner (p)
|
||||
{
|
||||
update ();
|
||||
}
|
||||
@@ -574,30 +537,6 @@ Multi2dPanner::~Multi2dPanner ()
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Multi2dPanner::snapshot (nframes_t now)
|
||||
{
|
||||
// how?
|
||||
}
|
||||
|
||||
void
|
||||
Multi2dPanner::transport_stopped (nframes_t frame)
|
||||
{
|
||||
//what?
|
||||
}
|
||||
|
||||
void
|
||||
Multi2dPanner::set_automation_style (AutoStyle style)
|
||||
{
|
||||
//what?
|
||||
}
|
||||
|
||||
void
|
||||
Multi2dPanner::set_automation_state (AutoState state)
|
||||
{
|
||||
// what?
|
||||
}
|
||||
|
||||
void
|
||||
Multi2dPanner::update ()
|
||||
{
|
||||
@@ -930,10 +869,10 @@ Panner::reset (uint32_t nouts, uint32_t npans)
|
||||
if (changed || ((left == 0.5) && (right == 0.5))) {
|
||||
|
||||
front()->set_position (0.0);
|
||||
front()->automation()->reset_default (0.0);
|
||||
front()->pan_control()->list()->reset_default (0.0);
|
||||
|
||||
back()->set_position (1.0);
|
||||
back()->automation()->reset_default (1.0);
|
||||
back()->pan_control()->list()->reset_default (1.0);
|
||||
|
||||
changed = true;
|
||||
}
|
||||
@@ -972,7 +911,7 @@ void
|
||||
Panner::set_automation_style (AutoStyle style)
|
||||
{
|
||||
for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
|
||||
(*i)->set_automation_style (style);
|
||||
(*i)->pan_control()->list()->set_automation_style (style);
|
||||
}
|
||||
_session.set_dirty ();
|
||||
}
|
||||
@@ -981,7 +920,7 @@ void
|
||||
Panner::set_automation_state (AutoState state)
|
||||
{
|
||||
for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
|
||||
(*i)->set_automation_state (state);
|
||||
(*i)->pan_control()->list()->set_automation_state (state);
|
||||
}
|
||||
_session.set_dirty ();
|
||||
}
|
||||
@@ -990,7 +929,7 @@ AutoState
|
||||
Panner::automation_state () const
|
||||
{
|
||||
if (!empty()) {
|
||||
return front()->automation()->automation_state ();
|
||||
return front()->pan_control()->list()->automation_state ();
|
||||
} else {
|
||||
return Off;
|
||||
}
|
||||
@@ -1000,7 +939,7 @@ AutoStyle
|
||||
Panner::automation_style () const
|
||||
{
|
||||
if (!empty()) {
|
||||
return front()->automation()->automation_style ();
|
||||
return front()->pan_control()->list()->automation_style ();
|
||||
} else {
|
||||
return Absolute;
|
||||
}
|
||||
@@ -1010,7 +949,7 @@ void
|
||||
Panner::transport_stopped (nframes_t frame)
|
||||
{
|
||||
for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
|
||||
(*i)->transport_stopped (frame);
|
||||
(*i)->pan_control()->list()->reposition_for_rt_add (frame);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1018,7 +957,9 @@ void
|
||||
Panner::snapshot (nframes_t now)
|
||||
{
|
||||
for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
|
||||
(*i)->snapshot (now);
|
||||
boost::shared_ptr<AutomationList> list = (*i)->pan_control()->list();
|
||||
if (list->automation_write())
|
||||
list->rt_add(now, (*i)->pan_control()->get_value());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1026,7 +967,7 @@ void
|
||||
Panner::clear_automation ()
|
||||
{
|
||||
for (vector<StreamPanner*>::iterator i = begin(); i != end(); ++i) {
|
||||
(*i)->automation()->clear ();
|
||||
(*i)->pan_control()->list()->clear ();
|
||||
}
|
||||
_session.set_dirty ();
|
||||
}
|
||||
@@ -1181,7 +1122,7 @@ bool
|
||||
Panner::touching () const
|
||||
{
|
||||
for (vector<StreamPanner*>::const_iterator i = begin(); i != end(); ++i) {
|
||||
if ((*i)->automation()->touching ()) {
|
||||
if ((*i)->pan_control()->list()->touching ()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,105 +58,10 @@ Plugin::Plugin (const Plugin& other)
|
||||
{
|
||||
}
|
||||
|
||||
void
|
||||
Plugin::setup_controls ()
|
||||
{
|
||||
uint32_t port_cnt = parameter_count();
|
||||
|
||||
/* set up a vector of null pointers for the controls.
|
||||
we'll fill this in on an as-needed basis.
|
||||
*/
|
||||
|
||||
for (uint32_t i = 0; i < port_cnt; ++i) {
|
||||
controls.push_back (0);
|
||||
}
|
||||
}
|
||||
|
||||
Plugin::~Plugin ()
|
||||
{
|
||||
for (vector<PortControllable*>::iterator i = controls.begin(); i != controls.end(); ++i) {
|
||||
if (*i) {
|
||||
delete *i;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Controllable *
|
||||
Plugin::get_nth_control (uint32_t n)
|
||||
{
|
||||
if (n >= parameter_count()) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (controls[n] == 0) {
|
||||
|
||||
Plugin::ParameterDescriptor desc;
|
||||
|
||||
get_parameter_descriptor (n, desc);
|
||||
|
||||
controls[n] = new PortControllable (describe_parameter (ParamID(PluginAutomation, n)), *this, n,
|
||||
desc.lower, desc.upper, desc.toggled, desc.logarithmic);
|
||||
}
|
||||
|
||||
return controls[n];
|
||||
}
|
||||
|
||||
Plugin::PortControllable::PortControllable (string name, Plugin& p, uint32_t port_id,
|
||||
float low, float up, bool t, bool loga)
|
||||
: Controllable (name), plugin (p), absolute_port (port_id)
|
||||
{
|
||||
toggled = t;
|
||||
logarithmic = loga;
|
||||
lower = low;
|
||||
upper = up;
|
||||
range = upper - lower;
|
||||
}
|
||||
|
||||
void
|
||||
Plugin::PortControllable::set_value (float value)
|
||||
{
|
||||
if (toggled) {
|
||||
if (value > 0.5) {
|
||||
value = 1.0;
|
||||
} else {
|
||||
value = 0.0;
|
||||
}
|
||||
} else {
|
||||
|
||||
if (!logarithmic) {
|
||||
value = lower + (range * value);
|
||||
} else {
|
||||
float _lower = 0.0f;
|
||||
if (lower > 0.0f) {
|
||||
_lower = log(lower);
|
||||
}
|
||||
|
||||
value = exp(_lower + log(range) * value);
|
||||
}
|
||||
}
|
||||
|
||||
plugin.set_parameter (absolute_port, value);
|
||||
}
|
||||
|
||||
float
|
||||
Plugin::PortControllable::get_value (void) const
|
||||
{
|
||||
float val = plugin.get_parameter (absolute_port);
|
||||
|
||||
if (toggled) {
|
||||
|
||||
return val;
|
||||
|
||||
} else {
|
||||
|
||||
if (logarithmic) {
|
||||
val = log(val);
|
||||
}
|
||||
|
||||
return ((val - lower) / range);
|
||||
}
|
||||
}
|
||||
|
||||
vector<string>
|
||||
Plugin::get_presets()
|
||||
{
|
||||
|
||||
@@ -59,8 +59,6 @@ PluginInsert::PluginInsert (Session& s, boost::shared_ptr<Plugin> plug, Placemen
|
||||
|
||||
_plugins.push_back (plug);
|
||||
|
||||
_plugins[0]->ParameterChanged.connect (mem_fun (*this, &PluginInsert::parameter_changed));
|
||||
|
||||
init ();
|
||||
|
||||
{
|
||||
@@ -80,8 +78,6 @@ PluginInsert::PluginInsert (Session& s, const XMLNode& node)
|
||||
|
||||
set_automatable ();
|
||||
|
||||
_plugins[0]->ParameterChanged.connect (mem_fun (*this, &PluginInsert::parameter_changed));
|
||||
|
||||
{
|
||||
Glib::Mutex::Lock em (_session.engine().process_lock());
|
||||
IO::MoreChannels (max(input_streams(), output_streams()));
|
||||
@@ -98,9 +94,6 @@ PluginInsert::PluginInsert (const PluginInsert& other)
|
||||
_plugins.push_back (plugin_factory (other.plugin (n)));
|
||||
}
|
||||
|
||||
|
||||
_plugins[0]->ParameterChanged.connect (mem_fun (*this, &PluginInsert::parameter_changed));
|
||||
|
||||
init ();
|
||||
|
||||
ProcessorCreated (this); /* EMIT SIGNAL */
|
||||
@@ -215,12 +208,13 @@ PluginInsert::set_automatable ()
|
||||
_plugins.front()->get_parameter_descriptor(i->id(), desc);
|
||||
boost::shared_ptr<AutomationList> list(new AutomationList(
|
||||
*i,
|
||||
(desc.min_unbound ? FLT_MIN : desc.lower),
|
||||
(desc.max_unbound ? FLT_MAX : desc.upper),
|
||||
//(desc.min_unbound ? FLT_MIN : desc.lower),
|
||||
//(desc.max_unbound ? FLT_MAX : desc.upper),
|
||||
desc.lower, desc.upper,
|
||||
_plugins.front()->default_value(i->id())));
|
||||
|
||||
add_control(boost::shared_ptr<AutomationControl>(
|
||||
new AutomationControl(_session, list)));
|
||||
new PluginControl(*this, list)));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -288,11 +282,10 @@ PluginInsert::connect_and_run (BufferSet& bufs, nframes_t nframes, nframes_t off
|
||||
if (c->list()->param_id().type() == PluginAutomation && c->list()->automation_playback()) {
|
||||
bool valid;
|
||||
|
||||
float val = c->list()->rt_safe_eval (now, valid);
|
||||
const float val = c->list()->rt_safe_eval (now, valid);
|
||||
|
||||
if (valid) {
|
||||
/* set the first plugin, the others will be set via signals */
|
||||
_plugins[0]->set_parameter (c->list()->param_id(), val);
|
||||
c->set_value(val);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -306,38 +299,6 @@ PluginInsert::connect_and_run (BufferSet& bufs, nframes_t nframes, nframes_t off
|
||||
/* leave remaining channel buffers alone */
|
||||
}
|
||||
|
||||
void
|
||||
PluginInsert::automation_snapshot (nframes_t now)
|
||||
{
|
||||
for (Controls::iterator li = _controls.begin(); li != _controls.end(); ++li) {
|
||||
|
||||
boost::shared_ptr<AutomationControl> c = li->second;
|
||||
|
||||
if (c->list() != 0 && c->list()->param_id().type() == PluginAutomation
|
||||
&& c->list()->automation_write ()) {
|
||||
|
||||
float val = _plugins[0]->get_parameter (c->list()->param_id());
|
||||
c->list()->rt_add (now, val);
|
||||
_last_automation_snapshot = now;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PluginInsert::transport_stopped (nframes_t now)
|
||||
{
|
||||
for (Controls::iterator li = _controls.begin(); li != _controls.end(); ++li) {
|
||||
|
||||
boost::shared_ptr<AutomationControl> c = li->second;
|
||||
|
||||
c->list()->reposition_for_rt_add (now);
|
||||
|
||||
if (c->list()->param_id().type() == PluginAutomation && c->list()->automation_state() != Off) {
|
||||
_plugins[0]->set_parameter (li->first, c->list()->eval (now));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
PluginInsert::silence (nframes_t nframes, nframes_t offset)
|
||||
{
|
||||
@@ -393,13 +354,22 @@ PluginInsert::set_parameter (ParamID param, float val)
|
||||
|
||||
boost::shared_ptr<AutomationControl> c = control (param);
|
||||
|
||||
if (c && c->list()->automation_write()) {
|
||||
c->list()->add (_session.audible_frame(), val);
|
||||
}
|
||||
if (c)
|
||||
c->set_value(val);
|
||||
|
||||
_session.set_dirty();
|
||||
}
|
||||
|
||||
float
|
||||
PluginInsert::get_parameter (ParamID param)
|
||||
{
|
||||
if (param.type() != PluginAutomation)
|
||||
return 0.0;
|
||||
else
|
||||
return
|
||||
_plugins[0]->get_parameter (param.id());
|
||||
}
|
||||
|
||||
void
|
||||
PluginInsert::automation_run (BufferSet& bufs, nframes_t nframes, nframes_t offset)
|
||||
{
|
||||
@@ -877,3 +847,74 @@ PluginInsert::type ()
|
||||
}
|
||||
}
|
||||
|
||||
PluginInsert::PluginControl::PluginControl (PluginInsert& p, boost::shared_ptr<AutomationList> list)
|
||||
: AutomationControl (p.session(), list, p.describe_parameter(list->param_id()))
|
||||
, _plugin (p)
|
||||
, _list (list)
|
||||
{
|
||||
Plugin::ParameterDescriptor desc;
|
||||
p.plugin(0)->get_parameter_descriptor (list->param_id().id(), desc);
|
||||
_logarithmic = desc.logarithmic;
|
||||
_toggled = desc.toggled;
|
||||
}
|
||||
|
||||
void
|
||||
PluginInsert::PluginControl::set_value (float val)
|
||||
{
|
||||
/* FIXME: probably should be taking out some lock here.. */
|
||||
|
||||
if (_toggled) {
|
||||
if (val > 0.5) {
|
||||
val = 1.0;
|
||||
} else {
|
||||
val = 0.0;
|
||||
}
|
||||
} else {
|
||||
|
||||
/*const float range = _list->get_max_y() - _list->get_min_y();
|
||||
const float lower = _list->get_min_y();
|
||||
|
||||
if (!_logarithmic) {
|
||||
val = lower + (range * val);
|
||||
} else {
|
||||
float log_lower = 0.0f;
|
||||
if (lower > 0.0f) {
|
||||
log_lower = log(lower);
|
||||
}
|
||||
|
||||
val = exp(log_lower + log(range) * val);
|
||||
}*/
|
||||
|
||||
}
|
||||
|
||||
for (vector<boost::shared_ptr<Plugin> >::iterator i = _plugin._plugins.begin();
|
||||
i != _plugin._plugins.end(); ++i) {
|
||||
(*i)->set_parameter (_list->param_id().id(), val);
|
||||
}
|
||||
|
||||
AutomationControl::set_value(val);
|
||||
}
|
||||
|
||||
float
|
||||
PluginInsert::PluginControl::get_value (void) const
|
||||
{
|
||||
/* FIXME: probably should be taking out some lock here.. */
|
||||
|
||||
float val = _plugin.get_parameter (_list->param_id());
|
||||
|
||||
return val;
|
||||
|
||||
/*if (_toggled) {
|
||||
|
||||
return val;
|
||||
|
||||
} else {
|
||||
|
||||
if (_logarithmic) {
|
||||
val = log(val);
|
||||
}
|
||||
|
||||
return ((val - lower) / range);
|
||||
}*/
|
||||
}
|
||||
|
||||
|
||||
@@ -3678,6 +3678,9 @@ Session::tempo_map_changed (Change ignored)
|
||||
void
|
||||
Session::ensure_buffers (ChanCount howmany)
|
||||
{
|
||||
if (current_block_size == 0)
|
||||
return; // too early? (is this ok?)
|
||||
|
||||
// We need at least 1 MIDI scratch buffer to mix/merge
|
||||
if (howmany.n_midi() < 1)
|
||||
howmany.set_midi(1);
|
||||
|
||||
@@ -120,7 +120,7 @@ void
|
||||
VSTPlugin::set_parameter (uint32_t which, float val)
|
||||
{
|
||||
_plugin->setParameter (_plugin, which, val);
|
||||
ParameterChanged (which, val); /* EMIT SIGNAL */
|
||||
//ParameterChanged (which, val); /* EMIT SIGNAL */
|
||||
}
|
||||
|
||||
float
|
||||
|
||||
Reference in New Issue
Block a user