Ejemplo n.º 1
0
        bool ExportClip(SaintCoinach.Sound.ScdFile sScdFile, string targetFileName)
        {
            for (var i = 0; i < sScdFile.ScdHeader.EntryCount; i++)
            {
                var sEntry = sScdFile.Entries[i];
                if (sEntry == null)
                {
                    continue;
                }

                var baseFileName = Path.Combine("output\\input.ogg");
                File.WriteAllBytes(baseFileName, sEntry.GetDecoded());

                var ffmpeg = new Process();
                ffmpeg.StartInfo             = new ProcessStartInfo(Config.FfmpegPath, "-ss 00:00:10.0 -t 00:00:15.0 -i output\\input.ogg -acodec libvorbis -b:a 32k output\\output.ogg");
                ffmpeg.StartInfo.WindowStyle = ProcessWindowStyle.Minimized;
                ffmpeg.Start();
                ffmpeg.WaitForExit();

                File.Move("output\\output.ogg", targetFileName);

                return(true);
            }

            return(false);
        }
Ejemplo n.º 2
0
        void ExportOrchestrionMusic(int orchestrionId, dynamic orchestrion)
        {
            // Skip if the file is already exported.
            var targetFileName = Path.Combine(_resultMusicPath, orchestrionId + ".ogg");

            if (File.Exists(targetFileName))
            {
                return;
            }

            var sOrchestrionPaths = _builder.Sheet("OrchestrionPath");
            var sPath             = sOrchestrionPaths[orchestrionId];
            var filePath          = sPath.AsString("File").ToString();

            if (!_builder.Realm.Packs.TryGetFile(filePath, out var sFile))
            {
                return;
            }

            var sScdFile = new SaintCoinach.Sound.ScdFile(sFile);

            if (!ExportClip(sScdFile, targetFileName))
            {
                DatabaseBuilder.PrintLine($"No SCD headers for orchestrion #{orchestrionId} {orchestrion.name}");
            }
        }
Ejemplo n.º 3
0
        private static bool ExportFile(string filePath, string suffix)
        {
            if (!Realm.realm.Packs.TryGetFile(filePath, out var file))
            {
                return(false);
            }

            var scdFile = new SaintCoinach.Sound.ScdFile(file);
            var count   = 0;

            for (var i = 0; i < scdFile.ScdHeader.EntryCount; ++i)
            {
                var e = scdFile.Entries[i];
                if (e == null)
                {
                    continue;
                }

                var fileNameWithoutExtension = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(filePath), System.IO.Path.GetFileNameWithoutExtension(filePath));
                if (suffix != null)
                {
                    fileNameWithoutExtension += "-" + suffix;
                }
                if (++count > 1)
                {
                    fileNameWithoutExtension += "-" + count;
                }

                var targetPath = System.IO.Path.Combine(Realm.realm.GameVersion, fileNameWithoutExtension);

                switch (e.Header.Codec)
                {
                case SaintCoinach.Sound.ScdCodec.MSADPCM:
                    targetPath += ".wav";
                    break;

                case SaintCoinach.Sound.ScdCodec.OGG:
                    targetPath += ".ogg";
                    break;

                default:
                    throw new NotSupportedException();
                }

                var fInfo = new System.IO.FileInfo(targetPath);

                if (!fInfo.Directory.Exists)
                {
                    fInfo.Directory.Create();
                }
                System.IO.File.WriteAllBytes(fInfo.FullName, e.GetDecoded());
            }

            return(true);
        }