32 auto address = juce::String(
"127.0.0.1");
36 m_pwrOnObjDef = std::make_unique<NanoOcp1::AmpDxDy::dbOcaObjectDef_Settings_PwrOn>();
37 m_potiLevelObjDef = std::make_unique<NanoOcp1::AmpGeneric::dbOcaObjectDef_Config_PotiLevel>(1);
38 m_soundobjectEnableObjDef = std::make_unique<NanoOcp1::DS100::dbOcaObjectDef_Positioning_Source_Enable>(1);
39 m_speakerGroupObjDef = std::make_unique<NanoOcp1::DS100::dbOcaObjectDef_Positioning_Speaker_Group>(1);
40 m_guidObjDef = std::make_unique<NanoOcp1::DS100::dbOcaObjectDef_Fixed_GUID>();
43 m_ipAndPortEditor = std::make_unique<TextEditor>();
44 m_ipAndPortEditor->setTextToShowWhenEmpty(address +
";" + juce::String(port), getLookAndFeel().findColour(juce::TextEditor::ColourIds::textColourId).darker().darker());
45 m_ipAndPortEditor->addListener(
this);
46 addAndMakeVisible(m_ipAndPortEditor.get());
49 m_connectedLED = std::make_unique<TextButton>(
"con");
50 m_connectedLED->setColour(juce::TextButton::ColourIds::buttonOnColourId, juce::Colours::forestgreen);
51 m_connectedLED->setColour(juce::TextButton::ColourIds::buttonColourId, juce::Colours::dimgrey);
52 m_connectedLED->setToggleState(
false, dontSendNotification);
53 m_connectedLED->setEnabled(
false);
54 addAndMakeVisible(m_connectedLED.get());
57 m_subscribeButton = std::make_unique<TextButton>(
"Subscribe");
58 m_subscribeButton->setColour(juce::TextButton::ColourIds::buttonOnColourId, juce::Colours::blue);
59 m_subscribeButton->setClickingTogglesState(
true);
60 m_subscribeButton->onClick = [=]()
62 if (m_subscribeButton->getToggleState())
68 m_ocaHandleMap.emplace(handle, m_potiLevelObjDef.get());
73 m_ocaHandleMap.emplace(handle, m_pwrOnObjDef.get());
78 m_ocaHandleMap.emplace(handle, m_soundobjectEnableObjDef.get());
83 m_ocaHandleMap.emplace(handle, m_speakerGroupObjDef.get());
88 m_ocaHandleMap.emplace(handle, m_pwrOnObjDef.get());
92 m_ocaHandleMap.emplace(handle, m_potiLevelObjDef.get());
96 m_ocaHandleMap.emplace(handle, m_soundobjectEnableObjDef.get());
100 m_ocaHandleMap.emplace(handle, m_speakerGroupObjDef.get());
104 m_ocaHandleMap.emplace(handle, m_guidObjDef.get());
110 std::uint32_t handle;
113 m_ocaHandleMap.emplace(handle, m_potiLevelObjDef.get());
118 m_ocaHandleMap.emplace(handle, m_pwrOnObjDef.get());
123 m_ocaHandleMap.emplace(handle, m_soundobjectEnableObjDef.get());
128 m_ocaHandleMap.emplace(handle, m_speakerGroupObjDef.get());
132 addAndMakeVisible(m_subscribeButton.get());
135 m_powerD40LED = std::make_unique<TextButton>(
"Power LED");
136 m_powerD40LED->setColour(juce::TextButton::ColourIds::buttonOnColourId, juce::Colours::forestgreen);
137 m_powerD40LED->setColour(juce::TextButton::ColourIds::buttonColourId, juce::Colours::dimgrey);
138 m_powerD40LED->setToggleState(
false, dontSendNotification);
139 m_powerD40LED->setEnabled(
false);
140 addAndMakeVisible(m_powerD40LED.get());
143 m_powerOffD40Button = std::make_unique<TextButton>(
"Pwr Off");
144 m_powerOffD40Button->onClick = [=]()
146 std::uint32_t handle;
150 addAndMakeVisible(m_powerOffD40Button.get());
153 m_powerOnD40Button = std::make_unique<TextButton>(
"Pwr On");
154 m_powerOnD40Button->onClick = [=]()
156 std::uint32_t handle;
160 addAndMakeVisible(m_powerOnD40Button.get());
163 m_gainSlider = std::make_unique<Slider>(Slider::LinearVertical, Slider::TextBoxBelow);
164 m_gainSlider->setRange(-57.5, 6, 0.5);
165 m_gainSlider->setTextValueSuffix(
"dB");
166 m_gainSlider->onValueChange = [=]()
168 std::uint32_t handle;
172 addAndMakeVisible(m_gainSlider.get());
177 m_nanoOcp1Client = std::make_unique<NanoOcp1::NanoOcp1Client>(address, port,
true );
182 m_nanoOcp1Client->onConnectionEstablished = [=]()
185 m_connectedLED->setToggleState(
true, juce::dontSendNotification);
187 m_nanoOcp1Client->onConnectionLost = [=]()
190 m_connectedLED->setToggleState(
false, juce::dontSendNotification);
192 m_nanoOcp1Client->start();
200 switch (msgObj->GetMessageType())
206 DBG(
"Got an OCA notification from ONo 0x" << juce::String::toHexString(notifObj->
GetEmitterOno()));
213 m_powerD40LED->setToggleState(switchSetting > 0, dontSendNotification);
218 m_gainSlider->setValue(newGain, dontSendNotification);
220 else if (notifObj->
MatchesObject(m_soundobjectEnableObjDef.get()))
223 DBG(juce::String(__FUNCTION__) + juce::String(
" Notification for Positioning_Source_Enable: ") + juce::String(switchSetting));
225 else if (notifObj->
MatchesObject(m_speakerGroupObjDef.get()))
228 DBG(juce::String(__FUNCTION__) + juce::String(
" Notification for Positioning_Speaker_Group: ") + juce::String(newGroup));
232 DBG(
"Got an OCA notification from UNKNOWN object ONo 0x" << juce::String::toHexString(notifObj->
GetEmitterOno()));
243 if (iter != m_ocaHandleMap.end())
257 " and paramCount " << juce::String(responseObj->
GetParamCount()));
262 if (objDef == m_pwrOnObjDef.get())
265 m_powerD40LED->setToggleState(switchSetting > 0, dontSendNotification);
267 else if (objDef == m_potiLevelObjDef.get())
270 m_gainSlider->setValue(newGain, dontSendNotification);
272 else if (objDef == m_guidObjDef.get())
275 DBG(juce::String(__FUNCTION__) + juce::String(
" Response for Fixed_GUID: ") + juce::String(newValue));
280 " which could not be processed (unknown object)!");
285 m_ocaHandleMap.erase(iter);
291 "; paramCount " << juce::String(responseObj->
GetParamCount()));
334 auto bounds = getLocalBounds();
336 auto connectionParamsHeight = 35;
337 auto connectionLedWidth = 60;
339 auto textEditorBounds = bounds.removeFromTop(connectionParamsHeight);
340 auto connectedLedBounds = textEditorBounds.removeFromRight(connectionLedWidth);
341 m_connectedLED->setBounds(connectedLedBounds.reduced(5));
342 m_ipAndPortEditor->setBounds(textEditorBounds.reduced(5));
344 auto sliderBounds = bounds.removeFromRight(connectionLedWidth);
345 m_gainSlider->setBounds(sliderBounds.reduced(5));
347 auto button1Bounds = bounds;
348 auto button2Bounds = button1Bounds.removeFromRight(button1Bounds.getWidth() / 2);
349 auto button3Bounds = button2Bounds.removeFromBottom(button2Bounds.getHeight() / 2);
350 auto button4Bounds = button1Bounds.removeFromBottom(button1Bounds.getHeight() / 2);
352 button1Bounds.reduce(5, 5);
353 button2Bounds.reduce(5, 5);
354 button3Bounds.reduce(5, 5);
355 button4Bounds.reduce(5, 5);
357 m_subscribeButton->setBounds(button1Bounds);
358 m_powerD40LED->setBounds(button2Bounds);
359 m_powerOffD40Button->setBounds(button3Bounds);
360 m_powerOnD40Button->setBounds(button4Bounds);