Loading...
Searching...
No Matches
score-plugin-vst/Vst/Library.hpp
1#pragma once
2#include <Library/LibraryInterface.hpp>
3#include <Library/ProcessesItemModel.hpp>
4#include <Vst/ApplicationPlugin.hpp>
5#include <Vst/EffectModel.hpp>
6
7#include <score/tools/Bind.hpp>
8
9#include <ossia/detail/algorithms.hpp>
10
11#include <algorithm>
12namespace vst
13{
14
15class LibraryHandler final
16 : public QObject
18{
19 SCORE_CONCRETE("6a13c3cc-bca7-44d6-a0ef-644e99204460")
21 override
22 {
23 constexpr static const auto key = Metadata<ConcreteKey_k, Model>::get();
24
25 auto& plug = ctx.applicationPlugin<vst::ApplicationPlugin>();
26
27 // Stage the whole plugin list; the model owns tree mutation and signals.
28 auto make_plugs = [&plug] {
29 Library::StagedNode fx{{{{}, "Effects", {}}, {}}, {}};
30 Library::StagedNode inst{{{{}, "Instruments", {}}, {}}, {}};
31 for(const auto& vst : plug.vst_infos)
32 {
33 if(vst.isValid)
34 {
35 const auto& name
36 = vst.displayName.isEmpty() ? vst.prettyName : vst.displayName;
37 Library::StagedNode p{{{key, name, QString::number(vst.uniqueID)}, {}}, {}};
38 (vst.isSynth ? inst : fx).children.push_back(std::move(p));
39 }
40 }
41 std::vector<Library::StagedNode> v;
42 v.push_back(std::move(fx));
43 v.push_back(std::move(inst));
44 return v;
45 };
46
47 model.clearAnchorKey(key);
48 model.replaceChildren(key, make_plugs());
49
50 con(plug, &vst::ApplicationPlugin::vstChanged, this,
51 [model = QPointer{&model}, make_plugs] {
52 if(model)
53 model->replaceChildren(key, make_plugs());
54 });
55 }
56};
57}
Definition LibraryInterface.hpp:26
Definition ProcessesItemModel.hpp:38
Definition score-plugin-vst/Vst/ApplicationPlugin.hpp:45
Definition score-plugin-vst/Vst/Library.hpp:18
Definition ProcessEntry.hpp:32
Static metadata implementation.
Definition lib/score/tools/Metadata.hpp:36
Specializes ApplicationContext with the QMainWindow.
Definition GUIApplicationContext.hpp:15