Skip to content

Commit ec11df5

Browse files
committed
Fix bug in LFP Display sub-processor selection
1 parent 78fb32f commit ec11df5

4 files changed

Lines changed: 57 additions & 46 deletions

File tree

Source/Plugins/LfpDisplayNode/LfpDisplayEditor.cpp

Lines changed: 40 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -120,43 +120,46 @@ void LfpDisplayEditor::updateSubprocessorSelectorOptions()
120120
inputSampleRates.clear();
121121
subprocessorSelection->clear(dontSendNotification);
122122

123-
hasNoInputs = lfpProcessor->getTotalDataChannels() != 0;
124-
125-
for (int i = 0, len = lfpProcessor->getTotalDataChannels(); i < len; ++i)
126-
{
127-
int subProcessorIdx = lfpProcessor->getDataChannel(i)->getSubProcessorIdx();
128-
129-
bool success = inputSubprocessorIndices.add(subProcessorIdx);
130-
131-
if (success) inputSampleRates.set(subProcessorIdx, lfpProcessor->getDataChannel(i)->getSampleRate());
132-
133-
}
134-
135-
for (int i = 0; i < inputSubprocessorIndices.size(); ++i)
136-
{
137-
subprocessorSelection->addItem (String (*(inputSubprocessorIndices.begin() + i)), i + 1);
138-
}
139-
140-
if (defaultSubprocessor >= 0)
141-
{
142-
subprocessorSelection->setSelectedId(defaultSubprocessor + 1, dontSendNotification);
143-
144-
String sampleRateLabelText = "Sample Rate: ";
145-
sampleRateLabelText += String(inputSampleRates[*(inputSubprocessorIndices.begin() + defaultSubprocessor)]);
146-
147-
subprocessorSampleRateLabel->setText(sampleRateLabelText, dontSendNotification);
148-
//setCanvasDrawableSubprocessor(defaultSubprocessor);
149-
}
150-
else
151-
{
152-
subprocessorSelection->addItem ("None", 1);
153-
subprocessorSelection->setSelectedId(1, dontSendNotification);
154-
155-
String sampleRateLabelText = "Sample Rate: <not available>";
156-
subprocessorSampleRateLabel->setText(sampleRateLabelText, dontSendNotification);
157-
//setCanvasDrawableSubprocessor(-1);
158-
159-
}
123+
if (lfpProcessor->getTotalDataChannels() != 0)
124+
125+
{
126+
127+
for (int i = 0, len = lfpProcessor->getTotalDataChannels(); i < len; ++i)
128+
{
129+
int subProcessorIdx = lfpProcessor->getDataChannel(i)->getSubProcessorIdx();
130+
131+
bool success = inputSubprocessorIndices.add(subProcessorIdx);
132+
133+
if (success) inputSampleRates.set(subProcessorIdx, lfpProcessor->getDataChannel(i)->getSampleRate());
134+
135+
}
136+
137+
for (int i = 0; i < inputSubprocessorIndices.size(); ++i)
138+
{
139+
subprocessorSelection->addItem(String(*(inputSubprocessorIndices.begin() + i)), i + 1);
140+
}
141+
142+
if (defaultSubprocessor >= 0)
143+
{
144+
subprocessorSelection->setSelectedId(defaultSubprocessor + 1, dontSendNotification);
145+
146+
String sampleRateLabelText = "Sample Rate: ";
147+
sampleRateLabelText += String(inputSampleRates[*(inputSubprocessorIndices.begin() + defaultSubprocessor)]);
148+
149+
subprocessorSampleRateLabel->setText(sampleRateLabelText, dontSendNotification);
150+
//setCanvasDrawableSubprocessor(defaultSubprocessor);
151+
}
152+
else
153+
{
154+
subprocessorSelection->addItem("None", 1);
155+
subprocessorSelection->setSelectedId(1, dontSendNotification);
156+
157+
String sampleRateLabelText = "Sample Rate: <not available>";
158+
subprocessorSampleRateLabel->setText(sampleRateLabelText, dontSendNotification);
159+
//setCanvasDrawableSubprocessor(-1);
160+
161+
}
162+
}
160163
}
161164

162165
void LfpDisplayEditor::setCanvasDrawableSubprocessor(int index)

Source/Plugins/LfpDisplayNode/LfpDisplayNode.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ LfpDisplayNode::LfpDisplayNode()
4646
}
4747

4848
subprocessorToDraw = 0;
49+
numSubprocessors = -1;
4950
numChannelsInSubprocessor = 0;
5051
updateSubprocessorsFlag = true;
5152
}
@@ -70,10 +71,20 @@ void LfpDisplayNode::updateSettings()
7071
std::cout << "Setting num inputs on LfpDisplayNode to " << getNumInputs() << std::endl;
7172

7273
numChannelsInSubprocessor = 0;
74+
int totalSubprocessors = 0;
75+
int currentSubprocessor = -1;
7376

7477
for (int i = 0; i < getNumInputs(); i++)
7578
{
76-
if (getDataChannel(i)->getSubProcessorIdx() == subprocessorToDraw)
79+
int channelSubprocessor = getDataChannel(i)->getSubProcessorIdx();
80+
81+
if (currentSubprocessor != channelSubprocessor)
82+
{
83+
totalSubprocessors++;
84+
currentSubprocessor = channelSubprocessor;
85+
}
86+
87+
if (channelSubprocessor == subprocessorToDraw)
7788
{
7889
numChannelsInSubprocessor++;
7990
subprocessorSampleRate = getDataChannel(i)->getSampleRate();
@@ -112,16 +123,13 @@ void LfpDisplayNode::updateSettings()
112123
displayBufferIndex.clear();
113124
displayBufferIndex.insertMultiple(0, 0, numChannelsInSubprocessor + numEventChannels);
114125

115-
// update the editor's subprocessor selection display
116-
if (updateSubprocessorsFlag)
126+
// update the editor's subprocessor selection display, only if there's a mismatch in # of subprocessors
127+
if (numSubprocessors != totalSubprocessors)
117128
{
118129
LfpDisplayEditor * ed = (LfpDisplayEditor*)getEditor();
119130
ed->updateSubprocessorSelectorOptions();
131+
numSubprocessors = totalSubprocessors;
120132
}
121-
else {
122-
updateSubprocessorsFlag = true;
123-
}
124-
125133
}
126134

127135
uint32 LfpDisplayNode::getChannelSourceID(const EventChannel* event) const

Source/Plugins/LfpDisplayNode/LfpDisplayNode.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,7 @@ class LfpDisplayNode : public GenericProcessor
9898

9999
int subprocessorToDraw;
100100
int numChannelsInSubprocessor;
101+
int numSubprocessors;
101102
float subprocessorSampleRate;
102103

103104
CriticalSection displayMutex;

Source/UI/EditorViewport.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1584,7 +1584,7 @@ const String EditorViewport::loadState(File fileToLoad)
15841584
{
15851585
procDesc.set(2, 4); //DataThread
15861586
procDesc.set(3, 1); //index
1587-
procDesc.set(4, "Rhytm FPGA"); //libraryName
1587+
procDesc.set(4, "Rhythm FPGA"); //libraryName
15881588
}
15891589
else
15901590
procDesc.set(3, int(procDesc[3]) - 1); //arrange old nodes to its current index
@@ -1685,7 +1685,6 @@ const String EditorViewport::loadState(File fileToLoad)
16851685

16861686
AccessClass::getProcessorGraph()->restoreParameters();
16871687

1688-
16891688
String error = "Opened ";
16901689
error += currentFile.getFileName();
16911690

0 commit comments

Comments
 (0)