示例#1
0
        /// <summary>
        /// flac > wav > split > gain
        /// </summary>
        /// <param name="flist"></param>
        public static void JobWavSplitGain(CommandJobData j)
        {
            foreach (var f in j.fileInfoList)
            {
                var filepath = f.filepath;

                if (filepath.Contains(".flac"))
                {
                    var f1 = filepath.GetDirectory().changeShortPath() + "\\" + filepath.getFileName();
                    var f2 = MainWindowHelper.ChangeOutputFileName(j.outputDir, filepath, "wav");
                    StartProcess(
                        "flac",
                        "-d {0} -o {1}".format(f1.quote(), f2.quote()));

                    filepath = filepath.replace(".flac", ".wav");
                }

                Helper.SetCurrentDirectory(filepath.GetDirectory());

                var outputDir = selectOutputDir(j.outputDir, filepath).changeShortPath();
                var wavdir    = outputDir + "\\" + filepath.GetBaseName() + "_WAV";

                MessageProcessStatus("splitWav ...");
                SplitWav(wavdir, filepath);

                //分割WavをCueSheetを元にリネーム
                MessageProcessStatus("applyWavDirCueSheet ...");
                ApplyWavDirCueSheet(wavdir, filepath);

                var files = Directory.GetFiles(wavdir, "*", System.IO.SearchOption.AllDirectories)
                            .Where(a => a.getExt() == ".wav")
                            .ToArray();

                foreach (var ff in  files)
                {
                    Debug.Log(ff);
                }

                //parallelCommand( flist, ( i, fileinfo, outputDir ) => {
                //}
                int num = 0;

                Parallel.For(0, files.Length, MainWindow.m_parallelOptions, i => {
                    try {
                        num++;
                        MessageProcessStatus($"処理中... ({num}/{files.Length})");
                        StartProcess("WaveGain", "-r -y {0}".format(files[i].quote()));
                    }
                    catch (Exception e) {
                        MainWindowHelper.SetExceptionLog(e);
                    }
                });
            }

            MessageProcessComplete(@"「WavSplitGain」が完了しました");
        }
示例#2
0
 static void RunParallel(CommandJobData j, Action <int, MediaFileInfo, string> func)
 {
     Parallel.For(0, j.fileInfoList.Count, MainWindow.m_parallelOptions, i => {
         try {
             func(i, j.fileInfoList[i], j.outputDir);
         }
         catch (Exception e) {
             MainWindowHelper.SetExceptionLog(e);
         }
     });
 }
示例#3
0
文件: Config.cs 项目: hananoki/MMConv
 public void ReadSettingJson(string filepath, Action complete = null)
 {
     try {
         using (var st = new StreamReader(filepath)) {
             MainWindow.m_config = LitJson.JsonMapper.ToObject <Config>(st.ReadToEnd());
         }
         complete?.Invoke();
     }
     catch (FileNotFoundException) {
         Debug.Log($"FileNotFoundException: {filepath} が見つかりません、デフォルト動作になります");
     }
     catch (Exception e) {
         MainWindowHelper.SetExceptionLog(e);
     }
 }
示例#4
0
        /// <summary>
        /// 分割WavをCueSheetを元にリネーム
        /// </summary>
        /// <param name="filepath"></param>
        static void ApplyWavDirCueSheet(string outputDir, string filepath)
        {
            var fdir = outputDir;

            var cue = new CueSheet();

            cue.read(filepath.ChangeExtention("cue"));

            string[] wavs = Directory.GetFiles(fdir, "*.wav", System.IO.SearchOption.TopDirectoryOnly);

            wavs = wavs.Where(a => !a.Contains("split-track00")).ToArray();
            //Array.Find( wavs, a => a == "split-track00" );

            bool allow = false;

            if (0 == wavs.Length || 0 == cue.Count)
            {
                allow = true;

                MessageProcessStatus("分割");
                return;
            }
            if (allow == false && wavs.Length != cue.Count)
            {
                MessageProcessComplete("error");
                return;
            }

            // リネーム用のリストがない場合は終了
            if (cue.Count == 0)
            {
                return;
            }

            foreach (var f in wavs)
            {
                foreach (Match match in Regex.Matches(f, "(split-track)([0-9]+)"))
                {
                    try {
                        int            i     = int.Parse(match.Groups[2].Value);
                        CueSheet.Track track = cue[i - 1];
                        string         title = track.title;
                        title = title.Replace("/", "/");
                        title = title.Replace("?", "?");
                        title = title.Replace("\\", "¥");
                        title = title.Replace("*", "*");
                        title = title.Replace(":", ":");
                        title = title.Replace("\"", "”");
                        title = title.Replace("<", "<");
                        title = title.Replace(">", ">");
                        title = title.Replace("|", "|");

                        try {
                            TagInfo tag1 = Tsukikage.DllPInvoke.MP3Tag.MP3Infp.LoadTag(f);
                            tag1.Album        = cue.m_title;
                            tag1.Artist       = track.performer;
                            tag1.Title        = track.title;
                            tag1.Genre        = cue.m_genre;
                            tag1.CreationDate = cue.m_date;
                            tag1.TrackNumber  = i.ToString();
                            Tsukikage.DllPInvoke.MP3Tag.MP3Infp.SaveTagInfoUnicode(tag1);
                        }
                        catch (Exception e) {
                            MainWindowHelper.SetExceptionLog(e);
                        }
                        var ss = Regex.Replace(f, "(split-track[0-9]+)", match.Groups[2].Value + " " + title);
                        //	println( titleList[i-1] );
                        //	var invalidChars = Path.GetInvalidFileNameChars();
                        //	var removed = string.Concat(original.Where(c => !invalidChars.Contains(c)));
                        File.Move(f, ss);
                    }
                    catch (Exception e) {
                        MainWindowHelper.SetExceptionLog(e);
                    }
                }
            }
        }