Loading...
Searching...
No Matches
score-plugin-vst/Vst/ApplicationPlugin.hpp
1#pragma once
2#include <Vst/Loader.hpp>
3
4#include <score/plugins/application/GUIApplicationPlugin.hpp>
5
6#include <ossia/detail/hash_map.hpp>
7
8#include <QtCore/qglobal.h>
9
10#include <score_plugin_vst_export.h>
11
12#include <thread>
13#include <verdigris>
14
15class QTimer;
16class QJsonObject;
17namespace Media
18{
19class PluginScanner;
20}
21
22namespace vst
23{
24struct VSTInfo
25{
26 QString path;
27 QString prettyName;
28 QString displayName;
29 QString author;
30 int32_t uniqueID{};
31 int32_t controls{};
32 bool isSynth{};
33 bool isValid{};
34};
35
38SCORE_PLUGIN_VST_EXPORT
39VSTInfo parseVstReply(const QString& path, const QJsonObject& obj);
40
41class Model;
43 : public QObject
45{
46 W_OBJECT(ApplicationPlugin)
47public:
49 void initialize() override;
50 ~ApplicationPlugin() override;
51
52 void clearVSTs();
53 void rescanVSTs(QStringList);
54
55 // Used for idle timers
56 void registerRunningVST(vst::Model*);
57 void unregisterRunningVST(vst::Model*);
58
59 void vstChanged() E_SIGNAL(SCORE_PLUGIN_VST_EXPORT, vstChanged);
60
61 std::vector<VSTInfo> vst_infos;
62 ossia::hash_map<int32_t, vst::Module*> vst_modules;
63
64 const std::thread::id m_tid{std::this_thread::get_id()};
65 auto mainThreadId() const noexcept { return m_tid; }
66 std::vector<vst::Model*> m_runningVSTs;
67
68private:
69 void onScanned(const QString& path, const QJsonObject& obj);
70 void onScanFailed(const QString& path, const QString& reason);
71 void removeEntriesForPath(const QString& path);
72 void persistCache();
73 void schedulePersist();
74
75#if QT_CONFIG(process)
76 std::unique_ptr<Media::PluginScanner> m_scanner;
77#endif
78 QTimer* m_persistTimer{};
79 bool m_scanRan{};
80
81 void timerEvent(QTimerEvent* event) override;
82};
83
85 : public QObject
87{
88public:
90 void initialize() override;
91};
92}
Definition GUIApplicationPlugin.hpp:31
Used to extend the software with application-wide data.
Definition GUIApplicationPlugin.hpp:89
Definition score-plugin-vst/Vst/ApplicationPlugin.hpp:45
void initialize() override
initialize
Definition score-plugin-vst/Vst/ApplicationPlugin.cpp:104
Definition score-plugin-vst/Vst/ApplicationPlugin.hpp:87
void initialize() override
initialize
Definition score-plugin-vst/Vst/ApplicationPlugin.cpp:349
Used to access all the application-wide state and structures.
Definition ApplicationContext.hpp:25
Specializes ApplicationContext with the QMainWindow.
Definition GUIApplicationContext.hpp:15
Definition score-plugin-vst/Vst/ApplicationPlugin.hpp:25