diff --git a/libs/ardour/ardour/vst3_host.h b/libs/ardour/ardour/vst3_host.h index 1125be973d..10e283752b 100644 --- a/libs/ardour/ardour/vst3_host.h +++ b/libs/ardour/ardour/vst3_host.h @@ -20,9 +20,9 @@ #define _ardour_vst3_host_h_ #include -#include -#include #include +#include +#include #include @@ -41,11 +41,11 @@ tresult PLUGIN_API queryInterface (const TUID _iid, void** obj) SMTG_OVERRIDE \ } #if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wnon-virtual-dtor" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif namespace Steinberg { @@ -56,11 +56,11 @@ LIBARDOUR_API extern bool utf8_to_tchar (Vst::TChar* rv, std::string const& s, s namespace Vst { /* see public.sdk/source/vst/vstpresetfile.cpp */ - typedef char ChunkID[4]; // using ChunkID = char[4]; - static const int32 kClassIDSize = 32; // ASCII-encoded FUID - static const int32 kHeaderSize = sizeof (ChunkID) + sizeof (int32) + kClassIDSize + sizeof (TSize); + typedef char ChunkID[4]; // using ChunkID = char[4]; + static const int32 kClassIDSize = 32; // ASCII-encoded FUID + static const int32 kHeaderSize = sizeof (ChunkID) + sizeof (int32) + kClassIDSize + sizeof (TSize); static const int32 kListOffsetPos = kHeaderSize - sizeof (TSize); -} +} // namespace Vst class LIBARDOUR_API HostAttribute { @@ -161,8 +161,16 @@ public: virtual ~HostAttributeList (); QUERY_INTERFACE_IMPL (Vst::IAttributeList); - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return RefObject::addRef (); } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return RefObject::release (); } + + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return RefObject::addRef (); + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return RefObject::release (); + } tresult PLUGIN_API setInt (AttrID aid, int64 value) SMTG_OVERRIDE; tresult PLUGIN_API getInt (AttrID aid, int64& value) SMTG_OVERRIDE; @@ -186,8 +194,16 @@ public: virtual ~HostMessage (); QUERY_INTERFACE_IMPL (Vst::IMessage); - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return RefObject::addRef (); } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return RefObject::release (); } + + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return RefObject::addRef (); + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return RefObject::release (); + } const char* PLUGIN_API getMessageID () SMTG_OVERRIDE; void PLUGIN_API setMessageID (const char* messageID) SMTG_OVERRIDE; @@ -205,8 +221,16 @@ public: ~ConnectionProxy () SMTG_OVERRIDE; QUERY_INTERFACE_IMPL (Vst::IConnectionPoint); - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return RefObject::addRef (); } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return RefObject::release (); } + + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return RefObject::addRef (); + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return RefObject::release (); + } /* IConnectionPoint API */ tresult PLUGIN_API connect (Vst::IConnectionPoint*) SMTG_OVERRIDE; @@ -225,8 +249,16 @@ class LIBARDOUR_API PlugInterfaceSupport : public Vst::IPlugInterfaceSupport public: PlugInterfaceSupport (); QUERY_INTERFACE_IMPL (Vst::IPlugInterfaceSupport); - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return 1; } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return 1; } + + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return 1; + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return 1; + } tresult PLUGIN_API isPlugInterfaceSupported (const TUID) SMTG_OVERRIDE; @@ -249,8 +281,15 @@ public: virtual ~HostApplication () {} tresult PLUGIN_API queryInterface (const TUID _iid, void** obj) SMTG_OVERRIDE; - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return 1; } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return 1; } + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return 1; + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return 1; + } tresult PLUGIN_API getName (Vst::String128 name) SMTG_OVERRIDE; tresult PLUGIN_API createInstance (TUID cid, TUID _iid, void** obj) SMTG_OVERRIDE; @@ -263,61 +302,91 @@ class LIBARDOUR_LOCAL Vst3ParamValueQueue : public Vst::IParamValueQueue { public: QUERY_INTERFACE_IMPL (Vst::IParamValueQueue); - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return 1; } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return 1; } + + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return 1; + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return 1; + } static const int maxNumPoints = 64; - Vst3ParamValueQueue() { + Vst3ParamValueQueue () + { _values.reserve (maxNumPoints); _id = Vst::kNoParamId; } - Vst::ParamID PLUGIN_API getParameterId() SMTG_OVERRIDE { return _id; } + Vst::ParamID PLUGIN_API getParameterId () SMTG_OVERRIDE + { + return _id; + } - void setParameterId (Vst::ParamID id) { - _values.clear(); + void setParameterId (Vst::ParamID id) + { + _values.clear (); _id = id; } - int32 PLUGIN_API getPointCount() SMTG_OVERRIDE { return _values.size(); } + int32 PLUGIN_API getPointCount () SMTG_OVERRIDE + { + return _values.size (); + } + tresult PLUGIN_API getPoint (int32 index, int32&, Vst::ParamValue&) SMTG_OVERRIDE; tresult PLUGIN_API addPoint (int32, Vst::ParamValue, int32&) SMTG_OVERRIDE; protected: struct Value { Value (Vst::ParamValue v, int32 offset) - : value(v) - , sampleOffset(offset) + : value (v) + , sampleOffset (offset) {} + Vst::ParamValue value; - int32 sampleOffset; + int32 sampleOffset; }; std::vector _values; - Vst::ParamID _id; + Vst::ParamID _id; }; class LIBARDOUR_LOCAL Vst3ParameterChanges : public Vst::IParameterChanges { public: QUERY_INTERFACE_IMPL (Vst::IParameterChanges); - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return 1; } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return 1; } - Vst3ParameterChanges () { + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return 1; + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return 1; + } + + Vst3ParameterChanges () + { clear (); } - void set_n_params (int n) { - _queue.resize(n); + void set_n_params (int n) + { + _queue.resize (n); } - void clear () { + void clear () + { _used_queue_count = 0; } - int32 PLUGIN_API getParameterCount() SMTG_OVERRIDE { + int32 PLUGIN_API getParameterCount () SMTG_OVERRIDE + { return _used_queue_count; } @@ -326,25 +395,36 @@ public: protected: std::vector _queue; - int _used_queue_count; + int _used_queue_count; }; class LIBARDOUR_LOCAL Vst3EventList : public Vst::IEventList { public: - Vst3EventList() { + Vst3EventList () + { _events.reserve (128); } QUERY_INTERFACE_IMPL (Vst::IEventList) - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return 1; } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return 1; } - int32 PLUGIN_API PLUGIN_API getEventCount() SMTG_OVERRIDE { + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return 1; + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return 1; + } + + int32 PLUGIN_API PLUGIN_API getEventCount () SMTG_OVERRIDE + { return _events.size (); } - tresult PLUGIN_API getEvent (int32 index, Vst::Event& e) SMTG_OVERRIDE { + tresult PLUGIN_API getEvent (int32 index, Vst::Event& e) SMTG_OVERRIDE + { if (index >= 0 && index < (int32)_events.size ()) { e = _events[index]; return kResultTrue; @@ -353,13 +433,15 @@ public: } } - tresult PLUGIN_API addEvent (Vst::Event& e) SMTG_OVERRIDE { + tresult PLUGIN_API addEvent (Vst::Event& e) SMTG_OVERRIDE + { _events.push_back (e); return kResultTrue; } - void clear() { - _events.clear(); + void clear () + { + _events.clear (); } protected: @@ -376,8 +458,16 @@ public: virtual ~RAMStream (); tresult PLUGIN_API queryInterface (const TUID _iid, void** obj) SMTG_OVERRIDE; - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return 1; } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return 1; } + + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return 1; + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return 1; + } /* IBStream API */ tresult PLUGIN_API read (void* buffer, int32 numBytes, int32* numBytesRead) SMTG_OVERRIDE; @@ -390,12 +480,19 @@ public: tresult PLUGIN_API setStreamSize (int64) SMTG_OVERRIDE; /* IStreamAttributes API */ - tresult PLUGIN_API getFileName (Vst::String128 name) SMTG_OVERRIDE; + tresult PLUGIN_API getFileName (Vst::String128 name) SMTG_OVERRIDE; Vst::IAttributeList* PLUGIN_API getAttributes () SMTG_OVERRIDE; /* convenience API for state I/O */ - void rewind () { _pos = 0; } - bool readonly () const { return _readonly; } + void rewind () + { + _pos = 0; + } + + bool readonly () const + { + return _readonly; + } bool write_int32 (int32 i); bool write_int64 (int64 i); @@ -408,8 +505,15 @@ public: bool read_TUID (TUID& tuid); /* direct access */ - uint8_t const* data () const { return _data; } - int64 size () const { return _size; } + uint8_t const* data () const + { + return _data; + } + + int64 size () const + { + return _size; + } #ifndef NDEBUG void hexdump (int64 max_len = 64) const; @@ -418,16 +522,20 @@ public: private: bool reallocate_buffer (int64 size, bool exact); - template bool read_pod (T& t) { + template + bool read_pod (T& t) + { int32 n_read = 0; - read ((void *)&t, sizeof(T), &n_read); - return n_read == sizeof(T); + read ((void*)&t, sizeof (T), &n_read); + return n_read == sizeof (T); } - template bool write_pod (const T& t) { + template + bool write_pod (const T& t) + { int32 written = 0; - write (const_cast((const void *)&t), sizeof(T), &written); - return written == sizeof(T); + write (const_cast ((const void*)&t), sizeof (T), &written); + return written == sizeof (T); } uint8_t* _data; @@ -446,8 +554,16 @@ public: virtual ~ROMStream (); tresult PLUGIN_API queryInterface (const TUID _iid, void** obj) SMTG_OVERRIDE; - uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return 1; } - uint32 PLUGIN_API release () SMTG_OVERRIDE { return 1; } + + uint32 PLUGIN_API addRef () SMTG_OVERRIDE + { + return 1; + } + + uint32 PLUGIN_API release () SMTG_OVERRIDE + { + return 1; + } /* IBStream API */ tresult PLUGIN_API read (void* buffer, int32 numBytes, int32* numBytesRead) SMTG_OVERRIDE; @@ -455,7 +571,11 @@ public: tresult PLUGIN_API seek (int64 pos, int32 mode, int64* result) SMTG_OVERRIDE; tresult PLUGIN_API tell (int64* pos) SMTG_OVERRIDE; - void rewind () { _pos = 0; } + void rewind () + { + _pos = 0; + } + protected: IBStream& _stream; int64 _offset; @@ -463,11 +583,10 @@ protected: int64 _pos; }; - #if defined(__clang__) -# pragma clang diagnostic pop +#pragma clang diagnostic pop #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# pragma GCC diagnostic pop +#pragma GCC diagnostic pop #endif } // namespace Steinberg diff --git a/libs/ardour/ardour/vst3_plugin.h b/libs/ardour/ardour/vst3_plugin.h index afaaecc5ca..f3fe57a78e 100644 --- a/libs/ardour/ardour/vst3_plugin.h +++ b/libs/ardour/ardour/vst3_plugin.h @@ -25,27 +25,27 @@ #include -#include "pbd/signals.h" #include "pbd/search_path.h" +#include "pbd/signals.h" #include "ardour/plugin.h" #include "ardour/vst3_host.h" -namespace ARDOUR { +namespace ARDOUR +{ class VST3PluginModule; class AutomationList; } #if defined(__clang__) -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wnon-virtual-dtor" +# pragma clang diagnostic push +# pragma clang diagnostic ignored "-Wnon-virtual-dtor" #elif __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6) -# pragma GCC diagnostic push -# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" +# pragma GCC diagnostic push +# pragma GCC diagnostic ignored "-Wnon-virtual-dtor" #endif namespace Steinberg { - /* VST3 hosted Plugin abstraction Implementation * * For convenience this is placed in the Steinberg namespace. @@ -92,32 +92,35 @@ public: tresult PLUGIN_API endEditContextInfoValue (FIDString) SMTG_OVERRIDE; /* GUI */ - bool has_editor () const; + bool has_editor () const; IPlugView* view (); - void close_view (); - PBD::Signal2 OnResizeView; + void close_view (); + void update_contoller_param (); #if SMTG_OS_LINUX void set_runloop (Linux::IRunLoop*); #endif - void update_contoller_param (); + PBD::Signal2 OnResizeView; tresult PLUGIN_API queryInterface (const TUID _iid, void** obj) SMTG_OVERRIDE; uint32 PLUGIN_API addRef () SMTG_OVERRIDE { return 1; } uint32 PLUGIN_API release () SMTG_OVERRIDE { return 1; } + FUID const& fuid () const { return _fuid; } + /* Ardour Preset Helpers */ Vst::IUnitInfo* unit_info (); - FUID const& fuid() const { return _fuid; } - Vst::ParameterInfo const& program_change_port() const { return _program_change_port; } - void set_n_factory_presets (size_t n) { _n_factory_presets = n; } + Vst::ParameterInfo const& program_change_port () const { return _program_change_port; } + + void set_n_factory_presets (size_t n) { _n_factory_presets = n; } size_t n_factory_presets () const { return _n_factory_presets; } /* API for Ardour -- Ports */ - uint32_t designated_bypass_port () const { return _port_id_bypass; } - uint32_t parameter_count () const { return _ctrl_params.size (); } - bool parameter_is_automatable (uint32_t p) const { return _ctrl_params[p].automatable; } - bool parameter_is_readonly (uint32_t p) const { return _ctrl_params[p].read_only; } - std::string parameter_label (uint32_t p) const { return _ctrl_params[p].label; } + uint32_t designated_bypass_port () const { return _port_id_bypass; } + uint32_t parameter_count () const { return _ctrl_params.size (); } + bool parameter_is_automatable (uint32_t p) const { return _ctrl_params[p].automatable; } + bool parameter_is_readonly (uint32_t p) const { return _ctrl_params[p].read_only; } + std::string parameter_label (uint32_t p) const { return _ctrl_params[p].label; } + float default_value (uint32_t p) const; void get_parameter_descriptor (uint32_t, ARDOUR::ParameterDescriptor&) const; std::string print_parameter (uint32_t p) const; @@ -147,20 +150,28 @@ public: std::string format_parameter (uint32_t p) const; Vst::ParamID index_to_id (uint32_t) const; - enum ParameterChange { BeginGesture, EndGesture , ValueChange, InternalChange, PresetChange }; + enum ParameterChange { BeginGesture, + EndGesture, + ValueChange, + InternalChange, + PresetChange }; + PBD::Signal3 OnParameterChange; /* API for Ardour -- Setup/Processing */ - uint32_t plugin_latency (); - bool set_block_size (int32_t); - bool activate (); - bool deactivate (); + uint32_t plugin_latency (); + bool set_block_size (int32_t); + bool activate (); + bool deactivate (); /* State */ bool save_state (RAMStream& stream); bool load_state (RAMStream& stream); - Vst::ProcessContext& context () { return _context; } + Vst::ProcessContext& context () + { + return _context; + } void set_owner (ARDOUR::SessionObject* o); @@ -169,7 +180,10 @@ public: void process (float** ins, float** outs, uint32_t n_samples); /* PSL Extension */ - Vst::IEditController* controller () const { return _controller; } + Vst::IEditController* controller () const + { + return _controller; + } bool add_slave (Vst::IEditController*, bool); bool remove_slave (Vst::IEditController*); @@ -197,7 +211,7 @@ private: void set_event_bus_state (bool enabled); - bool midi_controller (int32_t, int16_t, Vst::CtrlNumber, Vst::ParamID &id); + bool midi_controller (int32_t, int16_t, Vst::CtrlNumber, Vst::ParamID& id); bool live_midi_cc (int32_t, int16_t, Vst::CtrlNumber); bool setup_info_listener (); @@ -304,21 +318,25 @@ public: uint32_t nth_parameter (uint32_t port, bool& ok) const; bool print_parameter (uint32_t, std::string&) const; - bool parameter_is_audio (uint32_t) const { return false; } + bool parameter_is_audio (uint32_t) const { return false; } bool parameter_is_control (uint32_t) const { return true; } + bool parameter_is_input (uint32_t) const; bool parameter_is_output (uint32_t) const; uint32_t designated_bypass_port (); std::set automatable () const; - std::string describe_parameter (Evoral::Parameter); - IOPortDescription describe_io_port (DataType dt, bool input, uint32_t id) const; - PluginOutputConfiguration possible_output () const; + std::string describe_parameter (Evoral::Parameter); + IOPortDescription describe_io_port (DataType dt, bool input, uint32_t id) const; + PluginOutputConfiguration possible_output () const; void set_automation_control (uint32_t, boost::shared_ptr); - std::string state_node_name () const { return "vst3"; } + std::string state_node_name () const + { + return "vst3"; + } void add_state (XMLNode*) const; int set_state (const XMLNode&, int version); @@ -327,8 +345,15 @@ public: std::string do_save_preset (std::string); void do_remove_preset (std::string); - void activate () { _plug->activate (); } - void deactivate () { _plug->deactivate (); } + void activate () + { + _plug->activate (); + } + + void deactivate () + { + _plug->deactivate (); + } int set_block_size (pframes_t); @@ -342,13 +367,13 @@ public: ChanMapping const& in, ChanMapping const& out, pframes_t nframes, samplecnt_t offset); - bool has_editor () const; + bool has_editor () const; Steinberg::IPlugView* view (); - void close_view (); + void close_view (); + void update_contoller_param (); #if SMTG_OS_LINUX void set_runloop (Steinberg::Linux::IRunLoop*); #endif - void update_contoller_param (); PBD::Signal2 OnResizeView; @@ -362,9 +387,10 @@ private: PBD::Searchpath preset_search_path () const; Steinberg::VST3PI* _plug; + PBD::ScopedConnectionList _connections; - std::map _preset_uri_map; + std::map _preset_uri_map; std::vector _connected_inputs; std::vector _connected_outputs; @@ -380,7 +406,7 @@ public: PluginPtr load (Session& session); std::vector get_presets (bool user_only) const; - bool is_instrument () const; + bool is_instrument () const; boost::shared_ptr m; }; diff --git a/libs/ardour/vst3_host.cc b/libs/ardour/vst3_host.cc index dfd0bc7f34..37ec59554f 100644 --- a/libs/ardour/vst3_host.cc +++ b/libs/ardour/vst3_host.cc @@ -17,8 +17,8 @@ * */ -#include #include +#include #if (__cplusplus >= 201103L) #include @@ -27,8 +27,8 @@ #include "ardour/vst3_host.h" #ifndef VST3_SCANNER_APP -#include "pbd/compose.h" #include "ardour/debug.h" +#include "pbd/compose.h" #endif using namespace Steinberg; @@ -102,7 +102,7 @@ Steinberg::utf8_to_tchar (Vst::TChar* rv, const char* s, size_t l) memset (rv, 0, sizeof (Vst::TChar)); return false; } - if (l > 0 && l <= (size_t) len) { + if (l > 0 && l <= (size_t)len) { len = l - 1; } memcpy (rv, s16, len * sizeof (Vst::TChar)); @@ -114,7 +114,7 @@ Steinberg::utf8_to_tchar (Vst::TChar* rv, const char* s, size_t l) bool Steinberg::utf8_to_tchar (Vst::TChar* rv, std::string const& s, size_t l) { - return utf8_to_tchar (rv, s.c_str(), l); + return utf8_to_tchar (rv, s.c_str (), l); } /* ****************************************************************************/ @@ -341,13 +341,13 @@ ConnectionProxy::connect (Vst::IConnectionPoint* dst) } tresult - ConnectionProxy::disconnect (Vst::IConnectionPoint* dst) +ConnectionProxy::disconnect (Vst::IConnectionPoint* dst) { - if (!dst) { - return kInvalidArgument; + if (!dst) { + return kInvalidArgument; } - if (dst != _dst) { + if (dst != _dst) { return kInvalidArgument; } @@ -360,15 +360,14 @@ tresult return kResultTrue; } - tresult ConnectionProxy::notify (Vst::IMessage* message) { - if (!_dst) { + if (!_dst) { return kResultFalse; } #if 0 - if (strcmp ("ArdourGUI", pthread_name ())) { + if (strcmp ("ArdourGUI", pthread_name ())) { return kResultFalse; } #endif @@ -378,7 +377,7 @@ ConnectionProxy::notify (Vst::IMessage* message) bool ConnectionProxy::disconnect () { - return kResultTrue == disconnect (_dst); + return kResultTrue == disconnect (_dst); } /* ****************************************************************************/ @@ -491,7 +490,7 @@ HostApplication::queryInterface (const char* _iid, void** obj) #endif #ifndef VST3_SCANNER_APP - if (DEBUG_ENABLED(PBD::DEBUG::VST3Config)) { + if (DEBUG_ENABLED (PBD::DEBUG::VST3Config)) { char fuid[33]; FUID::fromTUID (_iid).toString (fuid); DEBUG_TRACE (PBD::DEBUG::VST3Config, string_compose ("HostApplication::queryInterface not supported: %1\n", fuid)); @@ -530,14 +529,13 @@ HostApplication::createInstance (TUID cid, TUID _iid, void** obj) tresult Vst3ParamValueQueue::getPoint (int32 index, int32& sampleOffset, Vst::ParamValue& value) { - if (index >=0 && index < (int32)_values.size ()) { + if (index >= 0 && index < (int32)_values.size ()) { const Value& v = _values[index]; - sampleOffset = v.sampleOffset; - value = v.value; + sampleOffset = v.sampleOffset; + value = v.value; return kResultTrue; } return kResultFalse; - } tresult @@ -547,7 +545,7 @@ Vst3ParamValueQueue::addPoint (int32 sampleOffset, Vst::ParamValue value, int32& for (uint32 i = 0; i < _values.size (); ++i) { if (_values[i].sampleOffset == sampleOffset) { _values[i].value = value; - index = i; + index = i; return kResultTrue; } else if (_values[i].sampleOffset > sampleOffset) { dest_index = i; @@ -571,27 +569,27 @@ Vst3ParamValueQueue::addPoint (int32 sampleOffset, Vst::ParamValue value, int32& Vst::IParamValueQueue* Vst3ParameterChanges::getParameterData (int32 index) { - if (index < _used_queue_count) { - return &_queue[index]; + if (index < _used_queue_count) { + return &_queue[index]; } - return 0; + return 0; } Vst::IParamValueQueue* Vst3ParameterChanges::addParameterData (Vst::ParamID const& pid, int32& index) { - for (int32 i = 0; i < _used_queue_count; ++i) { - if (_queue[i].getParameterId () == pid) { - index = i; - return &_queue[i]; - } - } + for (int32 i = 0; i < _used_queue_count; ++i) { + if (_queue[i].getParameterId () == pid) { + index = i; + return &_queue[i]; + } + } - if (_used_queue_count < (int32)_queue.size ()) { + if (_used_queue_count < (int32)_queue.size ()) { index = _used_queue_count++; _queue[index].setParameterId (pid); return &_queue[index]; - } + } index = 0; return 0; } @@ -628,7 +626,7 @@ RAMStream::RAMStream (std::string const& fn) , _pos (0) , _readonly (true) { - gchar* buf = NULL; + gchar* buf = NULL; gsize length = 0; if (!g_file_get_contents (fn.c_str (), &buf, &length, NULL)) { @@ -649,15 +647,15 @@ RAMStream::~RAMStream () tresult RAMStream::queryInterface (const TUID _iid, void** obj) { - QUERY_INTERFACE (_iid, obj, FUnknown::iid, IBStream) - QUERY_INTERFACE (_iid, obj, IBStream::iid, IBStream) - QUERY_INTERFACE (_iid, obj, FUnknown::iid, ISizeableStream) - QUERY_INTERFACE (_iid, obj, ISizeableStream::iid, ISizeableStream) - QUERY_INTERFACE (_iid, obj, FUnknown::iid, Vst::IStreamAttributes) - QUERY_INTERFACE (_iid, obj, Vst::IStreamAttributes::iid, Vst::IStreamAttributes) + QUERY_INTERFACE (_iid, obj, FUnknown::iid, IBStream) + QUERY_INTERFACE (_iid, obj, IBStream::iid, IBStream) + QUERY_INTERFACE (_iid, obj, FUnknown::iid, ISizeableStream) + QUERY_INTERFACE (_iid, obj, ISizeableStream::iid, ISizeableStream) + QUERY_INTERFACE (_iid, obj, FUnknown::iid, Vst::IStreamAttributes) + QUERY_INTERFACE (_iid, obj, Vst::IStreamAttributes::iid, Vst::IStreamAttributes) - *obj = nullptr; - return kNoInterface; + *obj = nullptr; + return kNoInterface; } bool @@ -665,7 +663,7 @@ RAMStream::reallocate_buffer (int64 size, bool exact) { if (size <= 0) { free (_data); - _data = 0; + _data = 0; _alloc = 0; return true; } @@ -686,7 +684,7 @@ RAMStream::reallocate_buffer (int64 size, bool exact) } } - _data = (uint8_t*) realloc (_data, size); + _data = (uint8_t*)realloc (_data, size); if (_data) { _alloc = size; @@ -710,7 +708,7 @@ RAMStream::read (void* buffer, int32 n_bytes, int32* n_read) } if (n_bytes > 0) { - memcpy(buffer, &_data[_pos], n_bytes); + memcpy (buffer, &_data[_pos], n_bytes); _pos += n_bytes; } if (n_read) { @@ -786,7 +784,8 @@ RAMStream::tell (int64* pos) } bool -RAMStream::write_int32 (int32 i) { +RAMStream::write_int32 (int32 i) +{ /* pluginterfaces/base/ftypes.h */ #if BYTEORDER == kBigEndian SWAP_32 (i) @@ -816,33 +815,34 @@ struct GUIDStruct { uint32_t data1; uint16_t data2; uint16_t data3; - uint8_t data4[8]; + uint8_t data4[8]; }; #endif bool RAMStream::write_TUID (const TUID& tuid) { - int i = 0; + int i = 0; int32 n_bytes = 0; - char buf[Vst::kClassIDSize + 1]; + char buf[Vst::kClassIDSize + 1]; #if COM_COMPATIBLE GUIDStruct guid; - memcpy (&guid, tuid, sizeof(GUIDStruct)); - sprintf(buf, "%08X%04X%04X", guid.data1, guid.data2, guid.data3); + memcpy (&guid, tuid, sizeof (GUIDStruct)); + sprintf (buf, "%08X%04X%04X", guid.data1, guid.data2, guid.data3); i += 8; #endif - for (; i < (int)sizeof(TUID); ++i){ - sprintf(buf + 2 * i, "%02X", (uint8_t)tuid[i]); + for (; i < (int)sizeof (TUID); ++i) { + sprintf (buf + 2 * i, "%02X", (uint8_t)tuid[i]); } write (buf, Vst::kClassIDSize, &n_bytes); return n_bytes == Vst::kClassIDSize; } bool -RAMStream::read_int32 (int32& i) { +RAMStream::read_int32 (int32& i) +{ if (!read_pod (i)) { return false; } @@ -853,7 +853,8 @@ RAMStream::read_int32 (int32& i) { } bool -RAMStream::read_int64 (int64& i) { +RAMStream::read_int64 (int64& i) +{ if (!read_pod (i)) { return false; } @@ -872,11 +873,11 @@ RAMStream::read_ChunkID (Vst::ChunkID& id) bool RAMStream::read_TUID (TUID& tuid) { - int i = 0; + int i = 0; int32 n_bytes = 0; - char buf[Vst::kClassIDSize+1]; + char buf[Vst::kClassIDSize + 1]; - read((void *)buf, Vst::kClassIDSize, &n_bytes); + read ((void*)buf, Vst::kClassIDSize, &n_bytes); if (n_bytes != Vst::kClassIDSize) { return false; } @@ -885,14 +886,14 @@ RAMStream::read_TUID (TUID& tuid) #if COM_COMPATIBLE GUIDStruct guid; - sscanf (buf, "%08x", &guid.data1); - sscanf (buf+8, "%04hx", &guid.data2); - sscanf (buf+12, "%04hx", &guid.data3); - memcpy (tuid, &guid, sizeof(TUID) >> 1); + sscanf (buf, "%08x", &guid.data1); + sscanf (buf + 8, "%04hx", &guid.data2); + sscanf (buf + 12, "%04hx", &guid.data3); + memcpy (tuid, &guid, sizeof (TUID) >> 1); i += 16; #endif - for (; i < Vst::kClassIDSize; i += 2){ + for (; i < Vst::kClassIDSize; i += 2) { uint32_t temp; sscanf (buf + i, "%02X", &temp); tuid[i >> 1] = temp; @@ -931,9 +932,9 @@ RAMStream::getAttributes () #ifndef NDEBUG +#include #include #include -#include void RAMStream::hexdump (int64 max_len) const @@ -941,14 +942,14 @@ RAMStream::hexdump (int64 max_len) const std::ostringstream out; size_t row_size = 16; - size_t length = max_len > 0 ? std::min (max_len, _size) : _size; + size_t length = max_len > 0 ? std::min (max_len, _size) : _size; - out << std::setfill('0'); + out << std::setfill ('0'); for (size_t i = 0; i < length; i += row_size) { - out << "0x" << std::setw(6) << std::hex << i << ": "; + out << "0x" << std::setw (6) << std::hex << i << ": "; for (size_t j = 0; j < row_size; ++j) { if (i + j < length) { - out << std::hex << std::setw(2) << static_cast(_data[i + j]) << " "; + out << std::hex << std::setw (2) << static_cast (_data[i + j]) << " "; } else { out << " "; } @@ -957,8 +958,8 @@ RAMStream::hexdump (int64 max_len) const if (true) { for (size_t j = 0; j < row_size; ++j) { if (i + j < length) { - if (isprint(_data[i + j])) { - out << static_cast(_data[i + j]); + if (isprint (_data[i + j])) { + out << static_cast (_data[i + j]); } else { out << "."; } @@ -975,7 +976,7 @@ ROMStream::ROMStream (IBStream& src, TSize offset, TSize size) : _stream (src) , _offset (offset) , _size (size) - , _pos (0) + , _pos (0) { _stream.addRef (); } @@ -988,11 +989,11 @@ ROMStream::~ROMStream () tresult ROMStream::queryInterface (const TUID _iid, void** obj) { - QUERY_INTERFACE (_iid, obj, FUnknown::iid, IBStream) - QUERY_INTERFACE (_iid, obj, IBStream::iid, IBStream) + QUERY_INTERFACE (_iid, obj, FUnknown::iid, IBStream) + QUERY_INTERFACE (_iid, obj, IBStream::iid, IBStream) - *obj = nullptr; - return kNoInterface; + *obj = nullptr; + return kNoInterface; } tresult @@ -1019,16 +1020,16 @@ ROMStream::read (void* buffer, int32 n_bytes, int32* n_read) } int32 _n_read = 0; - result = _stream.read (buffer, n_bytes, &_n_read); + result = _stream.read (buffer, n_bytes, &_n_read); - if (_n_read > 0) { - _pos += _n_read; + if (_n_read > 0) { + _pos += _n_read; } - if (n_read) { - *n_read = _n_read; + if (n_read) { + *n_read = _n_read; } - return result; + return result; } tresult diff --git a/libs/ardour/vst3_plugin.cc b/libs/ardour/vst3_plugin.cc index 9b9db16361..8119ca50e3 100644 --- a/libs/ardour/vst3_plugin.cc +++ b/libs/ardour/vst3_plugin.cc @@ -29,8 +29,8 @@ #include "pbd/tokenizer.h" #ifdef PLATFORM_WINDOWS -#include // CSIDL_* #include "pbd/windows_special_dirs.h" +#include // CSIDL_* #endif #include "ardour/audio_buffer.h" @@ -75,9 +75,9 @@ void VST3Plugin::init () { #ifndef NDEBUG - if (DEBUG_ENABLED(DEBUG::VST3Config)) { + if (DEBUG_ENABLED (DEBUG::VST3Config)) { char fuid[33]; - _plug->fuid().toString (fuid); + _plug->fuid ().toString (fuid); DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3 instantiating FUID: %1\n", fuid)); } #endif @@ -99,7 +99,8 @@ VST3Plugin::init () } void -VST3Plugin::forward_resize_view (int w, int h) { +VST3Plugin::forward_resize_view (int w, int h) +{ OnResizeView (w, h); /* EMIT SINAL */ } @@ -124,8 +125,8 @@ VST3Plugin::parameter_change_handler (VST3PI::ParameterChange t, uint32_t param, PresetsChanged (unique_id (), this, false); /* EMIT SIGNAL */ size_t n_presets = _plug->n_factory_presets (); // ths may be old, invalidated count if (_plug->program_change_port ().id != Vst::kNoParamId) { - int pgm = value * (n_presets > 1 ? (n_presets - 1) : 1); - std::string uri = string_compose (X_("VST3-P:%1:%2"), unique_id (), std::setw(4), std::setfill('0'), pgm); + int pgm = value * (n_presets > 1 ? (n_presets - 1) : 1); + std::string uri = string_compose (X_("VST3-P:%1:%2"), unique_id (), std::setw (4), std::setfill ('0'), pgm); const Plugin::PresetRecord* pset = Plugin::preset_by_uri (uri); if (pset && n_presets == _plug->n_factory_presets ()) { Plugin::load_preset (*pset); @@ -210,7 +211,7 @@ VST3Plugin::set_automation_control (uint32_t port, boost::shared_ptralist () || !_plug->subscribe_to_automation_changes ()) { return; } - ac->alist()->automation_state_changed.connect_same_thread (_connections, boost::bind (&VST3PI::automation_state_changed, _plug, port, _1, boost::weak_ptr (ac->alist ()))); + ac->alist ()->automation_state_changed.connect_same_thread (_connections, boost::bind (&VST3PI::automation_state_changed, _plug, port, _1, boost::weak_ptr (ac->alist ()))); } std::set @@ -238,7 +239,7 @@ bool VST3Plugin::print_parameter (uint32_t port, std::string& rv) const { rv = _plug->print_parameter (port); - return rv.size() > 0; + return rv.size () > 0; } Plugin::IOPortDescription @@ -283,7 +284,6 @@ VST3Plugin::set_runloop (Steinberg::Linux::IRunLoop* run_loop) } #endif - void VST3Plugin::update_contoller_param () { @@ -303,7 +303,7 @@ VST3PI::evoral_to_vst3 (Vst::Event& e, Evoral::Event const& ev, int return false; } - const uint8_t* data = ev.buffer(); + const uint8_t* data = ev.buffer (); uint8_t status = data[0]; if (status >= 0x80 && status < 0xF0) { @@ -313,13 +313,13 @@ VST3PI::evoral_to_vst3 (Vst::Event& e, Evoral::Event const& ev, int if (size == 2 || size == 3) { Vst::ParamID id = Vst::kNoParamId; - const uint8_t channel = data[0] & 0x0f; - const uint8_t data1 = data[1] & 0x7f; - const uint8_t data2 = size == 3 ? (data[2] & 0x7f) : 0; + const uint8_t channel = data[0] & 0x0f; + const uint8_t data1 = data[1] & 0x7f; + const uint8_t data2 = size == 3 ? (data[2] & 0x7f) : 0; switch (status) { case MIDI_CMD_NOTE_OFF: - e.type = Vst::Event::kNoteOffEvent; + e.type = Vst::Event::kNoteOffEvent; e.noteOff.channel = channel; e.noteOff.noteId = -1; e.noteOff.pitch = data1; @@ -327,7 +327,7 @@ VST3PI::evoral_to_vst3 (Vst::Event& e, Evoral::Event const& ev, int e.noteOff.tuning = 0.f; return true; case MIDI_CMD_NOTE_ON: - e.type = Vst::Event::kNoteOnEvent; + e.type = Vst::Event::kNoteOnEvent; e.noteOn.channel = channel; e.noteOn.noteId = -1; e.noteOn.pitch = data1; @@ -336,14 +336,14 @@ VST3PI::evoral_to_vst3 (Vst::Event& e, Evoral::Event const& ev, int e.noteOn.tuning = 0.f; return true; case MIDI_CMD_NOTE_PRESSURE: - e.type = Vst::Event::kPolyPressureEvent; + e.type = Vst::Event::kPolyPressureEvent; e.polyPressure.channel = channel; e.polyPressure.pitch = data1; e.polyPressure.pressure = data2 / 127.f; e.polyPressure.noteId = -1; return true; case MIDI_CMD_CONTROL: - if (ev.is_live_midi ()/* live input -- no playback */) { + if (ev.is_live_midi () /* live input -- no playback */) { live_midi_cc (bus, channel, data1); } if (midi_controller (bus, channel, data1, id)) { @@ -368,22 +368,22 @@ VST3PI::evoral_to_vst3 (Vst::Event& e, Evoral::Event const& ev, int return false; } } else if (status == MIDI_CMD_COMMON_SYSEX) { - memset (&e, 0, sizeof(Vst::Event)); + memset (&e, 0, sizeof (Vst::Event)); e.type = Vst::Event::kDataEvent; e.data.type = Vst::DataEvent::kMidiSysEx; e.data.bytes = ev.buffer (); // TODO copy ?! - e.data.size = ev.size(); + e.data.size = ev.size (); return true; } return false; } -#define vst_to_midi(x) (static_cast((x) * 127.f) & 0x7f) +#define vst_to_midi(x) (static_cast ((x)*127.f) & 0x7f) void VST3PI::vst3_to_midi_buffers (BufferSet& bufs, ChanMapping const& out_map) { - for (int32 i = 0; i < _output_events.getEventCount(); ++i) { + for (int32 i = 0; i < _output_events.getEventCount (); ++i) { Vst::Event e; if (_output_events.getEvent (i, e) == kResultFalse) { continue; @@ -391,13 +391,13 @@ VST3PI::vst3_to_midi_buffers (BufferSet& bufs, ChanMapping const& out_map) bool valid = false; uint32_t index = out_map.get (DataType::MIDI, e.busIndex, &valid); - if (!valid || bufs.count().n_midi() <= index) { + if (!valid || bufs.count ().n_midi () <= index) { DEBUG_TRACE (DEBUG::VST3Process, string_compose ("VST3PI::vst3_to_midi_buffers - Invalid MIDI Bus %1\n", e.busIndex)); continue; } MidiBuffer& mb = bufs.get_midi (index); - uint8_t data[3]; + uint8_t data[3]; switch (e.type) { case Vst::Event::kDataEvent: @@ -469,14 +469,14 @@ VST3PI::vst3_to_midi_buffers (BufferSet& bufs, ChanMapping const& out_map) void VST3Plugin::add_state (XMLNode* root) const { - XMLNode *child; + XMLNode* child; for (uint32_t i = 0; i < parameter_count (); ++i) { if (!parameter_is_input (i)) { continue; } - child = new XMLNode("Port"); - child->set_property("id", (uint32_t) _plug->index_to_id(i)); - child->set_property("value", _plug->get_parameter (i)); + child = new XMLNode ("Port"); + child->set_property ("id", (uint32_t)_plug->index_to_id (i)); + child->set_property ("value", _plug->get_parameter (i)); root->add_child_nocopy (*child); } @@ -499,35 +499,35 @@ VST3Plugin::set_state (const XMLNode& node, int version) { XMLNodeConstIterator iter; - if (node.name() != state_node_name()) { + if (node.name () != state_node_name ()) { error << string_compose (_("VST3<%1>: Bad node sent to VST3Plugin::set_state"), name ()) << endmsg; return -1; } const Plugin::PresetRecord* r = 0; - std::string preset_uri; + std::string preset_uri; if (node.get_property (X_("last-preset-uri"), preset_uri)) { r = preset_by_uri (preset_uri); } - if (r && _plug->program_change_port().id != Vst::kNoParamId) { + if (r && _plug->program_change_port ().id != Vst::kNoParamId) { std::vector tmp; - if (PBD::tokenize (r->uri, std::string(":"), std::back_inserter (tmp)) && tmp.size() == 3 && tmp[0] == "VST3-P") { - float value = PBD::atoi (tmp[2]); + if (PBD::tokenize (r->uri, std::string (":"), std::back_inserter (tmp)) && tmp.size () == 3 && tmp[0] == "VST3-P") { + float value = PBD::atoi (tmp[2]); size_t n_presets = _plug->n_factory_presets (); if (n_presets > 1) { value /= (n_presets - 1.f); } DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3Plugin::set_state: set_program (pgm: %1 plug: %2)\n", value, name ())); - _plug->controller ()->setParamNormalized (_plug->program_change_port().id, value); + _plug->controller ()->setParamNormalized (_plug->program_change_port ().id, value); } } XMLNodeList nodes = node.children ("Port"); - for (iter = nodes.begin(); iter != nodes.end(); ++iter) { + for (iter = nodes.begin (); iter != nodes.end (); ++iter) { XMLNode* child = *iter; uint32_t param_id; - float value; + float value; if (!child->get_property ("id", param_id)) { warning << string_compose (_("VST3<%1>: Missing parameter-id in VST3Plugin::set_state"), name ()) << endmsg; @@ -546,10 +546,10 @@ VST3Plugin::set_state (const XMLNode& node, int version) XMLNode* chunk; if ((chunk = find_named_node (node, X_("chunk"))) != 0) { - for (iter = chunk->children ().begin(); iter != chunk->children ().end(); ++iter) { + for (iter = chunk->children ().begin (); iter != chunk->children ().end (); ++iter) { if ((*iter)->is_content ()) { - gsize size = 0; - guchar* _data = g_base64_decode ((*iter)->content().c_str(), &size); + gsize size = 0; + guchar* _data = g_base64_decode ((*iter)->content ().c_str (), &size); RAMStream stream (_data, size); if (!_plug->load_state (stream)) { error << string_compose (_("VST3<%1>: failed to load chunk-data"), name ()) << endmsg; @@ -607,13 +607,13 @@ VST3Plugin::connect_and_run (BufferSet& bufs, ChanMapping const& in_map, ChanMapping const& out_map, pframes_t n_samples, samplecnt_t offset) { - DEBUG_TRACE (DEBUG::VST3Process, string_compose ("%1 run %2 offset %3\n", name(), n_samples, offset)); + DEBUG_TRACE (DEBUG::VST3Process, string_compose ("%1 run %2 offset %3\n", name (), n_samples, offset)); Plugin::connect_and_run (bufs, start, end, speed, in_map, out_map, n_samples, offset); Vst::ProcessContext& context (_plug->context ()); /* clear event ports */ - _plug->cycle_start(); + _plug->cycle_start (); context.state = Vst::ProcessContext::kContTimeValid | Vst::ProcessContext::kSystemTimeValid | Vst::ProcessContext::kSmpteValid | Vst::ProcessContext::kProjectTimeMusicValid | Vst::ProcessContext::kBarPositionValid | Vst::ProcessContext::kTempoValid | Vst::ProcessContext::kTimeSigValid | Vst::ProcessContext::kClockValid; @@ -623,10 +623,10 @@ VST3Plugin::connect_and_run (BufferSet& bufs, context.systemTime = g_get_monotonic_time (); { - TempoMap const& tmap (_session.tempo_map ()); - const Tempo& t (tmap.tempo_at_sample (start)); - const Timecode::BBT_Time& bbt (tmap.bbt_at_sample_rt (start)); - const MeterSection& ms (tmap.meter_section_at_sample (start)); + TempoMap const& tmap (_session.tempo_map ()); + const Tempo& t (tmap.tempo_at_sample (start)); + const Timecode::BBT_Time& bbt (tmap.bbt_at_sample_rt (start)); + const MeterSection& ms (tmap.meter_section_at_sample (start)); context.tempo = t.quarter_notes_per_minute (); context.timeSigNumerator = ms.divisions_per_bar (); @@ -706,8 +706,8 @@ VST3Plugin::connect_and_run (BufferSet& bufs, for (int32_t i = 0; i < (int32_t)_plug->n_midi_inputs (); ++i) { bool valid = false; uint32_t index = in_map.get (DataType::MIDI, in_index++, &valid); - if (valid && bufs.count().n_midi() > index) { - for (MidiBuffer::iterator m = bufs.get_midi(index).begin(); m != bufs.get_midi(index).end(); ++m) { + if (valid && bufs.count ().n_midi () > index) { + for (MidiBuffer::iterator m = bufs.get_midi (index).begin (); m != bufs.get_midi (index).end (); ++m) { const Evoral::Event ev (*m, false); _plug->add_event (ev, i); } @@ -719,7 +719,7 @@ VST3Plugin::connect_and_run (BufferSet& bufs, _plug->process (ins, outs, n_samples); /* handle outgoing MIDI events */ - if (_plug->n_midi_outputs () > 0 && bufs.count().n_midi() > 0) { + if (_plug->n_midi_outputs () > 0 && bufs.count ().n_midi () > 0) { _plug->vst3_to_midi_buffers (bufs, out_map); } @@ -735,17 +735,17 @@ VST3Plugin::load_preset (PresetRecord r) /* Extract the UUID of this preset from the URI */ std::vector tmp; - if (!PBD::tokenize (r.uri, std::string(":"), std::back_inserter (tmp))) { + if (!PBD::tokenize (r.uri, std::string (":"), std::back_inserter (tmp))) { return false; } - if (tmp.size() != 3) { + if (tmp.size () != 3) { return false; } std::string const& unique_id = tmp[1]; FUID fuid; - if (!fuid.fromString (unique_id.c_str()) || fuid != _plug->fuid ()) { + if (!fuid.fromString (unique_id.c_str ()) || fuid != _plug->fuid ()) { assert (0); return false; } @@ -782,9 +782,9 @@ VST3Plugin::load_preset (PresetRecord r) std::string VST3Plugin::do_save_preset (std::string name) { - assert (!preset_search_path().empty ()); + assert (!preset_search_path ().empty ()); std::string dir = preset_search_path ().front (); - std::string fn = Glib::build_filename (dir, legalize_for_universal_path (name) + ".vstpreset"); + std::string fn = Glib::build_filename (dir, legalize_for_universal_path (name) + ".vstpreset"); if (g_mkdir_with_parents (dir.c_str (), 0775)) { error << string_compose (_("Could not create VST3 Preset Folder '%1'"), dir) << endmsg; @@ -793,7 +793,7 @@ VST3Plugin::do_save_preset (std::string name) RAMStream stream; if (_plug->save_state (stream)) { GError* err = NULL; - if (!g_file_set_contents (fn.c_str (), (const gchar*) stream.data (), stream.size (), &err)) { + if (!g_file_set_contents (fn.c_str (), (const gchar*)stream.data (), stream.size (), &err)) { ::g_unlink (fn.c_str ()); if (err) { error << string_compose (_("Could not save VST3 Preset (%1)"), err->message) << endmsg; @@ -801,7 +801,7 @@ VST3Plugin::do_save_preset (std::string name) } return ""; } - std::string uri = string_compose (X_("VST3-S:%1:%2"), unique_id (), PBD::basename_nosuffix (fn)); + std::string uri = string_compose (X_("VST3-S:%1:%2"), unique_id (), PBD::basename_nosuffix (fn)); _preset_uri_map[uri] = fn; return uri; } @@ -811,9 +811,9 @@ VST3Plugin::do_save_preset (std::string name) void VST3Plugin::do_remove_preset (std::string name) { - assert (!preset_search_path().empty ()); + assert (!preset_search_path ().empty ()); std::string dir = preset_search_path ().front (); - std::string fn = Glib::build_filename (dir, legalize_for_universal_path (name) + ".vstpreset"); + std::string fn = Glib::build_filename (dir, legalize_for_universal_path (name) + ".vstpreset"); ::g_unlink (fn.c_str ()); std::string uri = string_compose (X_("VST3-S:%1:%2"), unique_id (), PBD::basename_nosuffix (fn)); if (_preset_uri_map.find (uri) != _preset_uri_map.end ()) { @@ -821,9 +821,10 @@ VST3Plugin::do_remove_preset (std::string name) } } -static bool vst3_preset_filter (const std::string& str, void*) +static bool +vst3_preset_filter (const std::string& str, void*) { - return str[0] != '.' && (str.length() > 9 && str.find (".vstpreset") == (str.length() - 10)); + return str[0] != '.' && (str.length () > 9 && str.find (".vstpreset") == (str.length () - 10)); } void @@ -835,7 +836,7 @@ VST3Plugin::find_presets () /* read vst3UnitPrograms */ Vst::IUnitInfo* nfo = _plug->unit_info (); if (nfo && _plug->program_change_port ().id != Vst::kNoParamId) { - Vst::UnitID program_unit_id = _plug->program_change_port().unitId; + Vst::UnitID program_unit_id = _plug->program_change_port ().unitId; int32 unit_count = nfo->getUnitCount (); @@ -845,10 +846,10 @@ VST3Plugin::find_presets () continue; } - int32 count = nfo->getProgramListCount(); + int32 count = nfo->getProgramListCount (); for (int32 i = 0; i < count; ++i) { Vst::ProgramListInfo pli; - if (nfo->getProgramListInfo(i, pli) != kResultTrue) { + if (nfo->getProgramListInfo (i, pli) != kResultTrue) { continue; } if (pli.id != unit_info.programListId) { @@ -863,8 +864,8 @@ VST3Plugin::find_presets () warning << string_compose (_("VST3<%1>: ignored unnamed factory preset/program"), name ()) << endmsg; continue; } - std::string uri = string_compose (X_("VST3-P:%1:%2"), unique_id (), std::setw(4), std::setfill('0'), j); - PresetRecord r (uri , preset_name, false); + std::string uri = string_compose (X_("VST3-P:%1:%2"), unique_id (), std::setw (4), std::setfill ('0'), j); + PresetRecord r (uri, preset_name, false); _presets.insert (make_pair (uri, r)); } if (nfo->hasProgramPitchNames (pli.id, j)) { @@ -880,13 +881,13 @@ VST3Plugin::find_presets () if (_presets.empty () && _plug->program_change_port ().id != Vst::kNoParamId) { /* fill in presets by number */ Vst::ParameterInfo const& pi (_plug->program_change_port ()); - int32 n_programs = pi.stepCount + 1; + int32 n_programs = pi.stepCount + 1; for (int32 i = 0; i < n_programs; ++i) { - float value = static_cast (i) / static_cast (pi.stepCount); + float value = static_cast (i) / static_cast (pi.stepCount); std::string preset_name = _plug->print_parameter (pi.id, value); if (!preset_name.empty ()) { - std::string uri = string_compose (X_("VST3-P:%1:%2"), unique_id (), std::setw(4), std::setfill('0'), i); - PresetRecord r (uri , preset_name, false); + std::string uri = string_compose (X_("VST3-P:%1:%2"), unique_id (), std::setw (4), std::setfill ('0'), i); + PresetRecord r (uri, preset_name, false); _presets.insert (make_pair (uri, r)); } } @@ -897,14 +898,14 @@ VST3Plugin::find_presets () // TODO check _plug->unit_data() // IUnitData: programDataSupported -> setUnitProgramData (IBStream) - PBD::Searchpath psp = preset_search_path (); + PBD::Searchpath psp = preset_search_path (); std::vector preset_files; find_paths_matching_filter (preset_files, psp, vst3_preset_filter, 0, false, true, false); - for (std::vector::iterator i = preset_files.begin(); i != preset_files.end (); ++i) { - bool is_user = PBD::path_is_within (psp.front(), *i); + for (std::vector::iterator i = preset_files.begin (); i != preset_files.end (); ++i) { + bool is_user = PBD::path_is_within (psp.front (), *i); std::string preset_name = PBD::basename_nosuffix (*i); - std::string uri = string_compose (X_("VST3-S:%1:%2"), unique_id (), preset_name); + std::string uri = string_compose (X_("VST3-S:%1:%2"), unique_id (), preset_name); if (_presets.find (uri) != _presets.end ()) { continue; } @@ -918,14 +919,14 @@ PBD::Searchpath VST3Plugin::preset_search_path () const { boost::shared_ptr nfo = boost::dynamic_pointer_cast (get_info ()); - PBD::Searchpath preset_path; std::string vendor = legalize_for_universal_path (nfo->creator); - std::string name = legalize_for_universal_path (nfo->name); + std::string name = legalize_for_universal_path (nfo->name); /* first listed is used to save custom user-presets */ + PBD::Searchpath preset_path; #ifdef __APPLE__ - preset_path += Glib::build_filename (Glib::get_home_dir(), "Library/Audio/Presets", vendor, name); + preset_path += Glib::build_filename (Glib::get_home_dir (), "Library/Audio/Presets", vendor, name); preset_path += Glib::build_filename ("/Library/Audio/Presets", vendor, name); #elif defined PLATFORM_WINDOWS std::string documents = PBD::get_win_special_folder_path (CSIDL_PERSONAL); @@ -934,7 +935,7 @@ VST3Plugin::preset_search_path () const preset_path += Glib::build_filename (documents, "vst3 presets", vendor, name); } - preset_path += Glib::build_filename (Glib::get_user_data_dir(), "VST3 Presets", vendor, name); + preset_path += Glib::build_filename (Glib::get_user_data_dir (), "VST3 Presets", vendor, name); std::string appdata = PBD::get_win_special_folder_path (CSIDL_APPDATA); if (!appdata.empty ()) { @@ -942,7 +943,7 @@ VST3Plugin::preset_search_path () const preset_path += Glib::build_filename (appdata, "vst3 presets", vendor, name); } #else - preset_path += Glib::build_filename (Glib::get_home_dir(), ".vst3", "presets", vendor, name); + preset_path += Glib::build_filename (Glib::get_home_dir (), ".vst3", "presets", vendor, name); preset_path += Glib::build_filename ("/usr/share/vst3/presets", vendor, name); preset_path += Glib::build_filename ("/usr/local/share/vst3/presets", vendor, name); #endif @@ -1023,7 +1024,7 @@ VST3PI::VST3PI (boost::shared_ptr m, std::string uniqu } #ifndef NDEBUG - if (DEBUG_ENABLED(DEBUG::VST3Config)) { + if (DEBUG_ENABLED (DEBUG::VST3Config)) { char fuid[33]; _fuid.toString (fuid); DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI create instance %1\n", fuid)); @@ -1114,7 +1115,7 @@ VST3PI::VST3PI (boost::shared_ptr m, std::string uniqu continue; } } - if (tchar_to_utf8 (pi.title).find("MIDI CC ") != std::string::npos) { + if (tchar_to_utf8 (pi.title).find ("MIDI CC ") != std::string::npos) { /* Some JUCE plugins add 16 * 128 automatable MIDI CC parameters */ continue; } @@ -1129,7 +1130,7 @@ VST3PI::VST3PI (boost::shared_ptr m, std::string uniqu p.read_only = 0 != (pi.flags & Vst::ParameterInfo::kIsReadOnly); p.automatable = 0 != (pi.flags & Vst::ParameterInfo::kCanAutomate); - if (pi.flags & /*Vst::ParameterInfo::kIsHidden*/ (1<<4)) { + if (pi.flags & /*Vst::ParameterInfo::kIsHidden*/ (1 << 4)) { p.label = X_("hidden"); } @@ -1163,11 +1164,11 @@ VST3PI::~VST3PI () Vst::IUnitInfo* VST3PI::unit_info () { - Vst::IUnitInfo* nfo = FUnknownPtr(_component); + Vst::IUnitInfo* nfo = FUnknownPtr (_component); if (nfo) { return nfo; } - return FUnknownPtr(_controller); + return FUnknownPtr (_controller); } #if 0 @@ -1232,7 +1233,7 @@ VST3PI::connect_components () return true; } - _component_cproxy = boost::shared_ptr (new ConnectionProxy (componentCP)); + _component_cproxy = boost::shared_ptr (new ConnectionProxy (componentCP)); _controller_cproxy = boost::shared_ptr (new ConnectionProxy (controllerCP)); tresult res = _component_cproxy->connect (controllerCP); @@ -1285,7 +1286,7 @@ VST3PI::queryInterface (const TUID _iid, void** obj) } #endif - if (DEBUG_ENABLED(DEBUG::VST3Config)) { + if (DEBUG_ENABLED (DEBUG::VST3Config)) { char fuid[33]; FUID::fromTUID (_iid).toString (fuid); DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI::queryInterface not supported: %1\n", fuid)); @@ -1340,7 +1341,7 @@ VST3PI::notifyUnitSelection (Vst::UnitID unitId) tresult VST3PI::notifyProgramListChange (Vst::ProgramListID, int32) { - float v = 0; + float v = 0; Vst::ParamID id = _program_change_port.id; if (id != Vst::kNoParamId) { v = _controller->getParamNormalized (id); @@ -1354,8 +1355,8 @@ tresult VST3PI::performEdit (Vst::ParamID id, Vst::ParamValue v) { std::map::const_iterator idx = _ctrl_id_index.find (id); - if (idx != _ctrl_id_index.end()) { - float value = v; + if (idx != _ctrl_id_index.end ()) { + float value = v; _shadow_data[idx->second] = value; _update_ctrl[idx->second] = true; set_parameter_internal (id, value, 0, true); @@ -1369,7 +1370,7 @@ tresult VST3PI::beginEdit (Vst::ParamID id) { std::map::const_iterator idx = _ctrl_id_index.find (id); - if (idx != _ctrl_id_index.end()) { + if (idx != _ctrl_id_index.end ()) { OnParameterChange (BeginGesture, idx->second, 0); /* EMIT SIGNAL */ } return kResultOk; @@ -1379,7 +1380,7 @@ tresult VST3PI::endEdit (Vst::ParamID id) { std::map::const_iterator idx = _ctrl_id_index.find (id); - if (idx != _ctrl_id_index.end()) { + if (idx != _ctrl_id_index.end ()) { OnParameterChange (EndGesture, idx->second, 0); /* EMIT SIGNAL */ } return kResultOk; @@ -1475,7 +1476,7 @@ VST3PI::update_processor () } Vst::ProcessSetup setup; - setup.processMode = AudioEngine::instance()->freewheeling () ? Vst::kOffline : Vst::kRealtime; + setup.processMode = AudioEngine::instance ()->freewheeling () ? Vst::kOffline : Vst::kRealtime; setup.symbolicSampleSize = Vst::kSample32; setup.maxSamplesPerBlock = _block_size; setup.sampleRate = _context.sampleRate; @@ -1506,7 +1507,7 @@ VST3PI::set_owner (SessionObject* o) if (!o) { _strip_connections.drop_connections (); _ac_connection_list.drop_connections (); - _ac_subscriptions.clear(); + _ac_subscriptions.clear (); return; } @@ -1519,7 +1520,7 @@ int32 VST3PI::count_channels (Vst::MediaType media, Vst::BusDirection dir, Vst::BusType type) { /* see also libs/ardour/vst3_scan.cc count_channels */ - int32 n_busses = _component->getBusCount (media, dir); + int32 n_busses = _component->getBusCount (media, dir); int32 n_channels = 0; for (int32 i = 0; i < n_busses; ++i) { Vst::BusInfo bus; @@ -1533,8 +1534,8 @@ VST3PI::count_channels (Vst::MediaType media, Vst::BusDirection dir, Vst::BusTyp } #endif - std::string bus_name = tchar_to_utf8 (bus.name); - bool is_sidechain = (type == Vst::kAux) && (dir == Vst::kInput); + std::string bus_name = tchar_to_utf8 (bus.name); + bool is_sidechain = (type == Vst::kAux) && (dir == Vst::kInput); if (media == Vst::kEvent) { #if 0 @@ -1568,7 +1569,7 @@ VST3PI::count_channels (Vst::MediaType media, Vst::BusDirection dir, Vst::BusTyp Vst::ParamID VST3PI::index_to_id (uint32_t p) const { - assert (_ctrl_index_id.find (p) != _ctrl_index_id.end()); + assert (_ctrl_index_id.find (p) != _ctrl_index_id.end ()); return (_ctrl_index_id.find (p))->second; } @@ -1592,7 +1593,7 @@ VST3PI::default_value (uint32_t port) const void VST3PI::get_parameter_descriptor (uint32_t port, ParameterDescriptor& desc) const { - Param const& p (_ctrl_params[port]); + Param const& p (_ctrl_params[port]); Vst::ParamID id (index_to_id (port)); desc.lower = _controller->normalizedParamToPlain (id, 0.f); @@ -1612,7 +1613,7 @@ VST3PI::get_parameter_descriptor (uint32_t port, ParameterDescriptor& desc) cons FUnknownPtr extra_ctrl (_controller); if (extra_ctrl && port != designated_bypass_port ()) { - int32 flags = extra_ctrl->getParamExtraFlags (id); + int32 flags = extra_ctrl->getParamExtraFlags (id); desc.inline_ctrl = (flags & kParamFlagMicroEdit) ? true : false; } } @@ -1674,12 +1675,11 @@ VST3PI::describe_io_port (ARDOUR::DataType dt, bool input, uint32_t id) const } } - bool VST3PI::try_set_parameter_by_id (Vst::ParamID id, float value) { std::map::const_iterator idx = _ctrl_id_index.find (id); - if (idx == _ctrl_id_index.end()) { + if (idx == _ctrl_id_index.end ()) { return false; } set_parameter (idx->second, value, 0); @@ -1738,7 +1738,7 @@ VST3PI::synchronize_states () { RAMStream stream; if (_component->getState (&stream) == kResultTrue) { - stream.rewind(); + stream.rewind (); tresult res = _controller->setComponentState (&stream); if (!(res == kResultOk || res == kNotImplemented)) { #ifndef NDEBUG @@ -1799,7 +1799,7 @@ VST3PI::set_parameter_by_id (Vst::ParamID id, float value, int32 sample_off) { set_parameter_internal (id, value, sample_off, true); std::map::const_iterator idx = _ctrl_id_index.find (id); - if (idx != _ctrl_id_index.end()) { + if (idx != _ctrl_id_index.end ()) { _shadow_data[idx->second] = value; _update_ctrl[idx->second] = true; } @@ -1846,7 +1846,7 @@ VST3PI::live_midi_cc (int32_t bus, int16_t channel, Vst::CtrlNumber ctrl) } bool -VST3PI::midi_controller (int32_t bus, int16_t channel, Vst::CtrlNumber ctrl, Vst::ParamID &id) +VST3PI::midi_controller (int32_t bus, int16_t channel, Vst::CtrlNumber ctrl, Vst::ParamID& id) { FUnknownPtr midiMapping (_controller); if (!midiMapping) { @@ -1868,14 +1868,13 @@ VST3PI::add_event (Evoral::Event const& ev, int32_t bus) Vst::Event e; e.busIndex = bus; e.flags = ev.is_live_midi () ? Vst::Event::kIsLive : 0; - e.sampleOffset = ev.time(); + e.sampleOffset = ev.time (); e.ppqPosition = _context.projectTimeMusic; if (evoral_to_vst3 (e, ev, bus)) { _input_events.addEvent (e); } } - void VST3PI::set_event_bus_state (bool enable) { @@ -1896,9 +1895,9 @@ VST3PI::enable_io (std::vector const& ins, std::vector const& outs) return; } - DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI::enable_io: ins = %1 == %3 outs = %2 == %4\n", ins.size(), outs.size(), n_audio_inputs (), n_audio_outputs ())); + DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI::enable_io: ins = %1 == %3 outs = %2 == %4\n", ins.size (), outs.size (), n_audio_inputs (), n_audio_outputs ())); - _enabled_audio_in = ins; + _enabled_audio_in = ins; _enabled_audio_out = outs; assert (_enabled_audio_in.size () == n_audio_inputs ()); @@ -1912,8 +1911,8 @@ VST3PI::enable_io (std::vector const& ins, std::vector const& outs) std::vector sa_in; std::vector sa_out; - bool enable = false; - Vst::SpeakerArrangement sa = 0; + bool enable = false; + Vst::SpeakerArrangement sa = 0; for (int i = 0; i < _n_inputs; ++i) { if (ins[i]) { @@ -1928,7 +1927,7 @@ VST3PI::enable_io (std::vector const& ins, std::vector const& outs) } enable = false; - sa = 0; + sa = 0; for (int i = 0; i < _n_aux_inputs; ++i) { if (ins[i + _n_inputs]) { enable = true; @@ -1942,14 +1941,14 @@ VST3PI::enable_io (std::vector const& ins, std::vector const& outs) } /* disable remaining input busses and set their speaker-count to zero */ - while (sa_in.size() < n_bus_in) { - DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI::enable_io: activateBus (kAudio, kInput, %1, false)\n", sa_in.size())); - _component->activateBus (Vst::kAudio, Vst::kInput, sa_in.size(), false); + while (sa_in.size () < n_bus_in) { + DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI::enable_io: activateBus (kAudio, kInput, %1, false)\n", sa_in.size ())); + _component->activateBus (Vst::kAudio, Vst::kInput, sa_in.size (), false); sa_in.push_back (0); } enable = false; - sa = 0; + sa = 0; for (int i = 0; i < _n_outputs; ++i) { if (outs[i]) { enable = true; @@ -1964,7 +1963,7 @@ VST3PI::enable_io (std::vector const& ins, std::vector const& outs) } enable = false; - sa = 0; + sa = 0; for (int i = 0; i < _n_aux_outputs; ++i) { if (outs[i + _n_outputs]) { enable = true; @@ -1977,9 +1976,9 @@ VST3PI::enable_io (std::vector const& ins, std::vector const& outs) sa_out.push_back (sa); } - while (sa_out.size() < n_bus_out) { - DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI::enable_io: activateBus (kAudio, kOutput, %1, false)\n", sa_out.size())); - _component->activateBus (Vst::kAudio, Vst::kOutput, sa_out.size(), false); + while (sa_out.size () < n_bus_out) { + DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI::enable_io: activateBus (kAudio, kOutput, %1, false)\n", sa_out.size ())); + _component->activateBus (Vst::kAudio, Vst::kOutput, sa_out.size (), false); sa_out.push_back (0); } @@ -2005,7 +2004,8 @@ VST3PI::enable_io (std::vector const& ins, std::vector const& outs) #endif } -static int32 used_bus_count (int auxes, int inputs) +static int32 +used_bus_count (int auxes, int inputs) { if (auxes > 0 && inputs > 0) { return 2; @@ -2024,7 +2024,7 @@ VST3PI::process (float** ins, float** outs, uint32_t n_samples) Vst::ProcessData data; data.numSamples = n_samples; - data.processMode = AudioEngine::instance()->freewheeling () ? Vst::kOffline : Vst::kRealtime; + data.processMode = AudioEngine::instance ()->freewheeling () ? Vst::kOffline : Vst::kRealtime; data.symbolicSampleSize = Vst::kSample32; data.numInputs = used_bus_count (_n_aux_inputs, _n_inputs); data.numOutputs = used_bus_count (_n_aux_outputs, _n_outputs); @@ -2032,8 +2032,8 @@ VST3PI::process (float** ins, float** outs, uint32_t n_samples) data.outputs = output; data.processContext = &_context; - data.inputEvents = &_input_events; - data.outputEvents = &_output_events; + data.inputEvents = &_input_events; + data.outputEvents = &_output_events; data.inputParameterChanges = &_input_param_changes; data.outputParameterChanges = &_output_param_changes; @@ -2064,29 +2064,29 @@ VST3PI::process (float** ins, float** outs, uint32_t n_samples) } /* handle output parameter changes */ - int n_changes = _output_param_changes.getParameterCount(); + int n_changes = _output_param_changes.getParameterCount (); for (int i = 0; i < n_changes; ++i) { Vst::IParamValueQueue* data = _output_param_changes.getParameterData (i); if (!data) { continue; } - Vst::ParamID id = data->getParameterId(); - int n_points = data->getPointCount(); + Vst::ParamID id = data->getParameterId (); + int n_points = data->getPointCount (); if (n_points == 0) { continue; } std::map::const_iterator idx = _ctrl_id_index.find (id); - if (idx != _ctrl_id_index.end()) { + if (idx != _ctrl_id_index.end ()) { /* automatable parameter, or read-only output */ - int32 offset = 0; - Vst::ParamValue value = 0; + int32 offset = 0; + Vst::ParamValue value = 0; /* only get most recent point */ - if (data->getPoint(n_points - 1, offset, value) == kResultOk) { + if (data->getPoint (n_points - 1, offset, value) == kResultOk) { if (_shadow_data[idx->second] != value) { _update_ctrl[idx->second] = true; - _shadow_data[idx->second] = (float) value; + _shadow_data[idx->second] = (float)value; } } } else { @@ -2109,40 +2109,42 @@ VST3PI::process (float** ins, float** outs, uint32_t n_samples) namespace Steinberg { namespace Vst { -enum ChunkType -{ - kHeader, - kComponentState, - kControllerState, - kProgramData, - kMetaInfo, - kChunkList, - kNumPresetChunks +enum ChunkType { + kHeader, + kComponentState, + kControllerState, + kProgramData, + kMetaInfo, + kChunkList, + kNumPresetChunks }; static const ChunkID commonChunks[kNumPresetChunks] = { - {'V', 'S', 'T', '3'}, // kHeader - {'C', 'o', 'm', 'p'}, // kComponentState - {'C', 'o', 'n', 't'}, // kControllerState - {'P', 'r', 'o', 'g'}, // kProgramData - {'I', 'n', 'f', 'o'}, // kMetaInfo - {'L', 'i', 's', 't'} // kChunkList + { 'V', 'S', 'T', '3' }, // kHeader + { 'C', 'o', 'm', 'p' }, // kComponentState + { 'C', 'o', 'n', 't' }, // kControllerState + { 'P', 'r', 'o', 'g' }, // kProgramData + { 'I', 'n', 'f', 'o' }, // kMetaInfo + { 'L', 'i', 's', 't' } // kChunkList }; static const int32 kFormatVersion = 1; -static const ChunkID& getChunkID (ChunkType type) +static const ChunkID& +getChunkID (ChunkType type) { - return commonChunks[type]; + return commonChunks[type]; } struct ChunkEntry { - void start_chunk (const ChunkID& id, RAMStream& stream) { + void start_chunk (const ChunkID& id, RAMStream& stream) + { memcpy (_id, &id, sizeof (ChunkID)); stream.tell (&_offset); _size = 0; } - void end_chunk (RAMStream& stream) { + void end_chunk (RAMStream& stream) + { int64 pos = 0; stream.tell (&pos); _size = pos - _offset; @@ -2153,33 +2155,34 @@ struct ChunkEntry { int64 _size; }; -} // Vst +} // namespace Vst typedef std::vector ChunkEntryVector; -} // Steinberg +} // namespace Steinberg - -static bool is_equal_ID (const Vst::ChunkID id1, const Vst::ChunkID id2) +static bool +is_equal_ID (const Vst::ChunkID id1, const Vst::ChunkID id2) { - return 0 == memcmp (id1, id2, sizeof (Vst::ChunkID)); + return 0 == memcmp (id1, id2, sizeof (Vst::ChunkID)); } -static bool read_equal_ID (RAMStream& stream, const Vst::ChunkID id) +static bool +read_equal_ID (RAMStream& stream, const Vst::ChunkID id) { Vst::ChunkID tmp; - return stream.read_ChunkID (tmp) && is_equal_ID (tmp, id); + return stream.read_ChunkID (tmp) && is_equal_ID (tmp, id); } bool VST3PI::load_state (RAMStream& stream) { - assert (stream.readonly()); + assert (stream.readonly ()); if (stream.size () < Vst::kHeaderSize) { return false; } - int32 version = 0; + int32 version = 0; int64 list_offset = 0; TUID class_id; @@ -2201,7 +2204,7 @@ VST3PI::load_state (RAMStream& stream) /* read chunklist */ ChunkEntryVector entries; - int64 seek_result = 0; + int64 seek_result = 0; stream.seek (list_offset, IBStream::kIBSeekSet, &seek_result); if (seek_result != list_offset) { return false; @@ -2231,7 +2234,7 @@ VST3PI::load_state (RAMStream& stream) } if (is_equal_ID (i->_id, Vst::getChunkID (Vst::kComponentState))) { ROMStream s (stream, i->_offset, i->_size); - tresult res = _component->setState (&s); + tresult res = _component->setState (&s); s.rewind (); tresult re2 = _controller->setComponentState (&s); @@ -2240,8 +2243,7 @@ VST3PI::load_state (RAMStream& stream) DEBUG_TRACE (DEBUG::VST3Config, "VST3PI::load_state: failed to restore component state\n"); rv = false; } - } - else if (is_equal_ID (i->_id, Vst::getChunkID (Vst::kControllerState))) { + } else if (is_equal_ID (i->_id, Vst::getChunkID (Vst::kControllerState))) { stream.seek (i->_offset, IBStream::kIBSeekSet, &seek_result); tresult res = _controller->setState (&stream); if (!(res == kResultOk || res == kNotImplemented)) { @@ -2275,15 +2277,15 @@ VST3PI::load_state (RAMStream& stream) bool VST3PI::save_state (RAMStream& stream) { - assert (!stream.readonly()); - Vst::ChunkEntry c; + assert (!stream.readonly ()); + Vst::ChunkEntry c; ChunkEntryVector entries; /* header */ stream.write_ChunkID (Vst::getChunkID (Vst::kHeader)); stream.write_int32 (Vst::kFormatVersion); stream.write_TUID (_fuid.toTUID ()); // class ID - stream.write_int64 (0); // skip offset + stream.write_int64 (0); // skip offset /* state chunks */ c.start_chunk (getChunkID (Vst::kComponentState), stream); @@ -2324,7 +2326,7 @@ void VST3PI::stripable_property_changed (PBD::PropertyChange const&) { FUnknownPtr il (_controller); - Stripable* s = dynamic_cast (_owner); + Stripable* s = dynamic_cast (_owner); assert (il && s); DEBUG_TRACE (DEBUG::VST3Callbacks, "VST3PI::stripable_property_changed\n"); @@ -2332,12 +2334,12 @@ VST3PI::stripable_property_changed (PBD::PropertyChange const&) IPtr al (new HostAttributeList ()); Vst::String128 tmp; - utf8_to_tchar (tmp, _owner->name(), 128); - al->setInt (Vst::ChannelContext::kChannelNameLengthKey, _owner->name().size()); + 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()); + 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; @@ -2354,13 +2356,13 @@ VST3PI::stripable_property_changed (PBD::PropertyChange const&) } al->setInt (Vst::ChannelContext::kChannelIndexNamespaceOrderKey, order_key); - al->setInt (Vst::ChannelContext::kChannelIndexKey, 1 + s->presentation_info ().order()); + al->setInt (Vst::ChannelContext::kChannelIndexKey, 1 + s->presentation_info ().order ()); utf8_to_tchar (tmp, ns, 128); - al->setInt (Vst::ChannelContext::kChannelIndexNamespaceLengthKey, ns.size()); + al->setInt (Vst::ChannelContext::kChannelIndexNamespaceLengthKey, ns.size ()); al->setString (Vst::ChannelContext::kChannelIndexNamespaceKey, tmp); - uint32_t rgba = s->presentation_info ().color(); + uint32_t rgba = s->presentation_info ().color (); Vst::ChannelContext::ColorSpec argb = ((rgba >> 8) & 0xffffff) | ((rgba & 0xff) << 24); al->setInt (Vst::ChannelContext::kChannelColorKey, argb); @@ -2380,7 +2382,7 @@ VST3PI::setup_info_listener () Stripable* s = dynamic_cast (_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)); + s->presentation_info ().PropertyChanged.connect_same_thread (_strip_connections, boost::bind (&VST3PI::stripable_property_changed, this, _1)); /* send initial change */ stripable_property_changed (PropertyChange ()); @@ -2419,9 +2421,9 @@ VST3PI::subscribe_to_automation_changes () const } void -VST3PI::automation_state_changed (uint32_t port, AutoState s, boost::weak_ptr wal) +VST3PI::automation_state_changed (uint32_t port, AutoState s, boost::weak_ptr wal) { - Vst::ParamID id (index_to_id (port)); + Vst::ParamID id (index_to_id (port)); boost::shared_ptr al = wal.lock (); FUnknownPtr extra_ctrl (_controller); assert (extra_ctrl); @@ -2436,16 +2438,16 @@ VST3PI::automation_state_changed (uint32_t port, AutoState s, boost::weak_ptr +static boost::shared_ptr lookup_ac (SessionObject* o, FIDString id) { Stripable* s = dynamic_cast (o); @@ -2465,9 +2466,9 @@ lookup_ac (SessionObject* o, FIDString id) } if (0 == strcmp (id, ContextInfo::kMute)) { - return s->mute_control(); + return s->mute_control (); } else if (0 == strcmp (id, ContextInfo::kSolo)) { - return s->solo_control(); + return s->solo_control (); } else if (0 == strcmp (id, ContextInfo::kPan)) { return s->pan_azimuth_control (); } else if (0 == strcmp (id, ContextInfo::kVolume)) { @@ -2511,19 +2512,19 @@ VST3PI::getContextInfoValue (int32& value, FIDString id) } else if (0 == strcmp (id, ContextInfo::kType)) { if (s->is_master ()) { value = ContextInfo::kOut; - } else if (s->presentation_info().flags() & PresentationInfo::AudioTrack) { + } else if (s->presentation_info ().flags () & PresentationInfo::AudioTrack) { value = ContextInfo::kTrack; - } else if (s->presentation_info().flags() & PresentationInfo::MidiTrack) { + } else if (s->presentation_info ().flags () & PresentationInfo::MidiTrack) { value = ContextInfo::kSynth; } else { value = ContextInfo::kBus; } } else if (0 == strcmp (id, ContextInfo::kMain)) { - value = s->is_master() ? 1 : 0; + value = s->is_master () ? 1 : 0; } else if (0 == strcmp (id, ContextInfo::kIndex)) { - value = s->presentation_info ().order(); + value = s->presentation_info ().order (); } else if (0 == strcmp (id, ContextInfo::kColor)) { - value = s->presentation_info ().color(); + value = s->presentation_info ().color (); #if BYTEORDER == kBigEndian SWAP_32 (value) // RGBA32 -> ABGR32 #endif @@ -2532,8 +2533,8 @@ VST3PI::getContextInfoValue (int32& value, FIDString id) } else if (0 == strcmp (id, ContextInfo::kSelected)) { value = s->is_selected () ? 1 : 0; } else if (0 == strcmp (id, ContextInfo::kFocused)) { - boost::shared_ptr stripable = s->session().selection().first_selected_stripable (); - value = stripable && stripable.get () == s ? 1 : 0; + boost::shared_ptr stripable = s->session ().selection ().first_selected_stripable (); + value = stripable && stripable.get () == s ? 1 : 0; } else if (0 == strcmp (id, ContextInfo::kSendCount)) { value = 0; while (s->send_enable_controllable (value)) { @@ -2571,7 +2572,7 @@ VST3PI::getContextInfoString (Vst::TChar* string, int32 max_len, FIDString id) return kNotInitialized; } if (0 == strcmp (id, ContextInfo::kID)) { - utf8_to_tchar (string, _owner->id().to_s (), max_len); + utf8_to_tchar (string, _owner->id ().to_s (), max_len); } else if (0 == strcmp (id, ContextInfo::kName)) { utf8_to_tchar (string, _owner->name (), max_len); } else if (0 == strcmp (id, ContextInfo::kActiveDocumentID)) { @@ -2597,7 +2598,7 @@ VST3PI::getContextInfoString (Vst::TChar* string, int32 max_len, FIDString id) } utf8_to_tchar (string, ac->get_user_string (), max_len); } - DEBUG_TRACE (DEBUG::VST3Callbacks, string_compose ("VST3PI::getContextInfoValue %1 = %2\n", id, tchar_to_utf8(string))); + DEBUG_TRACE (DEBUG::VST3Callbacks, string_compose ("VST3PI::getContextInfoValue %1 = %2\n", id, tchar_to_utf8 (string))); return kResultOk; } @@ -2620,12 +2621,12 @@ VST3PI::getContextInfoValue (double& value, FIDString id) value = 2.0; // Config->get_max_gain(); } else if (0 == strcmp (id, ContextInfo::kVolume)) { boost::shared_ptr ac = s->gain_control (); - value = ac->get_value(); // gain coefficient 0..2 (1.0 = 0dB) + value = ac->get_value (); // gain coefficient 0..2 (1.0 = 0dB) psl_subscribe_to (ac, id); } else if (0 == strcmp (id, ContextInfo::kPan)) { boost::shared_ptr ac = s->pan_azimuth_control (); if (ac) { - value = ac->internal_to_interface (ac->get_value(), true); + value = ac->internal_to_interface (ac->get_value (), true); psl_subscribe_to (ac, id); } else { value = 0.5; // center @@ -2633,7 +2634,7 @@ VST3PI::getContextInfoValue (double& value, FIDString id) } else if (0 == strncmp (id, ContextInfo::kSendLevel, strlen (ContextInfo::kSendLevel))) { boost::shared_ptr ac = lookup_ac (_owner, id); if (ac) { - value = ac->get_value(); // gain cofficient + value = ac->get_value (); // gain cofficient psl_subscribe_to (ac, id); } else { DEBUG_TRACE (DEBUG::VST3Callbacks, string_compose ("VST3PI::getContextInfoValue invalid AC %1\n", id)); @@ -2690,23 +2691,23 @@ VST3PI::setContextInfoValue (FIDString id, int32 value) #if BYTEORDER == kBigEndian SWAP_32 (value) // ABGR32 -> RGBA32 #endif - s->presentation_info ().set_color(value); + s->presentation_info ().set_color (value); } else if (0 == strcmp (id, ContextInfo::kSelected)) { - boost::shared_ptr stripable = s->session().stripable_by_id (s->id ()); + boost::shared_ptr stripable = s->session ().stripable_by_id (s->id ()); assert (stripable); if (value == 0) { - s->session().selection().remove (stripable, boost::shared_ptr()); + s->session ().selection ().remove (stripable, boost::shared_ptr ()); } else if (_add_to_selection) { - s->session().selection().add (stripable, boost::shared_ptr()); + s->session ().selection ().add (stripable, boost::shared_ptr ()); } else { - s->session().selection().set (stripable, boost::shared_ptr()); + s->session ().selection ().set (stripable, boost::shared_ptr ()); } } else if (0 == strcmp (id, ContextInfo::kMultiSelect)) { _add_to_selection = value != 0; } else if (0 == strcmp (id, ContextInfo::kMute)) { - s->session().set_control (lookup_ac (_owner, id), value != 0 ? 1 : 0, Controllable::NoGroup); + s->session ().set_control (lookup_ac (_owner, id), value != 0 ? 1 : 0, Controllable::NoGroup); } else if (0 == strcmp (id, ContextInfo::kSolo)) { - s->session().set_control (lookup_ac (_owner, id), value != 0 ? 1 : 0, Controllable::NoGroup); + s->session ().set_control (lookup_ac (_owner, id), value != 0 ? 1 : 0, Controllable::NoGroup); } else { DEBUG_TRACE (DEBUG::VST3Callbacks, "VST3PI::setContextInfoValue: unsupported ID\n"); return kNotImplemented; @@ -2741,7 +2742,7 @@ VST3PI::beginEditContextInfoValue (FIDString id) return kInvalidArgument; } DEBUG_TRACE (DEBUG::VST3Callbacks, string_compose ("VST3PI::beginEditContextInfoValue %1\n", id)); - ac->start_touch (ac->session().transport_sample()); + ac->start_touch (ac->session ().transport_sample ()); return kResultOk; } @@ -2757,7 +2758,7 @@ VST3PI::endEditContextInfoValue (FIDString id) return kInvalidArgument; } DEBUG_TRACE (DEBUG::VST3Callbacks, string_compose ("VST3PI::endEditContextInfoValue %1\n", id)); - ac->stop_touch (ac->session().transport_sample()); + ac->stop_touch (ac->session ().transport_sample ()); return kResultOk; } @@ -2776,7 +2777,7 @@ VST3PI::psl_subscribe_to (boost::shared_ptr ac, FIDSt } DEBUG_TRACE (DEBUG::VST3Callbacks, string_compose ("VST3PI::psl_subscribe_to: %1\n", ac->name ())); - ac->Changed.connect_same_thread (_ac_connection_list, boost::bind (&VST3PI::foward_signal, this, nfo2.get(), id)); + ac->Changed.connect_same_thread (_ac_connection_list, boost::bind (&VST3PI::foward_signal, this, nfo2.get (), id)); } void @@ -2790,7 +2791,7 @@ VST3PI::foward_signal (IContextInfoHandler2* handler, FIDString id) const void VST3PI::psl_stripable_property_changed (PBD::PropertyChange const& what_changed) { - FUnknownPtr nfo (_controller); + FUnknownPtr nfo (_controller); FUnknownPtr nfo2 (_controller); if (nfo && !nfo2) { DEBUG_TRACE (DEBUG::VST3Callbacks, "VST3PI::psl_stripable_property_changed v1\n"); @@ -2821,9 +2822,9 @@ bool VST3PI::setup_psl_info_handler () { /* initial update */ - FUnknownPtr nfo (_controller); + FUnknownPtr nfo (_controller); FUnknownPtr nfo2 (_controller); - DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI::setup_psl_info_handler: (%1) (%2)\n", nfo != 0, nfo2 !=0)); + DEBUG_TRACE (DEBUG::VST3Config, string_compose ("VST3PI::setup_psl_info_handler: (%1) (%2)\n", nfo != 0, nfo2 != 0)); if (nfo2) { nfo2->notifyContextInfoChange (""); @@ -2837,7 +2838,7 @@ VST3PI::setup_psl_info_handler () Stripable* s = dynamic_cast (_owner); s->PropertyChanged.connect_same_thread (_strip_connections, boost::bind (&VST3PI::psl_stripable_property_changed, this, _1)); - s->presentation_info().PropertyChanged.connect_same_thread (_strip_connections, boost::bind (&VST3PI::psl_stripable_property_changed, this, _1)); + s->presentation_info ().PropertyChanged.connect_same_thread (_strip_connections, boost::bind (&VST3PI::psl_stripable_property_changed, this, _1)); return true; } @@ -2890,7 +2891,7 @@ bool VST3PI::has_editor () const { IPlugView* view = _view; - if (!view){ + if (!view) { view = try_create_view (); } @@ -2898,7 +2899,7 @@ VST3PI::has_editor () const if (view) { #ifdef PLATFORM_WINDOWS rv = kResultOk == view->isPlatformTypeSupported (kPlatformTypeHWND); -#elif defined (__APPLE__) +#elif defined(__APPLE__) rv = kResultOk == view->isPlatformTypeSupported (kPlatformTypeNSView); #else rv = kResultOk == view->isPlatformTypeSupported (kPlatformTypeX11EmbedWindowID);