WS: properly support MIDI strips

This commit is contained in:
Luciano Iam 2020-09-05 13:12:04 +02:00 committed by Robin Gareus
parent dd833c89b9
commit 9ee828b47b
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
8 changed files with 154 additions and 54 deletions

View file

@ -65,7 +65,7 @@ WebsocketsDispatcher::update_all_nodes (Client client)
ValueVector strip_desc = ValueVector ();
strip_desc.push_back (strip.name ());
strip_desc.push_back (strip.has_pan ());
strip_desc.push_back ((int)strip.stripable ()->presentation_info ().flags ());
update (client, Node::strip_description, strip_addr, strip_desc);

View file

@ -219,12 +219,12 @@ void
ArdourFeedback::observe_strip_plugins (uint32_t strip_id, ArdourMixerStrip::PluginMap& plugins)
{
for (ArdourMixerStrip::PluginMap::iterator it = plugins.begin(); it != plugins.end(); ++it) {
uint32_t plugin_id = it->first;
boost::shared_ptr<ArdourMixerPlugin> plugin = it->second;
boost::shared_ptr<PluginInsert> insert = plugin->insert ();
uint32_t bypass = insert->plugin ()->designated_bypass_port ();
Evoral::Parameter param = Evoral::Parameter (PluginAutomation, 0, bypass);
boost::shared_ptr<AutomationControl> control = insert->automation_control (param);
uint32_t plugin_id = it->first;
boost::shared_ptr<ArdourMixerPlugin> plugin = it->second;
boost::shared_ptr<PluginInsert> insert = plugin->insert ();
uint32_t bypass = insert->plugin ()->designated_bypass_port ();
Evoral::Parameter param = Evoral::Parameter (PluginAutomation, 0, bypass);
boost::shared_ptr<AutomationControl> control = insert->automation_control (param);
if (control) {
control->Changed.connect (*plugin, MISSING_INVALIDATOR,

View file

@ -174,13 +174,15 @@ ArdourMixerStrip::plugins ()
double
ArdourMixerStrip::gain () const
{
return to_db (_stripable->gain_control ()->get_value ());
double val = _stripable->gain_control ()->get_value ();
return is_midi () ? static_cast<double> (to_velocity (val)) : to_db (val);
}
void
ArdourMixerStrip::set_gain (double db)
ArdourMixerStrip::set_gain (double gain)
{
_stripable->gain_control ()->set_value (from_db (db), PBD::Controllable::NoGroup);
double val = is_midi () ? from_velocity (static_cast<int> (gain)) : from_db (gain);
_stripable->gain_control ()->set_value (val, PBD::Controllable::NoGroup);
}
bool
@ -238,6 +240,12 @@ ArdourMixerStrip::name () const
return _stripable->name ();
}
bool
ArdourMixerStrip::is_midi () const
{
return _stripable->presentation_info ().flags () & PresentationInfo::Flag::MidiTrack;
}
void
ArdourMixerStrip::on_drop_plugin (uint32_t plugin_id)
{
@ -267,6 +275,18 @@ ArdourMixerStrip::from_db (double db)
return static_cast<double> (k);
}
int
ArdourMixerStrip::to_velocity (double k)
{
return static_cast<int> (127.0 * k / 2.0);
}
double
ArdourMixerStrip::from_velocity (int k)
{
return 2.0 * static_cast<double> (k) / 127.0;
}
int
ArdourMixer::start ()

View file

@ -48,8 +48,7 @@ public:
ArdourMixerPlugin (boost::shared_ptr<ARDOUR::PluginInsert>);
~ArdourMixerPlugin ();
boost::shared_ptr<ARDOUR::PluginInsert> insert () const;
boost::shared_ptr<PBD::ScopedConnectionList> connections () const;
boost::shared_ptr<ARDOUR::PluginInsert> insert () const;
bool enabled () const;
void set_enabled (bool);
@ -63,7 +62,7 @@ public:
static TypedValue param_value (boost::shared_ptr<ARDOUR::AutomationControl>);
private:
boost::shared_ptr<ARDOUR::PluginInsert> _insert;
boost::shared_ptr<ARDOUR::PluginInsert> _insert;
};
class ArdourMixerStrip : public PBD::ScopedConnectionList
@ -72,8 +71,7 @@ public:
ArdourMixerStrip (boost::shared_ptr<ARDOUR::Stripable>, PBD::EventLoop*);
~ArdourMixerStrip ();
boost::shared_ptr<ARDOUR::Stripable> stripable () const;
boost::shared_ptr<PBD::ScopedConnectionList> connections () const;
boost::shared_ptr<ARDOUR::Stripable> stripable () const;
typedef std::map<uint32_t, boost::shared_ptr<ArdourMixerPlugin> > PluginMap;
@ -97,11 +95,16 @@ public:
static double to_db (double);
static double from_db (double);
static int to_velocity (double);
static double from_velocity (int);
private:
boost::shared_ptr<ARDOUR::Stripable> _stripable;
boost::shared_ptr<ARDOUR::Stripable> _stripable;
PluginMap _plugins;
bool is_midi () const;
void on_drop_plugin (uint32_t);
};