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 <QElapsedTimer>
9 #if QT_CONFIG(process)
10 #include <QProcess>
11 #endif
12 #include <QWebSocketServer>
13 
14 #include <thread>
15 #include <verdigris>
16 namespace vst
17 {
18 struct VSTInfo
19 {
20  QString path;
21  QString prettyName;
22  QString displayName;
23  QString author;
24  int32_t uniqueID{};
25  int32_t controls{};
26  bool isSynth{};
27  bool isValid{};
28 };
29 
30 class Model;
32  : public QObject
34 {
35  W_OBJECT(ApplicationPlugin)
36 public:
38  void initialize() override;
39  ~ApplicationPlugin() override;
40 
41  void rescanVSTs(const QStringList&);
42  void processIncomingMessage(const QString& txt);
43  void addInvalidVST(const QString& path);
44  void addVST(const QString& path, const QJsonObject& json);
45 
46  // Used for idle timers
47  void registerRunningVST(vst::Model*);
48  void unregisterRunningVST(vst::Model*);
49 
50  void scanVSTsEvent();
51 
52  void vstChanged() W_SIGNAL(vstChanged)
53 
54  std::vector<VSTInfo> vst_infos;
55  ossia::hash_map<int32_t, vst::Module*> vst_modules;
56 
57  const std::thread::id m_tid{std::this_thread::get_id()};
58  auto mainThreadId() const noexcept { return m_tid; }
59  std::vector<vst::Model*> m_runningVSTs;
60 
61 #if QT_CONFIG(process)
62  struct ScanningProcess
63  {
64  QString path;
65  std::unique_ptr<QProcess> process;
66  bool scanning{};
67  QElapsedTimer timer;
68  };
69 
70  std::vector<ScanningProcess> m_processes;
71 
72 private:
73  QWebSocketServer m_wsServer;
74 #endif
75 
76  void timerEvent(QTimerEvent* event) override;
77 };
78 
80  : public QObject
82 {
83 public:
85  void initialize() override;
86 };
87 }
Definition: GUIApplicationPlugin.hpp:31
Used to extend the software with application-wide data.
Definition: GUIApplicationPlugin.hpp:89
Definition: score-plugin-vst/Vst/ApplicationPlugin.hpp:34
void initialize() override
initialize
Definition: score-plugin-vst/Vst/ApplicationPlugin.cpp:82
Definition: score-plugin-vst/Vst/ApplicationPlugin.hpp:82
void initialize() override
initialize
Definition: score-plugin-vst/Vst/ApplicationPlugin.cpp:357
Used to access all the application-wide state and structures.
Definition: ApplicationContext.hpp:24
Specializes ApplicationContext with the QMainWindow.
Definition: GUIApplicationContext.hpp:15
Definition: score-plugin-vst/Vst/ApplicationPlugin.hpp:19