Line data Source code
1 : /*
2 : * SPDX-License-Identifier: GPL-3.0-only
3 : * MuseScore-CLA-applies
4 : *
5 : * MuseScore Studio
6 : * Music Composition & Notation
7 : *
8 : * Copyright (C) 2021 MuseScore Limited and others
9 : *
10 : * This program is free software: you can redistribute it and/or modify
11 : * it under the terms of the GNU General Public License version 3 as
12 : * published by the Free Software Foundation.
13 : *
14 : * This program is distributed in the hope that it will be useful,
15 : * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 : * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 : * GNU General Public License for more details.
18 : *
19 : * You should have received a copy of the GNU General Public License
20 : * along with this program. If not, see <https://www.gnu.org/licenses/>.
21 : */
22 : #ifndef MUSE_VST_VSTCOMPONENTHANDLER_H
23 : #define MUSE_VST_VSTCOMPONENTHANDLER_H
24 :
25 : #include <atomic>
26 :
27 : #include "async/notification.h"
28 : #include "async/channel.h"
29 :
30 : #include "vsttypes.h"
31 :
32 : namespace muse::vst {
33 : class VstAdvancedHandler : public IAdvancedComponentHandler
34 : {
35 : DECLARE_FUNKNOWN_METHODS
36 : public:
37 : VstAdvancedHandler(async::Notification notifier);
38 0 : virtual ~VstAdvancedHandler() = default;
39 :
40 : void setSuppressNotify(bool suppress);
41 : bool suppressNotify() const;
42 :
43 : Steinberg::tresult setDirty(Steinberg::TBool state) override;
44 : Steinberg::tresult requestOpenEditor(Steinberg::FIDString name) override;
45 : Steinberg::tresult startGroupEdit() override;
46 : Steinberg::tresult finishGroupEdit() override;
47 :
48 : private:
49 : async::Notification m_paramsChanged;
50 : std::atomic_bool m_suppressNotify = false;
51 : };
52 :
53 : class VstComponentHandler : public IComponentHandler
54 : {
55 : DECLARE_FUNKNOWN_METHODS
56 : public:
57 : VstComponentHandler();
58 0 : virtual ~VstComponentHandler() = default;
59 :
60 : async::Channel<PluginParamId, PluginParamValue> pluginParamChanged() const;
61 : async::Notification pluginParamsChanged() const;
62 :
63 : // Suppress pluginParamsChanged() while applying config programmatically,
64 : // to avoid triggering a rescan of the state we are currently writing
65 : void setSuppressNotify(bool suppress);
66 :
67 : private:
68 : Steinberg::tresult beginEdit(Steinberg::Vst::ParamID id) override;
69 : Steinberg::tresult performEdit(Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue valueNormalized) override;
70 : Steinberg::tresult endEdit(Steinberg::Vst::ParamID id) override;
71 : Steinberg::tresult restartComponent(Steinberg::int32 flags) override;
72 :
73 : async::Channel<PluginParamId, PluginParamValue> m_paramChanged;
74 : async::Notification m_paramsChangedNotify;
75 :
76 : Steinberg::FUnknownPtr<VstAdvancedHandler> m_advancedHandler = nullptr;
77 : };
78 : }
79 :
80 : #endif // MUSE_VST_VSTCOMPONENTHANDLER_H
|