Umsci
Upmix Spatial Control Interface — OCA/OCP.1 spatial audio utility
Loading...
Searching...
No Matches
MainComponent.h
Go to the documentation of this file.
1/* Copyright (c) 2026, Christian Ahrens
2 *
3 * This file is part of Umsci <https://github.com/ChristianAhrens/Umsci>
4 *
5 * This tool is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU Lesser General Public License version 3.0 as published
7 * by the Free Software Foundation.
8 *
9 * This tool is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12 * details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this tool; if not, write to the Free Software Foundation, Inc.,
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17 */
18
19#pragma once
20
21#include <JuceHeader.h>
22
26#include "MidiController.h"
27#include "OscController.h"
28
29
36class AboutComponent;
37
75class MainComponent : public juce::Component,
76 public UmsciAppConfiguration::Dumper,
77 public UmsciAppConfiguration::Watcher
78{
79public:
122
123public:
125 ~MainComponent() override;
126
128 void applySettingsOption(const UmsciSettingsOption& option);
129
130 //==============================================================================
131 void resized() override;
132 void paint(juce::Graphics& g) override;
133 void lookAndFeelChanged() override;
134
136 bool keyPressed(const juce::KeyPress& key) override;
137
138 //==============================================================================
140 void performConfigurationDump() override;
142 void onConfigUpdated() override;
143
144 //==============================================================================
145 bool isFullscreenEnabled();
146
147 //==============================================================================
153 std::function<void(int, bool)> onPaletteStyleChange;
154
155 //==============================================================================
157 std::function<void(bool)> onSetFullscreenWindow;
158
159private:
160 //==============================================================================
161 void handleSettingsMenuResult(int selectedId);
162 void handleSettingsLookAndFeelMenuResult(int selectedId);
163 void handleSettingsControlColourMenuResult(int selectedId);
164 void handleSettingsControlFormatMenuResult(int selectedId);
165 void handleSettingsControlSizeMenuResult(int selectedId);
166 void handleSettingsFullscreenModeToggleResult();
167 void showConnectionSettings();
168 void showUpmixSettings();
169 void showExternalControlSettings();
170
171 //==============================================================================
174 void applyUpmixParamValue(UmsciExternalControlComponent::UpmixMidiParam param, float domainValue);
175
176 //==============================================================================
177 void setControlColour(const juce::Colour& meteringColour);
178 void applyControlColour();
179
180 void toggleFullscreenMode();
181
182 //==============================================================================
183 std::unique_ptr<UmsciControlComponent> m_controlComponent;
184 std::unique_ptr<UmsciDiscoveringHintComponent> m_discoverHintComponent;
185 std::unique_ptr<UmsciConnectingComponent> m_connectingComponent;
186
187 std::unique_ptr<juce::DrawableButton> m_settingsButton;
188 std::map<int, std::pair<std::string, int>> m_settingsItems;
189 int m_settingsHostLookAndFeelId = -1;
190
191 std::unique_ptr<juce::DrawableButton> m_connectionToggleButton;
192
193 std::unique_ptr<juce::DrawableButton> m_aboutButton;
194 std::unique_ptr<AboutComponent> m_aboutComponent;
195
196 //==============================================================================
197 struct UpmixSnapshot
198 {
199 float rot { 0.0f }, scale { 1.0f }, heightScale { 0.6f },
200 angleStretch { 1.0f }, offsetX { 0.0f }, offsetY { 0.0f };
201
202 juce::String toString() const
203 {
204 return "rot=" + juce::String(rot)
205 + ";scale=" + juce::String(scale)
206 + ";heightScale=" + juce::String(heightScale)
207 + ";angleStretch=" + juce::String(angleStretch)
208 + ";offsetX=" + juce::String(offsetX)
209 + ";offsetY=" + juce::String(offsetY);
210 }
211
212 static UpmixSnapshot fromString(const juce::String& s)
213 {
214 UpmixSnapshot p;
215 for (auto& token : juce::StringArray::fromTokens(s, ";", ""))
216 {
217 auto kv = juce::StringArray::fromTokens(token.trim(), "=", "");
218 if (kv.size() != 2) continue;
219 auto key = kv[0].trim();
220 auto val = kv[1].trim().getFloatValue();
221 if (key == "rot") p.rot = val;
222 else if (key == "scale") p.scale = val;
223 else if (key == "heightScale") p.heightScale = val;
224 else if (key == "angleStretch")p.angleStretch= val;
225 else if (key == "offsetX") p.offsetX = val;
226 else if (key == "offsetY") p.offsetY = val;
227 }
228 return p;
229 }
230 };
231 std::optional<UpmixSnapshot> m_upmixSnapshot;
232 std::unique_ptr<juce::DrawableButton> m_upmixSnapshotStoreButton;
233 std::unique_ptr<juce::DrawableButton> m_upmixSnapshotRecallButton;
234
235 std::unique_ptr<juce::AlertWindow> m_messageBox;
236 std::unique_ptr<UmsciZeroconfDiscoverComboComponent> m_zeroconfDiscoverComboComponent;
237 std::unique_ptr<UmsciExternalControlComponent> m_externalControlComponent;
238
239 juce::Colour m_controlColour = juce::Colours::forestgreen;
240
241 std::unique_ptr<UmsciAppConfiguration> m_config;
242
243 //==============================================================================
244 std::unique_ptr<MidiController> m_midiController;
245 std::unique_ptr<OscController> m_oscController;
246
247 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (MainComponent)
248};
249
Small overlay panel showing the application icon, version info, and a link to the project repository.
Root JUCE component — the top-level UI that wires together the device connection, the visualisation,...
void paint(juce::Graphics &g) override
void performConfigurationDump() override
UmsciAppConfiguration::Dumper — serialises all current settings to XML.
void resized() override
void applySettingsOption(const UmsciSettingsOption &option)
Applies a single settings option (called from both menu handlers and config restore).
std::function< void(int, bool)> onPaletteStyleChange
Fired when the look-and-feel palette changes, so the host application (if this is used as a plugin) c...
void lookAndFeelChanged() override
UmsciSettingsOption
Enumerates every user-selectable setting exposed via the settings menu.
@ UpmixSettings
Opens the upmix settings dialog.
@ ControlSize_L
Large icons.
@ ControlSize_M
Medium icons.
@ FullscreenWindowMode
Toggles fullscreen / windowed.
@ LookAndFeel_Light
Force light colour scheme.
@ ControlColour_Laser
Bright laser-style highlight.
@ ExternalControlSettings
Opens the external (MIDI) control settings dialog.
@ ConnectionSettings
Opens the connection settings dialog.
@ LookAndFeel_FollowHost
Inherit host application L&F.
@ ControlColour_Green
Green source icons.
@ LookAndFeel_Dark
Force dark colour scheme.
@ ControlSize_S
Small icons.
bool keyPressed(const juce::KeyPress &key) override
Handles the Escape key (exits fullscreen) and F key (toggles fullscreen).
void onConfigUpdated() override
UmsciAppConfiguration::Watcher — called when the config XML changes on disk.
std::function< void(bool)> onSetFullscreenWindow
Fired when the user requests fullscreen mode; the host window applies it.
~MainComponent() override
Fullscreen progress overlay shown while the OCP.1 connection is being established,...
The main visualisation and interaction surface for Umsci.
Fullscreen overlay shown when no DS100 connection has been configured yet.
UpmixMidiParam
Identifies each controllable upmix transform parameter.