private void ParseAutomation(IXmlNode node)
{
string type = null;
bool isLinear = false;
string barId = null;
float ratioPosition = 0;
float value = 0;
int reference = 0;
string text = null;
node.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
switch (c.LocalName)
{
case "Type":
type = GetValue(c);
break;
case "Linear":
isLinear = GetValue(c).ToLower() == "true";
break;
case "Bar":
barId = GetValue(c);
break;
case "Position":
ratioPosition = Std.ParseFloat(GetValue(c));
break;
case "Value":
var parts = GetValue(c).Split(' ');
value = Std.ParseFloat(parts[0]);
reference = Std.ParseInt(parts[1]);
break;
case "Text":
text = GetValue(c);
break;
}
}
});
if (type == null) return;
Automation automation = null;
switch (type)
{
case "Tempo":
automation = Automation.BuildTempoAutomation(isLinear, ratioPosition, value, reference);
break;
// TODO: other automations
}
if (automation != null)
{
automation.Text = text;
}
if (barId != null)
{
if (!_automations.ContainsKey(barId))
{
_automations[barId] = new FastList<Automation>();
}
_automations[barId].Add(automation);
}
}