Skip to content

Commit 38c80ac

Browse files
committed
Fix SelectedChannelsParameter initialization and channel count handling
1 parent 4665748 commit 38c80ac

1 file changed

Lines changed: 24 additions & 20 deletions

File tree

Source/Processors/Parameter/Parameter.cpp

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -698,19 +698,6 @@ SelectedChannelsParameter::SelectedChannelsParameter (ParameterOwner* owner,
698698
maxSelectableChannels (maxSelectableChannels_),
699699
channelCount (0)
700700
{
701-
if (defaultValue_.size() == 0 && maxSelectableChannels != std::numeric_limits<int>::max())
702-
{
703-
//Set default selected to the first maxSelectableChannels channels
704-
Array<var> values;
705-
for (int i = 0; i < maxSelectableChannels; i++)
706-
values.add (i);
707-
708-
currentValue = values;
709-
}
710-
else
711-
{
712-
currentValue = defaultValue_;
713-
}
714701
}
715702

716703
void SelectedChannelsParameter::setNextValue (var newValue_, bool undoable)
@@ -865,18 +852,35 @@ Array<var> SelectedChannelsParameter::parseSelectedString (const String& input)
865852

866853
void SelectedChannelsParameter::setChannelCount (int newCount)
867854
{
868-
if (newCount > 0 && channelCount > newCount)
855+
if (newCount > 0)
869856
{
870857
Array<var> values;
871-
for (int i = 0; i < currentValue.getArray()->size(); i++)
858+
859+
// If the new count is less than the current count, remove any channels that are out of bounds
860+
if (channelCount > newCount)
872861
{
873-
if ((int) currentValue[i] < newCount)
862+
for (int i = 0; i < currentValue.getArray()->size(); i++)
874863
{
875-
values.add (currentValue[i]);
864+
if ((int) currentValue[i] < newCount)
865+
{
866+
values.add (currentValue[i]);
867+
}
876868
}
869+
870+
currentValue = values;
877871
}
872+
else if (channelCount == 0) // If the current count is 0, set the selected channels to the first maxSelectableChannels channels
873+
{
874+
for (int i = 0; i < maxSelectableChannels; i++)
875+
{
876+
if (i < newCount)
877+
{
878+
values.add (i);
879+
}
880+
}
878881

879-
currentValue = values;
882+
currentValue = values;
883+
}
880884
}
881885

882886
channelCount = newCount;
@@ -1218,7 +1222,7 @@ void PathParameter::setNextValue (var newValue_, bool undoable)
12181222
{
12191223
newValue = newValue_;
12201224
}
1221-
1225+
12221226
if (! undoable)
12231227
{
12241228
getOwner()->parameterChangeRequest (this);
@@ -1228,7 +1232,7 @@ void PathParameter::setNextValue (var newValue_, bool undoable)
12281232
{
12291233
getOwner()->handleLinkedParameterChange (this, newValue);
12301234
}
1231-
else
1235+
else
12321236
{
12331237
ChangeValue* action = new Parameter::ChangeValue (getKey(), newValue);
12341238

0 commit comments

Comments
 (0)