Skip to content

Commit

Permalink
Code quality improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed Jul 2, 2024
1 parent 8afdf95 commit 5819a28
Showing 1 changed file with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,15 +70,14 @@ public ConvolutionBoxFormatConfigurationFile(string path) : base(Path.GetFileNam
}
stream.Position = 8; // Sample rate is read in the constructor
int entries = stream.ReadInt32();
List<(string name, FilterGraphNode root)> inputChannels = new List<(string, FilterGraphNode)>();
List<(int index, FilterGraphNode root)> inputChannels = new List<(int, FilterGraphNode)>();
Dictionary<int, FilterGraphNode> lastNodes = new Dictionary<int, FilterGraphNode>();
FilterGraphNode GetChannel(int index) { // Get an actual channel's last node
if (lastNodes.ContainsKey(index)) {
return lastNodes[index];
}
string name = "CH" + (index + 1);
FilterGraphNode newChannel = new FilterGraphNode(new InputChannel(name));
inputChannels.Add((name, newChannel));
FilterGraphNode newChannel = new FilterGraphNode(new InputChannel("CH" + (index + 1)));
inputChannels.Add((index, newChannel));
return newChannel;
}

Expand Down Expand Up @@ -118,7 +117,7 @@ FilterGraphNode GetChannel(int index) { // Get an actual channel's last node
}
}

inputChannels.Sort((a, b) => a.name.CompareTo(b.name));
inputChannels.Sort((a, b) => a.index.CompareTo(b.index));
foreach (KeyValuePair<int, FilterGraphNode> node in lastNodes) {
if (node.Key >= 0) {
// TODO: many points make input or output channels from channels, create them from names instead
Expand All @@ -130,7 +129,7 @@ FilterGraphNode GetChannel(int index) { // Get an actual channel's last node
}
}
}
return inputChannels.ToArray();
return inputChannels.Select(x => (((InputChannel)x.root.Filter).Name, x.root)).ToArray();
}

/// <inheritdoc/>
Expand Down

0 comments on commit 5819a28

Please sign in to comment.