Skip to content

Commit 1075b3f

Browse files
committed
Update selected channels parameter value when channel count changes
1 parent b4138b4 commit 1075b3f

1 file changed

Lines changed: 31 additions & 3 deletions

File tree

Source/Processors/Parameter/Parameter.cpp

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -361,10 +361,24 @@ SelectedChannelsParameter::SelectedChannelsParameter(GenericProcessor* processor
361361
void SelectedChannelsParameter::setNextValue(var newValue_)
362362
{
363363

364-
if (newValue_.getArray()->size() <= maxSelectableChannels)
364+
if (newValue_ == currentValue)
365+
return;
366+
367+
int arraySize = newValue_.getArray()->size();
368+
if (arraySize <= maxSelectableChannels && arraySize <= channelCount)
365369
{
370+
for (int i = 0; i < arraySize; i++)
371+
{
372+
if ((int) newValue_[i] < 0 || (int) newValue_[i] >= channelCount)
373+
return;
374+
}
375+
366376
newValue = newValue_;
367377
}
378+
else
379+
{
380+
return;
381+
}
368382

369383
processor->parameterChangeRequest(this);
370384
}
@@ -446,9 +460,23 @@ Array<var> SelectedChannelsParameter::parseSelectedString(const String& input)
446460
return selectedChannels;
447461
}
448462

449-
void SelectedChannelsParameter::setChannelCount(int count)
463+
void SelectedChannelsParameter::setChannelCount(int newCount)
450464
{
451-
channelCount = count;
465+
if (channelCount > newCount && getScope() != ParameterScope::SPIKE_CHANNEL_SCOPE)
466+
{
467+
Array<var> values;
468+
for (int i = 0; i < currentValue.getArray()->size(); i++)
469+
{
470+
if ((int) currentValue[i] < newCount)
471+
{
472+
values.add (currentValue[i]);
473+
}
474+
}
475+
476+
currentValue = values;
477+
}
478+
479+
channelCount = newCount;
452480

453481
// std::cout << "Setting selected channels channels count to " << count << " at " << this << std::endl;
454482
}

0 commit comments

Comments
 (0)