コード例 #1
0
ファイル: Program.cs プロジェクト: heshuimu/scharfrichter
        static void Main(string[] args)
        {
            Console.WriteLine("DJSLACKERS - DJMainExtract");

            args = Subfolder.Parse(args);

            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
                if (args[0] == "")
                {
                    args[0] = @"D:\chds\753jaa11.chd";
                }
            }

            for (int i = 0; i < args.Length; i++)
            {
                if (File.Exists(args[i]))
                {
                    string sourceFileName = Path.GetFileNameWithoutExtension(args[i]);
                    string sourcePath     = Path.GetDirectoryName(args[i]);
                    string targetPath     = Path.Combine(sourcePath, sourceFileName);
                    Directory.CreateDirectory(targetPath);

                    Console.WriteLine();
                    Console.WriteLine("Processing " + args[i]);

                    using (FileStream fs = new FileStream(args[i], FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        CHD          chd    = CHD.Load(fs);
                        BinaryReader reader = new BinaryReader(chd);

                        long totalChunks = (int)(chd.Length / 0x1000000L);

                        for (int j = 0; j < totalChunks; j++)
                        {
                            chd.Position = (long)j * 0x1000000;
                            //DJMainChunk chunk = DJMainChunk.Read(chd, new int[] { 0x002000, 0x006000, 0x00A000, 0x00E000, 0x012000, 0x016000 }, new int[] { 0x000000, 0x000200 }, 0x020000);
                            DJMainChunk chunk = DJMainChunk.Read(chd, new int[] { 0x000400 }, new int[] { 0x000000, 0x000200 }, 0x002000);

                            if (chunk.ChartCount > 0)
                            {
                                Console.WriteLine("Exporting set " + j.ToString());
                                string fname = Path.Combine(Path.GetDirectoryName(args[i]), Util.ConvertToDecimalString(j, 3));
                                //ConvertHelper.BemaniToBMS.ConvertChart(chunk.Charts[0], 16, 192, fname, "", 0, chunk.SampleMaps[0]);
                                ConvertHelper.BemaniToBMS.ConvertSounds(chunk.Sounds, fname, 0.6f);
                            }
                        }
                    }
                }
            }
        }
コード例 #2
0
        static void Main(string[] args)
        {
            Splash.Show("LZDecompress");
            args = Subfolder.Parse(args);

            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: LZDecompress <input file>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine("The output file will be the input file appended with a .DEC extension.");
                return;
            }

            if (args.Length > 0)
            {
                foreach (string filename in args)
                {
                    try
                    {
                        Console.Write("Decompressing " + filename + "... ");
                        byte[] data = File.ReadAllBytes(filename);
                        using (MemoryStream mem = new MemoryStream(data))
                        {
                            using (MemoryStream output = new MemoryStream())
                            {
                                BemaniLZ.Decompress(mem, output);
                                File.WriteAllBytes(filename + ".dec", output.ToArray());
                            }
                        }
                        Console.WriteLine("Success.");
                    }
                    catch
                    {
                        Console.WriteLine("FAILED.");
                    }
                }
            }
        }
コード例 #3
0
        static void Main(string[] args)
        {
            Splash.Show("FirebeatDecompress");
            args = Subfolder.Parse(args);

            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: FirebeatDecompress <input file>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine("The output file will be the input file appended with a .DEC extension.");
                return;
            }

            foreach (string filename in args)
            {
                using (MemoryStream source = new MemoryStream(File.ReadAllBytes(filename)), target = new MemoryStream())
                {
                    BemaniLZSS2.DecompressFirebeat(source, target, (int)source.Length, 0);
                    File.WriteAllBytes(filename + ".dec", target.ToArray());
                }
            }
        }
コード例 #4
0
ファイル: BemaniToBMS.cs プロジェクト: heshuimu/scharfrichter
        static public void Convert(string[] inArgs, long unitNumerator, long unitDenominator)
        {
            // configuration
            Configuration config          = LoadConfig();
            Configuration db              = LoadDB();
            int           quantizeMeasure = config["BMS"].GetValue("QuantizeMeasure");
            int           quantizeNotes   = config["BMS"].GetValue("QuantizeNotes");

            // splash
            Splash.Show("Bemani to BeMusic Script");
            Console.WriteLine("Timing: " + unitNumerator.ToString() + "/" + unitDenominator.ToString());
            Console.WriteLine("Measure Quantize: " + quantizeMeasure.ToString());

            // args
            string[] args;
            if (inArgs.Length > 0)
            {
                args = Subfolder.Parse(inArgs);
            }
            else
            {
                args = inArgs;
            }

            // debug args (if applicable)
            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
            }

            // show usage if no args provided
            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: BemaniToBMS <input file>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine();
                Console.WriteLine("Supported formats:");
                Console.WriteLine("1, 2DX, CS, SD9, SSP");
            }

            // process files
            for (int i = 0; i < args.Length; i++)
            {
                if (File.Exists(args[i]))
                {
                    Console.WriteLine();
                    Console.WriteLine("Processing File: " + args[i]);
                    string filename = args[i];

                    string IIDXDBName = Path.GetFileNameWithoutExtension(filename);
                    while (IIDXDBName.StartsWith("0"))
                    {
                        IIDXDBName = IIDXDBName.Substring(1);
                    }

                    byte[] data = File.ReadAllBytes(args[i]);
                    switch (Path.GetExtension(args[i]).ToUpper())
                    {
                    case @".1":
                        using (MemoryStream source = new MemoryStream(data))
                        {
                            Bemani1 archive = Bemani1.Read(source, unitNumerator, unitDenominator);

                            if (db[IIDXDBName]["TITLE"] != "")
                            {
                                for (int j = 0; j < archive.ChartCount; j++)
                                {
                                    Chart chart = archive.Charts[j];
                                    if (chart != null)
                                    {
                                        chart.Tags["TITLE"]  = db[IIDXDBName]["TITLE"];
                                        chart.Tags["ARTIST"] = db[IIDXDBName]["ARTIST"];
                                        chart.Tags["GENRE"]  = db[IIDXDBName]["GENRE"];
                                        if (j < 6)
                                        {
                                            chart.Tags["PLAYLEVEL"] = db[IIDXDBName]["DIFFICULTYSP" + config["IIDX"]["DIFFICULTY" + j.ToString()]];
                                        }
                                        else if (j < 12)
                                        {
                                            chart.Tags["PLAYLEVEL"] = db[IIDXDBName]["DIFFICULTYDP" + config["IIDX"]["DIFFICULTY" + j.ToString()]];
                                        }
                                    }
                                }
                            }

                            ConvertArchive(archive, config, args[i]);
                        }
                        break;

                    case @".2DX":
                        using (MemoryStream source = new MemoryStream(data))
                        {
                            Console.WriteLine("Converting Samples");
                            Bemani2DX archive = Bemani2DX.Read(source);
                            ConvertSounds(archive.Sounds, filename, 0.6f);
                        }
                        break;

                    case @".CS":
                        using (MemoryStream source = new MemoryStream(data))
                            ConvertChart(BeatmaniaIIDXCSNew.Read(source), config, filename, -1, null);
                        break;

                    case @".CS2":
                        using (MemoryStream source = new MemoryStream(data))
                            ConvertChart(BeatmaniaIIDXCSOld.Read(source), config, filename, -1, null);
                        break;

                    case @".CS5":
                        using (MemoryStream source = new MemoryStream(data))
                            ConvertChart(Beatmania5Key.Read(source), config, filename, -1, null);
                        break;

                    case @".CS9":
                        break;

                    case @".SD9":
                        using (MemoryStream source = new MemoryStream(data))
                        {
                            Sound  sound      = BemaniSD9.Read(source);
                            string targetFile = Path.GetFileNameWithoutExtension(filename);
                            string targetPath = Path.Combine(Path.GetDirectoryName(filename), targetFile) + ".wav";
                            sound.WriteFile(targetPath, 1.0f);
                        }
                        break;

                    case @".SSP":
                        using (MemoryStream source = new MemoryStream(data))
                            ConvertSounds(BemaniSSP.Read(source).Sounds, filename, 1.0f);
                        break;
                    }
                }
            }

            // wrap up
            Console.WriteLine("BemaniToBMS finished.");
        }
コード例 #5
0
        static void Main(string[] args)
        {
            Console.WriteLine("DJSLACKERS - DJMainExtract");

            args = Subfolder.Parse(args);

            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
                if (args[0] == "")
                {
                    args[0] = @"D:\chds\bmfinal.zip";
                }
            }

            for (int i = 0; i < args.Length; i++)
            {
                if (File.Exists(args[i]))
                {
                    string sourceFileName = Path.GetFileNameWithoutExtension(args[i]);
                    string sourcePath     = Path.GetDirectoryName(args[i]);
                    string targetPath     = Path.Combine(sourcePath, sourceFileName);
                    Directory.CreateDirectory(targetPath);

                    Console.WriteLine();
                    Console.WriteLine("Processing " + args[i]);

                    // default config
                    config              = new Configuration();
                    sampleMapOffsets    = new int[] { 0x000000, 0x000200 };
                    sampleMapAssignment = new int[] { 0, 0, 0, 0, 0, 0 };
                    soundOffset         = 0x002000;

                    var source = ConvertHelper.StreamAdapter.Open(args[i]);
                    using (var fs = source.Stream)
                    {
                        int chunkLength = 0x1000000;

                        BinaryReader reader = new BinaryReader(fs);

                        totalChunks = (long)(source.Length - chunkLength) / (long)chunkLength;
                        var identifiedMix = IdentifyMix(fs);

                        if (totalChunks >= 1)
                        {
                            byte[] rawData = new byte[chunkLength];

                            for (int j = 0; j < totalChunks; j++)
                            {
                                if (fs.Read(rawData, 0, CHUNK_LENGTH) < CHUNK_LENGTH)
                                {
                                    break;
                                }

                                using (MemoryStream ms = new MemoryStream(rawData))
                                {
                                    var    chunk     = DJMainChunk.Read(ms, chartOffsets, sampleMapOffsets, soundOffset);
                                    string soundPath = Path.Combine(targetPath, Util.ConvertToDecimalString(j, 3));
                                    string chartPath = Path.Combine(soundPath, Util.ConvertToDecimalString(j, 3));

                                    if (chunk.ChartCount > 0)
                                    {
                                        Console.WriteLine("Converting set " + j.ToString());
                                        Directory.CreateDirectory(soundPath);
                                        for (int chartIndex = 0; chartIndex < chunk.ChartCount; chartIndex++)
                                        {
                                            ConvertHelper.BemaniToBMS.ConvertChart(chunk.Charts[chartIndex], config, chartPath, chartIndex, chunk.SampleMaps[sampleMapAssignment[chartIndex]]);
                                        }

                                        Console.WriteLine("Consolidating set " + j.ToString());
                                        ConvertHelper.StereoCombiner.Process(chunk.Sounds, chunk.Charts, stereoAmp);
                                        Console.WriteLine("Writing set " + j.ToString());
                                        ConvertHelper.BemaniToBMS.ConvertSounds(chunk.Sounds, soundPath, 0.6f);
                                    }
                                    else
                                    {
                                        bool chunkEmpty = true;
                                        byte byteZero   = rawData[0];
                                        for (int k = 0; k < chunkLength; k++)
                                        {
                                            if (rawData[k] != byteZero)
                                            {
                                                chunkEmpty = false;
                                                break;
                                            }
                                        }
                                        if (!chunkEmpty)
                                        {
                                            Console.WriteLine("Nonempty chunk failed heuristic: " + j.ToString());
                                            File.WriteAllBytes(soundPath, rawData);
                                        }
                                        else
                                        {
                                            Console.WriteLine("Skipping empty set " + j.ToString());
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #6
0
        static public void Convert(string[] inArgs)
        {
            // configuration
            Configuration config = LoadConfig();

            // splash
            Splash.Show("Bemani To Stepmania");

            // parse args
            string[] args;
            if (inArgs.Length > 0)
            {
                args = Subfolder.Parse(inArgs);
            }
            else
            {
                args = inArgs;
            }

            // usage if no args present
            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: BemaniToSM <input file>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine();
                Console.WriteLine("Supported formats:");
                Console.WriteLine("SSQ, XWB");
            }

            string iSelect = "";

            foreach (string filename in args)
            {
                if (File.Exists(filename) && Path.GetExtension(filename).ToUpper() == ".SSQ")
                {
                    Console.WriteLine();
                    Console.Write("At least one ssq files detected.");
                    Console.WriteLine();
                    Console.Write("Enable manual fill-up simfile data?");
                    Console.WriteLine();
                    Console.Write("Input y for Yes, ENTER for No: ");
                    iSelect = Console.ReadLine();
                    break;
                }
            }

            // process
            foreach (string filename in args)
            {
                if (File.Exists(filename))
                {
                    Console.WriteLine();
                    Console.WriteLine("Processing File: " + filename);

                    switch (Path.GetExtension(filename).ToUpper())
                    {
                    case @".XWB":
                    {
                        using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        {
                            Console.WriteLine("Reading XWB bank");
                            MicrosoftXWB bank    = MicrosoftXWB.Read(fs);
                            string       outPath = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename));

                            Directory.CreateDirectory(outPath);

                            int count = bank.SoundCount;

                            for (int i = 0; i < count; i++)
                            {
                                string outFileName;

                                if (bank.Sounds[i].Name == null || bank.Sounds[i].Name == "")
                                {
                                    outFileName = Util.ConvertToHexString(i, 4);
                                }
                                else
                                {
                                    outFileName = bank.Sounds[i].Name;
                                }

                                string outFile = Path.Combine(outPath, outFileName + ".wav");
                                Console.WriteLine("Writing " + outFile);
                                bank.Sounds[i].WriteFile(outFile, 1.0f);
                            }

                            bank = null;
                        }
                    }
                    break;

                    case @".SSQ":
                    {
                        string iTitle          = "";
                        string iArtist         = "";
                        string iTitleTranslit  = "";
                        string iArtistTranslit = "";
                        string iCDTitle        = "";

                        using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        {
                            BemaniSSQ   ssq = BemaniSSQ.Read(fs, 0x1000);
                            StepmaniaSM sm  = new StepmaniaSM();

                            if (iSelect == "y")
                            {
                                Console.WriteLine();
                                Console.Write("TITLE: ");
                                iTitle = Console.ReadLine();

                                Console.Write("ARTIST: ");
                                iArtist = Console.ReadLine();

                                Console.Write("TITLETRANSLIT: ");
                                iTitleTranslit = Console.ReadLine();

                                Console.Write("ARTISTTRANSLIT: ");
                                iArtistTranslit = Console.ReadLine();

                                Console.Write("Origin (for CDTitle): ");
                                iCDTitle = Console.ReadLine();

                                Console.WriteLine();
                                Console.WriteLine("Input difficulty ratings for song " + iTitle + " below.");
                                Console.WriteLine();
                            }

                            sm.Tags["SongID"] = Path.GetFileNameWithoutExtension(@filename);
                            sm.Tags["TITLE"]  = iTitle;
                            sm.Tags["ARTIST"] = iArtist;

                            if (iSelect == "y")
                            {
                                if (iTitleTranslit != "")
                                {
                                    sm.Tags["TITLETRANSLIT"] = iTitleTranslit;
                                }

                                if (iArtistTranslit != "")
                                {
                                    sm.Tags["ARTISTTRANSLIT"] = iArtistTranslit;
                                }
                            }
                            else
                            {
                                sm.Tags["TITLETRANSLIT"]  = "";
                                sm.Tags["ARTISTTRANSLIT"] = "";
                            }

                            if (iTitleTranslit == "")
                            {
                                sm.Tags["BANNER"] = iTitle + ".png";
                            }
                            else
                            {
                                sm.Tags["BANNER"] = iTitleTranslit + ".png";
                            }

                            if (iTitleTranslit == "")
                            {
                                sm.Tags["BACKGROUND"] = iTitle + "-bg.png";
                            }
                            else
                            {
                                sm.Tags["BACKGROUND"] = iTitleTranslit + "-bg.png";
                            }

                            sm.Tags["CDTITLE"] = "./CDTitles/" + iCDTitle + ".png";

                            if (iTitleTranslit == "")
                            {
                                sm.Tags["MUSIC"] = iTitle + ".ogg";
                            }
                            else
                            {
                                sm.Tags["MUSIC"] = iTitleTranslit + ".ogg";
                            }

                            sm.Tags["SAMPLESTART"]  = "20";
                            sm.Tags["SAMPLELENGTH"] = "15";

                            sm.CreateTempoTags(ssq.TempoEntries.ToArray());

                            string[] gType = { "dance-single", "dance-double", "dance-couple", "dance-solo" };
                            string   meter = "";

                            foreach (string gName in gType)
                            {
                                string[] dType = { "Beginner", "Easy", "Medium", "Hard", "Challenge", "" };

                                foreach (string dName in dType)
                                {
                                    foreach (Chart chart in ssq.Charts)
                                    {
                                        string gameType = config["SM"]["DanceMode" + chart.Tags["Panels"]];

                                        if (gName == gameType)
                                        {
                                            string difficulty = config["SM"]["Difficulty" + config["DDR"]["Difficulty" + chart.Tags["Difficulty"]]];
                                            chart.Entries.Sort();

                                            if (gameType == config["SM"]["DanceMode8"] && difficulty == "")
                                            {
                                                break;
                                            }

                                            if (dName == difficulty)
                                            {
                                                // solo chart check
                                                if (gameType == config["SM"]["DanceMode6"])
                                                {
                                                    foreach (Entry entry in chart.Entries)
                                                    {
                                                        if (entry.Type == EntryType.Marker)
                                                        {
                                                            switch (entry.Column)
                                                            {
                                                            case 0: entry.Column = 0; break;

                                                            case 1: entry.Column = 2; break;

                                                            case 2: entry.Column = 3; break;

                                                            case 3: entry.Column = 5; break;

                                                            case 4: entry.Column = 1; break;

                                                            case 6: entry.Column = 4; break;
                                                            }
                                                        }
                                                    }
                                                }

                                                // couples chart check
                                                else if (gameType == config["SM"]["DanceMode4"])
                                                {
                                                    foreach (Entry entry in chart.Entries)
                                                    {
                                                        if (entry.Type == EntryType.Marker && entry.Column >= 4)
                                                        {
                                                            gameType             = config["SM"]["DanceModeCouple"];
                                                            chart.Tags["Panels"] = "8";
                                                            break;
                                                        }
                                                    }
                                                }

                                                string difText = difficulty;

                                                switch (difficulty)
                                                {
                                                case "Easy": difText = "Basic"; break;

                                                case "Medium": difText = "Difficult"; break;

                                                case "Hard": difText = "Expert"; break;

                                                case "": difText = "Difficult"; break;
                                                }

                                                if (iSelect == "y")
                                                {
                                                    Console.Write(ToUpperFirstLetter(gameType.Replace("dance-", "")) + "-" + difText + ": ");
                                                    meter = Console.ReadLine();
                                                }

                                                if (meter == "")
                                                {
                                                    meter = "0";
                                                }

                                                string dif = difficulty;

                                                if (difficulty == "")
                                                {
                                                    dif = "Medium";
                                                }

                                                sm.CreateStepTag(chart.Entries.ToArray(), gameType, "", dif, meter, "", System.Convert.ToInt32(chart.Tags["Panels"]), config["SM"].GetValue("QuantizeNotes"));
                                            }
                                        }
                                    }
                                }
                            }

                            string outTitle = iTitle;

                            if (iTitleTranslit != "")
                            {
                                outTitle = iTitleTranslit;
                            }
                            else if (iTitle == "")
                            {
                                outTitle = Path.GetFileNameWithoutExtension(@filename);
                            }

                            sm.WriteFile(Path.Combine(Path.GetDirectoryName(filename), outTitle + ".sm"));
                        }
                    }
                    break;
                    }
                }
            }
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: heshuimu/scharfrichter
        static void Main(string[] args)
        {
            Console.WriteLine("DJSLACKERS - TwinkleIIDXExtract");

            args = Subfolder.Parse(args);

            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
                if (args[0] == "")
                {
                    args[0] = @"C:\Users\Tony\Desktop\work\2ndstyle.img";
                }
            }

            for (int i = 0; i < args.Length; i++)
            {
                if (File.Exists(args[i]))
                {
                    string sourceFileName = Path.GetFileNameWithoutExtension(args[i]);
                    string sourcePath     = Path.GetDirectoryName(args[i]);
                    string targetPath     = Path.Combine(sourcePath, sourceFileName);
                    Directory.CreateDirectory(targetPath);

                    Console.WriteLine();
                    Console.WriteLine("Processing " + args[i]);

                    Configuration config = new Configuration();
                    config["BMS"].SetDefaultValue("QuantizeMeasure", 16);
                    config["BMS"].SetDefaultValue("QuantizeNotes", 192);
                    config["BMS"].SetDefaultString("Difficulty1", "02000");
                    config["BMS"].SetDefaultString("Difficulty2", "06000");
                    config["BMS"].SetDefaultString("Difficulty3", "0A000");
                    config["BMS"].SetDefaultString("Difficulty4", "0E000");
                    config["BMS"].SetDefaultString("Difficulty5", "12000");
                    config["BMS"].SetDefaultString("Difficulty6", "16000");
                    config["BMS"].SetDefaultString("Difficulty7", "1A000");
                    config["BMS"].SetDefaultString("Difficulty8", "1E000");
                    config["IIDX"].SetDefaultString("Difficulty0", "1");
                    config["IIDX"].SetDefaultString("Difficulty1", "2");
                    config["IIDX"].SetDefaultString("Difficulty2", "3");
                    config["IIDX"].SetDefaultString("Difficulty3", "4");
                    config["IIDX"].SetDefaultString("Difficulty4", "5");
                    config["IIDX"].SetDefaultString("Difficulty5", "6");
                    config["IIDX"].SetDefaultString("Difficulty6", "7");
                    config["IIDX"].SetDefaultString("Difficulty7", "8");

                    using (FileStream fs = new FileStream(args[i], FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        int          chunkLength = 0x1A00000;
                        BinaryReader reader      = new BinaryReader(fs);
                        fs.Position = 0x8000000;

                        long   totalChunks = (int)((fs.Length - fs.Position) / (long)chunkLength);
                        byte[] rawData     = new byte[chunkLength];

                        for (int j = 0; j < totalChunks; j++)
                        {
                            fs.Read(rawData, 0, rawData.Length);

                            using (MemoryStream ms = new MemoryStream(rawData))
                            {
                                TwinkleChunk chunk     = TwinkleChunk.Read(ms, new int[] { 0x002000, 0x006000, 0x00A000, 0x00E000, 0x012000, 0x016000, 0x01A000, 0x01E000 }, new int[] { 0x000000 }, 0x100000);
                                string       soundPath = Path.Combine(targetPath, Util.ConvertToDecimalString(j, 3));
                                string       chartPath = Path.Combine(soundPath, Util.ConvertToDecimalString(j, 3));

                                if (chunk.ChartCount > 0)
                                {
                                    Console.WriteLine("Converting set " + j.ToString());
                                    Directory.CreateDirectory(soundPath);
                                    for (int chartIndex = 0; chartIndex < chunk.ChartCount; chartIndex++)
                                    {
                                        ConvertHelper.BemaniToBMS.ConvertChart(chunk.Charts[chartIndex], config, chartPath, chartIndex, chunk.SampleMaps[0]);
                                    }
                                    Console.WriteLine("Consolidating set " + j.ToString());
                                    ConvertHelper.StereoCombiner.Process(chunk.Sounds, chunk.Charts);
                                    Console.WriteLine("Writing set " + j.ToString());
                                    ConvertHelper.BemaniToBMS.ConvertSounds(chunk.Sounds, soundPath, 0.6f);
                                }
                                else
                                {
                                    bool chunkEmpty = true;
                                    for (int k = 0; k < chunkLength; k++)
                                    {
                                        if (rawData[k] != 0)
                                        {
                                            chunkEmpty = false;
                                            break;
                                        }
                                    }
                                    if (!chunkEmpty)
                                    {
                                        Console.WriteLine("Nonempty chunk failed heuristic: " + j.ToString());
                                        File.WriteAllBytes(soundPath, rawData);
                                    }
                                    else
                                    {
                                        Console.WriteLine("Skipping empty set " + j.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #8
0
ファイル: PopnToBMS.cs プロジェクト: mirai364/scharfrichter
        static public void Convert(string[] inArgs, long unitNumerator, long unitDenominator, int version)
        {
            // configuration
            Configuration config = Configuration.LoadIIDXConfig(Common.configFileName);
            Configuration db     = Common.LoadDB("PopnDB");

            // splash
            Splash.Show("Popn to BeMusic Script");

            // args
            string[] args;
            if (inArgs.Length > 0)
            {
                args = Subfolder.Parse(inArgs);
            }
            else
            {
                args = inArgs;
            }

            // show usage if no args provided
            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: PopnToBMS <input file>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine();
                Console.WriteLine("Supported formats:");
                Console.WriteLine("2DX");
            }

            string output = config["BMS"]["Output"];

            // process files
            for (int i = 0; i < args.Length; i++)
            {
                if (File.Exists(args[i]))
                {
                    Console.WriteLine("Processing File: " + args[i]);
                    string filename = args[i];
                    if (Path.GetExtension(filename).ToUpper() != @".2DX")
                    {
                        Console.WriteLine();
                        Console.WriteLine("Usage: PopnToBMS <input file>");
                        Console.WriteLine();
                        Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                        Console.WriteLine();
                        Console.WriteLine("Supported formats:");
                        Console.WriteLine("2DX");
                        Console.WriteLine();
                        Console.WriteLine();
                        Console.WriteLine();
                        continue;
                    }

                    string title = Path.GetFileNameWithoutExtension(filename);
                    string input = Path.GetDirectoryName(filename) + "\\";
                    if (output == "")
                    {
                        output = input;
                    }
                    string suffix = "";
                    if (title.Length > 4)
                    {
                        suffix = title.Substring(title.Length - 4, 4);
                    }
                    if (suffix == "_pre")
                    {
                        title = title.Substring(0, title.Length - 4);

                        try
                        {
                            byte[] data = File.ReadAllBytes(filename);
                            using (MemoryStream source = new MemoryStream(data))
                            {
                                Console.WriteLine("Converting Samples");
                                Bemani2DX archive  = Bemani2DX.Read(source);
                                string    titleTmp = title;
                                if (db[title]["TITLE"] != "")
                                {
                                    titleTmp = db[title]["TITLE"];
                                }

                                float volume = 0.6f;
                                ConvertSounds(archive.Sounds, filename, volume, null, output, titleTmp, true, "");
                            }
                        }
                        catch (Exception e)
                        {
                            Console.WriteLine(e);
                            Console.WriteLine();
                            Console.WriteLine();
                            return;
                        }
                    }
                    else
                    {
                        int maxIndex        = -1;
                        int difficaltyIndex = 0;
                        for (int j = 0; j < 5; j++)
                        {
                            switch (j)
                            {
                            case 0:
                                // Convert Sounds
                                break;

                            case 1:
                                // EASY
                                filename = input + title + "_ep.bin";
                                if (!File.Exists(filename))
                                {
                                    continue;
                                }
                                Console.WriteLine("Processing File: " + filename);
                                difficaltyIndex = 3;
                                break;

                            case 2:
                                // NOERMAL
                                filename = input + title + "_np.bin";
                                if (!File.Exists(filename))
                                {
                                    continue;
                                }
                                Console.WriteLine("Processing File: " + filename);
                                difficaltyIndex = 1;
                                break;

                            case 3:
                                // HYPER
                                filename = input + title + "_hp.bin";
                                if (!File.Exists(filename))
                                {
                                    continue;
                                }
                                Console.WriteLine("Processing File: " + filename);
                                difficaltyIndex = 0;
                                break;

                            case 4:
                                // EX
                                filename = input + title + "_op.bin";
                                if (!File.Exists(filename))
                                {
                                    continue;
                                }
                                Console.WriteLine("Processing File: " + filename);
                                difficaltyIndex = 2;
                                break;
                                //case 5:
                                //    // Battle
                                //    filename = output + title + "_bp.bin";
                                //    if (!File.Exists(filename))
                                //    {
                                //        continue;
                                //    }
                                //    Console.WriteLine("Processing File: " + filename);
                                //    difficaltyIndex = 99;
                                //    break;
                            }

                            byte[] data = File.ReadAllBytes(filename);

                            try
                            {
                                switch (Path.GetExtension(filename).ToUpper())
                                {
                                case @".BIN":
                                    using (MemoryStream source = new MemoryStream(data))
                                    {
                                        Popn archive = Popn.Read(source, unitNumerator, unitDenominator, maxIndex, version);
                                        if (db[title]["TITLE"] != "")
                                        {
                                            Chart chart = archive.Charts[0];
                                            chart.Tags["TITLE"]     = db[title]["TITLE"];
                                            chart.Tags["ARTIST"]    = db[title]["ARTIST"];
                                            chart.Tags["GENRE"]     = db[title]["GENRE"];
                                            chart.Tags["PLAYLEVEL"] = db[title]["DIFFICULTYDP" + config["IIDX"]["DIFFICULTY" + difficaltyIndex.ToString()]];
                                        }
                                        ConvertChart(archive.Charts[0], config, title, difficaltyIndex, null, "", output);
                                    }
                                    break;

                                case @".2DX":
                                    using (MemoryStream source = new MemoryStream(data))
                                    {
                                        Console.WriteLine("Converting Samples");
                                        Bemani2DX archive  = Bemani2DX.Read(source);
                                        string    titleTmp = title;
                                        if (db[title]["TITLE"] != "")
                                        {
                                            titleTmp = db[title]["TITLE"];
                                        }

                                        float volume = 0.6f;
                                        maxIndex = ConvertSounds(archive.Sounds, filename, volume, null, output, titleTmp, false, "");
                                    }
                                    break;
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine(e);
                                Console.WriteLine();
                                Console.WriteLine();
                                return;
                            }
                        }
                    }
                }
            }

            // wrap up
            Console.WriteLine("PopnToBMS finished.");
            Console.WriteLine();
            Console.WriteLine();
        }
コード例 #9
0
        static void Main(string[] args)
        {
            Console.WriteLine("DJSLACKERS - IFSExtract");
            args = Subfolder.Parse(args);

            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
                if (args[0] == "")
                {
                    args[0] = @"D:\BMS\sound\[IFS]\10006.ifs";
                    //args[0] = @"d:\bms\sound\[ifs]\01000.ifs";
                }
            }

            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: IFSExtract <input file>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine();
                Console.WriteLine("Supported formats:");
                Console.WriteLine("IFS");
            }

            if (args != null && args.Length > 0)
            {
                for (int i = 0; i < args.Length; i++)
                {
                    string filename = args[i];

                    if (File.Exists(filename) && Path.GetExtension(filename).ToUpper() == @".IFS")
                    {
                        Console.WriteLine();
                        Console.WriteLine("Processing file " + args[i]);

                        using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.ReadWrite, FileShare.ReadWrite))
                        {
                            string outputPath     = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename));
                            string outputFileBase = Path.Combine(outputPath, Path.GetFileNameWithoutExtension(Path.GetFileName(filename)));

                            Directory.CreateDirectory(outputPath);

                            BemaniIFS archive = BemaniIFS.Read(fs);
                            int       count   = archive.RawDataCount;

                            //Console.WriteLine("Exporting files.");

                            //for (int j = 0; j < count; j++)
                            //{
                            //    string outputNumber = Util.ConvertToDecimalString(j, 4);
                            //    string outputFile = outputFileBase;
                            //    string extension = "dat";

                            //    byte[] data = archive.RawData[j];

                            //    // heuristics block
                            //    if (Heuristics.DetectBemaniModel2DXAC(data))
                            //        extension = "model";
                            //    else if (Heuristics.DetectBemani2DXArchive(data))
                            //        extension = "2dx";
                            //    else if (Heuristics.DetectBemani1(data))
                            //        extension = "1";
                            //    else if (Heuristics.DetectBemaniImage2DXAC(data))
                            //        extension = "cimg";

                            //    outputFile += "-" + outputNumber + "." + extension;
                            //    File.WriteAllBytes(outputFile, archive.RawData[j]);
                            //}
                        }
                    }
                }
            }
        }
コード例 #10
0
        static void Main(string[] args)
        {
            Console.WriteLine("DJSLACKERS - TwinkleIIDXExtract");

            args = Subfolder.Parse(args);

            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
                if (args[0] == "")
                {
                    args[0] = @"d:\CHDs\iidx8th.zip";
                }
            }

            for (int i = 0; i < args.Length; i++)
            {
                if (File.Exists(args[i]))
                {
                    string sourceFileName = Path.GetFileNameWithoutExtension(args[i]);
                    string sourcePath     = Path.GetDirectoryName(args[i]);
                    string targetPath     = Path.Combine(sourcePath, sourceFileName);
                    Directory.CreateDirectory(targetPath);

                    Console.WriteLine();
                    Console.WriteLine("Processing " + args[i]);

                    var chartOffsets        = new int[] { 0x002000, 0x006000, 0x00A000, 0x00E000, 0x012000, 0x016000, 0x01A000, 0x01E000 };
                    var sampleMapAssignment = new int[] { 0, 0, 0, 0, 0, 0, 0, 0 };
                    var sampleMapOffsets    = new int[] { 0x000000 };

                    Configuration config = new Configuration();
                    config["BMS"].SetDefaultString("Difficulty1", "5key");
                    config["BMS"].SetDefaultString("Difficulty2", "light");
                    config["BMS"].SetDefaultString("Difficulty3", "normal");
                    config["BMS"].SetDefaultString("Difficulty4", "another");
                    config["BMS"].SetDefaultString("Difficulty5", "12000");
                    config["BMS"].SetDefaultString("Difficulty6", "16000");
                    config["BMS"].SetDefaultString("Difficulty7", "1A000");
                    config["BMS"].SetDefaultString("Difficulty8", "1E000");
                    config["IIDX"].SetDefaultString("Difficulty0", "3");
                    config["IIDX"].SetDefaultString("Difficulty1", "2");
                    config["IIDX"].SetDefaultString("Difficulty2", "1");
                    config["IIDX"].SetDefaultString("Difficulty3", "4");
                    config["IIDX"].SetDefaultString("Difficulty4", "3");
                    config["IIDX"].SetDefaultString("Difficulty5", "2");
                    config["IIDX"].SetDefaultString("Difficulty6", "4");
                    config["IIDX"].SetDefaultString("Difficulty7", "8");

                    var source = ConvertHelper.StreamAdapter.Open(args[i]);
                    using (var fs = source.Stream)
                    {
                        BinaryReader reader = new BinaryReader(fs);

                        long totalChunks = (int)((source.Length - DATA_START) / (long)CHUNK_LENGTH);
                        if (source.Length > CHUNK_LENGTH)
                        {
                            Util.DiscardBytes(fs, DATA_START);
                        }
                        else
                        {
                            totalChunks = 1;
                        }

                        byte[] rawData = new byte[CHUNK_LENGTH];

                        for (int j = 0; j < totalChunks; j++)
                        {
                            Console.WriteLine("Reading " + j.ToString());
                            if (fs.Read(rawData, 0, CHUNK_LENGTH) < CHUNK_LENGTH)
                            {
                                break;
                            }

                            using (MemoryStream ms = new MemoryStream(rawData))
                            {
                                TwinkleChunk chunk     = TwinkleChunk.Read(ms, chartOffsets, sampleMapOffsets, 0x100000);
                                string       soundPath = Path.Combine(targetPath, Util.ConvertToDecimalString(j, 3));
                                string       chartPath = Path.Combine(soundPath, Util.ConvertToDecimalString(j, 3));

                                if (chunk.ChartCount > 0)
                                {
                                    Console.WriteLine("Converting set " + j.ToString());
                                    Directory.CreateDirectory(soundPath);
                                    for (int chartIndex = 0; chartIndex < chunk.ChartCount; chartIndex++)
                                    {
                                        ConvertHelper.BemaniToBMS.ConvertChart(chunk.Charts[chartIndex], config, chartPath, chartIndex, chunk.SampleMaps[sampleMapAssignment[chartIndex]]);
                                    }
                                    Console.WriteLine("Consolidating set " + j.ToString());
                                    ConvertHelper.StereoCombiner.Process(chunk.Sounds, chunk.Charts);
                                    Console.WriteLine("Writing set " + j.ToString());
                                    ConvertHelper.BemaniToBMS.ConvertSounds(chunk.Sounds, soundPath, 0.6f);
                                }
                                else
                                {
                                    bool chunkEmpty = true;
                                    byte byteZero   = rawData[0];
                                    for (int k = 0; k < CHUNK_LENGTH; k++)
                                    {
                                        if (rawData[k] != byteZero)
                                        {
                                            chunkEmpty = false;
                                            break;
                                        }
                                    }
                                    if (!chunkEmpty)
                                    {
                                        Console.WriteLine("Nonempty chunk failed heuristic: " + j.ToString());
                                        File.WriteAllBytes(soundPath, rawData);
                                    }
                                    else
                                    {
                                        Console.WriteLine("Skipping empty set " + j.ToString());
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
コード例 #11
0
        static public void RenderWAV(string[] inArgs, long unitNumerator, long unitDenominator, bool idUseRenderAutoTip)
        {
            // configuration
            Configuration config = Configuration.LoadIIDXConfig(Common.configFileName);
            Configuration db     = Common.LoadDB();

            if (config["BMS"].GetBool("ForceRenderAutoTip"))
            {
                idUseRenderAutoTip = true;
            }
            Dictionary <int, int> ignore = new Dictionary <int, int>();

            if (idUseRenderAutoTip)
            {
                ignore.Add(1, 1);
                ignore.Add(2, 2);
            }

            Splash.Show("Render");
            Console.WriteLine("Timing: " + unitNumerator.ToString() + "/" + unitDenominator.ToString());

            string output = config["BMS"]["Output"];

            string[] args;

            if (inArgs.Length > 0)
            {
                args = Subfolder.Parse(inArgs);
            }
            else
            {
                args = inArgs;
            }

            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
            }

            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: Render2DX <files..>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine();
                Console.WriteLine("You must have both the chart file (.1) and the sound file (.2dx).");
                Console.WriteLine("Supported formats:");
                Console.WriteLine("1, 2DX");
            }

            Dictionary <string, Sound[]> sounds = new Dictionary <string, Sound[]>();

            Chart[] charts     = null;
            bool    cancel     = false;
            string  outFile    = "0001";
            string  targetPath = null;
            string  IIDXDBName = Path.GetFileNameWithoutExtension(args[0]);
            string  title      = IIDXDBName;
            string  version    = IIDXDBName.Substring(0, 2);

            if (IIDXDBName.Contains("pre"))
            {
                IIDXDBName = IIDXDBName.Substring(0, 5);
            }
            if (IIDXDBName.Length > 5)
            {
                IIDXDBName = IIDXDBName.Substring(0, 5);
            }
            while (IIDXDBName.StartsWith("0"))
            {
                IIDXDBName = IIDXDBName.Substring(1);
            }

            if (db[IIDXDBName]["TITLE"] != "")
            {
                title = db[IIDXDBName]["TITLE"];
                title = Common.nameReplace(title);
            }

            foreach (string filename in args)
            {
                if (cancel)
                {
                    break;
                }

                string tmp   = Path.GetFileNameWithoutExtension(filename);
                string INDEX = "0";
                if (tmp.Contains("pre"))
                {
                    continue;
                }
                if (tmp.Length > 5)
                {
                    INDEX = tmp.Substring(5);
                }

                if (File.Exists(filename))
                {
                    switch (Path.GetExtension(filename).ToUpper())
                    {
                    case @".1":
                        if (charts == null)
                        {
                            Console.WriteLine();
                            Console.WriteLine("Valid charts:");
                            if (!idUseRenderAutoTip)
                            {
                                outFile = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename));
                            }
                            using (MemoryStream mem = new MemoryStream(File.ReadAllBytes(filename)))
                            {
                                charts = Bemani1.Read(mem, unitNumerator, unitDenominator, ignore).Charts;
                                for (int i = 0; i < charts.Length; i++)
                                {
                                    if (charts[i] != null)
                                    {
                                        Console.Write(i.ToString() + "  ");
                                    }
                                }
                            }
                            Console.WriteLine();
                        }
                        break;

                    case @".2DX":
                        if (!sounds.ContainsKey(INDEX))
                        {
                            using (MemoryStream mem = new MemoryStream(File.ReadAllBytes(filename)))
                            {
                                sounds.Add(INDEX, Bemani2DX.Read(mem).Sounds);
                            }
                        }
                        break;

                    case @".S3P":
                        if (!sounds.ContainsKey(INDEX))
                        {
                            using (MemoryStream mem = new MemoryStream(File.ReadAllBytes(filename)))
                            {
                                sounds.Add(INDEX, BemaniS3P.Read(mem).Sounds);
                            }
                        }
                        break;
                    }
                }
            }

            if (!cancel && (sounds != null) && (charts != null))
            {
                List <byte[]> rendered      = new List <byte[]>();
                List <int>    renderedIndex = new List <int>();

                for (int k = 0; k < charts.Length; k++)
                {
                    string keySet = "0";
                    if (k < 6)
                    {
                        keySet = db[IIDXDBName]["KEYSETSP" + config["IIDX"]["DIFFICULTY" + k.ToString()]];
                    }
                    else if (k < 12)
                    {
                        keySet = db[IIDXDBName]["KEYSETDP" + config["IIDX"]["DIFFICULTY" + k.ToString()]];
                    }
                    Chart chart = charts[k];

                    if (chart == null)
                    {
                        continue;
                    }


                    //Console.WriteLine("");
                    Console.WriteLine("Rendering " + k.ToString());
                    //Console.WriteLine("Use keySet " + keySet);
                    Sound[] tmpSound;
                    if (!sounds.TryGetValue(keySet, out tmpSound))
                    {
                        Console.WriteLine("not found keySet");
                        if (!sounds.TryGetValue("0", out tmpSound))
                        {
                            Console.WriteLine("not found sounds \n continue");
                            continue;
                        }
                    }

                    byte[] data = ChartRenderer.Render(chart, tmpSound);

                    int  renderedCount = rendered.Count;
                    int  matchIndex    = -1;
                    bool match         = false;

                    for (int i = 0; i < renderedCount; i++)
                    {
                        int renderedLength = rendered[i].Length;
                        if (renderedLength == data.Length)
                        {
                            byte[] renderedBytes = rendered[i];
                            match = true;
                            for (int j = 0; j < renderedLength; j++)
                            {
                                if (renderedBytes[j] != data[j])
                                {
                                    match = false;
                                    break;
                                }
                            }
                            if (match)
                            {
                                matchIndex = i;
                                break;
                            }
                        }
                    }
                    if (idUseRenderAutoTip)
                    {
                        string targetFolder = "sounds";
                        if (keySet != "0")
                        {
                            targetFolder = "sounds_" + keySet;
                        }
                        targetPath = Path.Combine(output, version, title, targetFolder);
                        match      = false;
                    }

                    if (!match)
                    {
                        if (idUseRenderAutoTip)
                        {
                            Console.WriteLine("Writing unique " + (k < 6 ? 1 : 3) + config["IIDX"].GetValue("DIFFICULTY" + k.ToString()));
                            Common.SafeCreateDirectory(targetPath);
                            File.WriteAllBytes(targetPath + "\\" + outFile + "-" + (k < 6 ? 1 : 3) + config["IIDX"].GetValue("DIFFICULTY" + k.ToString()) + ".wav", data);
                        }
                        else
                        {
                            Console.WriteLine("Writing unique " + k.ToString());
                            File.WriteAllBytes(outFile + " -" + Util.ConvertToDecimalString(k, 2) + ".wav", data);
                        }
                        rendered.Add(data);
                        renderedIndex.Add(k);
                    }
                    else
                    {
                        Console.WriteLine("Matches " + renderedIndex[matchIndex].ToString());
                    }
                }
            }
        }
コード例 #12
0
ファイル: Render.cs プロジェクト: heshuimu/scharfrichter
        static public void RenderWAV(string[] inArgs, long unitNumerator, long unitDenominator)
        {
            Splash.Show("Render");
            Console.WriteLine("Timing: " + unitNumerator.ToString() + "/" + unitDenominator.ToString());

            string[] args;

            if (inArgs.Length > 0)
            {
                args = Subfolder.Parse(inArgs);
            }
            else
            {
                args = inArgs;
            }

            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
            }

            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: Render2DX <files..>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine();
                Console.WriteLine("You must have both the chart file (.1) and the sound file (.2dx).");
                Console.WriteLine("Supported formats:");
                Console.WriteLine("1, 2DX");
            }

            Sound[] sounds  = null;
            Chart[] charts  = null;
            bool    cancel  = false;
            string  outFile = null;

            foreach (string filename in args)
            {
                if (cancel)
                {
                    break;
                }

                if (File.Exists(filename))
                {
                    switch (Path.GetExtension(filename).ToUpper())
                    {
                    case @".1":
                        if (charts == null)
                        {
                            Console.WriteLine();
                            Console.WriteLine("Valid charts:");
                            outFile = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename));
                            using (MemoryStream mem = new MemoryStream(File.ReadAllBytes(filename)))
                            {
                                charts = Bemani1.Read(mem, unitNumerator, unitDenominator).Charts;
                                for (int i = 0; i < charts.Length; i++)
                                {
                                    if (charts[i] != null)
                                    {
                                        Console.Write(i.ToString() + "  ");
                                    }
                                }
                            }
                            Console.WriteLine();
                        }
                        break;

                    case @".2DX":
                        if (sounds == null)
                        {
                            using (MemoryStream mem = new MemoryStream(File.ReadAllBytes(filename)))
                            {
                                sounds = Bemani2DX.Read(mem).Sounds;
                            }
                        }
                        break;
                    }
                }
            }

            if (!cancel && (sounds != null) && (charts != null))
            {
                List <byte[]> rendered      = new List <byte[]>();
                List <int>    renderedIndex = new List <int>();

                for (int k = 0; k < charts.Length; k++)
                {
                    Chart chart = charts[k];

                    if (chart == null)
                    {
                        continue;
                    }

                    Console.WriteLine("Rendering " + k.ToString());
                    byte[] data = ChartRenderer.Render(chart, sounds);

                    int  renderedCount = rendered.Count;
                    int  matchIndex    = -1;
                    bool match         = false;

                    for (int i = 0; i < renderedCount; i++)
                    {
                        int renderedLength = rendered[i].Length;
                        if (renderedLength == data.Length)
                        {
                            byte[] renderedBytes = rendered[i];
                            match = true;
                            for (int j = 0; j < renderedLength; j++)
                            {
                                if (renderedBytes[j] != data[j])
                                {
                                    match = false;
                                    break;
                                }
                            }
                            if (match)
                            {
                                matchIndex = i;
                                break;
                            }
                        }
                    }

                    if (!match)
                    {
                        Console.WriteLine("Writing unique " + k.ToString());
                        File.WriteAllBytes(outFile + "-" + Util.ConvertToDecimalString(k, 2) + ".wav", data);
                        rendered.Add(data);
                        renderedIndex.Add(k);
                    }
                    else
                    {
                        Console.WriteLine("Matches " + renderedIndex[matchIndex].ToString());
                    }
                }
            }
        }
コード例 #13
0
ファイル: BemaniToSM.cs プロジェクト: heshuimu/scharfrichter
        static public void Convert(string[] inArgs)
        {
            // configuration
            Configuration config = LoadConfig();

            // splash
            Splash.Show("Bemani To Stepmania");

            // parse args
            string[] args;
            if (inArgs.Length > 0)
            {
                args = Subfolder.Parse(inArgs);
            }
            else
            {
                args = inArgs;
            }

            // usage if no args present
            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: BemaniToSM <input file>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine();
                Console.WriteLine("Supported formats:");
                Console.WriteLine("SSQ, XWB");
            }

            // process
            foreach (string filename in args)
            {
                if (File.Exists(filename))
                {
                    Console.WriteLine();
                    Console.WriteLine("Processing File: " + filename);
                    switch (Path.GetExtension(filename).ToUpper())
                    {
                    case @".XWB":
                    {
                        using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        {
                            Console.WriteLine("Reading XWB bank");
                            MicrosoftXWB bank    = MicrosoftXWB.Read(fs);
                            string       outPath = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename));

                            Directory.CreateDirectory(outPath);

                            int count = bank.SoundCount;

                            for (int i = 0; i < count; i++)
                            {
                                string outFileName;

                                if ((bank.Sounds[i].Name == null) || (bank.Sounds[i].Name == ""))
                                {
                                    outFileName = Util.ConvertToHexString(i, 4);
                                }
                                else
                                {
                                    outFileName = bank.Sounds[i].Name;
                                }

                                string outFile = Path.Combine(outPath, outFileName + ".wav");
                                Console.WriteLine("Writing " + outFile);
                                bank.Sounds[i].WriteFile(outFile, 1.0f);
                            }

                            bank = null;
                        }
                    }
                    break;

                    case @".SSQ":
                    {
                        string outTitle = Path.GetFileNameWithoutExtension(filename);
                        string outFile  = Path.Combine(Path.GetDirectoryName(filename), Path.GetFileNameWithoutExtension(filename) + ".SM");

                        Console.WriteLine();
                        Console.WriteLine("Processing file " + filename);

                        using (FileStream fs = new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                        {
                            BemaniSSQ   ssq = BemaniSSQ.Read(fs, 0x1000);
                            StepmaniaSM sm  = new StepmaniaSM();

                            sm.Tags["TITLE"]          = outTitle;
                            sm.Tags["ARTIST"]         = "";
                            sm.Tags["TITLETRANSLIT"]  = "";
                            sm.Tags["ARTISTTRANSLIT"] = "";
                            sm.Tags["CDTITLE"]        = "";
                            sm.Tags["BANNER"]         = outTitle + ".png";
                            sm.Tags["BACKGROUND"]     = outTitle + "-bg.png";
                            sm.Tags["OFFSET"]         = "0.000";
                            sm.Tags["SAMPLELENGTH"]   = "14.000";

                            sm.CreateTempoTags(ssq.TempoEntries.ToArray());

                            foreach (Chart chart in ssq.Charts)
                            {
                                string gameType   = config["SM"]["DanceMode" + chart.Tags["Panels"]];
                                string difficulty = config["SM"]["Difficulty" + config["DDR"]["Difficulty" + chart.Tags["Difficulty"]]];
                                chart.Entries.Sort();

                                // solo chart check
                                if (gameType == config["SM"]["DanceMode6"])
                                {
                                    foreach (Entry entry in chart.Entries)
                                    {
                                        if (entry.Type == EntryType.Marker)
                                        {
                                            switch (entry.Column)
                                            {
                                            case 0: entry.Column = 0; break;

                                            case 1: entry.Column = 2; break;

                                            case 2: entry.Column = 3; break;

                                            case 3: entry.Column = 5; break;

                                            case 4: entry.Column = 1; break;

                                            case 6: entry.Column = 4; break;
                                            }
                                        }
                                    }
                                }

                                // couples chart check
                                else if (gameType == config["SM"]["DanceMode4"])
                                {
                                    foreach (Entry entry in chart.Entries)
                                    {
                                        if (entry.Type == EntryType.Marker && entry.Column >= 4)
                                        {
                                            gameType             = config["SM"]["DanceModeCouple"];
                                            chart.Tags["Panels"] = "8";
                                            break;
                                        }
                                    }
                                }

                                sm.CreateStepTag(chart.Entries.ToArray(), gameType, "", difficulty, "0", "", System.Convert.ToInt32(chart.Tags["Panels"]), config["SM"].GetValue("QuantizeNotes"));
                            }

                            sm.WriteFile(outFile);
                        }
                    }
                    break;
                    }
                }
            }
        }
コード例 #14
0
        static public void Convert(string[] inArgs, long unitNumerator, long unitDenominator, bool idUseRenderAutoTip = false)
        {
            // configuration
            Configuration config          = Configuration.LoadIIDXConfig(Common.configFileName);
            Configuration db              = Common.LoadDB();
            int           quantizeMeasure = config["BMS"].GetValue("QuantizeMeasure");
            int           quantizeNotes   = config["BMS"].GetValue("QuantizeNotes");

            // splash
            Splash.Show("Bemani to BeMusic Script");
            Console.WriteLine("Timing: " + unitNumerator.ToString() + "/" + unitDenominator.ToString());
            Console.WriteLine("Measure Quantize: " + quantizeMeasure.ToString());

            // args
            string[] args;
            if (inArgs.Length > 0)
            {
                args = Subfolder.Parse(inArgs);
            }
            else
            {
                args = inArgs;
            }

            // debug args (if applicable)
            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
            }

            // show usage if no args provided
            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: BemaniToBMS <input file>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine();
                Console.WriteLine("Supported formats:");
                Console.WriteLine("1, 2DX, S3P, CS, SD9, SSP");
            }

            string output = config["BMS"]["Output"];

            // process files
            for (int i = 0; i < args.Length; i++)
            {
                try
                {
                    if (File.Exists(args[i]))
                    {
                        Console.WriteLine();
                        Console.WriteLine("Processing File: " + args[i]);
                        string filename = args[i];
                        if (output == "")
                        {
                            output = Path.GetDirectoryName(filename) + "\\";
                        }

                        string IIDXDBName = Path.GetFileNameWithoutExtension(filename);
                        string version    = IIDXDBName.Substring(0, 2);
                        bool   isPre2DX   = false;
                        string INDEX      = null;
                        if (IIDXDBName.Contains("pre"))
                        {
                            isPre2DX   = true;
                            IIDXDBName = IIDXDBName.Substring(0, 5);
                        }
                        if (IIDXDBName.Length > 5)
                        {
                            INDEX      = IIDXDBName.Substring(5);
                            IIDXDBName = IIDXDBName.Substring(0, 5);
                        }
                        while (IIDXDBName.StartsWith("0"))
                        {
                            IIDXDBName = IIDXDBName.Substring(1);
                        }

                        byte[] data = File.ReadAllBytes(args[i]);
                        switch (Path.GetExtension(args[i]).ToUpper())
                        {
                        case @".1":
                            using (MemoryStream source = new MemoryStream(data))
                            {
                                Dictionary <int, int> ignore = new Dictionary <int, int>();
                                if (idUseRenderAutoTip)
                                {
                                    Console.WriteLine("Convert AutoTips");
                                    Console.WriteLine(args[i].Remove(args[i].Length - 8));
                                    string[] files = System.IO.Directory.GetFiles(args[i].Remove(args[i].Length - 8), "*", SearchOption.AllDirectories);
                                    Render.RenderWAV(files, 1, 1000, true);

                                    ignore.Add(3, 3);
                                }
                                Bemani1 archive = Bemani1.Read(source, unitNumerator, unitDenominator, ignore);

                                if (db[IIDXDBName]["TITLE"] != "")
                                {
                                    for (int j = 0; j < archive.ChartCount; j++)
                                    {
                                        Chart chart = archive.Charts[j];
                                        if (chart != null)
                                        {
                                            chart.Tags["TITLE"]      = db[IIDXDBName]["TITLE"];
                                            chart.Tags["ARTIST"]     = db[IIDXDBName]["ARTIST"];
                                            chart.Tags["GENRE"]      = db[IIDXDBName]["GENRE"];
                                            chart.Tags["VIDEO"]      = db[IIDXDBName]["VIDEO"];
                                            chart.Tags["VIDEODELAY"] = db[IIDXDBName]["VIDEODELAY"];
                                            if (j < 6)
                                            {
                                                chart.Tags["PLAYLEVEL"]          = db[IIDXDBName]["DIFFICULTYSP" + config["IIDX"]["DIFFICULTY" + j.ToString()]];
                                                chart.Tags["KEYSET"]             = db[IIDXDBName]["KEYSETSP" + config["IIDX"]["DIFFICULTY" + j.ToString()]];
                                                chart.Tags["ISUSERENDERAUTOTIP"] = idUseRenderAutoTip.ToString();
                                            }
                                            else if (j < 12)
                                            {
                                                chart.Tags["PLAYLEVEL"]          = db[IIDXDBName]["DIFFICULTYDP" + config["IIDX"]["DIFFICULTY" + j.ToString()]];
                                                chart.Tags["KEYSET"]             = db[IIDXDBName]["KEYSETDP" + config["IIDX"]["DIFFICULTY" + j.ToString()]];
                                                chart.Tags["ISUSERENDERAUTOTIP"] = idUseRenderAutoTip.ToString();
                                            }
                                        }
                                    }
                                }

                                ConvertArchive(archive, config, args[i], version, idUseRenderAutoTip);
                            }
                            break;

                        case @".2DX":
                            using (MemoryStream source = new MemoryStream(data))
                            {
                                Console.WriteLine("Converting Samples");
                                Bemani2DX archive = Bemani2DX.Read(source);


                                float  volume = 0.6f;
                                string title  = "";
                                if (db[IIDXDBName]["TITLE"] != "")
                                {
                                    volume = float.Parse(db[IIDXDBName]["VOLUME"]) / 127.0f;
                                    title  = db[IIDXDBName]["TITLE"];
                                }
                                ConvertSounds(archive.Sounds, filename, volume, INDEX, output, title, isPre2DX, version);
                            }
                            break;

                        case @".S3P":
                            using (MemoryStream source = new MemoryStream(data))
                            {
                                Console.WriteLine("Converting Samples");
                                BemaniS3P archive = BemaniS3P.Read(source);

                                float  volume = 0.6f;
                                string title  = "";
                                if (db[IIDXDBName]["TITLE"] != "")
                                {
                                    volume = float.Parse(db[IIDXDBName]["VOLUME"]) / 127.0f;
                                    title  = db[IIDXDBName]["TITLE"];
                                }
                                ConvertSounds(archive.Sounds, filename, volume, INDEX, output, title, isPre2DX, version);
                            }
                            break;

                        case @".CS":
                            using (MemoryStream source = new MemoryStream(data))
                                ConvertChart(BeatmaniaIIDXCSNew.Read(source), config, filename, -1, null);
                            break;

                        case @".CS2":
                            using (MemoryStream source = new MemoryStream(data))
                                ConvertChart(BeatmaniaIIDXCSOld.Read(source), config, filename, -1, null);
                            break;

                        case @".CS5":
                            using (MemoryStream source = new MemoryStream(data))
                                ConvertChart(Beatmania5Key.Read(source), config, filename, -1, null);
                            break;

                        case @".CS9":
                            break;

                        case @".SD9":
                            using (MemoryStream source = new MemoryStream(data))
                            {
                                Sound  sound      = BemaniSD9.Read(source);
                                string targetFile = Path.GetFileNameWithoutExtension(filename);
                                string targetPath = Path.Combine(Path.GetDirectoryName(filename), targetFile) + ".wav";
                                sound.WriteFile(targetPath, 1.0f);
                            }
                            break;

                        case @".SSP":
                            using (MemoryStream source = new MemoryStream(data))
                                ConvertSounds(BemaniSSP.Read(source).Sounds, filename, 1.0f);
                            break;
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("{0} Exception caught." + args[i], e);
                }
            }

            // wrap up
            Console.WriteLine("BemaniToBMS finished.");
        }
コード例 #15
0
        static public void Convert(string[] inArgs, long unitNumerator, long unitDenominator, bool idUseRenderAutoTip = false)
        {
            // configuration
            Configuration config          = Configuration.LoadIIDXConfig(Common.configFileName);
            Configuration db              = Common.LoadDB();
            int           quantizeMeasure = config["BMS"].GetValue("QuantizeMeasure");
            int           quantizeNotes   = config["BMS"].GetValue("QuantizeNotes");

            // splash
            Splash.Show("Chuni to Sus Script");
            Console.WriteLine("Timing: " + unitNumerator.ToString() + "/" + unitDenominator.ToString());
            Console.WriteLine("Measure Quantize: " + quantizeMeasure.ToString());

            // args
            string[] args;
            if (inArgs.Length > 0)
            {
                args = Subfolder.Parse(inArgs);
            }
            else
            {
                args = inArgs;
            }

            // debug args (if applicable)
            if (System.Diagnostics.Debugger.IsAttached && args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Debugger attached. Input file name:");
                args = new string[] { Console.ReadLine() };
            }

            // show usage if no args provided
            if (args.Length == 0)
            {
                Console.WriteLine();
                Console.WriteLine("Usage: ChuniToSus <input file>");
                Console.WriteLine();
                Console.WriteLine("Drag and drop with files and folders is fully supported for this application.");
                Console.WriteLine();
                Console.WriteLine("Supported formats:");
                Console.WriteLine("C2S");
            }

            string output = config["BMS"]["Output"];

            // process files
            for (int i = 0; i < args.Length; i++)
            {
                if (File.Exists(args[i]))
                {
                    Console.WriteLine();
                    Console.WriteLine("Processing File: " + args[i]);
                    string filename = args[i];

                    byte[] data = File.ReadAllBytes(args[i]);
                    switch (Path.GetExtension(args[i]).ToUpper())
                    {
                    case @".C2S":
                        // Find ID
                        string fileName = Path.GetFileName(filename);
                        // Read Music file
                        string   C2sDir        = Path.GetDirectoryName(filename) + "\\";
                        XElement musicXml      = XElement.Load(Path.Combine(C2sDir, "Music.xml"));
                        string   id            = musicXml.Element("name").Element("id").Value;
                        string   title         = musicXml.Element("name").Element("str").Value;
                        string   artist        = musicXml.Element("artistName").Element("str").Value;
                        string   genre         = musicXml.Element("genreNames").Element("list").Element("StringID").Element("str").Value;
                        var      boxedLunchRow = musicXml.Element("fumens").Elements("MusicFumenData");

                        Dictionary <string, MusicData> musicData = new Dictionary <string, MusicData>();
                        foreach (XElement boxedLunchElement in boxedLunchRow)
                        {
                            if (boxedLunchElement.Element("file").Element("path").Value != "")
                            {
                                if (boxedLunchElement.Element("type").Element("id").Value == "4")
                                {
                                    musicData.Add(
                                        boxedLunchElement.Element("file").Element("path").Value,
                                        new MusicData()
                                    {
                                        type     = boxedLunchElement.Element("type").Element("id").Value + ":" + musicXml.Element("worldsEndTagName").Element("str").Value,
                                        typeName = boxedLunchElement.Element("type").Element("data").Value,
                                        level    = musicXml.Element("starDifType").Value
                                    }
                                        );
                                }
                                else
                                {
                                    musicData.Add(
                                        boxedLunchElement.Element("file").Element("path").Value,
                                        new MusicData()
                                    {
                                        type     = boxedLunchElement.Element("type").Element("id").Value,
                                        typeName = boxedLunchElement.Element("type").Element("data").Value,
                                        level    = boxedLunchElement.Element("level").Value
                                    }
                                        );
                                }
                            }
                        }

                        System.IO.StreamReader file = new System.IO.StreamReader(args[i]);
                        ChuniC2S   archive          = ChuniC2S.Read(file, unitNumerator, unitDenominator);
                        ChartChuni chart            = archive.chart;
                        chart.Tags["ID"]        = id;
                        chart.Tags["TITLE"]     = title;
                        chart.Tags["ARTIST"]    = artist;
                        chart.Tags["GENRE"]     = genre;
                        chart.Tags["PLAYLEVEL"] = musicData[fileName].level;
                        chart.Tags["TYPE"]      = musicData[fileName].type;
                        chart.Tags["TYPENAME"]  = musicData[fileName].typeName;

                        ConvertChart(chart, config, filename, 1, null, "1");
                        break;

                    case @".DDS":
                        // Find ID
                        fileName = Path.GetFileName(filename);
                        // Read Music file
                        C2sDir   = Path.GetDirectoryName(filename) + "\\";
                        musicXml = XElement.Load(Path.Combine(C2sDir, "Music.xml"));
                        title    = musicXml.Element("name").Element("str").Value;
                        genre    = musicXml.Element("genreNames").Element("list").Element("StringID").Element("str").Value;

                        DDSImage img = new DDSImage(filename);

                        string dirPath = Path.Combine(config["BMS"]["Output"], Common.nameReplace(genre), Common.nameReplace(title), "jacket.jpg");
                        img.Save(dirPath);

                        break;
                    }
                }
            }

            // wrap up
            Console.WriteLine("BemaniToBMS finished.");
        }