/// <summary>
        /// create SongInfo List from PSARC file 
        /// with option to output to *.txt file
        /// </summary>
        /// <param name="inputFilePath"></param>
        /// <param name="outputDir is optional"></param>
        /// <returns>SongInfo List</returns>
        public IList<SongInfo> PsarcSongList(string inputFilePath, string outputDir = null)
        {
            var browser = new PsarcBrowser(inputFilePath);
            var songList = browser.GetSongList();

            if (outputDir != null)
            {
                var songInfo = String.Format("ARCHIVE  -  {0}  -  SONG LIST INFO", Path.GetFileName(inputFilePath));
                songInfo += Environment.NewLine + Environment.NewLine;
                songInfo += "[Song Identifier]  Artist - Title  (Album, Year)  {Arrangements}";
                songInfo += Environment.NewLine;
                songInfo += "----------------------------------------------------------------";
                songInfo += Environment.NewLine + Environment.NewLine;

                foreach (var song in songList)
                {
                    songInfo += String.Format("[{0}]  {1} - {2}  ({3}, {4})  {{{5}}}", song.Identifier,
                                              song.Artist, song.Title, song.Album, song.Year,
                                              string.Join(", ", song.Arrangements));
                    songInfo += Environment.NewLine;
                }
                songInfo += Environment.NewLine + Environment.NewLine;
                songInfo += "End of Report";

                var outputFile = Path.GetFileNameWithoutExtension(inputFilePath).ToLower();
                var outputPath = Path.Combine(outputDir, String.Format("{0}_songlist.txt", outputFile));

                using (TextWriter tw = new StreamWriter(outputPath))
                {
                    tw.Write(songInfo);
                }
            }

            return songList;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// create SongInfo List from PSARC file
        /// with option to output to *.txt file
        /// </summary>
        /// <param name="inputFilePath"></param>
        /// <param name="outputDir is optional"></param>
        /// <returns>SongInfo List</returns>
        public IList <SongInfo> PsarcSongList(string inputFilePath, string outputDir = null)
        {
            var browser  = new PsarcBrowser(inputFilePath);
            var songList = browser.GetSongList();

            if (outputDir != null)
            {
                var songInfo = String.Format("ARCHIVE  -  {0}  -  SONG LIST INFO", Path.GetFileName(inputFilePath));
                songInfo += Environment.NewLine + Environment.NewLine;
                songInfo += "[Song Identifier]  Artist - Title  (Album, Year)  {Arrangements}";
                songInfo += Environment.NewLine;
                songInfo += "----------------------------------------------------------------";
                songInfo += Environment.NewLine + Environment.NewLine;

                foreach (var song in songList)
                {
                    songInfo += String.Format("[{0}]  {1} - {2}  ({3}, {4})  {{{5}}}", song.Identifier,
                                              song.Artist, song.Title, song.Album, song.Year,
                                              string.Join(", ", song.Arrangements));
                    songInfo += Environment.NewLine;
                }
                songInfo += Environment.NewLine + Environment.NewLine;
                songInfo += "End of Report";

                var outputFile = Path.GetFileNameWithoutExtension(inputFilePath).ToLower();
                var outputPath = Path.Combine(outputDir, String.Format("{0}_songlist.txt", outputFile));

                using (TextWriter tw = new StreamWriter(outputPath))
                {
                    tw.Write(songInfo);
                }
            }

            return(songList);
        }
Ejemplo n.º 3
0
        private IEnumerable <ExistingDlcItem> GetExistingItemsFromPsArcFile(string psArcFile)
        {
            var browser = new PsarcBrowser(psArcFile);

            var songList = new List <SongInfo>(browser.GetSongList());

            foreach (var song in songList)
            {
                yield return(MapSongToExistingDlcItem(song, psArcFile));
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// extract Song2014 from PSARC file for a specific
        /// songId (short song title) and arrangement (lead, rhythm, bass)
        /// defaults to the first songId and arrangement if not specified
        /// </summary>
        /// <param name="inputFilePath"></param>
        /// <param name="songId"></param>
        /// <param name="arrangement"></param>
        /// <returns>Song2014</returns>
        public Song2014 PsarcToSong2014(string inputFilePath, string songId = null, string arrangement = null)
        {
            var browser  = new PsarcBrowser(inputFilePath);
            var songList = browser.GetSongList();

            if (songId == null) // grab the first song.Identifier
            {
                songId = songList.FirstOrDefault().Identifier;
            }
            else // check if songId exists in song.Identifier
            {
                if (songList.FirstOrDefault(x => x.Identifier.Contains(songId)) == null)
                {
                    Console.WriteLine("Could not find songId: " + songId);
                    return(null);
                }
            }

            if (arrangement == null) // grab the first song.Arrangment[0]
            {
                arrangement = songList.FirstOrDefault().Arrangements[0];
            }
            else // check if track exists in song.Arrangments
            {
                if (songList.FirstOrDefault(x => x.Arrangements.Contains(arrangement)) == null)
                {
                    Console.WriteLine("Could not find arrangement: " + arrangement);
                    return(null);
                }
            }

            // push Song2014 into memory for this arrangement
            Song2014 arrSong2014 = browser.GetArrangement(songId, arrangement);

            Console.WriteLine("Pushed To Memory: [{0}] {{{1}}}", songId, arrangement);

            return(arrSong2014);
        }
        /// <summary>
        /// extract Song2014 from PSARC file for a specific
        /// songId (short song title) and arrangement (lead, rhythm, bass)
        /// defaults to the first songId and arrangement if not specified
        /// </summary>
        /// <param name="inputFilePath"></param>
        /// <param name="songId"></param>
        /// <param name="arrangement"></param>
        /// <returns>Song2014</returns>
        public Song2014 PsarcToSong2014(string inputFilePath, string songId = null, string arrangement = null)
        {
            var browser = new PsarcBrowser(inputFilePath);
            var songList = browser.GetSongList();

            if (songId == null) // grab the first song.Identifier
            {
                songId = songList.FirstOrDefault().Identifier;
            }
            else // check if songId exists in song.Identifier
            {
                if (songList.FirstOrDefault(x => x.Identifier.Contains(songId)) == null)
                {
                    Console.WriteLine("Could not find songId: " + songId);
                    return null;
                }
            }

            if (arrangement == null) // grab the first song.Arrangment[0]
            {
                arrangement = songList.FirstOrDefault().Arrangements[0];
            }
            else // check if track exists in song.Arrangments
            {
                if (songList.FirstOrDefault(x => x.Arrangements.Contains(arrangement)) == null)
                {
                    Console.WriteLine("Could not find arrangement: " + arrangement);
                    return null;
                }
            }

            // push Song2014 into memory for this arrangement
            Song2014 arrSong2014 = browser.GetArrangement(songId, arrangement);
            Console.WriteLine("Pushed To Memory: [{0}] {{{1}}}", songId, arrangement);

            return arrSong2014;
        }
Ejemplo n.º 6
0
        static void ExportPsarc(string psarcFile, CmdOptions options)
        {
            var archiveName = Path.GetFileNameWithoutExtension(psarcFile);

            try
            {
                var browser = new PsarcBrowser(psarcFile);

                var songList    = browser.GetSongList();
                var toolkitInfo = browser.GetToolkitInfo();

                if (options.ListSongs)
                {
                    foreach (var song in songList)
                    {
                        Console.WriteLine("[{0}] {1} - {2}  ({3}, {4})   {{{5}}}", song.Identifier,
                                          song.Artist, song.Title, song.Album, song.Year,
                                          string.Join(", ", song.Arrangements));
                    }
                    return;
                }

                // collect all songs to convert
                var toConvert = new List <SongInfo>();
                if (options.Tracks == null || options.Tracks.Count == 0)
                {
                    // if nothing was specified, convert all songs
                    toConvert = toConvert.Concat(songList).ToList();
                }
                else
                {
                    foreach (var songId in options.Tracks)
                    {
                        var songInfo = songList.FirstOrDefault(x => x.Identifier == songId);
                        if (songInfo != null)
                        {
                            toConvert.Add(songInfo);
                        }
                    }
                }

                for (int i = 0; i < toConvert.Count; ++i)
                {
                    var song  = toConvert[i];
                    var score = new Score();
                    // figure out which arrangements to convert
                    var arrangements = song.Arrangements;
                    if (options.Arrangements != null && options.Arrangements.Count > 0)
                    {
                        arrangements = arrangements.Intersect(options.Arrangements).ToList();
                    }

                    Console.WriteLine("({1}/{2}) Converting song {0} ...", song.Identifier, i + 1, toConvert.Count);
                    foreach (var arr in arrangements)
                    {
                        var arrangement = browser.GetArrangement(song.Identifier, arr);
                        if (arrangement == null)
                        {
                            Console.WriteLine(" Failed to get arrangement {0}", arr);
                            continue;
                        }
                        if (arrangement.ArrangementProperties.Metronome == 1)
                        {
                            // CDLC feature: optional arrangements can be generated which feature only
                            // metronome ticks, no music. However, the tab is identical to the normal
                            // track, so we don't need this unless it was explicitly requested.
                            if (options.Arrangements == null || options.Arrangements.Count == 0)
                            {
                                Console.WriteLine(" Arrangement {0} is a metronome track, ignore.", arr);
                                continue;
                            }
                        }
                        ExportArrangement(score, arrangement, arr, options.DifficultyLevel, psarcFile, toolkitInfo);

                        if (options.SplitArrangements)
                        {
                            string baseFileName = ConstructFileName(options.FileNameFormat, score, song.Identifier,
                                                                    archiveName, toolkitInfo);
                            baseFileName = CleanFileName(string.Format("{0} ({1})", baseFileName, arr));
                            SaveScore(score, baseFileName, options.OutputDirectory, options.OutputFormat);
                            // remember to remove the track from the score again
                            score.Tracks.Clear();
                        }
                    }

                    if (!options.SplitArrangements)
                    {
                        score.SortTracks();
                        string baseFileName = CleanFileName(
                            ConstructFileName(options.FileNameFormat, score, song.Identifier, archiveName, toolkitInfo));
                        SaveScore(score, baseFileName, options.OutputDirectory, options.OutputFormat);
                    }
                }
                Console.WriteLine();
            }
            catch (IOException e)
            {
                Console.WriteLine("Error encountered:");
                Console.WriteLine(e.Message);
            }
        }
        /// <summary>
        /// Load a PSARC file into memory and
        /// convert to GuitarPro file(s)
        /// </summary>
        /// <param name="inputFilePath"></param>
        /// <param name="outputDir"></param>
        /// <param name="songListShort"></param>
        /// <param name="outputFormat"></param>
        /// <param name="allDif"></param>
        public void PsarcToGp5(string inputFilePath, string outputDir, IList<SongInfoShort> songListShort = null, string outputFormat = "gp5", bool allDif = false)
        {
            Console.WriteLine("Opening archive {0} ...", inputFilePath);
            Console.WriteLine();

            try
            {
                var browser = new PsarcBrowser(inputFilePath);
                var songList = browser.GetSongList();
                var toolkitInfo = browser.GetToolkitInfo();

                // collect all songs to convert
                var toConvert = new List<SongInfo>();
                // if nothing was specified, convert all songs
                if (songListShort == null || songListShort.Count == 0)
                    toConvert = toConvert.Concat(songList).ToList();
                else
                    // convert only the user selected songs and arrangements
                    toConvert = SongInfoShortToSongInfo(songListShort, songList);

                foreach (var song in toConvert)
                {
                    var score = new Score();
                    // get all default or user specified arrangements for the song 
                    var arrangements = song.Arrangements;
                    Console.WriteLine("Converting song " + song.Identifier + "...");

                    foreach (var arr in arrangements)
                    {
                        var arrangement = (Song2014)browser.GetArrangement(song.Identifier, arr);
                        // get maximum difficulty for the arrangement
                        var mf = new ManifestFunctions(GameVersion.RS2014);
                        int maxDif = mf.GetMaxDifficulty(arrangement);

                        if (allDif) // create seperate file for each difficulty
                        {
                            for (int difLevel = 0; difLevel <= maxDif; difLevel++)
                            {
                                ExportArrangement(score, arrangement, difLevel, inputFilePath, toolkitInfo);
                                Console.WriteLine("Difficulty Level: {0}", difLevel);

                                var baseFileName = CleanFileName(
                                    String.Format("{0} - {1}", score.Artist, score.Title));
                                baseFileName += String.Format(" ({0})", arr);
                                baseFileName += String.Format(" (level {0:D2})", difLevel);

                                SaveScore(score, baseFileName, outputDir, outputFormat);
                                // remember to remove the track from the score again
                                score.Tracks.Clear();
                            }
                        }
                        else // combine maximum difficulty arrangements into one file
                        {
                            Console.WriteLine("Maximum Difficulty Level: {0}", maxDif);
                            ExportArrangement(score, arrangement, maxDif, inputFilePath, toolkitInfo);
                        }
                    }

                    if (!allDif) // only maximum difficulty
                    {
                        var baseFileName = CleanFileName(
                            String.Format("{0} - {1}", score.Artist, score.Title));
                        SaveScore(score, baseFileName, outputDir, outputFormat);
                    }
                }

                Console.WriteLine();
            }

            catch (IOException e)
            {
                Console.WriteLine("Error encountered:");
                Console.WriteLine(e.Message);
            }

        }
Ejemplo n.º 8
0
        /// <summary>
        /// Load a PSARC file into memory and
        /// convert to GuitarPro file(s)
        /// </summary>
        /// <param name="inputFilePath"></param>
        /// <param name="outputDir"></param>
        /// <param name="songListShort"></param>
        /// <param name="outputFormat"></param>
        /// <param name="allDif"></param>
        public void PsarcToGp5(string inputFilePath, string outputDir, IList <SongInfoShort> songListShort = null, string outputFormat = "gp5", bool allDif = false)
        {
            Console.WriteLine("Opening archive {0} ...", inputFilePath);
            Console.WriteLine();

            try
            {
                var browser     = new PsarcBrowser(inputFilePath);
                var songList    = browser.GetSongList();
                var toolkitInfo = browser.GetToolkitInfo();

                // collect all songs to convert
                var toConvert = new List <SongInfo>();
                // if nothing was specified, convert all songs
                if (songListShort == null || songListShort.Count == 0)
                {
                    toConvert = toConvert.Concat(songList).ToList();
                }
                else
                {
                    // convert only the user selected songs and arrangements
                    toConvert = SongInfoShortToSongInfo(songListShort, songList);
                }

                foreach (var song in toConvert)
                {
                    var score = new Score();
                    // get all default or user specified arrangements for the song
                    var arrangements = song.Arrangements;
                    Console.WriteLine("Converting song " + song.Identifier + "...");

                    foreach (var arr in arrangements)
                    {
                        var arrangement = (Song2014)browser.GetArrangement(song.Identifier, arr);
                        // get maximum difficulty for the arrangement
                        var mf     = new ManifestFunctions(GameVersion.RS2014);
                        int maxDif = mf.GetMaxDifficulty(arrangement);

                        if (allDif) // create separate file for each difficulty
                        {
                            for (int difLevel = 0; difLevel <= maxDif; difLevel++)
                            {
                                ExportArrangement(score, arrangement, difLevel, inputFilePath, toolkitInfo);
                                Console.WriteLine("Difficulty Level: {0}", difLevel);

                                var baseFileName = CleanFileName(
                                    String.Format("{0} - {1}", score.Artist, score.Title));
                                baseFileName += String.Format(" ({0})", arr);
                                baseFileName += String.Format(" (level {0:D2})", difLevel);

                                SaveScore(score, baseFileName, outputDir, outputFormat);
                                // remember to remove the track from the score again
                                score.Tracks.Clear();
                            }
                        }
                        else // combine maximum difficulty arrangements into one file
                        {
                            Console.WriteLine("Maximum Difficulty Level: {0}", maxDif);
                            ExportArrangement(score, arrangement, maxDif, inputFilePath, toolkitInfo);
                        }
                    }

                    if (!allDif) // only maximum difficulty
                    {
                        var baseFileName = CleanFileName(
                            String.Format("{0} - {1}", score.Artist, score.Title));
                        SaveScore(score, baseFileName, outputDir, outputFormat);
                    }
                }

                Console.WriteLine();
            }

            catch (IOException e)
            {
                Console.WriteLine("Error encountered:");
                Console.WriteLine(e.Message);
            }
        }