clap

CLAP Audio Plugin API
Log | Files | Refs | README | LICENSE

commit 0d7fcf69887244c3d08058104510281b0a32ba7e
parent 0e83938ef834d0a0d88438dba4a8c1132a02db80
Author: Alexandre BIQUE <bique.alexandre@gmail.com>
Date:   Wed, 15 Sep 2021 12:41:28 +0200

add transport subscription mechanism for the proxy

Diffstat:
Mexamples/plugins/gui/transport-proxy.cc | 15+++++++++++++--
Mexamples/plugins/gui/transport-proxy.hh | 27++++++++++++++++-----------
Mexamples/plugins/io/messages.hh | 6++++++
3 files changed, 35 insertions(+), 13 deletions(-)

diff --git a/examples/plugins/gui/transport-proxy.cc b/examples/plugins/gui/transport-proxy.cc @@ -1,4 +1,6 @@ #include "transport-proxy.hh" +#include "../io/messages.hh" +#include "application.hh" TransportProxy::TransportProxy(QObject *parent) : QObject(parent) {} @@ -58,4 +60,14 @@ void TransportProxy::update(bool hasTransport, const clap_event_transport &trans update<int>(_timeSignatureDenominator, transport.tsig_denom, &TransportProxy::timeSignatureDenominatorChanged); -} -\ No newline at end of file +} + +void TransportProxy::setIsSubscribed(bool value) { + if (value == _isSubscribed) + return; + + _isSubscribed = value; + isSubscribedChanged(); + clap::messages::SubscribeToTransportRequest rq{value}; + Application::instance().remoteChannel().sendRequestAsync(rq); +} diff --git a/examples/plugins/gui/transport-proxy.hh b/examples/plugins/gui/transport-proxy.hh @@ -7,6 +7,7 @@ class TransportProxy : public QObject { Q_OBJECT Q_PROPERTY(bool hasTransport READ hasTransport NOTIFY hasTransportChanged) + Q_PROPERTY(bool isSubscribed READ isSubscribed WRITE setIsSubscribed NOTIFY isSubscribedChanged) Q_PROPERTY(bool hasBeatsTimeline READ hasBeatsTimeline NOTIFY hasBeatsTimelineChanged) Q_PROPERTY(bool hasSecondsTimeline READ hasSecondsTimeline NOTIFY hasSecondsTimelineChanged) @@ -40,6 +41,9 @@ public: void update(bool hasTransport, const clap_event_transport &transport); + [[nodiscard]] bool isSubscribed() const noexcept { return _isSubscribed; } + void setIsSubscribed(bool value); + [[nodiscard]] bool hasTransport() const noexcept { return _hasTransport; } [[nodiscard]] bool hasBeatsTimeline() const noexcept { return _hasBeatsTimeline; } @@ -83,6 +87,8 @@ public: signals: void updated(); + void isSubscribedChanged(); + void hasTransportChanged(); void hasBeatsTimelineChanged(); @@ -110,18 +116,17 @@ signals: void timeSignatureDenominatorChanged(); private: + using NotifyType = void (TransportProxy::*)(); + + template <typename T> + void update(T &attr, T value, NotifyType notify) { + if (value == attr) + return; + attr = value; + (this->*notify)(); + } - using NotifyType = void (TransportProxy::*)(); - - template <typename T> - void update(T& attr, T value, NotifyType notify) - { - if (value == attr) - return; - attr = value; - (this->*notify)(); - } - + bool _isSubscribed = false; bool _hasTransport = false; bool _hasBeatsTimeline = false; diff --git a/examples/plugins/io/messages.hh b/examples/plugins/io/messages.hh @@ -12,6 +12,7 @@ namespace clap::messages { // GUI->DSP kAdjustRequest, + kSubscribeToTransportRequest, // Gui, Host->Plugin kSetScaleRequest, @@ -56,6 +57,11 @@ namespace clap::messages { clap_event_transport transport; }; + struct SubscribeToTransportRequest final { + static const constexpr Type type = kSubscribeToTransportRequest; + bool isSubscribed; + }; + struct ParameterValueRequest final { static const constexpr Type type = kParameterValueRequest; clap_id paramId;