Skip to content

Commit 365eadf

Browse files
committed
Merge branch 'rec-node-default-dir' into development-juce8
2 parents c627ae2 + 32651db commit 365eadf

20 files changed

Lines changed: 748 additions & 144 deletions

Source/Processors/Editors/SyncLineSelector.cpp

Lines changed: 48 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,26 +73,23 @@ SetPrimaryButton::~SetPrimaryButton() {}
7373

7474
void SetPrimaryButton::paintButton (Graphics& g, bool isMouseOver, bool isButtonDown)
7575
{
76+
Colour backgroundColour = findColour (ThemeColours::widgetBackground);
77+
78+
if (getToggleState())
79+
backgroundColour = findColour (ThemeColours::highlightedFill);
80+
7681
if (isMouseOver)
77-
{
78-
if (getToggleState())
79-
g.setColour (findColour (ThemeColours::highlightedFill).withAlpha (0.5f));
80-
else
81-
g.setColour (findColour (ThemeColours::widgetBackground).contrasting (0.3f));
82-
}
83-
else
84-
{
85-
if (getToggleState())
86-
g.setColour (findColour (ThemeColours::highlightedFill));
87-
else
88-
g.setColour (findColour (ThemeColours::widgetBackground));
89-
}
82+
backgroundColour = backgroundColour.contrasting (0.1f);
83+
84+
backgroundColour.withAlpha (isEnabled() ? 1.0f : 0.5f);
85+
86+
g.setColour (backgroundColour);
9087
g.fillRoundedRectangle (1.0f, 1.0f, (float) getWidth() - 2.0f, (float) getHeight() - 2.0f, 2.0f);
9188

92-
g.setColour (findColour (ThemeColours::outline));
89+
g.setColour (findColour (ThemeColours::outline).withAlpha (isEnabled() ? 1.0f : 0.5f));
9390
g.drawRoundedRectangle (0.0f, 0.0f, (float) getWidth(), (float) getHeight(), 2.0f, 1.0f);
9491

95-
g.setColour (findColour (ThemeColours::defaultText));
92+
g.setColour (findColour (ThemeColours::defaultText).withAlpha (isEnabled() ? 1.0f : 0.5f));
9693
g.setFont (FontOptions ("Inter", "Regular", 12.0f));
9794
g.drawText (String (getName()), 0, 0, getWidth(), getHeight(), Justification::centred);
9895
}
@@ -145,6 +142,9 @@ SyncLineSelector::SyncLineSelector (Component* parent, SyncLineSelector::Listene
145142
setPrimaryStreamButton->setBounds (0, height, 0.5 * width, width / nColumns);
146143
setPrimaryStreamButton->addListener (this);
147144
addChildAndSetID (setPrimaryStreamButton, "SETPRIMARY");
145+
146+
if (canSelectNone && selectedLine == -1)
147+
setPrimaryStreamButton->setEnabled (false);
148148
}
149149
else
150150
{
@@ -191,15 +191,21 @@ void SyncLineSelector::buttonClicked (Button* button)
191191
if (canSelectNone && sameButton)
192192
{
193193
selectedLine = -1;
194+
195+
if (! isPrimary)
196+
setPrimaryStreamButton->setEnabled (false);
194197
}
195198
else
196199
{
197200
button->setToggleState (true, dontSendNotification);
198201
selectedLine = std::stoi (button->getComponentID().toStdString());
202+
203+
if (! isPrimary)
204+
setPrimaryStreamButton->setEnabled (true);
199205
}
200206

201207
listener->selectedLineChanged (selectedLine);
202-
repaint();
208+
updatePopup();
203209
}
204210

205211
detectedChange = true;
@@ -215,4 +221,30 @@ void SyncLineSelector::updatePopup()
215221
else
216222
buttons[i]->setToggleState (false, NotificationType::dontSendNotification);
217223
}
224+
225+
if (listener->isPrimaryStream() && setPrimaryStreamButton != nullptr)
226+
{
227+
setPrimaryStreamButton->setVisible (false);
228+
isPrimary = true;
229+
setSize (width, buttonSize * nRows);
230+
height = buttonSize * (nRows);
231+
}
232+
else if (! listener->isPrimaryStream())
233+
{
234+
height = buttonSize * (nRows);
235+
if (setPrimaryStreamButton == nullptr)
236+
{
237+
setPrimaryStreamButton = new SetPrimaryButton ("Set as main clock");
238+
setPrimaryStreamButton->setBounds (0, height, 0.5 * width, buttonSize);
239+
setPrimaryStreamButton->addListener (this);
240+
addChildAndSetID (setPrimaryStreamButton, "SETPRIMARY");
241+
}
242+
243+
setPrimaryStreamButton->setVisible (true);
244+
setSize (width, height + buttonSize);
245+
isPrimary = false;
246+
247+
if (canSelectNone && selectedLine == -1)
248+
setPrimaryStreamButton->setEnabled (false);
249+
}
218250
}

Source/Processors/Editors/SyncLineSelector.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,9 @@ class PLUGIN_API SyncLineSelector : public PopupComponent,
8888

8989
// Called when the user sets the primary stream for synchronization
9090
virtual void primaryStreamChanged() = 0;
91+
92+
// Called when the updating to popup to reflect changes
93+
virtual bool isPrimaryStream() = 0;
9194
};
9295

9396
/** Constructor */

Source/Processors/EventTranslator/EventTranslator.cpp

Lines changed: 82 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ void EventTranslator::registerParameters()
6060
"Use this stream as main sync",
6161
{},
6262
0,
63+
false,
6364
true);
6465

6566
// Sync line selection parameter
@@ -90,7 +91,9 @@ void EventTranslator::updateSettings()
9091
{
9192
const uint16 streamId = stream->getStreamId();
9293

93-
synchronizer.addDataStream (stream->getKey(), stream->getSampleRate());
94+
TtlLineParameter* syncLineParam = static_cast<TtlLineParameter*> (stream->getParameter ("sync_line"));
95+
int syncLine = syncLineParam->getSelectedLine();
96+
synchronizer.addDataStream (stream->getKey(), stream->getSampleRate(), syncLine, stream->generatesTimestamps());
9497

9598
EventChannel::Settings s {
9699
EventChannel::Type::TTL,
@@ -107,24 +110,92 @@ void EventTranslator::updateSettings()
107110
}
108111

109112
synchronizer.finishedUpdate();
113+
114+
// Set the main sync stream from the synchronizer
115+
auto param = getParameter ("main_sync");
116+
Array<String> streamNames = ((SelectedStreamParameter*) param)->getStreamNames();
117+
String mainStreamKey = synchronizer.mainStreamKey;
118+
if (mainStreamKey.isEmpty())
119+
{
120+
param->setNextValue (-1, false); // no main stream selected
121+
}
122+
else
123+
{
124+
int mainStreamIndex = -1;
125+
for (int i = 0; i < streamNames.size(); i++)
126+
{
127+
if (streamNames[i] == mainStreamKey)
128+
{
129+
mainStreamIndex = i;
130+
break;
131+
}
132+
}
133+
param->setNextValue (mainStreamIndex, false); // set main stream index
134+
}
110135
}
111136

112137
void EventTranslator::parameterValueChanged (Parameter* p)
113138
{
114139
if (p->getName() == "sync_line")
115140
{
116-
synchronizer.setSyncLine (getDataStream (p->getStreamId())->getKey(), ((TtlLineParameter*) p)->getSelectedLine());
141+
int selectedLine = ((TtlLineParameter*) p)->getSelectedLine();
142+
const String streamKey = getDataStream (p->getStreamId())->getKey();
143+
144+
synchronizer.setSyncLine (streamKey, selectedLine);
145+
146+
// If sync line is set to none and this is the main stream, we need to find another main stream
147+
if (selectedLine == -1 && synchronizer.mainStreamKey == streamKey)
148+
{
149+
int streamIndex = 0;
150+
for (auto stream : dataStreams)
151+
{
152+
if (stream->getStreamId() != p->getStreamId()
153+
&& ! synchronizer.streamGeneratesTimestamps (stream->getKey()))
154+
{
155+
getParameter ("main_sync")->setNextValue (streamIndex, false);
156+
return;
157+
}
158+
streamIndex++;
159+
}
160+
161+
getParameter ("main_sync")->setNextValue (-1, false);
162+
}
163+
else if (selectedLine >= 0 && synchronizer.mainStreamKey.isEmpty())
164+
{
165+
// If the sync line is set, but no main stream is set, we need to set the main stream to the one with the sync line
166+
int streamIndex = 0;
167+
for (auto stream : dataStreams)
168+
{
169+
if (stream->getKey() == streamKey)
170+
{
171+
getParameter ("main_sync")->setNextValue (streamIndex, false);
172+
return;
173+
}
174+
streamIndex++;
175+
}
176+
}
117177
}
118178
else if (p->getName() == "main_sync")
119179
{
120-
Array<String> streamNames = ((SelectedStreamParameter*) p)->getStreamNames();
121-
for (auto stream : dataStreams)
180+
int streamIndex = ((SelectedStreamParameter*) p)->getSelectedIndex();
181+
182+
if (streamIndex == -1)
122183
{
123-
String key = stream->getKey();
124-
if (key == streamNames[((SelectedStreamParameter*) p)->getSelectedIndex()])
184+
synchronizer.setMainDataStream ("");
185+
return;
186+
}
187+
else
188+
{
189+
Array<String> streamNames = ((SelectedStreamParameter*) p)->getStreamNames();
190+
for (auto stream : dataStreams)
125191
{
126-
synchronizer.setMainDataStream (stream->getKey());
127-
break;
192+
String key = stream->getKey();
193+
if (key == streamNames[streamIndex]
194+
&& ! synchronizer.streamGeneratesTimestamps (key))
195+
{
196+
synchronizer.setMainDataStream (stream->getKey());
197+
break;
198+
}
128199
}
129200
}
130201
}
@@ -184,14 +255,14 @@ void EventTranslator::handleTTLEvent (TTLEventPtr event)
184255
if (streamKey == eventStreamKey)
185256
continue; // don't translate events back to the main stream
186257

187-
if (synchronizer.isStreamSynced (streamKey))
258+
if (synchronizer.isStreamSynced (streamKey) && ! synchronizer.streamGeneratesTimestamps (streamKey))
188259
{
189-
// std::cout << "original sample number: " << sampleNumber << std::endl;
260+
// std::cout << "original sample number: " << sampleNumber << std::endl;
190261
//std::cout << "original timestamp: " << timestamp << std::endl;
191262

192263
int64 newSampleNumber = synchronizer.convertTimestampToSampleNumber (streamKey, timestamp);
193264

194-
// std::cout << "new sample number (" << streamId << "): " << newSampleNumber << std::endl;
265+
// std::cout << "new sample number (" << streamId << "): " << newSampleNumber << std::endl;
195266

196267
int64 firstSampleNumberForBlock = getFirstSampleNumberForBlock (streamId);
197268

Source/Processors/FileReader/FileReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ void FileReader::initialize (bool signalChainIsLoading)
211211

212212
bool FileReader::setFile (String fullpath, bool shouldUpdateSignalChain)
213213
{
214-
if (fullpath.equalsIgnoreCase ("default"))
214+
if (fullpath.equalsIgnoreCase ("default") || fullpath.equalsIgnoreCase ("None"))
215215
{
216216
File executable = File::getSpecialLocation (File::currentApplicationFile);
217217

Source/Processors/GenericProcessor/GenericProcessor.cpp

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -644,6 +644,7 @@ void GenericProcessor::clearSettings()
644644
configurationObjects.addArray (configurationObjectsToKeep);
645645

646646
Array<DataStream*> dataStreamsToDelete;
647+
savedDataStreamParameters.clear();
647648

648649
for (auto obj : dataStreams)
649650
{
@@ -1059,7 +1060,26 @@ void GenericProcessor::update()
10591060
else if (param->getType() == Parameter::TTL_LINE_PARAM)
10601061
{
10611062
TtlLineParameter* p = (TtlLineParameter*) param;
1062-
stream->addParameter (new TtlLineParameter (*p));
1063+
1064+
// If the stream is hardware synchronized, default the sync line to None
1065+
if (p->syncModeEnabled() && stream->generatesTimestamps())
1066+
{
1067+
TtlLineParameter* p2 = new TtlLineParameter (nullptr,
1068+
p->getScope(),
1069+
p->getName(),
1070+
p->getDisplayName(),
1071+
p->getDescription(),
1072+
p->getMaxAvailableLines(),
1073+
true,
1074+
true,
1075+
p->shouldDeactivateDuringAcquisition());
1076+
p2->currentValue = -1;
1077+
stream->addParameter (p2);
1078+
}
1079+
else
1080+
{
1081+
stream->addParameter (new TtlLineParameter (*p));
1082+
}
10631083
}
10641084
}
10651085
}
@@ -1128,8 +1148,8 @@ void GenericProcessor::update()
11281148

11291149
if (! isMerger() && ! isSource())
11301150
updateSettings(); // allow processors to change custom settings,
1131-
// including creation of streams / channels and
1132-
// setting isEnabled variable
1151+
// including creation of streams / channels and
1152+
// setting isEnabled variable
11331153

11341154
LOGG (" Updated custom settings in ", MS_FROM_START, " milliseconds");
11351155

0 commit comments

Comments
 (0)