13
0

VST3: implement ChannelContext::IInfoListener

This commit is contained in:
Robin Gareus 2020-10-06 23:33:28 +02:00
parent bbbd6a36ec
commit 9746a63625
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04
3 changed files with 79 additions and 0 deletions

View File

@ -181,6 +181,11 @@ private:
bool midi_controller (int32_t, int16_t, Vst::CtrlNumber, Vst::ParamID &id);
bool live_midi_cc (int32_t, int16_t, Vst::CtrlNumber);
void setup_info_listener ();
void stripable_property_changed (PBD::PropertyChange const&);
PBD::ScopedConnectionList _strip_connections;
boost::shared_ptr<ARDOUR::VST3PluginModule> _module;
std::vector <Vst::IConnectionPoint*> _connections;

View File

@ -58,6 +58,7 @@ DEF_CLASS_IID (Vst::IProgramListData)
DEF_CLASS_IID (Vst::IStreamAttributes)
DEF_CLASS_IID (Vst::IUnitData)
DEF_CLASS_IID (Vst::IUnitInfo)
DEF_CLASS_IID (Vst::ChannelContext::IInfoListener)
#if SMTG_OS_LINUX
DEF_CLASS_IID (Linux::IRunLoop);
@ -315,7 +316,9 @@ PlugInterfaceSupport::PlugInterfaceSupport ()
addPlugInterfaceSupported (INoteExpressionController::iid);
//---VST 3.6.5--------------------------------
#endif
addPlugInterfaceSupported (ChannelContext::IInfoListener::iid);
#if 0
addPlugInterfaceSupported (IPrefetchableSupport::iid);
addPlugInterfaceSupported (IAutomationState::iid);

View File

@ -35,6 +35,7 @@
#include "ardour/audio_buffer.h"
#include "ardour/audioengine.h"
#include "ardour/session.h"
#include "ardour/stripable.h"
#include "ardour/tempo.h"
#include "ardour/utils.h"
#include "ardour/vst3_module.h"
@ -1462,6 +1463,11 @@ void
VST3PI::set_owner (SessionObject* o)
{
_owner = o;
if (!o) {
_strip_connections.drop_connections ();
return;
}
setup_info_listener ();
}
int32
@ -2254,6 +2260,71 @@ VST3PI::save_state (RAMStream& stream)
return entries.size () > 0;
}
/* ****************************************************************************/
void
VST3PI::stripable_property_changed (PBD::PropertyChange const&)
{
FUnknownPtr<Vst::ChannelContext::IInfoListener> il (_controller);
Stripable* s = dynamic_cast<Stripable*> (_owner);
assert (il && s);
IPtr<HostAttributeList> al (new HostAttributeList ());
Vst::String128 tmp;
utf8_to_tchar (tmp, _owner->name(), 128);
al->setInt (Vst::ChannelContext::kChannelNameLengthKey, _owner->name().size());
al->setString (Vst::ChannelContext::kChannelNameKey, tmp);
utf8_to_tchar (tmp, _owner->id().to_s(), 128);
al->setInt (Vst::ChannelContext::kChannelNameLengthKey, _owner->id().to_s().size());
al->setString (Vst::ChannelContext::kChannelUIDKey, tmp);
std::string ns;
int order_key;
if (s->is_master ()) {
ns = _("Master");
order_key = 2;
} else if (s->is_monitor ()) {
ns = _("Monitor");
order_key = 3;
} else {
ns = _("Track");
order_key = 1;
}
al->setInt (Vst::ChannelContext::kChannelIndexNamespaceOrderKey, order_key);
al->setInt (Vst::ChannelContext::kChannelIndexKey, 1 + s->presentation_info ().order());
utf8_to_tchar (tmp, ns, 128);
al->setInt (Vst::ChannelContext::kChannelIndexNamespaceLengthKey, ns.size());
al->setString (Vst::ChannelContext::kChannelIndexNamespaceKey, tmp);
uint32_t rgba = s->presentation_info ().color();
Vst::ChannelContext::ColorSpec argb = ((rgba >> 8) & 0xffffff) | ((rgba & 0xff) << 24);
al->setInt (Vst::ChannelContext::kChannelColorKey, argb);
al->setInt (Vst::ChannelContext::kChannelPluginLocationKey, Vst::ChannelContext::kPreVolumeFader); // XXX
il->setChannelContextInfos (al);
}
void
VST3PI::setup_info_listener ()
{
FUnknownPtr<Vst::ChannelContext::IInfoListener> il (_controller);
if (!il) {
return;
}
Stripable* s = dynamic_cast<Stripable*> (_owner);
s->PropertyChanged.connect_same_thread (_strip_connections, boost::bind (&VST3PI::stripable_property_changed, this, _1));
s->presentation_info().PropertyChanged.connect_same_thread (_strip_connections, boost::bind (&VST3PI::stripable_property_changed, this, _1));
/* send initial change */
stripable_property_changed (PropertyChange ());
}
/* ****************************************************************************
* GUI
*/