public void ReadMixTableChange(Beat beat)
{
var tableChange = new MixTableChange();
tableChange.Instrument = Data.ReadByte();
if (_versionNumber >= 500)
{
Data.Skip(16); // Rse Info
}
tableChange.Volume = Data.ReadSignedByte();
tableChange.Balance = Data.ReadSignedByte();
var chorus = Data.ReadSignedByte();
var reverb = Data.ReadSignedByte();
var phaser = Data.ReadSignedByte();
var tremolo = Data.ReadSignedByte();
if (_versionNumber >= 500)
{
tableChange.TempoName = ReadStringIntByte();
}
tableChange.Tempo = ReadInt32();
// durations
if (tableChange.Volume >= 0)
{
Data.ReadByte();
}
if (tableChange.Balance >= 0)
{
Data.ReadByte();
}
if (chorus >= 0)
{
Data.ReadByte();
}
if (reverb >= 0)
{
Data.ReadByte();
}
if (phaser >= 0)
{
Data.ReadByte();
}
if (tremolo >= 0)
{
Data.ReadByte();
}
if (tableChange.Tempo >= 0)
{
tableChange.Duration = Data.ReadSignedByte();
if (_versionNumber >= 510)
{
Data.ReadByte(); // hideTempo (bool)
}
}
if (_versionNumber >= 400)
{
Data.ReadByte(); // all tracks flag
}
// unknown
if (_versionNumber >= 500)
{
Data.ReadByte();
}
// unknown
if (_versionNumber >= 510)
{
ReadStringIntByte();
ReadStringIntByte();
}
if (tableChange.Volume >= 0)
{
var volumeAutomation = new Automation();
volumeAutomation.IsLinear = true;
volumeAutomation.Type = AutomationType.Volume;
volumeAutomation.Value = tableChange.Volume;
beat.Automations.Add(volumeAutomation);
}
if (tableChange.Balance >= 0)
{
var balanceAutomation = new Automation();
balanceAutomation.IsLinear = true;
balanceAutomation.Type = AutomationType.Balance;
balanceAutomation.Value = tableChange.Balance;
beat.Automations.Add(balanceAutomation);
}
if (tableChange.Instrument >= 0)
{
var instrumentAutomation = new Automation();
instrumentAutomation.IsLinear = true;
instrumentAutomation.Type = AutomationType.Instrument;
instrumentAutomation.Value = tableChange.Instrument;
beat.Automations.Add(instrumentAutomation);
}
if (tableChange.Tempo >= 0)
{
var tempoAutomation = new Automation();
tempoAutomation.IsLinear = true;
tempoAutomation.Type = AutomationType.Tempo;
tempoAutomation.Value = tableChange.Tempo;
beat.Automations.Add(tempoAutomation);
beat.Voice.Bar.MasterBar.TempoAutomation = tempoAutomation;
}
}