private void openFileDialog_FileOk(object sender, CancelEventArgs e) { var tempVinyl = new Imaging.Vinyl(openFileDialog.FileName); try { InitializeFields(tempVinyl); } catch (Exception ex) { if (ex is OverflowException || ex is ArgumentOutOfRangeException) { MessageBox.Show( "Вероятно, выбранное изображение не является изображением пластинки. " + "Выберите другое изображение или попробуйте уменьшить исходное до размера " + "2000*2000 или менее.", "Что-то не так с изображением", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } throw; } _editing = false; _vinyl = tempVinyl; pictureBoxPlate.Image = _vinyl.GetOriginal(); Text = String.Format("Восстановление \"виниловых\" пластинок - {0}", openFileDialog.SafeFileName); }
private void InitializeFields(Imaging.Vinyl vinyl) { numericUpDownCenterX.Value = vinyl.Center.X; numericUpDownCenterY.Value = vinyl.Center.Y; numericUpDownGapWidth.Value = (decimal)vinyl.GapWidth; numericUpDownTrackWidth.Value = (decimal)vinyl.TrackWidth; textBoxSpinCount.Text = vinyl.SpinCount.ToString(); textBoxDuration.Text = vinyl.Duration.ToString(); panelProperties.Visible = true; }
static void Main(string[] args) { var stopwatch = new Stopwatch(); Console.WriteLine("Recovering..."); stopwatch.Start(); var vinyl = new Imaging.Vinyl(args[0]); byte[] res; if (args.Length < 2) { res = Imaging.Vinyl.ExtractAudioBytes(vinyl); } else { res = Imaging.Vinyl.ExtractAudioBytes(vinyl, Imaging.Vinyl.ExtractionOptions.SaveTrack); vinyl.GetTrack().Save(args[1]); } stopwatch.Stop(); Console.WriteLine("Recovered in {0} ms.", stopwatch.ElapsedMilliseconds); Console.WriteLine("\nCenter of this plate:\t{0}", vinyl.Center); Console.WriteLine("Average width of one track:\t{0:f3}", vinyl.TrackWidth); Console.WriteLine("Average width of one gap:\t{0:f3}", vinyl.GapWidth); Console.WriteLine("Approximate count of spins:\t{0}", vinyl.SpinCount); Console.WriteLine("Approximate duration:\t{0}", vinyl.Duration); Console.WriteLine("\nSaving..."); stopwatch.Restart(); var outputFilename = String.Format("{0}.wav", args[0]); using (var writer = new WavPcmWriter(res.Length / vinyl.Duration.Seconds, 8, 1, outputFilename)) { writer.Write(res, 0); } stopwatch.Stop(); Console.WriteLine("Saved in {0} ms.", stopwatch.ElapsedMilliseconds); }