Ejemplo n.º 1
0
        /// <summary>
        /// Creates the score.
        /// </summary>
        /// <param name="gpScore">The gp score.</param>
        /// <returns>
        /// TabLib.Score.
        /// </returns>
        private static TabLib.Score CreateScore(alphatab.model.Score gpScore)
        {
            var score = new TabLib.Score();

            score.Album      = gpScore.album;
            score.Artist     = gpScore.artist;
            score.Title      = gpScore.title;
            score.Tempo      = gpScore.tempo;
            score.MasterBars = CreateMasterBars(gpScore);
            score.Tracks     = CreateTracks(gpScore, score.MasterBars);

            return(score);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates the tracks.
        /// </summary>
        /// <param name="gpScore">The gp score.</param>
        /// <param name="masterBars">The master bars.</param>
        /// <returns></returns>
        private static TabLib.Track[] CreateTracks(alphatab.model.Score gpScore, TabLib.MasterBar[] masterBars)
        {
            var tracks = new TabLib.Track[gpScore.tracks.length];

            for (var i = 0; i < gpScore.tracks.length; i++)
            {
                var gpTrack = gpScore.tracks[i] as alphatab.model.Track;
                if (gpTrack != null)
                {
                    var track = new TabLib.Track();

                    track.Index = gpTrack.index;
                    track.Name  = gpTrack.name;
                    track.Bars  = CreateBars(gpTrack, masterBars);

                    tracks[i] = track;
                }
            }

            return(tracks);
        }
Ejemplo n.º 3
0
        /// <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);
        }