@soundor/vst3-host 0.0.0-stage → 0.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (54) hide show
  1. package/CMakeLists.txt +194 -0
  2. package/CMakePresets.json +115 -0
  3. package/LICENSE +21 -0
  4. package/NOTICE.md +17 -0
  5. package/README.md +40 -2
  6. package/cmake/Vst3HostDependencies.cmake +179 -0
  7. package/dist/cli.d.mts +1 -0
  8. package/dist/cli.mjs +88 -0
  9. package/dist/cli.mjs.map +1 -0
  10. package/dist/index.d.mts +586 -0
  11. package/dist/index.d.mts.map +1 -0
  12. package/dist/index.mjs +1 -0
  13. package/dist/prepare-ayjTVhfk.mjs +1149 -0
  14. package/dist/prepare-ayjTVhfk.mjs.map +1 -0
  15. package/native/src/Bundle.cpp +253 -0
  16. package/native/src/Bundle.h +32 -0
  17. package/native/src/EditorArea.h +92 -0
  18. package/native/src/EditorAreaMac.mm +52 -0
  19. package/native/src/EditorAreaWindows.cpp +66 -0
  20. package/native/src/EditorAreaX11.cpp +512 -0
  21. package/native/src/EditorWindow.h +72 -0
  22. package/native/src/EditorWindowMac.mm +134 -0
  23. package/native/src/EditorWindowWindows.cpp +148 -0
  24. package/native/src/EventLoop.h +50 -0
  25. package/native/src/EventLoopLinux.cpp +204 -0
  26. package/native/src/EventLoopMac.mm +146 -0
  27. package/native/src/EventLoopWindows.cpp +132 -0
  28. package/native/src/HostContext.cpp +217 -0
  29. package/native/src/HostContext.h +116 -0
  30. package/native/src/HostInterface.cpp +1026 -0
  31. package/native/src/HostInterface.h +138 -0
  32. package/native/src/HostWindow.cpp +901 -0
  33. package/native/src/HostWindow.h +187 -0
  34. package/native/src/Ipc.cpp +158 -0
  35. package/native/src/Ipc.h +91 -0
  36. package/native/src/Json.cpp +426 -0
  37. package/native/src/Json.h +85 -0
  38. package/native/src/LiveAudio.cpp +416 -0
  39. package/native/src/LiveAudio.h +121 -0
  40. package/native/src/Main.cpp +178 -0
  41. package/native/src/Paths.h +20 -0
  42. package/native/src/Plugin.cpp +1865 -0
  43. package/native/src/Plugin.h +321 -0
  44. package/native/src/Session.cpp +656 -0
  45. package/native/src/Session.h +82 -0
  46. package/native/src/Settings.cpp +93 -0
  47. package/native/src/Settings.h +23 -0
  48. package/native/src/Version.h.in +11 -0
  49. package/native/src/X11Library.cpp +127 -0
  50. package/native/src/X11Library.h +83 -0
  51. package/native/tools/Embed.cpp +49 -0
  52. package/package.json +58 -3
  53. package/protocol.json +7 -0
  54. package/targets.json +33 -0
@@ -0,0 +1,138 @@
1
+ // The host interface, drawn with Dear ImGui around the editor, after the web
2
+ // runtime's host page (runtimes/web-runtime/src/client/shell):
3
+ //
4
+ // - a dock floating under the editor: mute and volume, play/pause and stop,
5
+ // the position, and the button that opens the panel;
6
+ // - a side panel, closed by default: the transport, the audio input and
7
+ // status, an on-screen keyboard (plugins with an event input), the
8
+ // parameters, the plugin's details and the host's settings.
9
+ //
10
+ // It controls what the protocol controls (the transport, live audio,
11
+ // parameter values), through the same objects: it is one more client of
12
+ // the session.
13
+ #pragma once
14
+
15
+ #include "EventLoop.h"
16
+ #include "Json.h"
17
+ #include "LiveAudio.h"
18
+ #include "Plugin.h"
19
+ #include "Settings.h"
20
+
21
+ #include <functional>
22
+ #include <optional>
23
+ #include <string>
24
+ #include <utility>
25
+ #include <vector>
26
+
27
+ struct ImFont;
28
+ struct SDL_Window;
29
+
30
+ namespace soundor::vst3host
31
+ {
32
+ /** What the interface controls. */
33
+ struct HostModel
34
+ {
35
+ Plugin& plugin;
36
+ LiveAudio& audio;
37
+ Settings& settings;
38
+ /** Emits a protocol event (changes made in the interface). */
39
+ std::function<void(const std::string& event, Json params)> emit;
40
+ };
41
+
42
+ struct InterfaceLayout
43
+ {
44
+ /** The window's size, in the interface's coordinates. */
45
+ float width = 0;
46
+ float height = 0;
47
+ /** The interface's scale (its sizes are in units of 1 / scale). */
48
+ float scale = 1;
49
+ /** The panel's width, 0 when closed. */
50
+ float panelWidth = 0;
51
+ float editorX = 0;
52
+ float editorY = 0;
53
+ float editorWidth = 0;
54
+ float editorHeight = 0;
55
+ bool resizable = false;
56
+ /** The editor's image while the window presents it (an SDL_Texture),
57
+ and its part to draw where in the window. */
58
+ void* editorImage = nullptr;
59
+ float editorImageX = 0;
60
+ float editorImageY = 0;
61
+ float editorImageWidth = 0;
62
+ float editorImageHeight = 0;
63
+ float editorImageU0 = 0;
64
+ float editorImageV0 = 0;
65
+ float editorImageU1 = 1;
66
+ float editorImageV1 = 1;
67
+ };
68
+
69
+ class HostInterface
70
+ {
71
+ public:
72
+ HostInterface(EventLoop& loop, HostModel& model, SDL_Window* window, ImFont* semibold, bool bare);
73
+
74
+ void draw(const InterfaceLayout& layout);
75
+ /** A grip drag, consumed after the interface finishes drawing. */
76
+ std::optional<std::pair<int, int>> takeEditorSize();
77
+
78
+ [[nodiscard]] bool resizingEditor() const { return gripActive_ || wantedSize_.has_value(); }
79
+ [[nodiscard]] bool panelOpen() const { return panelOpen_; }
80
+ /** The dock's width in units, as last drawn. */
81
+ [[nodiscard]] float dockWidth() const { return dockWidth_; }
82
+ /** Live audio moves the meters and the position: draw again soon. */
83
+ [[nodiscard]] bool animating() const;
84
+
85
+ // Layout, in units.
86
+ static constexpr float padding = 16;
87
+ static constexpr float dockSpace = 76;
88
+ static constexpr float panelWidth = 300;
89
+ static constexpr float panelMinHeight = 560;
90
+
91
+ private:
92
+ /** Draws the editor's image and nothing else. */
93
+ bool bare_ = false;
94
+ void drawStage(const InterfaceLayout& layout) const;
95
+ static void drawEditorImage(const InterfaceLayout& layout);
96
+ void drawDock(const InterfaceLayout& layout);
97
+ void drawResizeGrip(const InterfaceLayout& layout);
98
+ [[nodiscard]] std::pair<float, float> pointer() const;
99
+ void drawPanel(const InterfaceLayout& layout);
100
+ void drawTransport();
101
+ void drawAudio();
102
+ void drawKeyboard();
103
+ void drawParameters();
104
+ /** True when pressed. */
105
+ [[nodiscard]] bool drawToggle(const char* title, bool on) const;
106
+ void drawPlugin();
107
+ void drawSettings();
108
+ /** A section's heading; a collapsible one starts closed. False: closed. */
109
+ bool section(const char* title, bool collapsible = false);
110
+ bool rangeSlider(const char* id, double& value, double defaultValue) const;
111
+ void startAudio();
112
+ void play();
113
+ void chooseFile();
114
+ void audioChanged() const;
115
+ void noteOn(int pitch);
116
+ void noteOff();
117
+
118
+ EventLoop& loop_;
119
+ HostModel& model_;
120
+ SDL_Window* window_;
121
+ ImFont* semibold_;
122
+ float scale_ = 1;
123
+ bool gripActive_ = false;
124
+ /** Where in the grip the pointer took it, from the editor's corner. */
125
+ float dragX_ = 0;
126
+ float dragY_ = 0;
127
+ std::pair<int, int> dragWanted_ {};
128
+ std::optional<std::pair<int, int>> wantedSize_;
129
+ bool panelOpen_;
130
+ float dockWidth_ = 330;
131
+ bool firstSection_ = true;
132
+ float meters_[2] = { 0, 0 };
133
+ int heldNote_ = -1;
134
+ int parameterGeneration_ = -1;
135
+ std::vector<HostParameter> parameters_;
136
+ std::string audioFailure_;
137
+ };
138
+ } // namespace soundor::vst3host