/// <summary> /// Creates the beats. /// </summary> /// <param name="gpVoice">The gp voice.</param> /// <param name="masterBar">The master bar.</param> /// <returns></returns> private static TabLib.Beat[] CreateBeats(alphatab.model.Bar gpBar, TabLib.MasterBar masterBar) { var gpVoice = gpBar.voices[0] as alphatab.model.Voice; var beats = new TabLib.Beat[gpVoice.beats.length]; for (var i = 0; i < gpVoice.beats.length; i++) { var gpBeat = gpVoice.beats[i] as alphatab.model.Beat; if (gpBeat != null && !gpBeat.isEmpty) { var beat = new TabLib.Beat(); beat.Index = gpBeat.index; beat.Duration = GetDuration(gpBeat.duration); beat.Notes = CreateNotes(gpBeat); beat.Text = gpBeat.text; beat.Dots = gpBeat.dots; beat.TupletDenominator = gpBeat.tupletDenominator; beat.TupletNumerator = gpBeat.tupletNumerator; beat.CalculateDuration(masterBar.Tempo); beats[i] = beat; } } return(beats); }
/// <summary> /// Creates the master bars. /// </summary> /// <param name="gpScore">The gp score.</param> /// <returns></returns> private static TabLib.MasterBar[] CreateMasterBars(alphatab.model.Score gpScore) { var masterBars = new TabLib.MasterBar[gpScore.masterBars.length]; for (var i = 0; i < gpScore.masterBars.length; i++) { var gpMasterBar = gpScore.masterBars[i] as alphatab.model.MasterBar; if (gpMasterBar != null) { var masterBar = new TabLib.MasterBar(); masterBar.Index = i; // Get the master bar informations if (gpMasterBar.tempoAutomation != null && gpMasterBar.tempoAutomation.type == alphatab.model.AutomationType.Tempo) { masterBar.Tempo = (int)gpMasterBar.tempoAutomation.value; } else if (masterBar.Index == 0) { // Take the score tempo masterBar.Tempo = gpMasterBar.score.tempo; } else { // Take the previous tempo masterBar.Tempo = (int)masterBars[masterBar.Index - 1].Tempo; } masterBar.TimeSignatureNumerator = gpMasterBar.timeSignatureNumerator; masterBar.TimeSignatureDenominator = gpMasterBar.timeSignatureDenominator; masterBars[i] = masterBar; } } return(masterBars); }
/// <summary> /// Creates the master bars. /// </summary> /// <param name="gpScore">The gp score.</param> /// <returns></returns> private static TabLib.MasterBar[] CreateMasterBars(alphatab.model.Score gpScore) { var masterBars = new TabLib.MasterBar[gpScore.masterBars.length]; for (var i = 0; i < gpScore.masterBars.length; i++) { var gpMasterBar = gpScore.masterBars[i] as alphatab.model.MasterBar; if (gpMasterBar != null) { var masterBar = new TabLib.MasterBar(); masterBar.Index = i; // Get the master bar informations if (gpMasterBar.tempoAutomation != null && gpMasterBar.tempoAutomation.type == alphatab.model.AutomationType.Tempo) { masterBar.Tempo = (int)gpMasterBar.tempoAutomation.value; } else if (masterBar.Index == 0) { // Take the score tempo masterBar.Tempo = gpMasterBar.score.tempo; } else { // Take the previous tempo masterBar.Tempo = (int)masterBars[masterBar.Index - 1].Tempo; } masterBar.TimeSignatureNumerator = gpMasterBar.timeSignatureNumerator; masterBar.TimeSignatureDenominator = gpMasterBar.timeSignatureDenominator; masterBars[i] = masterBar; } } return masterBars; }