Loading...
Searching...
No Matches
EditHandler.hpp
1#pragma once
2#include <Vst3/Commands.hpp>
3#include <Vst3/Control.hpp>
4#include <Vst3/EffectModel.hpp>
5
6#include <QDebug>
7
8#include <pluginterfaces/vst/ivstcomponent.h>
9#include <pluginterfaces/vst/ivsteditcontroller.h>
10
11namespace vst3
12{
13class Model;
15 : virtual public Steinberg::Vst::IComponentHandler
16 , virtual public Steinberg::Vst::IComponentHandler2
17{
18 vst3::Model& m_model;
19
20public:
22 : m_model{fx}
23 {
24 }
25
27
28 Steinberg::tresult queryInterface(const Steinberg::TUID _iid, void** obj) override
29 {
30 using namespace Steinberg;
31 if(FUID::fromTUID(_iid) == Steinberg::Vst::IComponentHandler2::iid)
32 {
33 *obj = static_cast<Steinberg::Vst::IComponentHandler2*>(this);
34 return kResultOk;
35 }
36 *obj = nullptr;
37 return kResultFalse;
38 }
39 Steinberg::uint32 addRef() override { return 1; }
40 Steinberg::uint32 release() override { return 1; }
41
42 Steinberg::tresult beginEdit(Steinberg::Vst::ParamID id) override
43 {
44 // TODO implement ongoingdispatcher
45 if(auto ctrl = m_model.controls.find(id); ctrl == m_model.controls.end())
46 {
47 ossia::qt::run_async(&m_model, [&proc = m_model, id] {
48 if(auto ctrl = proc.controls.find(id); ctrl == proc.controls.end())
49 {
50 auto& ctx = score::IDocument::documentContext(proc);
51 CommandDispatcher<>{ctx.commandStack}.submit<CreateControl>(proc, id);
52 }
53 });
54 }
55 return Steinberg::kResultOk;
56 }
57
58 Steinberg::tresult performEdit(
59 Steinberg::Vst::ParamID id, Steinberg::Vst::ParamValue valueNormalized) override
60 {
61 if(auto ctrl = m_model.controls.find(id); ctrl != m_model.controls.end())
62 {
63 ctrl->second->setValue(valueNormalized);
64 }
65 return Steinberg::kResultOk;
66 }
67
68 Steinberg::tresult endEdit(Steinberg::Vst::ParamID id) override
69 {
70 return Steinberg::kResultOk;
71 }
72
73 Steinberg::tresult restartComponent(Steinberg::int32 flags) override
74 {
75 return m_model.restartComponent(flags);
76 }
77
78 Steinberg::tresult setDirty(Steinberg::TBool state) override
79 {
80 return Steinberg::kResultOk;
81 }
82
83 Steinberg::tresult requestOpenEditor(Steinberg::FIDString name) override
84 {
85 Process::setupExternalUI(m_model, score::IDocument::documentContext(m_model), true);
86 return Steinberg::kResultOk;
87 }
88
89 Steinberg::tresult startGroupEdit() override { return Steinberg::kResultOk; }
90
91 Steinberg::tresult finishGroupEdit() override { return Steinberg::kResultOk; }
92};
93}
The CommandDispatcher class.
Definition CommandDispatcher.hpp:13
Definition EditHandler.hpp:17
Definition plugins/score-plugin-vst3/Vst3/commands.hpp:41
Definition score-plugin-vst3/Vst3/EffectModel.hpp:43