Ejemplo n.º 1
0
        internal void LoadDeck(int row)
        {
            CUEConfig _config  = (MdiParent as frmCUEPlayer).Config;
            DataSet1  dataSet  = (MdiParent as frmCUEPlayer).DataSet;
            Playlist  playlist = (MdiParent as frmCUEPlayer).wndPlaylist;
            string    path     = dataSet.Playlist[row].path;
            int       track    = dataSet.Playlist[row].track;

            try
            {
                playingCue = new CUESheet(_config);
                playingCue.Open(path);
                playingSource          = new CUESheetAudio(playingCue);
                playingSource.Position = (long)playingCue.TOC[track].Start * 588;
                playingSource          = new AudioPipe(playingSource, 0x2000);
                playingStart           = playingSource.Position;
                playingFinish          = playingStart + (long)playingCue.TOC[track].Length * 588;
                playingRow             = row;
                //playlist.List.Items[playingRow].BackColor = Color.AliceBlue;
                needUpdate = true;
                UpdateDeck();
            }
            catch (Exception ex)
            {
                playingStart  = playingFinish = 0;
                playingCue    = null;
                playingSource = null;
                return;
            }
        }
Ejemplo n.º 2
0
 private void buttonStop_Click(object sender, EventArgs e)
 {
     if (playThread != null)
     {
         stopNow = true;
         playThread.Join();
     }
     else
     {
         if (playingSource != null)
         {
             playingSource.Close();
             playingSource = null;
         }
         if (playingCue != null)
         {
             playingCue.Close();
             playingCue = null;
         }
         playingFinish = 0;
         playingStart  = 0;
         playingRow    = -1;
         needUpdate    = true;
         UpdateDeck();
     }
 }
Ejemplo n.º 3
0
        public void OpenCDExtra()
        {
            // test playstation-type CD-Extra
            CUESheet target = new CUESheet(new CUEConfig());

            target.Open("Circuitry\\1.cue");
            Assert.AreEqual <string>("-0:37001:70001:99814:126819:160976", target.TOC.ToString(), "Wrong TOC");

            // test playstation-type CD-Extra with nonstandard pregap
            target = new CUESheet(new CUEConfig());
            target.Open("Headcandy\\Headcandy.cue");
            Assert.AreEqual <string>("-0:141942:168581:223645:248699:279575:312824", target.TOC.ToString(), "Wrong TOC");

            // test playstation-type CD-Extra with no info in cuesheet
            target = new CUESheet(new CUEConfig());
            target.Open("Anatomy\\Anatomy.cue");
            Assert.AreEqual <string>("-0:19687:33144:50680:69872:89822:108084:132098:150625:166271:194882:200172:215884:236046:242815:269518:282018:293416", target.TOC.ToString(), "Wrong TOC");

            // test playstation-type CD-Extra with two data tracks
            target = new CUESheet(new CUEConfig());
            target.Open("Les Mysterieuses Cites d'Or\\Les Mysterieuses Cites d'Or.cue");
            Assert.AreEqual <string>("-0:-31952:127883:137816:149173:160223:171479:180777:186738:196134:205613:214526:221674:227031:232824:239376:249495:259604:266115:267080:275100:281599:284452:291422:295511:297642:302114:309263:312269:320051:326235:333841", target.TOC.ToString(), "Wrong TOC");

            // test playstation-type CD-Extra with two data tracks and no info in cuesheet
            target = new CUESheet(new CUEConfig());
            target.Open("Les Mysterieuses Cites d'Or\\2.cue");
            Assert.AreEqual <string>("-0:-31952:127883:137816:149173:160223:171479:180777:186738:196134:205613:214526:221674:227031:232824:239376:249495:259604:266115:267080:275100:281599:284452:291422:295511:297642:302114:309263:312269:320051:326235:333841", target.TOC.ToString(), "Wrong TOC");
        }
Ejemplo n.º 4
0
        public void OpenOneTrackCD()
        {
            // test one-track CD
            CUESheet target = new CUESheet(new CUEConfig());

            target.Open("Amarok\\Amarok.cue");
            Assert.AreEqual <string>("00041f6d-00083ece-020e1201", AccurateRipVerify.CalculateAccurateRipId(target.TOC), "Wrong TOC");
        }
Ejemplo n.º 5
0
 public static string GetAccurateRipLog(CUESheet sheet)
 {
     using (StringWriter stringWriter = new StringWriter())
     {
         WriteAccurateRipLog(sheet, stringWriter);
         return(stringWriter.ToString());
     }
 }
Ejemplo n.º 6
0
        public void OpenEnhancedCD()
        {
            // test Enhanced-CD
            CUESheet target = new CUESheet(new CUEConfig());

            target.Open("No Man's Land\\1.cue");
            Assert.AreEqual <string>("0015c42c-00d1e13f-ba0fe50d", AccurateRipVerify.CalculateAccurateRipId(target.TOC), "Wrong TOC");
        }
Ejemplo n.º 7
0
 public CUEToolsVerifyTask(CUESheet cueSheet, int start, int end, AccurateRipVerify ar)
     : this(cueSheet, start, end, ar, null)
 {
     if (cueSheet.Config.detectHDCD && CUEProcessorPlugins.hdcd != null)
     {
         try { this.hdcd = Activator.CreateInstance(CUEProcessorPlugins.hdcd, 2, 44100, 20, false) as IAudioDest; }
         catch { this.hdcd = null; }
     }
 }
Ejemplo n.º 8
0
 public CUESheetAudio(CUESheet cueSheet)
 {
     this.cueSheet      = cueSheet;
     this.currentAudio  = null;
     this._samplePos    = 0;
     this._sampleLen    = 0;
     this.currentSource = -1;
     this.nextPos       = 0;
     cueSheet._sources.ForEach(s => this._sampleLen += s.Length);
 }
Ejemplo n.º 9
0
        private void fileSystemTreeView1_NodeExpand(object sender, CUEControls.FileSystemTreeViewNodeExpandEventArgs e)
        {
            List <FileGroupInfo> fileGroups = CUESheet.ScanFolder(_config, e.files);

            foreach (FileGroupInfo fileGroup in fileGroups)
            {
                TreeNode node = fileSystemTreeView1.NewNode(fileGroup.main);
                if (fileGroup.type == FileGroupInfoType.TrackFiles)
                {
                    node.Text = node.Text + ": " + fileGroup.files.Count.ToString() + " files";
                }
                e.node.Nodes.Add(node);
            }
        }
Ejemplo n.º 10
0
        private static double GetRangeQuality(CUESheet sheet, uint start, uint length)
        {
            int retrySectorsCount = 0;

            for (int i = 0; i < (int)length; i++)
            {
                retrySectorsCount += sheet.CDRipper.RetryCount[(int)start - (int)sheet.TOC[sheet.TOC.FirstAudio][0].Start + i];
            }
#if LOGQ
            int max_scans = (16 << sheet.CDRipper.CorrectionQuality) - 1;
            return(100 * (1.0 - Math.Log(retrySectorsCount / 100.0 + 1) / Math.Log(max_scans * (int)length / 100.0 + 1)));
#else
            return(100.0 * (sheet.CDRipper.CorrectionQuality + 1) * length / retrySectorsCount);
#endif
        }
Ejemplo n.º 11
0
        private void listViewTracks_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetDataPresent(DataFormats.FileDrop))
            {
                string[] files = (string[])e.Data.GetData(DataFormats.FileDrop);
                if (files.Length == 1)
                {
                    string path = files[0];
                    try
                    {
                        CUESheet cue = new CUESheet(_config);
                        cue.Open(path);
                        for (int iTrack = 0; iTrack < cue.TrackCount; iTrack++)
                        {
                            DataSet1.PlaylistRow row = dataSet.Playlist.AddPlaylistRow(
                                path,
                                cue.Metadata.Artist,
                                cue.Metadata.Tracks[iTrack].Title,
                                cue.Metadata.Title,
                                (int)cue.TOC[cue.TOC.FirstAudio + iTrack].Length / 75,
                                iTrack + 1);
                            listViewTracks.Items.Add(ToItem(row));
                        }
                        cue.Close();
                        return;
                    }
                    catch (Exception ex)
                    {
                        Trace.WriteLine(ex.Message);
                    }

                    FileInfo fi = new FileInfo(path);
                    if (fi.Extension != ".cue")
                    {
                        DataSet1.PlaylistRow row = dataSet.Playlist.AddPlaylistRow(
                            path,
                            null,                          // cue.Artist,
                            null,                          // cue.Tracks[iTrack].Title,
                            null,                          // cue.Title,
                            0,                             // (int)cue.TOC[cue.TOC.FirstAudio + iTrack].Length / 75,
                            0);
                        listViewTracks.Items.Add(ToItem(row));
                    }
                }
            }
        }
Ejemplo n.º 12
0
        public static string GetTOCContents(CUESheet sheet)
        {
            StringWriter sw = new StringWriter();

            sw.WriteLine("     Track |   Start  |  Length  | Start sector | End sector ");
            sw.WriteLine("    ---------------------------------------------------------");
            for (int track = 1; track <= sheet.TOC.TrackCount; track++)
            {
                sw.WriteLine("{0,9}  | {1,8} | {2,8} |  {3,8}    | {4,8}   ",
                             track, // sheet.TOC[track].Number,
                             CDImageLayout.TimeToString("{0,2}:{1:00}.{2:00}", sheet.TOC[track].Start),
                             CDImageLayout.TimeToString("{0,2}:{1:00}.{2:00}", sheet.TOC[track].Length),
                             sheet.TOC[track].Start,
                             sheet.TOC[track].End);
            }
            return(sw.ToString());
        }
Ejemplo n.º 13
0
 private CUEToolsVerifyTask(CUESheet cueSheet, int start, int end, AccurateRipVerify ar, IAudioDest hdcd)
 {
     this.cueSheet = cueSheet;
     this.start    = start;
     this.end      = end;
     this.source   = new CUESheetAudio(cueSheet);
     if (cueSheet.IsCD || cueSheet.Config.separateDecodingThread)
     {
         this.source = new AudioPipe(this.source, 0x10000);
     }
     this.source.Position = start;
     this.ar   = cueSheet.IsUsingAccurateRip ? ar : null;
     this.hdcd = hdcd;
     if (this.ar != null)
     {
         this.ar.Position = start;
     }
 }
Ejemplo n.º 14
0
        /// <summary>
        /// CUEからCDオブジェクトを生成
        /// </summary>
        /// <param name="cue">CUEシート</param>
        /// <param name="cueFilename">CUEシートのファイル名。埋め込みの場合は音源ファイル名。</param>
        /// <param name="alternativeFilename">FILE命令の代替とする音源のファイル名。</param>
        /// <param name="readStream">音源のファイルまで読んで解析するかどうか。trueでないとビットレートや最終トラックの長さが取得できない</param>
        /// <returns>CDオブジェクト</returns>
        private static CD ConvertCue2CD(CUESheet cue, string cueFilename, string alternativeFilename = null, bool readStream = true)
        {
            var    cd           = new CD();
            var    info         = new StreamInfo();
            string lastFilename = null;

            CD.Track prevTrack = null, currentTrack = null;
            for (int i = 0; i < cue.Tracks.Count; i++)
            {
                var cueTr = cue.Tracks[i];
                if (cueTr.Type != Tags.CUESheet.TrackType.AUDIO)
                {
                    continue;
                }
                currentTrack = new CD.Track();
                var rootedFilename = (!Path.IsPathRooted(cueTr.Filename) ? Path.GetDirectoryName(cueFilename) + Path.DirectorySeparatorChar : "") + cueTr.Filename;
                if (rootedFilename != lastFilename)
                {
                    lastFilename = rootedFilename;
                    if (readStream)
                    {
                        info      = GetStreamInfo(alternativeFilename ?? rootedFilename);
                        cd.length = cd.length.Add(info.Length);
                    }
                }
                else if (prevTrack != null)
                {
                    prevTrack.End = cueTr.Index01.ToFrames;
                }
                /* Set Stream info */
                currentTrack.bitrate  = info.Bitrate;
                currentTrack.channels = info.Channels;
                currentTrack.freq     = info.Freq;

                currentTrack.Start              = cueTr.Index01.ToFrames;
                currentTrack.End                = (int)(info.LengthInSec * 75);
                currentTrack.file_name          = cueFilename + new String(' ', (i + 1));
                currentTrack.file_name_CUESheet = rootedFilename;

                /* Set track info to Tag */
                currentTrack.AddTag("TRACK", (i + 1).ToString());
                currentTrack.AddTag("TITLE", cueTr.Title);
                currentTrack.AddTag("ARTIST", cueTr.Performer);
                currentTrack.AddTag("COMMENT", cueTr.Comment);
                currentTrack.AddTag("ISRC", cueTr.Isrc);
                currentTrack.AddTag("TRACK GAIN", cueTr.Gain);
                currentTrack.AddTag("TRACK PEAK", cueTr.Peak);

                /* Set album info to Tag */
                currentTrack.AddTag("ALBUM", cue.Title);
                currentTrack.AddTag("ARTIST", cue.Performer);
                currentTrack.AddTag("ALBUM ARTIST", cue.Performer);
                currentTrack.AddTag("GENRE", cue.Genre);
                currentTrack.AddTag("DATE", cue.Date);
                currentTrack.AddTag("COMMENT", cue.Comment);
                currentTrack.AddTag("ALBUM GAIN", cue.Gain);
                currentTrack.AddTag("ALBUM PEAK", cue.Peak);

                cd.tracks.Add(currentTrack);
                prevTrack = currentTrack;
            }
            return(cd);
        }
Ejemplo n.º 15
0
 public ArchiveFileAbstraction(CUESheet cueSheet, string file)
 {
     name      = file;
     _cueSheet = cueSheet;
 }
Ejemplo n.º 16
0
 private void PlayThread()
 {
     try
     {
         do
         {
             if (playingSource == null)
             {
                 writer.Pause();
             }
             else
             {
                 if (seekTo >= 0 && playingStart + seekTo < playingFinish)
                 {
                     playingSource.Position = playingStart + seekTo;
                     seekTo = -1;
                 }
                 if (playingSource.Position == playingFinish || stopNow || seekTo == (int)(playingFinish - playingStart))
                 {
                     seekTo = -1;
                     playingSource.Close();
                     playingSource = null;
                     if (playingCue != null)
                     {
                         playingCue.Close();
                         playingCue = null;
                     }
                     playingFinish = 0;
                     playingStart  = 0;
                     playingRow    = -1;
                     if (stopNow || nextDeck == null || nextDeck.playingSource == null)
                     {
                         writer.Flush();
                         stopNow = false;
                         mixer.BufferPlaying(iSource, false);
                         needUpdate = true;
                         playThread = null;
                         return;
                     }
                     playingSource          = nextDeck.playingSource;
                     playingCue             = nextDeck.playingCue;
                     playingStart           = nextDeck.playingStart;
                     playingFinish          = nextDeck.playingFinish;
                     playingRow             = nextDeck.playingRow;
                     needUpdate             = true;
                     nextDeck.playingSource = null;
                     nextDeck.playingCue    = null;
                     nextDeck.playingStart  = 0;
                     nextDeck.playingFinish = 0;
                     nextDeck.playingRow    = -1;
                     nextDeck.needUpdate    = true;
                 }
                 if (buff == null || buff.PCM.SampleRate != playingSource.PCM.SampleRate || buff.PCM.ChannelCount != playingSource.PCM.ChannelCount || buff.PCM.BitsPerSample != playingSource.PCM.BitsPerSample)
                 {
                     buff = new AudioBuffer(playingSource.PCM, 0x2000);
                 }
                 playingSource.Read(buff, Math.Min(buff.Size, (int)(playingFinish - playingSource.Position)));
                 writer.Write(buff);
             }
         } while (true);
     }
     catch (Exception ex)
     {
     }
     if (playingCue != null)
     {
         playingCue.Close();
         playingCue = null;
     }
     if (playingSource != null)
     {
         playingSource.Close();
         playingSource = null;
     }
     playThread = null;
 }
Ejemplo n.º 17
0
        public static void WriteAccurateRipLog(CUESheet sheet, TextWriter writer)
        {
            writer.WriteLine("[CUETools log; Date: {0}; Version: {1}]", DateTime.Now, CUESheet.CUEToolsVersion);
            if (sheet.PreGapLength != 0)
            {
                writer.WriteLine("Pregap length {0}.", sheet.PreGapLengthMSF);
            }
            if (!sheet.TOC[1].IsAudio)
            {
                writer.WriteLine("Playstation type data track length {0}.", sheet.TOC[sheet.TOC.FirstAudio].StartMSF);
            }
            if (!sheet.TOC[sheet.TOC.TrackCount].IsAudio)
            {
                writer.WriteLine("CD-Extra data track length {0}.",
                                 sheet.TOC[sheet.TOC.TrackCount].Length == 0 && sheet.MinDataTrackLength.HasValue ?
                                 CDImageLayout.TimeToString(sheet.MinDataTrackLength.Value) + " - " + CDImageLayout.TimeToString(sheet.MinDataTrackLength.Value + 74) :
                                 sheet.TOC[sheet.TOC.TrackCount].LengthMSF);
            }
            if (sheet.CDDBDiscIdTag != null && AccurateRipVerify.CalculateCDDBId(sheet.TOC).ToUpper() != sheet.CDDBDiscIdTag.ToUpper() && !sheet.MinDataTrackLength.HasValue)
            {
                writer.WriteLine("CDDBId mismatch: {0} vs {1}", sheet.CDDBDiscIdTag.ToUpper(), AccurateRipVerify.CalculateCDDBId(sheet.TOC).ToUpper());
            }
            if (sheet.AccurateRipId != null && AccurateRipVerify.CalculateAccurateRipId(sheet.TOC) != sheet.AccurateRipId)
            {
                writer.WriteLine("Using preserved id, actual id is {0}.", AccurateRipVerify.CalculateAccurateRipId(sheet.TOC));
            }
            if (sheet.Truncated4608)
            {
                writer.WriteLine("Truncated 4608 extra samples in some input files.");
            }
            if (sheet.PaddedToFrame)
            {
                writer.WriteLine("Padded some input files to a frame boundary.");
            }

            if (!sheet.Processed)
            {
                if (sheet.IsUsingCUEToolsDB)
                {
                    sheet.GenerateCTDBLog(writer);
                }
                if (sheet.IsUsingAccurateRip)
                {
                    writer.WriteLine("[AccurateRip ID: {0}] {1}.", sheet.AccurateRipId ?? AccurateRipVerify.CalculateAccurateRipId(sheet.TOC), sheet.ArVerify.ARStatus ?? "found");
                }
                return;
            }

            if (sheet.HDCDDecoder != null && string.Format("{0:s}", sheet.HDCDDecoder) != "")
            {
                writer.WriteLine("HDCD: {0:f}", sheet.HDCDDecoder);
            }
            if (0 != sheet.WriteOffset)
            {
                writer.WriteLine("Offset applied: {0}", sheet.WriteOffset);
            }
            if (sheet.IsUsingCUEToolsDBFix)// && _CUEToolsDB.SelectedEntry != null)
            {
                writer.WriteLine("CUETools DB: corrected {0} errors.", sheet.CTDB.SelectedEntry.repair.CorrectableErrors);
            }
            else if (sheet.IsUsingCUEToolsDB)
            {
                sheet.GenerateCTDBLog(writer);
            }
            sheet.ArVerify.GenerateFullLog(writer, sheet.Config.arLogVerbose, sheet.AccurateRipId ?? AccurateRipVerify.CalculateAccurateRipId(sheet.TOC));
        }
Ejemplo n.º 18
0
 public CUEToolsVerifyTask(CUESheet cueSheet, int start, int end)
     : this(cueSheet, start, end, cueSheet.IsUsingAccurateRip || cueSheet.IsUsingCUEToolsDB ? new AccurateRipVerify(cueSheet.TOC, null) : null, null)
 {
 }
Ejemplo n.º 19
0
        public static string GetExactAudioCopyLog(CUESheet sheet)
        {
            StringWriter logWriter = new StringWriter(CultureInfo.InvariantCulture);
            string       eacHeader = "{7}\r\n" +
                                     "\r\n" +
                                     "EAC extraction logfile from {0:d'.' MMMM yyyy', 'H':'mm}\r\n" +
                                     "\r\n" +
                                     "{1} / {2}\r\n" +
                                     "\r\n" +
                                     "Used drive  : {3}   Adapter: 1  ID: 0\r\n" +
                                     "\r\n" +
                                     "Read mode               : {4}\r\n" +
                                     "Utilize accurate stream : Yes\r\n" +
                                     "Defeat audio cache      : Yes\r\n" +
                                     "Make use of C2 pointers : No\r\n" +
                                     "\r\n" +
                                     "Read offset correction                      : {5}\r\n" +
                                     "Overread into Lead-In and Lead-Out          : No\r\n" +
                                     "Fill up missing offset samples with silence : Yes\r\n" +
                                     "Delete leading and trailing silent blocks   : No\r\n" +
                                     "Null samples used in CRC calculations       : Yes\r\n" +
                                     "Used interface                              : Native Win32 interface for Win NT & 2000\r\n" +
                                     "{6}" +
                                     "\r\n" +
                                     "Used output format : Internal WAV Routines\r\n" +
                                     "Sample format      : 44.100 Hz; 16 Bit; Stereo\r\n";

            logWriter.WriteLine(eacHeader,
                                DateTime.Now,
                                sheet.Metadata.Artist, sheet.Metadata.Title,
                                sheet.CDRipper.EACName,
                                sheet.CDRipper.CorrectionQuality > 0 ? "Secure" : "Burst",
                                sheet.CDRipper.DriveOffset,
                                (sheet.OutputStyle == CUEStyle.SingleFile || sheet.OutputStyle == CUEStyle.SingleFileWithCUE) ? "" :
                                "Gap handling                                : " +
                                (sheet.CDRipper.GapsDetected ? "Appended to previous track\r\n" : "Not detected, thus appended to previous track\r\n"),
                                sheet.CDRipper.RipperVersion); // "Exact Audio Copy V0.99 prebeta 4 from 23. January 2008"

            logWriter.WriteLine();
            logWriter.WriteLine("TOC of the extracted CD");
            logWriter.WriteLine();
            logWriter.Write(GetTOCContents(sheet));
            logWriter.WriteLine();

            bool htoaToFile = ((sheet.OutputStyle == CUEStyle.GapsAppended) && sheet.Config.preserveHTOA &&
                               (sheet.TOC.Pregap != 0));
            int  accurateTracks = 0, knownTracks = 0;
            bool wereErrors = false;

            if (sheet.OutputStyle != CUEStyle.SingleFile && sheet.OutputStyle != CUEStyle.SingleFileWithCUE)
            {
                logWriter.WriteLine();
                for (int track = 0; track < sheet.TOC.AudioTracks; track++)
                {
                    logWriter.WriteLine("Track {0,2}", track + 1);
                    logWriter.WriteLine();
                    logWriter.WriteLine("     Filename {0}", Path.ChangeExtension(Path.GetFullPath(sheet.DestPaths[track + (htoaToFile ? 1 : 0)]), ".wav"));
                    if (sheet.TOC[track + sheet.TOC.FirstAudio].Pregap > 0 || track + sheet.TOC.FirstAudio == 1)
                    {
                        logWriter.WriteLine();
                        logWriter.WriteLine("     Pre-gap length  0:{0}.{1:00}", CDImageLayout.TimeToString("{0:00}:{1:00}", sheet.TOC[track + sheet.TOC.FirstAudio].Pregap + (track + sheet.TOC.FirstAudio == 1 ? 150U : 0U)), (sheet.TOC[track + sheet.TOC.FirstAudio].Pregap % 75) * 100 / 75);
                    }

                    wereErrors |= sheet.PrintErrors(logWriter, sheet.TOC[track + sheet.TOC.FirstAudio].Start, sheet.TOC[track + sheet.TOC.FirstAudio].Length);

                    logWriter.WriteLine();
                    logWriter.WriteLine("     Peak level {0:F1} %", (sheet.ArVerify.PeakLevel(track + 1) * 1000 / 65534) * 0.1);
                    logWriter.WriteLine("     Track quality {0:F1} %", GetRangeQuality(sheet, sheet.TOC[track + sheet.TOC.FirstAudio].Start, sheet.TOC[track + sheet.TOC.FirstAudio].Length));
                    if (sheet.ArTestVerify != null)
                    {
                        logWriter.WriteLine("     Test CRC {0:X8}", sheet.ArTestVerify.CRC32(track + 1));
                    }
                    logWriter.WriteLine("     Copy CRC {0:X8}", sheet.ArVerify.CRC32(track + 1));
                    if (sheet.ArVerify.Total(track) == 0)
                    {
                        logWriter.WriteLine("     Track not present in AccurateRip database");
                    }
                    else
                    {
                        knownTracks++;
                        if (sheet.ArVerify.Confidence(track) == 0)
                        {
                            logWriter.WriteLine("     Cannot be verified as accurate (confidence {0})  [{1:X8}], AccurateRip returned [{2:X8}]", sheet.ArVerify.Total(track), sheet.ArVerify.CRC(track), sheet.ArVerify.DBCRC(track));
                        }
                        else
                        {
                            logWriter.WriteLine("     Accurately ripped (confidence {0})  [{1:X8}]", sheet.ArVerify.Confidence(track), sheet.ArVerify.CRC(track));
                            accurateTracks++;
                        }
                    }
                    logWriter.WriteLine("     Copy OK");
                    logWriter.WriteLine();
                }
            }
            else
            {
                logWriter.WriteLine();
                logWriter.WriteLine("Range status and errors");
                logWriter.WriteLine();
                logWriter.WriteLine("Selected range");
                logWriter.WriteLine();
                logWriter.WriteLine("     Filename {0}", Path.ChangeExtension(Path.GetFullPath(sheet.DestPaths[0]), ".wav"));
                wereErrors = sheet.PrintErrors(logWriter, sheet.TOC[sheet.TOC.FirstAudio][0].Start, sheet.TOC.AudioLength);
                logWriter.WriteLine();
                logWriter.WriteLine("     Peak level {0:F1} %", (sheet.ArVerify.PeakLevel() * 1000 / 65535) * 0.1);
                logWriter.WriteLine("     Range quality {0:F1} %", GetRangeQuality(sheet, sheet.TOC[sheet.TOC.FirstAudio][0].Start, sheet.TOC.AudioLength));
                if (sheet.ArTestVerify != null)
                {
                    logWriter.WriteLine("     Test CRC {0:X8}", sheet.ArTestVerify.CRC32(0));
                }
                logWriter.WriteLine("     Copy CRC {0:X8}", sheet.ArVerify.CRC32(0));
                logWriter.WriteLine("     Copy OK");
                logWriter.WriteLine();
                if (wereErrors)
                {
                    logWriter.WriteLine("There were errors");
                }
                else
                {
                    logWriter.WriteLine("No errors occurred");
                }
                logWriter.WriteLine();
                logWriter.WriteLine();
                logWriter.WriteLine("AccurateRip summary");
                logWriter.WriteLine();
                for (int track = 0; track < sheet.TOC.AudioTracks; track++)
                {
                    if (sheet.ArVerify.Total(track) == 0)
                    {
                        logWriter.WriteLine("Track {0,2}  not present in database", track + 1);
                    }
                    else
                    {
                        knownTracks++;
                        if (sheet.ArVerify.Confidence(track) == 0)
                        {
                            logWriter.WriteLine("Track {3,2}  cannot be verified as accurate (confidence {0})  [{1:X8}], AccurateRip returned [{2:X8}]", sheet.ArVerify.Total(track), sheet.ArVerify.CRC(track), sheet.ArVerify.DBCRC(track), track + 1);
                        }
                        else
                        {
                            logWriter.WriteLine("Track {2,2}  accurately ripped (confidence {0})  [{1:X8}]", sheet.ArVerify.Confidence(track), sheet.ArVerify.CRC(track), track + 1);
                            accurateTracks++;
                        }
                    }
                }
            }
            logWriter.WriteLine();
            if (knownTracks == 0)
            {
                logWriter.WriteLine("None of the tracks are present in the AccurateRip database");
            }
            else if (accurateTracks == 0)
            {
                logWriter.WriteLine("No tracks could be verified as accurate");
                logWriter.WriteLine("You may have a different pressing from the one(s) in the database");
            }
            else if (accurateTracks == sheet.TrackCount)
            {
                logWriter.WriteLine("All tracks accurately ripped");
            }
            else
            {
                logWriter.WriteLine("{0,2} track(s) accurately ripped", accurateTracks);
                if (sheet.TrackCount - knownTracks > 0)
                {
                    logWriter.WriteLine("{0,2} track(s) not present in the AccurateRip database", sheet.TrackCount - knownTracks);
                }
                logWriter.WriteLine();
                logWriter.WriteLine("Some tracks could not be verified as accurate");
            }
            logWriter.WriteLine();
            if (sheet.OutputStyle != CUEStyle.SingleFile && sheet.OutputStyle != CUEStyle.SingleFileWithCUE)
            {
                if (wereErrors)
                {
                    logWriter.WriteLine("There were errors");
                }
                else
                {
                    logWriter.WriteLine("No errors occurred");
                }
                logWriter.WriteLine();
            }
            logWriter.WriteLine("End of status report");
            logWriter.Close();

            return(logWriter.ToString());
        }
Ejemplo n.º 20
0
        static int Main(string[] args)
        {
            bool   ok      = true;
            bool   verbose = false;
            string pathIn  = null;

            for (int arg = 0; arg < args.Length; arg++)
            {
                if (args[arg].Length == 0)
                {
                    ok = false;
                }
                else if ((args[arg] == "-v" || args[arg] == "--verbose"))
                {
                    verbose = true;
                }
                else if (args[arg][0] != '-' && pathIn == null)
                {
                    pathIn = args[arg];
                }
                else
                {
                    ok = false;
                }
                if (!ok)
                {
                    break;
                }
            }

            if (!ok || pathIn == null)
            {
                Console.SetOut(Console.Error);
                Console.WriteLine("Usage    : CUETools.ARCUE.exe [options] <filename>");
                Console.WriteLine();
                Console.WriteLine("Options:");
                Console.WriteLine();
                Console.WriteLine(" -v --verbose         Verbose mode");
                return(1);
            }
            if (!File.Exists(pathIn))
            {
                Console.SetOut(Console.Error);
                Console.WriteLine("Input CUE Sheet not found.");
                return(2);
            }

            CUEConfig config = new CUEConfig();

            config.writeArLogOnVerify       = false;
            config.writeArTagsOnVerify      = false;
            config.autoCorrectFilenames     = true;
            config.extractAlbumArt          = false;
            config.embedAlbumArt            = false;
            config.advanced.DetailedCTDBLog = verbose;

            string accurateRipLog;

            try
            {
                CUESheet cueSheet = new CUESheet(config);
                cueSheet.Action = CUEAction.Verify;
                //cueSheet.OutputStyle = CUEStyle.SingleFile;
                cueSheet.Open(pathIn);
                cueSheet.UseAccurateRip();
                cueSheet.UseCUEToolsDB("ARCUE " + CUESheet.CUEToolsVersion, null, true, CTDBMetadataSearch.None);
                cueSheet.GenerateFilenames(AudioEncoderType.NoAudio, "dummy", pathIn);
                cueSheet.Go();

                accurateRipLog = CUESheetLogWriter.GetAccurateRipLog(cueSheet);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error: " + ex.Message);
                return(3);
            }

            Console.Write(accurateRipLog);
            return(0);
        }
Ejemplo n.º 21
0
        public static string GetRipperLog(CUESheet sheet)
        {
            StringWriter logWriter = new StringWriter(CultureInfo.InvariantCulture);

            logWriter.WriteLine("{0}", sheet.CDRipper.RipperVersion);
            logWriter.WriteLine("Extraction logfile from : {0}", DateTime.Now);
            logWriter.WriteLine("Used drive              : {0}", sheet.CDRipper.ARName);
            logWriter.WriteLine("Read offset correction  : {0}", sheet.CDRipper.DriveOffset);
            logWriter.WriteLine("Read command            : {0}", sheet.CDRipper.CurrentReadCommand);
            logWriter.WriteLine("Secure mode             : {0}", sheet.CDRipper.CorrectionQuality);
            logWriter.WriteLine("Disk length             : {0}", CDImageLayout.TimeToString(sheet.TOC.AudioLength));
            logWriter.WriteLine("AccurateRip             : {0}", sheet.ArVerify.ARStatus == null ? "ok" : sheet.ArVerify.ARStatus);
            if (sheet.HDCDDecoder != null && string.Format("{0:s}", sheet.HDCDDecoder) != "")
            {
                logWriter.WriteLine("HDCD                    : {0:f}", sheet.HDCDDecoder);
            }
            logWriter.WriteLine();
            logWriter.WriteLine("TOC of the extracted CD");
            logWriter.WriteLine();
            logWriter.Write(GetTOCContents(sheet));
            logWriter.WriteLine();
            logWriter.WriteLine("     Track |   Pregap  | Indexes");
            logWriter.WriteLine("    ---------------------------------------------------------");
            for (int track = 1; track <= sheet.TOC.TrackCount; track++)
            {
                logWriter.WriteLine("{0,9}  | {1,8} |    {2,2}",
                                    sheet.TOC[track].Number,
                                    CDImageLayout.TimeToString(sheet.TOC[track].Pregap + (track == 1 ? 150U : 0U)),
                                    sheet.TOC[track].LastIndex);
            }
            logWriter.WriteLine();
            logWriter.WriteLine("Destination files");
            foreach (string path in sheet.DestPaths)
            {
                logWriter.WriteLine("    {0}", path);
            }
            bool wereErrors = sheet.PrintErrors(logWriter, sheet.TOC[sheet.TOC.FirstAudio][0].Start, sheet.TOC.AudioLength);

            if (wereErrors)
            {
                logWriter.WriteLine();
                if (wereErrors)
                {
                    logWriter.WriteLine("There were errors");
                }
                else
                {
                    logWriter.WriteLine("No errors occurred");
                }
            }
            if (sheet.IsUsingCUEToolsDB)
            {
                logWriter.WriteLine();
                sheet.GenerateCTDBLog(logWriter);
            }
            if (sheet.IsUsingAccurateRip)
            {
                logWriter.WriteLine();
                logWriter.WriteLine("AccurateRip summary");
                logWriter.WriteLine();
                sheet.ArVerify.GenerateFullLog(logWriter, true, AccurateRipVerify.CalculateAccurateRipId(sheet.TOC));
            }
            logWriter.WriteLine();
            logWriter.WriteLine("End of status report");
            logWriter.Close();

            return(logWriter.ToString());
        }