Пример #1
0
        public void BeginSplit(CueSongInfo info)
        {
            long mstart = info.StartTime.ToMiliSeconds();
            long mend   = info.EndTime.ToMiliSeconds();

            newFileName = path + "\\" + info.FileName + ".wav";
            string newfilename = "\"" + path + "\\" + info.FileName + ".wav\"";

            long startpos = mstart / 1000 * bytesPerSec + bytesPerSec / 1000 * (mstart % 1000);
            long endpos   = mend / 1000 * bytesPerSec + bytesPerSec / 1000 * (mend % 1000);

            if (endpos == 0)
            {
                endpos = fileSize;
            }
            Split(startpos, endpos, newFileName);
            //ProcessStartInfo psi = new ProcessStartInfo(exename);
            //psi.Arguments = "\""+filename + "\" " + mstart.ToString() +
            //    " " + mend.ToString () + " "+newfilename;
            //psi.UseShellExecute = false;
            //psi.WindowStyle = ProcessWindowStyle.Hidden;
            //psi.RedirectStandardOutput = true;
            //psi.CreateNoWindow = true;
            //psi.RedirectStandardError = true;

            //process.StartInfo = psi;
            //process.ErrorDataReceived += new DataReceivedEventHandler(process_ErrorDataReceived);
            //process.OutputDataReceived += new DataReceivedEventHandler(process_OutputDataReceived);

            //process.Start();
            //process.BeginOutputReadLine();
            //process.BeginErrorReadLine();
        }
Пример #2
0
        public IList <CueSongInfo> ReadAllSounds()
        {
            CueSongInfo  model  = new CueSongInfo();
            StreamReader reader = new StreamReader(cuefile, Encoding.Default);

            while (!reader.EndOfStream)
            {
                string str      = reader.ReadLine().Trim();
                int    splitpos = str.IndexOf(' ');
                string cmd      = str.Substring(0, splitpos).ToUpper();
                string value    = str.Substring(splitpos).Replace('\"', ' ').Trim();

                switch (cmd)
                {
                case "TRACK":
                    int t = 0;
                    if (int.TryParse(value.Substring(0, 2), out t))
                    {
                        model.Track = t;
                    }
                    CueSongInfo song = ReadTrackInfo(reader, model);
                    songs.Add(song);
                    break;

                case "TITLE":
                    model.Album = value.Trim();
                    break;

                case "PERFORMER":
                    model.Artist = value.Trim();
                    break;

                case "FILE":
                    this.audioFile = value.Substring(0, value.LastIndexOf(' ')).Trim();
                    break;

                case "REM":
                    string v2cmd   = value.Substring(0, value.IndexOf(' ')).ToUpper();
                    string v2value = value.Substring(value.IndexOf(' '));
                    if (v2cmd == "DATE")
                    {
                        model.Year = v2value.Trim();
                    }
                    else if (v2cmd == "GENRE")
                    {
                        model.Genre = v2value.Trim();
                    }
                    break;
                }
            }

            (songs as List <CueSongInfo>).Sort();
            AdjustTime();

            return(songs);
        }
Пример #3
0
 public Mp3Converter(string wavfile, CueSongInfo info)
 {
     this.filename = wavfile;
     newname       = System.IO.Path.ChangeExtension(wavfile, "mp3");
     this.songinfo = info;
     InitStartInfo();
     regexLine = new Regex(
         @"(\d+)/(\d+)\D+(\d+)\D+([\d:]+)\D+([\d:]+)\D+([\d:]+)\D+([\d:]+)\D+([\d\.]+)\D+([\d:]+)",
         RegexOptions.IgnoreCase | RegexOptions.CultureInvariant |
         RegexOptions.IgnorePatternWhitespace | RegexOptions.Compiled);
 }
Пример #4
0
        private CueSongInfo ReadTrackInfo(StreamReader reader, CueSongInfo model)
        {
            CueSongInfo info = model.Clone() as CueSongInfo;

            while (!reader.EndOfStream)
            {
                string str = reader.ReadLine().Trim();
                if (string.IsNullOrEmpty(str))
                {
                    continue;
                }
                int    splitpos = str.IndexOf(' ');
                string cmd      = str.Substring(0, splitpos).ToUpper();
                string value    = str.Substring(splitpos).Replace('\"', ' ').Trim();

                switch (cmd)
                {
                case "TITLE":
                    info.Title = value.Trim();
                    break;

                case "PERFORMER":
                    info.Artist = value.Trim();
                    break;

                case "GERNE":
                    info.Genre = value.Trim();
                    break;

                case "YEAR":
                    info.Year = value.Trim();
                    break;

                case "ISRC":
                    info.Isrc = value.Trim();
                    break;

                case "INDEX":
                    int     timesplit = value.IndexOf(' ');
                    string  type      = value.Substring(0, timesplit);
                    string  tstr      = value.Substring(timesplit).Trim();
                    CueTime time      = new CueTime(0, 0, 0);
                    if (CueTime.TryParse(tstr, out time))
                    {
                        if (type == "01")
                        {
                            info.StartTime = time;
                        }
                        else
                        {
                            info.EndTime = time;
                        }
                    }


                    break;

                case "REM":
                    string v2cmd   = value.Substring(0, value.IndexOf(' ')).ToUpper();
                    string v2value = value.Substring(value.IndexOf(' '));
                    if (v2cmd == "DATE")
                    {
                        model.Year = v2value.Trim();
                    }
                    else if (v2cmd == "GENRE")
                    {
                        model.Genre = v2value.Trim();
                    }
                    break;

                case "TRACK":
                    int t;
                    if (int.TryParse(value.Substring(0, 2), out t))
                    {
                        model.Track = t;
                    }
                    CueSongInfo song = ReadTrackInfo(reader, model);
                    songs.Add(song);
                    break;
                }
            }
            return(info);
        }