Skip to content

Commit

Permalink
Optional extra parameters to spatial remapping XML generation
Browse files Browse the repository at this point in the history
  • Loading branch information
VoidXH committed Nov 29, 2023
1 parent 14377a1 commit e45707b
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion Cavern/Channels/SpatialRemapping.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,23 @@ public static string ToEqualizerAPO(float[][] matrix) {
/// <summary>
/// Convert a spatial remapping matrix to an XML file.
/// </summary>
public static string ToXML(float[][] matrix) {
/// <param name="matrix">A mixing matrix created with one of the <see cref="GetMatrix(Channel[])"/> functions</param>
/// <param name="extraParams">Optional argument keys and their values for all output channels - if the number of the
/// values is less than the number of channels, the last channels without values will skip that attribute</param>
public static string ToXML(float[][] matrix, params (string key, string[] values)[] extraParams) {
StringBuilder result = new StringBuilder();
using XmlWriter writer = XmlWriter.Create(result);
writer.WriteStartElement("matrix");
for (int output = 0; output < matrix.Length; output++) {
float[] inputs = matrix[output];
writer.WriteStartElement("output");
writer.WriteAttributeString("channel", output.ToString());
for (int extra = 0; extra < extraParams.Length; extra++) {
(string key, string[] values) = extraParams[extra];
if (output < values.Length) {
writer.WriteAttributeString(key, values[output].ToString());
}
}
for (int input = 0; input < inputs.Length; input++) {
if (inputs[input] != 0) {
writer.WriteStartElement("input");
Expand Down

0 comments on commit e45707b

Please sign in to comment.