Repository navigation
Expand file tree
/
Copy pathMainComponent.cpp
More file actions
10120 lines (9215 loc) · 459 KB
/
Copy pathMainComponent.cpp
File metadata and controls
10120 lines (9215 loc) · 459 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Super Timecode Converter
// Copyright (c) 2026 Fiverecords -- MIT License
// https://github.com/fiverecords/SuperTimecodeConverter
#include "MainComponent.h"
#include "WaveformCache.h"
using SrcType = TimecodeEngine::InputSource;
//==============================================================================
// Remove " *" or " [Engine N]" markers from combo item text to get the
// underlying device name. Used when saving device names to settings.
//==============================================================================
static juce::String stripComboMarker(const juce::String& text)
{
static const juce::String dotChar = juce::String::charToString(0x25CF);
static const juce::String dotWithSpace = juce::String(" ") + dotChar;
auto s = text;
if (s.endsWith(dotWithSpace))
s = s.dropLastCharacters(dotWithSpace.length());
else if (s.endsWith(dotChar))
s = s.dropLastCharacters(dotChar.length());
int bracket = s.lastIndexOf(" [");
if (bracket >= 0 && s.endsWith("]"))
s = s.substring(0, bracket);
return s.trimEnd();
}
//==============================================================================
// Select the item of `cmb` that shows `label` (markers stripped), preferring
// `preferredId` while its item still shows it -- two MIDI ports can share a
// name. With no such item nothing is selected. Returns whether one was.
//==============================================================================
static bool selectComboItemByLabel(juce::ComboBox& cmb, const juce::String& label, int preferredId)
{
const int preferredIndex = cmb.indexOfItemId(preferredId);
if (preferredIndex >= 0 && stripComboMarker(cmb.getItemText(preferredIndex)) == label)
{
cmb.setSelectedId(preferredId, juce::dontSendNotification);
return true;
}
for (int i = 0; i < cmb.getNumItems(); ++i)
if (stripComboMarker(cmb.getItemText(i)) == label)
{
cmb.setSelectedItemIndex(i, juce::dontSendNotification);
return true;
}
cmb.setSelectedId(0, juce::dontSendNotification);
return false;
}
//==============================================================================
// Where the interface labelled `label` ("name (ip)") is in `labels`: the
// same label, or else the only label with the same interface name -- the
// interface with a new address, such as a link-local one replaced by a
// DHCP lease. -1 when there is neither, or when the name is listed with
// more than one address and none is the old one.
//==============================================================================
static int findInterfaceLabel(const juce::StringArray& labels, const juce::String& label)
{
if (const int same = labels.indexOf(label); same >= 0)
return same;
auto nameOf = [](const juce::String& l) { return l.upToLastOccurrenceOf(" (", false, false); };
const auto name = nameOf(label);
int found = -1;
for (int i = 0; i < labels.size(); ++i)
{
if (nameOf(labels[i]) != name)
continue;
if (found >= 0)
return -1;
found = i;
}
return found;
}
//==============================================================================
// The position, in the MIDI device list as it is now, of the device a MIDI
// selector shows -- or, with nothing selected, of `savedName`, the engine's
// configured device. The selector's items are the list from when it was
// filled, and the MTC input or output enumerates the devices again when it
// starts, so a device plugged in or out since then moved the positions.
// The shown device is the name the selector was filled with for that item
// (`filledNames`, by item ID - 1), not the item's text: the text carries
// the in-use marker, and stripping it cannot tell a device named
// "Port [2]" from a "Port" in use by another engine. That exact name is
// looked for at the shown position (two ports can share one), then
// anywhere. The saved name is stripComboMarker's text, as flushSettings
// saves it, which also strips a device's own trailing " [...]" or space:
// it matches a device by its name, then by its name stripped the same way.
// -1 when the device is not listed, or there is no name: the engine opens
// nothing then, so STC never opens a MIDI port the operator did not pick
// (AUDIT UI-6). Message thread.
//==============================================================================
static int midiDeviceToStart(const juce::ComboBox& cmb, const juce::StringArray& filledNames,
const juce::String& savedName, bool isInput)
{
const int selectedId = cmb.getSelectedId();
const juce::String name = selectedId > 0 ? filledNames[selectedId - 1] : stripComboMarker(savedName);
if (name.isEmpty())
return -1;
const auto devices = isInput ? juce::MidiInput::getAvailableDevices()
: juce::MidiOutput::getAvailableDevices();
for (const bool exact : { true, false })
{
if (! exact && selectedId > 0)
break; // the shown device is known by its own name
auto isNamed = [&name, exact](const juce::String& device)
{
return exact ? device == name : stripComboMarker(device) == name;
};
if (selectedId > 0 && selectedId <= devices.size() && isNamed(devices[selectedId - 1].name))
return selectedId - 1;
for (int i = 0; i < devices.size(); ++i)
if (isNamed(devices[i].name))
return i;
}
return -1;
}
//==============================================================================
// BPM x 100 for a TCNet layer, as the casts it replaces computed it
// (truncated), and 0 for a tempo that is unknown, not finite, negative or
// beyond 1000 BPM: a double -> uint32_t cast of a value out of range is
// undefined (AUDIT A17). getBPM's own 0 for an unknown tempo (AUDIT PDL-1)
// is not relied on.
//==============================================================================
static uint32_t bpmToTimes100(double bpm)
{
return (bpm > 0.0 && bpm < 1000.0) ? (uint32_t) (bpm * 100.0) : 0u;
}
//==============================================================================
// An Engine DJ cue's sample offset as ms, 0 when it is not a finite value
// that fits: the database is the device's, and a double -> uint32_t cast of
// a value out of range is undefined.
//==============================================================================
static uint32_t denonCueToMs(double sampleOffset, double sampleRate)
{
const double ms = sampleOffset / sampleRate * 1000.0;
return (std::isfinite(ms) && ms >= 0.0 && ms <= 4294967295.0) ? (uint32_t) ms : 0u;
}
//==============================================================================
// BACKGROUND AUDIO DEVICE SCANNER
//==============================================================================
MainComponent::AudioScanThread::AudioScanThread(MainComponent* owner)
: juce::Thread("AudioScanThread"), safeOwner(owner) {}
void MainComponent::AudioScanThread::run()
{
juce::Array<AudioDeviceEntry> inputs, outputs;
if (!tempManager)
return;
for (auto* type : tempManager->getAvailableDeviceTypes())
{
if (threadShouldExit()) return;
auto typeName = type->getTypeName();
type->scanForDevices();
for (auto& name : type->getDeviceNames(true))
inputs.add({ typeName, name, AudioDeviceEntry::makeDisplayName(typeName, name) });
for (auto& name : type->getDeviceNames(false))
outputs.add({ typeName, name, AudioDeviceEntry::makeDisplayName(typeName, name) });
}
// A scan that sees the stop request -- from the destructor, or from a
// newer scan that replaces it -- before posting posts nothing: its lists
// would arrive after, or on top of, the newer state (AUDIT UI-1). A
// stop requested after this check still posts; those lists then apply
// before the newer scan's.
if (threadShouldExit()) return;
juce::MessageManager::callAsync([owner = safeOwner, inputs, outputs]()
{
if (auto* comp = owner.getComponent())
comp->onAudioScanComplete(inputs, outputs);
});
}
//==============================================================================
// SAMPLE RATE / BUFFER SIZE helpers (same as v1.3)
//==============================================================================
static int sampleRateToComboId(double sr)
{
if (sr <= 0) return 1;
if (std::abs(sr - 44100) < 1) return 2;
if (std::abs(sr - 48000) < 1) return 3;
if (std::abs(sr - 88200) < 1) return 4;
if (std::abs(sr - 96000) < 1) return 5;
return 1;
}
static int bufferSizeToComboId(int bs)
{
if (bs <= 0) return 1;
if (bs <= 32) return 2;
if (bs <= 64) return 3;
if (bs <= 128) return 4;
if (bs <= 256) return 5;
if (bs <= 512) return 6;
if (bs <= 1024) return 7;
if (bs <= 2048) return 8;
if (bs <= 4096) return 9;
return 10;
}
//==============================================================================
// CONSTRUCTOR / DESTRUCTOR
//==============================================================================
MainComponent::MainComponent()
{
setLookAndFeel(&customLookAndFeel);
// --- Create initial engine BEFORE setSize, because setSize triggers
// resized() which calls currentEngine() ---
engines.push_back(std::make_unique<TimecodeEngine>(0));
engines[0]->setSharedProDJLinkInput(&sharedProDJLinkInput);
engines[0]->setSharedStageLinQInput(&sharedStageLinQInput);
sharedStageLinQInput.onMetadataRequest = [this](const juce::String& path)
{
sharedStageLinQDb.requestMetadata(path);
};
sharedStageLinQInput.onFileTransferAvailable = [this](const juce::String& ip, uint16_t port, const uint8_t* token)
{
sharedStageLinQDb.start(ip, port, token);
};
sharedProDJLinkInput.onPlayerLost = [this](const juce::String& playerIP)
{
sharedDbClient.invalidatePlayer(playerIP);
};
sharedProDJLinkInput.onPlayerMoved = [this](const juce::String& oldIp, const juce::String& newIp)
{
sharedDbClient.movePlayer(oldIp, newIp);
};
sharedProDJLinkInput.onMediaChanged = [this](const juce::String& playerIP, uint8_t slot)
{
sharedDbClient.mediaChanged(playerIP, slot);
};
engines[0]->setDbServerClient(&sharedDbClient);
engines[0]->setTrackMap(&settings.trackMap);
engines[0]->setMixerMap(&sharedMixerMap);
engines[0]->setSlqMixerMap(&sharedSlqMixerMap);
setSize(900, 700);
setWantsKeyboardFocus(true); // for the keyboard shortcuts in keyPressed
// --- Tab bar ---
addAndMakeVisible(btnAddEngine);
btnAddEngine.setColour(juce::TextButton::buttonColourId, juce::Colour(0xFF1A1D23));
btnAddEngine.setColour(juce::TextButton::textColourOffId, accentBlue);
btnAddEngine.onClick = [this] { if (!isShowLocked()) addEngine(); };
rebuildTabButtons();
// --- Left panel scrollable viewport ---
addAndMakeVisible(leftViewport);
leftViewport.setViewedComponent(&leftContent, false);
leftViewport.setScrollBarsShown(true, false);
// --- Right panel scrollable viewport ---
addAndMakeVisible(rightViewport);
rightViewport.setViewedComponent(&rightContent, false);
rightViewport.setScrollBarsShown(true, false);
// --- Input buttons ---
for (auto* btn : { &btnMtcIn, &btnArtnetIn, &btnSysTime, &btnLtcIn, &btnProDJLinkIn, &btnStageLinQIn, &btnLANetTCIn })
{ leftContent.addAndMakeVisible(btn); btn->setClickingTogglesState(false); }
// HippoNet input hidden pending hardware validation (code preserved in HippotizerInput.h)
btnHippoIn.setVisible(false);
// Winamp input: Windows-only (the WinampInput class is a stub on macOS).
// The button is added to the layout on every platform so the resized()
// logic doesn't have to branch, but on macOS it is hidden so the user
// never sees an unusable control.
leftContent.addAndMakeVisible(btnWinampIn);
btnWinampIn.setClickingTogglesState(false);
#if JUCE_WINDOWS
btnWinampIn.setVisible(true);
#else
btnWinampIn.setVisible(false);
#endif
// Winamp expandable panel labels. Start hidden -- shown only when
// Winamp is the active source AND the input config is expanded.
leftContent.addAndMakeVisible(lblWinampInfoHeader);
leftContent.addAndMakeVisible(lblWinampInfo);
lblWinampInfoHeader.setText("WINAMP STATUS:", juce::dontSendNotification);
styleLabel(lblWinampInfoHeader);
styleLabel(lblWinampInfo);
lblWinampInfo.setText("--", juce::dontSendNotification);
lblWinampInfoHeader.setVisible(false);
lblWinampInfo.setVisible(false);
btnMtcIn.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
if (eng.getActiveInput() == SrcType::MTC) { inputConfigExpanded = !inputConfigExpanded; updateDeviceSelectorVisibility(); resized(); }
else { inputConfigExpanded = true; eng.setInputSource(SrcType::MTC); startCurrentMtcInput(); updateInputButtonStates(); updateDeviceSelectorVisibility(); resized(); populateFilteredOutputDeviceCombos(); saveSettings(); }
};
btnArtnetIn.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
if (eng.getActiveInput() == SrcType::ArtNet) { inputConfigExpanded = !inputConfigExpanded; updateDeviceSelectorVisibility(); resized(); }
else { inputConfigExpanded = true; eng.setInputSource(SrcType::ArtNet); startCurrentArtnetInput(); updateInputButtonStates(); updateDeviceSelectorVisibility(); resized(); populateFilteredOutputDeviceCombos(); saveSettings(); }
};
btnLANetTCIn.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
if (eng.getActiveInput() == SrcType::LANetTC) { inputConfigExpanded = !inputConfigExpanded; updateDeviceSelectorVisibility(); resized(); }
else { inputConfigExpanded = true; eng.setInputSource(SrcType::LANetTC); startCurrentLANetTCInput(); updateInputButtonStates(); updateDeviceSelectorVisibility(); resized(); populateFilteredOutputDeviceCombos(); saveSettings(); }
};
btnSysTime.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
if (eng.getActiveInput() == SrcType::SystemTime) { inputConfigExpanded = !inputConfigExpanded; updateDeviceSelectorVisibility(); resized(); }
else
{
inputConfigExpanded = true;
eng.setInputSource(SrcType::SystemTime);
// Reopen the Generator audio output if the toggle was left on
// from before -- setInputSource() closed it when leaving
// SystemTime to free the device for other engines, so the
// symmetrical thing on returning is to reopen if the user
// had it on.
if (btnGenAudioOut.getToggleState()
&& cmbGenAudioDevice.getSelectedId() > 0
&& cmbGenAudioDevice.getSelectedId() != kPlaceholderItemId)
{
startCurrentGenAudio();
}
// Re-push the selected preset's cues into the engine.
// setInputSource cleared armedCues + rawGeneratorCues to keep
// sources from leaking into each other; without this restore
// the user would have to re-select their preset in the combo
// for cues to fire after switching back from another input.
if (cmbGenPreset.isVisible() && cmbGenPreset.getSelectedId() > 0)
{
if (auto* preset = settings.generatorPresets.find(cmbGenPreset.getText()))
eng.setGeneratorCuePoints(preset->cuePoints);
}
updateInputButtonStates(); updateDeviceSelectorVisibility(); resized();
populateFilteredOutputDeviceCombos(); // refresh markers (Gen audio device may have changed occupancy)
saveSettings();
}
};
btnLtcIn.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
if (eng.getActiveInput() == SrcType::LTC) { inputConfigExpanded = !inputConfigExpanded; updateDeviceSelectorVisibility(); resized(); }
else { inputConfigExpanded = true; eng.setInputSource(SrcType::LTC); if (!scannedAudioInputs.isEmpty()) startCurrentLtcInput(); updateInputButtonStates(); updateDeviceSelectorVisibility(); resized(); populateFilteredOutputDeviceCombos(); saveSettings(); }
};
btnProDJLinkIn.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
if (eng.getActiveInput() == SrcType::ProDJLink) { inputConfigExpanded = !inputConfigExpanded; updateDeviceSelectorVisibility(); resized(); }
else { inputConfigExpanded = true; eng.setInputSource(SrcType::ProDJLink); startCurrentProDJLinkInput(); updateInputButtonStates(); updateDeviceSelectorVisibility(); resized(); populateFilteredOutputDeviceCombos(); saveSettings(); }
};
btnStageLinQIn.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
if (eng.getActiveInput() == SrcType::StageLinQ) { inputConfigExpanded = !inputConfigExpanded; updateDeviceSelectorVisibility(); resized(); }
else { inputConfigExpanded = true; eng.setInputSource(SrcType::StageLinQ); startCurrentStageLinQInput(); updateInputButtonStates(); updateDeviceSelectorVisibility(); resized(); populateFilteredOutputDeviceCombos(); saveSettings(); }
};
btnHippoIn.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
if (eng.getActiveInput() == SrcType::Hippotizer) { inputConfigExpanded = !inputConfigExpanded; updateDeviceSelectorVisibility(); resized(); }
else { inputConfigExpanded = true; eng.setInputSource(SrcType::Hippotizer); startCurrentHippotizerInput(); updateInputButtonStates(); updateDeviceSelectorVisibility(); resized(); populateFilteredOutputDeviceCombos(); saveSettings(); }
};
btnWinampIn.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
if (eng.getActiveInput() == SrcType::Winamp) { inputConfigExpanded = !inputConfigExpanded; updateDeviceSelectorVisibility(); resized(); }
else { inputConfigExpanded = true; eng.setInputSource(SrcType::Winamp); eng.startWinampInput(); updateInputButtonStates(); updateDeviceSelectorVisibility(); resized(); populateFilteredOutputDeviceCombos(); saveSettings(); }
};
// --- Output toggles ---
for (auto* btn : { &btnMtcOut, &btnArtnetOut, &btnLtcOut, &btnThruOut, &btnTcnetOut, &btnLANetTCOut })
rightContent.addAndMakeVisible(btn);
styleOutputToggle(btnMtcOut, accentRed);
styleOutputToggle(btnArtnetOut, accentOrange);
styleOutputToggle(btnLANetTCOut, juce::Colour{0xFF63D8FB});
styleOutputToggle(btnLtcOut, accentPurple);
styleOutputToggle(btnThruOut, accentCyan);
styleOutputToggle(btnTcnetOut, juce::Colour(0xFF00CC66));
// On-air gate lives in the ProDJLink input panel (it gates input activity,
// not a particular output). Use the small tick-style toggle like btnLink
// to match the look of the ProDJLink panel controls, not the big output
// toggles on the right side.
leftContent.addAndMakeVisible(btnOnAirGate);
btnOnAirGate.setColour(juce::ToggleButton::textColourId, textMid);
btnOnAirGate.setColour(juce::ToggleButton::tickColourId, juce::Colour(0xFFE040FB));
btnOnAirGate.onClick = [this]
{
if (syncing) return;
if (isShowLockedToggle(btnOnAirGate)) return;
currentEngine().setOnAirGateEnabled(btnOnAirGate.getToggleState());
saveSettings();
};
auto outputToggleHandler = [this]
{
if (syncing) return;
if (isShowLockedRevert()) return;
auto& eng = currentEngine();
eng.setOutputMtcEnabled(btnMtcOut.getToggleState());
eng.setOutputArtnetEnabled(btnArtnetOut.getToggleState());
eng.setOutputLANetTCEnabled(btnLANetTCOut.getToggleState());
eng.setOutputLtcEnabled(btnLtcOut.getToggleState());
eng.setOutputThruEnabled(btnThruOut.getToggleState());
eng.setOutputTcnetEnabled(btnTcnetOut.getToggleState());
// Auto-start/stop shared TCNet output based on any engine needing it
bool anyTcnet = false;
for (auto& e : engines)
if (e->isOutputTcnetEnabled()) { anyTcnet = true; break; }
if (anyTcnet && !sharedTcnetOutput.getIsRunning())
{
sharedTcnetOutput.refreshNetworkInterfaces();
sharedTcnetOutput.start(nicIdToStart(cmbTcnetInterface, kNicTcnet) - 2); // what the selector shows, as listed now (AUDIT UI-6)
}
else if (!anyTcnet && sharedTcnetOutput.getIsRunning())
{
sharedTcnetOutput.stop();
}
updateCurrentOutputStates();
// After toggling outputs, audio devices for LTC out / Thru out are
// opened/closed in updateCurrentOutputStates(); MIDI devices for MTC
// out are too. Refresh both combo families so the in-use markers
// (bullet for current engine, [ENGINE N] for others) reflect the
// new occupancy across all selectors.
populateFilteredOutputDeviceCombos();
populateMidiAndNetworkCombos();
updateDeviceSelectorVisibility();
resized();
saveSettings();
};
btnMtcOut.onClick = btnArtnetOut.onClick = btnLtcOut.onClick = btnThruOut.onClick = btnTcnetOut.onClick = btnLANetTCOut.onClick = outputToggleHandler;
// --- Collapse toggle buttons for outputs ---
for (auto* btn : { &btnCollapseMtcOut, &btnCollapseArtnetOut, &btnCollapseLtcOut, &btnCollapseThruOut, &btnCollapseLANetTCOut })
{
rightContent.addAndMakeVisible(btn);
styleCollapseButton(*btn);
}
auto makeCollapseHandler = [this](bool& expandedFlag, juce::TextButton& collapseBtn) {
return [this, &expandedFlag, &collapseBtn] {
expandedFlag = !expandedFlag;
updateCollapseButtonText(collapseBtn, expandedFlag);
updateDeviceSelectorVisibility();
resized();
};
};
btnCollapseMtcOut.onClick = makeCollapseHandler(mtcOutExpanded, btnCollapseMtcOut);
btnCollapseArtnetOut.onClick = makeCollapseHandler(artnetOutExpanded, btnCollapseArtnetOut);
btnCollapseLANetTCOut.onClick = makeCollapseHandler(laNetTCOutExpanded, btnCollapseLANetTCOut);
btnCollapseLtcOut.onClick = makeCollapseHandler(ltcOutExpanded, btnCollapseLtcOut);
btnCollapseThruOut.onClick = makeCollapseHandler(thruOutExpanded, btnCollapseThruOut);
updateCollapseButtonText(btnCollapseMtcOut, mtcOutExpanded);
updateCollapseButtonText(btnCollapseArtnetOut, artnetOutExpanded);
updateCollapseButtonText(btnCollapseLANetTCOut, laNetTCOutExpanded);
updateCollapseButtonText(btnCollapseLtcOut, ltcOutExpanded);
updateCollapseButtonText(btnCollapseThruOut, thruOutExpanded);
// Input collapse button
leftContent.addAndMakeVisible(btnCollapseInput);
styleCollapseButton(btnCollapseInput);
btnCollapseInput.onClick = [this] {
inputConfigExpanded = !inputConfigExpanded;
updateCollapseButtonText(btnCollapseInput, inputConfigExpanded);
updateDeviceSelectorVisibility();
resized();
};
updateCollapseButtonText(btnCollapseInput, inputConfigExpanded);
// --- FPS buttons ---
for (auto* btn : { &btnFps2398, &btnFps24, &btnFps25, &btnFps2997, &btnFps30 })
{ addAndMakeVisible(btn); btn->setClickingTogglesState(false); }
btnFps2398.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
// LTC and LA-Net (24, 25 or 30 only), MTC and Art-Net (rate code 0)
// carry 23.976 as 24: the choice is marked so that the engine's
// input branch keeps 23.976 against a detected 24 (AUDIT NET-4,
// TimecodeEngine::followDetectedRate). The flag is persisted as
// ltcFpsUserOverride.
const auto src = eng.getActiveInput();
if (src == SrcType::LTC || src == SrcType::MTC || src == SrcType::ArtNet || src == SrcType::LANetTC)
eng.setUserOverrodeLtcFps(true);
eng.setFrameRate(FrameRate::FPS_2398); updateFpsButtonStates(); saveSettings();
};
btnFps24.onClick = [this] {
if (syncing || isShowLocked()) return;
currentEngine().setUserOverrodeLtcFps(false);
currentEngine().setFrameRate(FrameRate::FPS_24); updateFpsButtonStates(); saveSettings();
};
btnFps25.onClick = [this] {
if (syncing || isShowLocked()) return;
currentEngine().setUserOverrodeLtcFps(false);
currentEngine().setFrameRate(FrameRate::FPS_25); updateFpsButtonStates(); saveSettings();
};
btnFps2997.onClick = [this] {
if (syncing || isShowLocked()) return;
auto& eng = currentEngine();
// LTC and LA-Net carry 29.97 as 30 (MTC and Art-Net have a code for
// it): marked as for 23.976 above (AUDIT NET-4).
const auto src = eng.getActiveInput();
if (src == SrcType::LTC || src == SrcType::LANetTC)
eng.setUserOverrodeLtcFps(true);
eng.setFrameRate(FrameRate::FPS_2997); updateFpsButtonStates(); saveSettings();
};
btnFps30.onClick = [this] {
if (syncing || isShowLocked()) return;
currentEngine().setUserOverrodeLtcFps(false);
currentEngine().setFrameRate(FrameRate::FPS_30); updateFpsButtonStates(); saveSettings();
};
// --- FPS Conversion ---
addAndMakeVisible(btnFpsConvert);
styleOutputToggle(btnFpsConvert, accentGreen);
btnFpsConvert.onClick = [this]
{
if (syncing) return;
if (isShowLockedToggle(btnFpsConvert)) return;
auto& eng = currentEngine();
eng.setFpsConvertEnabled(btnFpsConvert.getToggleState());
updateOutputFpsButtonStates();
resized(); repaint();
saveSettings();
};
for (auto* btn : { &btnOutFps2398, &btnOutFps24, &btnOutFps25, &btnOutFps2997, &btnOutFps30 })
{ addAndMakeVisible(btn); btn->setClickingTogglesState(false); }
btnOutFps2398.onClick = [this] { if (!syncing && !isShowLocked()) { currentEngine().setOutputFrameRate(FrameRate::FPS_2398); updateOutputFpsButtonStates(); saveSettings(); } };
btnOutFps24.onClick = [this] { if (!syncing && !isShowLocked()) { currentEngine().setOutputFrameRate(FrameRate::FPS_24); updateOutputFpsButtonStates(); saveSettings(); } };
btnOutFps25.onClick = [this] { if (!syncing && !isShowLocked()) { currentEngine().setOutputFrameRate(FrameRate::FPS_25); updateOutputFpsButtonStates(); saveSettings(); } };
btnOutFps2997.onClick = [this] { if (!syncing && !isShowLocked()) { currentEngine().setOutputFrameRate(FrameRate::FPS_2997); updateOutputFpsButtonStates(); saveSettings(); } };
btnOutFps30.onClick = [this] { if (!syncing && !isShowLocked()) { currentEngine().setOutputFrameRate(FrameRate::FPS_30); updateOutputFpsButtonStates(); saveSettings(); } };
addAndMakeVisible(timecodeDisplay);
// =====================================================================
// LEFT PANEL -- INPUT SELECTORS
// =====================================================================
auto addLabelAndCombo = [this](juce::Label& lbl, juce::ComboBox& cmb, const juce::String& text)
{
leftContent.addAndMakeVisible(lbl); leftContent.addAndMakeVisible(cmb);
lbl.setText(text, juce::dontSendNotification);
styleLabel(lbl); styleComboBox(cmb);
};
auto addRightLabelAndCombo = [this](juce::Label& lbl, juce::ComboBox& cmb, const juce::String& text)
{
rightContent.addAndMakeVisible(lbl); rightContent.addAndMakeVisible(cmb);
lbl.setText(text, juce::dontSendNotification);
styleLabel(lbl); styleComboBox(cmb);
};
addLabelAndCombo(lblAudioInputTypeFilter, cmbAudioInputTypeFilter, "AUDIO DRIVER:");
cmbAudioInputTypeFilter.onChange = [this]
{
if (syncing) return;
if (isShowLockedRevert()) return;
populateFilteredInputDeviceCombo();
if (currentEngine().getActiveInput() == SrcType::LTC)
startCurrentLtcInput();
saveSettings();
};
addLabelAndCombo(lblSampleRate, cmbSampleRate, "SAMPLE RATE / BUFFER:");
populateSampleRateCombo();
cmbSampleRate.onChange = [this] {
if (syncing || isShowLockedRevert()) return;
cmbSampleRateOut.setSelectedId(cmbSampleRate.getSelectedId(), juce::dontSendNotification);
restartAllAudioDevices(); saveSettings();
};
addLabelAndCombo(lblBufferSize, cmbBufferSize, "BUFFER SIZE:");
populateBufferSizeCombo();
populateOutputAudioCombos();
cmbBufferSize.onChange = [this] {
if (syncing || isShowLockedRevert()) return;
cmbBufferSizeOut.setSelectedId(cmbBufferSize.getSelectedId(), juce::dontSendNotification);
restartAllAudioDevices(); saveSettings();
};
addLabelAndCombo(lblMidiInputDevice, cmbMidiInputDevice, "MIDI INPUT DEVICE:");
// AUDIT D10: how long the signal inputs keep counting as present after the
// last frame or packet. The operator's trade-off: a longer window
// rides through USB stalls and display wakes without the outputs
// noticing; a real stop reaches them that much later.
addLabelAndCombo(lblInputFreewheel, cmbInputFreewheel, "FREEWHEEL:");
cmbInputFreewheel.addItem("150 ms (default)", 150);
cmbInputFreewheel.addItem("250 ms", 250);
cmbInputFreewheel.addItem("500 ms", 500);
cmbInputFreewheel.addItem("1 s", 1000);
cmbInputFreewheel.addItem("2 s", 2000);
cmbInputFreewheel.setSelectedId(150, juce::dontSendNotification);
cmbInputFreewheel.onChange = [this]
{
if (syncing) return;
if (isShowLockedRevert()) return;
currentEngine().setInputFreewheelMs(cmbInputFreewheel.getSelectedId());
saveSettings();
};
cmbMidiInputDevice.onChange = [this]
{
if (syncing) return;
if (isShowLockedRevert()) return;
if (cmbMidiInputDevice.getSelectedId() > 0 && currentEngine().getActiveInput() == SrcType::MTC)
{
const int sel = midiDeviceToStart(cmbMidiInputDevice, midiInputNames, {}, true); // as listed now (AUDIT UI-6)
currentEngine().stopMtcInput();
currentEngine().getMtcInput().refreshDeviceList();
currentEngine().startMtcInput(sel);
populateMidiAndNetworkCombos(); // refresh markers (auto-restores selections)
saveSettings();
}
};
addLabelAndCombo(lblArtnetInputInterface, cmbArtnetInputInterface, "ART-NET INPUT DEVICE:");
cmbArtnetInputInterface.onChange = [this]
{
if (syncing) return;
if (isShowLockedRevert()) return;
if (currentEngine().getActiveInput() == SrcType::ArtNet)
{
int sel = nicIdToStart(cmbArtnetInputInterface, kNicArtnetIn) - 1; // as listed now (AUDIT UI-6)
currentEngine().stopArtnetInput();
currentEngine().startArtnetInput(sel);
// A bind that fell back to All Interfaces shows it before the
// repopulate. Only then: the selector's IDs are positions in the
// list it was filled from, the input's in today's.
const int actual = currentEngine().getArtnetInput().getSelectedInterface();
if (actual != sel)
cmbArtnetInputInterface.setSelectedId(actual + 1, juce::dontSendNotification);
populateMidiAndNetworkCombos(); // refresh markers (auto-restores all selections)
saveSettings();
}
};
addLabelAndCombo(lblLANetTCInputInterface, cmbLANetTCInputInterface, "LA-NET INPUT DEVICE:");
cmbLANetTCInputInterface.onChange = [this]
{
if (syncing) return;
if (isShowLockedRevert()) return;
if (currentEngine().getActiveInput() == SrcType::LANetTC)
{
int sel = nicIdToStart(cmbLANetTCInputInterface, kNicLANetIn) - 1; // as listed now (AUDIT UI-6)
currentEngine().stopLANetTCInput();
currentEngine().startLANetTCInput(sel);
// A fallback to All Interfaces shows (see the Art-Net input).
const int actual = currentEngine().getLANetTCInput().getSelectedInterface();
if (actual != sel)
cmbLANetTCInputInterface.setSelectedId(actual + 1, juce::dontSendNotification);
populateMidiAndNetworkCombos(); // refresh markers (auto-restores all selections)
saveSettings();
}
};
addLabelAndCombo(lblHippoInputInterface, cmbHippoInputInterface, "HIPPONET INPUT DEVICE:");
cmbHippoInputInterface.onChange = [this]
{
if (syncing) return;
if (isShowLockedRevert()) return;
if (currentEngine().getActiveInput() == SrcType::Hippotizer)
{
int sel = nicIdToStart(cmbHippoInputInterface, kNicHippoIn) - 1; // as listed now (AUDIT UI-6)
currentEngine().stopHippotizerInput();
currentEngine().startHippotizerInput(sel);
// A fallback to All Interfaces shows (see the Art-Net input).
const int actual = currentEngine().getHippotizerInput().getSelectedInterface();
if (actual != sel)
cmbHippoInputInterface.setSelectedId(actual + 1, juce::dontSendNotification);
populateMidiAndNetworkCombos();
saveSettings();
}
};
addLabelAndCombo(lblHippoTcChannel, cmbHippoTcChannel, "HIPPONET TC CHANNEL:");
cmbHippoTcChannel.addItem("TC 1", 1);
cmbHippoTcChannel.addItem("TC 2", 2);
cmbHippoTcChannel.setSelectedId(1, juce::dontSendNotification);
cmbHippoTcChannel.onChange = [this]
{
if (syncing) return;
if (isShowLockedRestore([this] {
cmbHippoTcChannel.setSelectedId(currentEngine().getHippotizerInput().getSelectedTcIndex() + 1,
juce::dontSendNotification); }))
return;
int sel = cmbHippoTcChannel.getSelectedId() - 1; // 0-based
currentEngine().getHippotizerInput().setSelectedTcIndex(sel);
saveSettings();
};
// --- Generator controls (play/pause/stop + start/stop TC) ---
{
leftContent.addAndMakeVisible(btnGenClock);
btnGenClock.setVisible(false);
btnGenClock.setColour(juce::ToggleButton::textColourId, juce::Colour(0xFFAAAAAA));
btnGenClock.onClick = [this]
{
if (isShowLocked()) { btnGenClock.setToggleState(!btnGenClock.getToggleState(), juce::dontSendNotification); return; }
auto& eng = currentEngine();
eng.setGeneratorClockMode(btnGenClock.getToggleState());
updateDeviceSelectorVisibility();
resized();
saveSettings();
};
auto genBtnColor = juce::Colour(0xFF444444);
for (auto* btn : { &btnGenPlay, &btnGenPause, &btnGenStop })
{
leftContent.addAndMakeVisible(btn);
btn->setColour(juce::TextButton::buttonColourId, genBtnColor);
btn->setVisible(false);
}
btnGenPlay.onClick = [this] {
auto& eng = currentEngine();
eng.generatorPlay();
};
btnGenPause.onClick = [this] {
auto& eng = currentEngine();
eng.generatorPause();
};
btnGenStop.onClick = [this] {
auto& eng = currentEngine();
eng.generatorStop();
};
auto setupTcEditor = [&](juce::TextEditor& ed, juce::Label& lbl,
const juce::String& labelText)
{
leftContent.addAndMakeVisible(ed);
ed.setFont(juce::Font(juce::FontOptions(11.0f)));
ed.setColour(juce::TextEditor::backgroundColourId, juce::Colour(0xFF222222));
ed.setColour(juce::TextEditor::textColourId, juce::Colours::white);
ed.setJustification(juce::Justification::centred);
ed.setVisible(false);
ed.setText("00:00:00:00", juce::dontSendNotification);
leftContent.addAndMakeVisible(lbl);
styleLabel(lbl, 8.0f);
lbl.setText(labelText, juce::dontSendNotification);
lbl.setVisible(false);
};
setupTcEditor(txtGenStartTC, lblGenStartTC, "START TC:");
setupTcEditor(txtGenStopTC, lblGenStopTC, "STOP TC (0=FREE):");
// Callbacks use member pointers directly (no dangling reference)
// Locked: the field shows the engine's value again rather than the
// one typed and not applied.
auto applyStartTC = [this] {
auto& eng = currentEngine();
if (isShowLockedRestore([&] { txtGenStartTC.setText(msToTimecodeString(eng.getGeneratorStartMs(), eng.getCurrentFps()), false); }))
return;
eng.setGeneratorStartMs(parseTimecodeToMs(txtGenStartTC.getText(), eng.getCurrentFps()));
txtGenStartTC.setText(msToTimecodeString(eng.getGeneratorStartMs(), eng.getCurrentFps()), false);
saveSettings();
};
txtGenStartTC.onReturnKey = applyStartTC;
txtGenStartTC.onFocusLost = applyStartTC;
auto applyStopTC = [this] {
auto& eng = currentEngine();
if (isShowLockedRestore([&] { txtGenStopTC.setText(msToTimecodeString(eng.getGeneratorStopMs(), eng.getCurrentFps()), false); }))
return;
eng.setGeneratorStopMs(parseTimecodeToMs(txtGenStopTC.getText(), eng.getCurrentFps()));
txtGenStopTC.setText(msToTimecodeString(eng.getGeneratorStopMs(), eng.getCurrentFps()), false);
saveSettings();
};
txtGenStopTC.onReturnKey = applyStopTC;
txtGenStopTC.onFocusLost = applyStopTC;
// Preset selector
leftContent.addAndMakeVisible(lblGenPreset);
styleLabel(lblGenPreset, 8.0f);
lblGenPreset.setText("PRESET:", juce::dontSendNotification);
lblGenPreset.setVisible(false);
leftContent.addAndMakeVisible(cmbGenPreset);
cmbGenPreset.setVisible(false);
cmbGenPreset.setTextWhenNothingSelected("(select preset)");
cmbGenPreset.onChange = [this] {
int sel = cmbGenPreset.getSelectedId();
if (sel > 0)
loadGenPresetToFields(cmbGenPreset.getText());
};
leftContent.addAndMakeVisible(btnGenPrev);
btnGenPrev.setVisible(false);
btnGenPrev.setColour(juce::TextButton::buttonColourId, juce::Colour(0xFF444444));
btnGenPrev.onClick = [this] { cycleGenPreset(-1); };
leftContent.addAndMakeVisible(btnGenNext);
btnGenNext.setVisible(false);
btnGenNext.setColour(juce::TextButton::buttonColourId, juce::Colour(0xFF444444));
btnGenNext.onClick = [this] { cycleGenPreset(+1); };
leftContent.addAndMakeVisible(btnGenGo);
btnGenGo.setVisible(false);
btnGenGo.setColour(juce::TextButton::buttonColourId, juce::Colour(0xFF22AA44));
btnGenGo.onClick = [this] {
int sel = cmbGenPreset.getSelectedId();
if (sel > 0)
activateGenPreset(cmbGenPreset.getText());
};
leftContent.addAndMakeVisible(btnGenPresetEdit);
btnGenPresetEdit.setVisible(false);
btnGenPresetEdit.setColour(juce::TextButton::buttonColourId, juce::Colour(0xFF444444));
btnGenPresetEdit.onClick = [this] {
if (isShowLocked()) return;
openGeneratorPresetEditor();
};
// --- Generator audio playback (plays the audio file attached to a preset) ---
leftContent.addAndMakeVisible(btnGenAudioOut);
styleOutputToggle(btnGenAudioOut, juce::Colour(0xFFCC8844));
btnGenAudioOut.setVisible(false);
btnGenAudioOut.onClick = [this]
{
if (isShowLocked()) { btnGenAudioOut.setToggleState(!btnGenAudioOut.getToggleState(), juce::dontSendNotification); return; }
auto& eng = currentEngine();
if (btnGenAudioOut.getToggleState())
startCurrentGenAudio();
else
eng.stopGeneratorAudio();
populateFilteredOutputDeviceCombos(); // refresh in-use markers
updateDeviceSelectorVisibility();
resized();
saveSettings();
};
addLabelAndCombo(lblGenAudioDevice, cmbGenAudioDevice, "AUDIO PLAYBACK DEVICE:");
cmbGenAudioDevice.setVisible(false); lblGenAudioDevice.setVisible(false);
cmbGenAudioDevice.onChange = [this]
{
if (syncing) return;
if (isShowLockedRevert()) return;
if (cmbGenAudioDevice.getSelectedId() > 0
&& cmbGenAudioDevice.getSelectedId() != kPlaceholderItemId
&& btnGenAudioOut.getToggleState())
{
startCurrentGenAudio();
populateFilteredOutputDeviceCombos(); // refresh markers
}
saveSettings();
};
addLabelAndCombo(lblGenAudioChannel, cmbGenAudioChannel, "AUDIO CHANNEL:");
cmbGenAudioChannel.setVisible(false); lblGenAudioChannel.setVisible(false);
cmbGenAudioChannel.onChange = [this]
{
if (syncing) return;
if (isShowLockedRevert()) return;
if (btnGenAudioOut.getToggleState() && cmbGenAudioDevice.getSelectedId() > 0
&& cmbGenAudioDevice.getSelectedId() != kPlaceholderItemId)
{
startCurrentGenAudio();
}
saveSettings();
};
// File channel mode: which channel(s) of the audio FILE to use.
// Independent of the output routing -- handles the common case of
// industry-standard files with audio on L and LTC on R.
addLabelAndCombo(lblGenAudioFileMode, cmbGenAudioFileMode, "FILE CHANNELS:");
cmbGenAudioFileMode.addItem("Stereo (L+R)", 1);
cmbGenAudioFileMode.addItem("Left only", 2);
cmbGenAudioFileMode.addItem("Right only", 3);
cmbGenAudioFileMode.setSelectedId(1, juce::dontSendNotification);
cmbGenAudioFileMode.setVisible(false); lblGenAudioFileMode.setVisible(false);
cmbGenAudioFileMode.onChange = [this]
{
if (syncing) return;
if (isShowLockedRestore([this] {
cmbGenAudioFileMode.setSelectedId(
juce::jlimit(0, 2, currentEngine().getGeneratorAudioFileChannelMode()) + 1,
juce::dontSendNotification); }))
return;
// No need to reopen the device or reload the file -- the player
// reads this flag in the audio callback on every block, so the
// change takes effect immediately.
const int mode = cmbGenAudioFileMode.getSelectedId() - 1; // 0..2
currentEngine().setGeneratorAudioFileChannelMode(mode);
saveSettings();
};
// No sample rate / buffer of its own: the generator's audio follows
// the global SAMPLE RATE / BUFFER SIZE like every other audio
// component (DESIGN D7, DESIGN D23). The interface is one shared
// device with one format, and a per-engine format here could only
// disagree with what was actually running.
// Volume slider: 0..1.5 linear (1=unity, 1.5=+3.5 dB headroom).
leftContent.addAndMakeVisible(lblGenAudioVolume);
styleLabel(lblGenAudioVolume, 9.0f);
lblGenAudioVolume.setText("VOLUME", juce::dontSendNotification);
lblGenAudioVolume.setVisible(false);
leftContent.addAndMakeVisible(sldGenAudioVolume);
sldGenAudioVolume.setSliderStyle(juce::Slider::LinearHorizontal);
sldGenAudioVolume.setRange(0.0, 1.5, 0.0);
sldGenAudioVolume.setValue(1.0, juce::dontSendNotification);
sldGenAudioVolume.setTextBoxStyle(juce::Slider::TextBoxRight, false, 50, 18);
sldGenAudioVolume.setNumDecimalPlacesToDisplay(2);
sldGenAudioVolume.setVisible(false);
// Not locked by Show Lock: a level ridden during the show, like the
// generator transport and preset buttons.
sldGenAudioVolume.onValueChange = [this]
{
if (syncing) return;
currentEngine().setGeneratorAudioVolume((float) sldGenAudioVolume.getValue());
// Mirror the value in the floating waveform window if open.
if (genWaveformWindow != nullptr)
{
if (auto* content = dynamic_cast<GeneratorWaveformWindow*>(genWaveformWindow->getContentComponent()))
content->setVolumeFromOutside((float) sldGenAudioVolume.getValue());
}
};
// Save settings only when the user finishes dragging, not on every
// intermediate value (avoids JSON write storms while sliding).
sldGenAudioVolume.onDragEnd = [this] { saveSettings(); };
leftContent.addAndMakeVisible(lblGenAudioStatus);
styleLabel(lblGenAudioStatus, 8.0f);
lblGenAudioStatus.setVisible(false);
// Mini waveform view (clickable -> opens the floating window).
leftContent.addAndMakeVisible(miniWaveform);
miniWaveform.setMode(GeneratorWaveformView::Mode::Mini);
miniWaveform.setVisible(false);
miniWaveform.onMiniClick = [this] { openGeneratorWaveformWindow(); };
leftContent.addAndMakeVisible(btnGenWaveformOpen);
btnGenWaveformOpen.setColour(juce::TextButton::buttonColourId, juce::Colour(0xFF444444));
btnGenWaveformOpen.setVisible(false);
btnGenWaveformOpen.onClick = [this] { openGeneratorWaveformWindow(); };
}
// --- OSC Input (generator remote control) ---
leftContent.addAndMakeVisible(btnOscIn);
styleOutputToggle(btnOscIn, juce::Colour(0xFF8888CC));
btnOscIn.setVisible(false);
btnOscIn.onClick = [this]
{
if (isShowLocked()) { btnOscIn.setToggleState(!btnOscIn.getToggleState(), juce::dontSendNotification); return; }
if (btnOscIn.getToggleState())
startOscInput();
else
stopOscInput();
updateDeviceSelectorVisibility();
resized();
saveSettings();
};
addLabelAndCombo(lblOscInputInterface, cmbOscInputInterface, "OSC NETWORK DEVICE:");
cmbOscInputInterface.onChange = [this]
{
if (isShowLockedRestore([this] { cmbOscInputInterface.setSelectedId(settings.oscInputInterface + 1, juce::dontSendNotification); }))
return;
settings.oscInputInterface = cmbOscInputInterface.getSelectedId() - 1;
if (btnOscIn.getToggleState())
{
stopOscInput();
startOscInput();
}
saveSettings();
};
leftContent.addAndMakeVisible(lblOscInPort);
styleLabel(lblOscInPort, 8.0f);
lblOscInPort.setText("OSC PORT:", juce::dontSendNotification);
lblOscInPort.setVisible(false);
leftContent.addAndMakeVisible(txtOscInPort);
txtOscInPort.setFont(juce::Font(juce::FontOptions(11.0f)));
txtOscInPort.setColour(juce::TextEditor::backgroundColourId, juce::Colour(0xFF222222));
txtOscInPort.setColour(juce::TextEditor::textColourId, juce::Colours::white);
txtOscInPort.setJustification(juce::Justification::centred);
txtOscInPort.setText("9800", juce::dontSendNotification);
txtOscInPort.setVisible(false);
auto applyOscPort = [this]
{
if (isShowLockedRestore([this] { txtOscInPort.setText(juce::String(settings.oscInputPort), false); }))
return;
int port = juce::jlimit(1, 65535, txtOscInPort.getText().getIntValue());
txtOscInPort.setText(juce::String(port), false);