Ejemplo n.º 1
0
        public void Load(SettingsReader sr)
        {
            _config.Load(sr);

            _useFreeDb = sr.LoadBoolean("FreedbLookup") ?? _useFreeDb;
            _useMusicBrainz = sr.LoadBoolean("MusicBrainzLookup") ?? _useMusicBrainz;
            _useAccurateRip = sr.LoadBoolean("AccurateRipLookup") ?? _useAccurateRip;
            _useCUEToolsDB = sr.LoadBoolean("CUEToolsDBLookup") ?? _useCUEToolsDB;
            _useLocalDB = sr.LoadBoolean("LocalDBLookup") ?? _useLocalDB;
            _skipRecent = sr.LoadBoolean("SkipRecent") ?? _skipRecent;
            _outputAudioType = (AudioEncoderType?)sr.LoadInt32("OutputAudioType", null, null) ?? _outputAudioType;
            _outputAudioFormat = sr.Load("OutputAudioFmt") ?? _outputAudioFormat;
            _action = (CUEAction?)sr.LoadInt32("AccurateRipMode", (int)CUEAction.Encode, (int)CUEAction.CorrectFilenames) ?? _action;
            _CUEStyle = (CUEStyle?)sr.LoadInt32("CUEStyle", null, null) ?? _CUEStyle;
            _writeOffset = sr.LoadInt32("WriteOffset", null, null) ?? 0;
            _outputTemplate = sr.Load("OutputPathTemplate") ?? _outputTemplate;
            _script = sr.Load("Script") ?? _script;
        }
Ejemplo n.º 2
0
        public void Load(SettingsReader sr)
        {
            int version = sr.LoadInt32("Version", null, null) ?? 202;

            fixOffsetMinimumConfidence = sr.LoadUInt32("ArFixWhenConfidence", 1, 1000) ?? 2;
            fixOffsetMinimumTracksPercent = sr.LoadUInt32("ArFixWhenPercent", 1, 100) ?? 51;
            encodeWhenConfidence = sr.LoadUInt32("ArEncodeWhenConfidence", 1, 1000) ?? 2;
            encodeWhenPercent = sr.LoadUInt32("ArEncodeWhenPercent", 1, 100) ?? 100;
            encodeWhenZeroOffset = sr.LoadBoolean("ArEncodeWhenZeroOffset") ?? false;
            noUnverifiedOutput = sr.LoadBoolean("ArNoUnverifiedOutput") ?? false;
            fixOffset = sr.LoadBoolean("ArFixOffset") ?? false;
            writeArTagsOnEncode = sr.LoadBoolean("ArWriteCRC") ?? writeArTagsOnEncode;
            writeArLogOnConvert = sr.LoadBoolean("ArWriteLog") ?? true;
            writeArTagsOnVerify = sr.LoadBoolean("ArWriteTagsOnVerify") ?? false;
            writeArLogOnVerify = sr.LoadBoolean("ArWriteLogOnVerify") ?? false;

            preserveHTOA = sr.LoadBoolean("PreserveHTOA") ?? true;
            detectGaps = sr.LoadBoolean("DetectGaps") ?? true;
            autoCorrectFilenames = sr.LoadBoolean("AutoCorrectFilenames") ?? true;
            keepOriginalFilenames = sr.LoadBoolean("KeepOriginalFilenames") ?? false;
            singleFilenameFormat = sr.Load("SingleFilenameFormat") ?? singleFilenameFormat;
            trackFilenameFormat = sr.Load("TrackFilenameFormat") ?? trackFilenameFormat;
            removeSpecial = sr.LoadBoolean("RemoveSpecialCharacters") ?? false;
            specialExceptions = sr.Load("SpecialCharactersExceptions") ?? "-()";
            replaceSpaces = sr.LoadBoolean("ReplaceSpaces") ?? false;
            embedLog = sr.LoadBoolean("EmbedLog") ?? true;
            extractLog = sr.LoadBoolean("ExtractLog") ?? true;
            fillUpCUE = sr.LoadBoolean("FillUpCUE") ?? true;
            overwriteCUEData = sr.LoadBoolean("OverwriteCUEData") ?? false;
            filenamesANSISafe = sr.LoadBoolean("FilenamesANSISafe") ?? true;
            bruteForceDTL = sr.LoadBoolean("BruteForceDTL") ?? false;
            createEACLOG = sr.LoadBoolean("CreateEACLOG") ?? createEACLOG;
            detectHDCD = sr.LoadBoolean("DetectHDCD") ?? true;
            wait750FramesForHDCD = sr.LoadBoolean("Wait750FramesForHDCD") ?? true;
            decodeHDCD = sr.LoadBoolean("DecodeHDCD") ?? false;
            createM3U = sr.LoadBoolean("CreateM3U") ?? false;
            createCUEFileWhenEmbedded = sr.LoadBoolean("CreateCUEFileWhenEmbedded") ?? true;
            truncate4608ExtraSamples = sr.LoadBoolean("Truncate4608ExtraSamples") ?? true;
            lossyWAVQuality = sr.LoadInt32("LossyWAVQuality", 0, 10) ?? 5;
            decodeHDCDtoLW16 = sr.LoadBoolean("DecodeHDCDToLossyWAV16") ?? false;
            decodeHDCDto24bit = sr.LoadBoolean("DecodeHDCDTo24bit") ?? true;

            oneInstance = sr.LoadBoolean("OneInstance") ?? true;
            checkForUpdates = sr.LoadBoolean("CheckForUpdates") ?? true;

            writeBasicTagsFromCUEData = sr.LoadBoolean("WriteBasicTagsFromCUEData") ?? true;
            copyBasicTags = sr.LoadBoolean("CopyBasicTags") ?? true;
            copyUnknownTags = sr.LoadBoolean("CopyUnknownTags") ?? true;
            CopyAlbumArt = sr.LoadBoolean("CopyAlbumArt") ?? true;
            embedAlbumArt = sr.LoadBoolean("EmbedAlbumArt") ?? true;
            extractAlbumArt = sr.LoadBoolean("ExtractAlbumArt") ?? true;
            maxAlbumArtSize = sr.LoadInt32("MaxAlbumArtSize", 100, 10000) ?? maxAlbumArtSize;

            arLogToSourceFolder = sr.LoadBoolean("ArLogToSourceFolder") ?? arLogToSourceFolder;
            arLogVerbose = sr.LoadBoolean("ArLogVerbose") ?? arLogVerbose;
            fixOffsetToNearest = sr.LoadBoolean("FixOffsetToNearest") ?? fixOffsetToNearest;
            ArLogFilenameFormat = sr.Load("ArLogFilenameFormat") ?? ArLogFilenameFormat;
            AlArtFilenameFormat = sr.Load("AlArtFilenameFormat") ?? AlArtFilenameFormat;

            separateDecodingThread = sr.LoadBoolean("SeparateDecodingThread") ?? separateDecodingThread;

            try
            {
                using (TextReader reader = new StringReader(sr.Load("Advanced")))
                    advanced = CUEConfigAdvanced.serializer.Deserialize(reader) as CUEConfigAdvanced;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Trace.WriteLine(ex.Message);
            }

            int totalEncoders = sr.LoadInt32("ExternalEncoders", 0, null) ?? 0;
            for (int nEncoders = 0; nEncoders < totalEncoders; nEncoders++)
            {
                string name = sr.Load(string.Format("ExternalEncoder{0}Name", nEncoders));
                string extension = sr.Load(string.Format("ExternalEncoder{0}Extension", nEncoders));
                string path = sr.Load(string.Format("ExternalEncoder{0}Path", nEncoders));
                string parameters = sr.Load(string.Format("ExternalEncoder{0}Parameters", nEncoders));
                bool lossless = sr.LoadBoolean(string.Format("ExternalEncoder{0}Lossless", nEncoders)) ?? true;
                string supported_modes = sr.Load(string.Format("ExternalEncoder{0}Modes", nEncoders)) ?? "";
                string default_mode = sr.Load(string.Format("ExternalEncoder{0}Mode", nEncoders)) ?? "";
                CUEToolsUDC encoder;
                if (name == null) continue;
                if (!encoders.TryGetValue(name, out encoder))
                {
                    if (path == null || parameters == null || extension == null) continue;
                    encoders.Add(new CUEToolsUDC(name, extension, lossless, supported_modes, default_mode, path, parameters));
                }
                else if (version == 203)
                {
                    if (encoder.path != null)
                    {
                        if (path == null || parameters == null || extension == null) continue;
                        encoder.extension = extension;
                        encoder.path = path;
                        encoder.lossless = lossless;
                        encoder.parameters = parameters;
                    }
                    else
                    {
                        if (encoder.settingsSerializer != null && parameters != "")
                            try
                            {
                                using (TextReader reader = new StringReader(parameters))
                                    encoder.settings = encoder.settingsSerializer.Deserialize(reader);
                            }
                            catch
                            {
                            }
                    }
                    encoder.supported_modes = supported_modes;
                    encoder.default_mode = default_mode;
                }
            }

            int totalDecoders = sr.LoadInt32("ExternalDecoders", 0, null) ?? 0;
            for (int nDecoders = 0; nDecoders < totalDecoders; nDecoders++)
            {
                string name = sr.Load(string.Format("ExternalDecoder{0}Name", nDecoders));
                string extension = sr.Load(string.Format("ExternalDecoder{0}Extension", nDecoders));
                string path = sr.Load(string.Format("ExternalDecoder{0}Path", nDecoders));
                string parameters = sr.Load(string.Format("ExternalDecoder{0}Parameters", nDecoders));
                CUEToolsUDC decoder;
                if (!decoders.TryGetValue(name, out decoder))
                    decoders.Add(name, new CUEToolsUDC(name, extension, true, "", "", path, parameters));
                else
                {
                    decoder.extension = extension;
                    decoder.path = path;
                    decoder.parameters = parameters;
                }
            }

            int totalFormats = sr.LoadInt32("CustomFormats", 0, null) ?? 0;
            for (int nFormats = 0; nFormats < totalFormats; nFormats++)
            {
                string extension = sr.Load(string.Format("CustomFormat{0}Name", nFormats));
                string encoderLossless = sr.Load(string.Format("CustomFormat{0}EncoderLossless", nFormats)) ?? "";
                string encoderLossy = sr.Load(string.Format("CustomFormat{0}EncoderLossy", nFormats)) ?? "";
                string decoder = sr.Load(string.Format("CustomFormat{0}Decoder", nFormats));
                CUEToolsTagger tagger = (CUEToolsTagger)(sr.LoadInt32(string.Format("CustomFormat{0}Tagger", nFormats), 0, 2) ?? 0);
                bool allowLossless = sr.LoadBoolean(string.Format("CustomFormat{0}AllowLossless", nFormats)) ?? false;
                bool allowLossy = sr.LoadBoolean(string.Format("CustomFormat{0}AllowLossy", nFormats)) ?? false;
                bool allowLossyWav = sr.LoadBoolean(string.Format("CustomFormat{0}AllowLossyWAV", nFormats)) ?? false;
                bool allowEmbed = sr.LoadBoolean(string.Format("CustomFormat{0}AllowEmbed", nFormats)) ?? false;
                CUEToolsFormat format;
                CUEToolsUDC udcLossless, udcLossy;
                if (encoderLossless == "" || !encoders.TryGetValue(encoderLossless, out udcLossless))
					udcLossless = encoders.GetDefault(extension, true);
                if (encoderLossy == "" || !encoders.TryGetValue(encoderLossy, out udcLossy))
					udcLossy = encoders.GetDefault(extension, false);
                if (!formats.TryGetValue(extension, out format))
                    formats.Add(extension, new CUEToolsFormat(extension, tagger, allowLossless, allowLossy, allowLossyWav, allowEmbed, false, udcLossless, udcLossy, decoder));
                else
                {
                    format.encoderLossless = udcLossless;
                    format.encoderLossy = udcLossy;
                    format.decoder = decoder;
                    if (!format.builtin)
                    {
                        format.tagger = tagger;
                        format.allowLossless = allowLossless;
                        format.allowLossy = allowLossy;
                        format.allowLossyWAV = allowLossyWav;
                        format.allowEmbed = allowEmbed;
                    }
                }
            }

            int totalScripts = sr.LoadInt32("CustomScripts", 0, null) ?? 0;
            for (int nScripts = 0; nScripts < totalScripts; nScripts++)
            {
                string name = sr.Load(string.Format("CustomScript{0}Name", nScripts));
                string code = sr.Load(string.Format("CustomScript{0}Code", nScripts));
                List<CUEAction> conditions = new List<CUEAction>();
                int totalConditions = sr.LoadInt32(string.Format("CustomScript{0}Conditions", nScripts), 0, null) ?? 0;
                for (int nCondition = 0; nCondition < totalConditions; nCondition++)
                    conditions.Add((CUEAction)sr.LoadInt32(string.Format("CustomScript{0}Condition{1}", nScripts, nCondition), 0, null));
                CUEToolsScript script;
                if (!scripts.TryGetValue(name, out script))
                {
                    if (name != "submit")
                        scripts.Add(name, new CUEToolsScript(name, false, conditions, code));
                }
                else
                {
                    if (!script.builtin)
                    {
                        script.code = code;
                        script.conditions = conditions;
                    }
                }
            }

            defaultVerifyScript = sr.Load("DefaultVerifyScript") ?? "default";
            defaultEncodeScript = sr.Load("DefaultVerifyAndConvertScript") ?? "default";

            gapsHandling = (CUEStyle?)sr.LoadInt32("GapsHandling", null, null) ?? gapsHandling;

            language = sr.Load("Language") ?? Thread.CurrentThread.CurrentUICulture.Name;

            if (ArLogFilenameFormat.Contains("%F"))
                ArLogFilenameFormat = "%filename%.accurip";
            if (singleFilenameFormat.Contains("%F"))
                singleFilenameFormat = "%filename%";
            if (trackFilenameFormat.Contains("%N"))
                trackFilenameFormat = "%tracknumber%. %title%";
        }
Ejemplo n.º 3
0
		static void Main(string[] args)
		{
			TextWriter stdout = Console.Out;
			Console.SetOut(Console.Error);
			Console.WriteLine("CUETools.Converter, Copyright (C) 2009 Grigory Chudov.");
			Console.WriteLine("This is free software under the GNU GPLv3+ license; There is NO WARRANTY, to");
			Console.WriteLine("the extent permitted by law. <http://www.gnu.org/licenses/> for details.");
			if (args.Length < 2)
			{
				Usage();
				return;
			}
			string sourceFile = args[0];
			string destFile = args[1];

			DateTime start = DateTime.Now;
			TimeSpan lastPrint = TimeSpan.FromMilliseconds(0);
			CUEConfig config = new CUEConfig();

			SettingsReader sr = new SettingsReader("CUE Tools", "settings.txt", null);
			config.Load(sr);
#if !DEBUG
			try
#endif
			{
				IAudioSource audioSource = AudioReadWrite.GetAudioSource(sourceFile, null, config);
				IAudioDest audioDest = AudioReadWrite.GetAudioDest(AudioEncoderType.Lossless, destFile, (long)audioSource.Length, audioSource.PCM.BitsPerSample, audioSource.PCM.SampleRate, 8192, config);
				AudioBuffer buff = new AudioBuffer(audioSource, 0x10000);

				Console.WriteLine("Filename  : {0}", sourceFile);
				Console.WriteLine("File Info : {0}kHz; {1} channel; {2} bit; {3}", audioSource.PCM.SampleRate, audioSource.PCM.ChannelCount, audioSource.PCM.BitsPerSample, TimeSpan.FromSeconds(audioSource.Length * 1.0 / audioSource.PCM.SampleRate));

				while (audioSource.Read(buff, -1) != 0)
				{
					audioDest.Write(buff);
					TimeSpan elapsed = DateTime.Now - start;
					if ((elapsed - lastPrint).TotalMilliseconds > 60)
					{
						Console.Error.Write("\rProgress  : {0:00}%; {1:0.00}x; {2}/{3}",
							100.0 * audioSource.Position / audioSource.Length,
							audioSource.Position / elapsed.TotalSeconds / audioSource.PCM.SampleRate,
							elapsed,
							TimeSpan.FromMilliseconds(elapsed.TotalMilliseconds / audioSource.Position * audioSource.Length)
							);
						lastPrint = elapsed;
					}
				}

				TimeSpan totalElapsed = DateTime.Now - start;
				Console.Error.Write("\r                                                                         \r");
				Console.WriteLine("Results   : {0:0.00}x; {1}",
					audioSource.Position / totalElapsed.TotalSeconds / audioSource.PCM.SampleRate,
					totalElapsed
					);
				audioSource.Close();
				audioDest.Close();

				TagLib.UserDefined.AdditionalFileTypes.Config = config;
				TagLib.File sourceInfo = TagLib.File.Create(new TagLib.File.LocalFileAbstraction(sourceFile));
				TagLib.File destInfo = TagLib.File.Create(new TagLib.File.LocalFileAbstraction(destFile));
				if (Tagging.UpdateTags(destInfo, Tagging.Analyze(sourceInfo), config))
				{
					sourceInfo.Tag.CopyTo(destInfo.Tag, true);
					destInfo.Tag.Pictures = sourceInfo.Tag.Pictures;
					destInfo.Save();
				}
			}
#if !DEBUG
			catch (Exception ex)
			{
				Console.WriteLine();
				Console.WriteLine("Error: {0}", ex.Message);
				//Console.WriteLine("{0}", ex.StackTrace);
			}
#endif
		}
Ejemplo n.º 4
0
		//// Calculate the graphics path that representing the figure in the bitmap 
		//// excluding the transparent color which is the top left pixel.
		//private static GraphicsPath CalculateControlGraphicsPath(Bitmap bitmap, Color colorTransparent)
		//{
		//    // Create GraphicsPath for our bitmap calculation
		//    GraphicsPath graphicsPath = new GraphicsPath();

		//    // Use the top left pixel as our transparent color
		//    colorTransparent = bitmap.GetPixel(0, 0); 

		//    // This is to store the column value where an opaque pixel is first found.
		//    // This value will determine where we start scanning for trailing 
		//    // opaque pixels.
		//    int colOpaquePixel = 0;

		//    // Go through all rows (Y axis)
		//    for (int row = 0; row < bitmap.Height; row++)
		//    {
		//        // Reset value
		//        colOpaquePixel = 0;

		//        // Go through all columns (X axis)
		//        for (int col = 0; col < bitmap.Width; col++)
		//        {
		//            // If this is an opaque pixel, mark it and search 
		//            // for anymore trailing behind
		//            if (bitmap.GetPixel(col, row) != colorTransparent)
		//            {
		//                // Opaque pixel found, mark current position
		//                colOpaquePixel = col;
		//                // Create another variable to set the current pixel position
		//                int colNext = col;
		//                // Starting from current found opaque pixel, search for 
		//                // anymore opaque pixels trailing behind, until a transparent
		//                // pixel is found or minimum width is reached
		//                for (colNext = colOpaquePixel; colNext < bitmap.Width; colNext++)
		//                    if (bitmap.GetPixel(colNext, row) == colorTransparent)
		//                        break;
		//                // Form a rectangle for line of opaque pixels found and 
		//                // add it to our graphics path
		//                graphicsPath.AddRectangle(new Rectangle(colOpaquePixel,
		//                                           row, colNext - colOpaquePixel, 1));
		//                // No need to scan the line of opaque pixels just found
		//                col = colNext;
		//            }
		//        }
		//    }

		//    // Return calculated graphics path
		//    return graphicsPath;
		//}

		//private static void CreateControlRegion(Button button, Bitmap bitmap, Color colorTransparent)
		//{
		//    // Return if control and bitmap are null
		//    if (button == null || bitmap == null)
		//        return;

		//    // Set our control's size to be the same as the bitmap
		//    button.Width = bitmap.Width;
		//    button.Height = bitmap.Height;

		//    // Do not show button text
		//    button.Text = "";

		//    // Change cursor to hand when over button
		//    button.Cursor = Cursors.Hand;

		//    // Set background image of button
		//    button.BackgroundImage = bitmap;

		//    // Calculate the graphics path based on the bitmap supplied
		//    GraphicsPath graphicsPath = CalculateControlGraphicsPath(bitmap, colorTransparent);

		//    // Apply new region

		//    button.Region = new Region(graphicsPath);
		//}

		private void frmCUERipper_Load(object sender, EventArgs e)
		{
			//buttonTrackMetadata.Parent = listTracks;
			//buttonTrackMetadata.ImageList = null;
			//CreateControlRegion(buttonTrackMetadata, new Bitmap(imageListChecked.Images[0]), imageListChecked.TransparentColor);
			//CreateControlRegion(buttonTrackMetadata, Properties.Resources.cdrepair, Color.White);

			SettingsReader sr = new SettingsReader("CUERipper", "settings.txt", Application.ExecutablePath);
			_config.Load(sr);
			_defaultLosslessFormat = sr.Load("DefaultLosslessFormat") ?? "flac";
			_defaultLossyFormat = sr.Load("DefaultLossyFormat") ?? "mp3";
			_defaultHybridFormat = sr.Load("DefaultHybridFormat") ?? "lossy.flac";
			//_config.createEACLOG = sr.LoadBoolean("CreateEACLOG") ?? true;
			//_config.preserveHTOA = sr.LoadBoolean("PreserveHTOA") ?? false;
			//_config.createM3U = sr.LoadBoolean("CreateM3U") ?? true;

			bindingSourceCR.DataSource = data;
			bnComboBoxDrives.ImageList = m_icon_mgr.ImageList;
			bnComboBoxFormat.ImageList = m_icon_mgr.ImageList;
			SetupControls();

			int iFormat, nFormats = sr.LoadInt32("OutputPathUseTemplates", 0, 10) ?? 0;
			for (iFormat = 0; iFormat < OutputPathUseTemplates.Length; iFormat++)
				bnComboBoxOutputFormat.Items.Add(OutputPathUseTemplates[iFormat]);
			for (iFormat = nFormats - 1; iFormat >= 0; iFormat--)
				bnComboBoxOutputFormat.Items.Add(sr.Load(string.Format("OutputPathUseTemplate{0}", iFormat)) ?? "");

			bnComboBoxOutputFormat.Text = sr.Load("PathFormat") ?? "%music%\\%artist%\\[%year% - ]%album%\\%artist% - %album%.cue";
			SelectedOutputAudioType = (AudioEncoderType?)sr.LoadInt32("OutputAudioType", null, null) ?? AudioEncoderType.Lossless;
			bnComboBoxImage.SelectedIndex = sr.LoadInt32("ComboImage", 0, bnComboBoxImage.Items.Count - 1) ?? 0;
			trackBarSecureMode.Value = sr.LoadInt32("SecureMode", 0, trackBarSecureMode.Maximum - 1) ?? 1;
			trackBarSecureMode_Scroll(this, new EventArgs());
			defaultDrive = sr.Load("DefaultDrive");
            this.checkBoxTestAndCopy.Checked = this.testAndCopy = sr.LoadBoolean("TestAndCopy") ?? this.testAndCopy;

			Size SizeIncrement = new Size(sr.LoadInt32("WidthIncrement", 0, null) ?? 0, sr.LoadInt32("HeightIncrement", 0, null) ?? 0);
			Size = MinimumSize + SizeIncrement;
			Left -= SizeIncrement.Width / 2;
			Top -= SizeIncrement.Height / 2;
			UpdateDrives();
		}