Ejemplo n.º 1
0
        private void buttonExtract_Click(object sender, EventArgs e)
        {
            var parameters = new ExtractionParameters
            {
                Center     = new Imaging.Point((int)numericUpDownCenterX.Value, (int)numericUpDownCenterY.Value),
                GapWidth   = (double)numericUpDownGapWidth.Value,
                TrackWidth = (double)numericUpDownTrackWidth.Value
            };

            byte[] audioBytes;

            try
            {
                if (checkBoxTrack.Checked)
                {
                    audioBytes            = Imaging.Vinyl.ExtractAudioBytes(_vinyl, parameters, Imaging.Vinyl.ExtractionOptions.SaveTrack);
                    pictureBoxPlate.Image = _vinyl.GetTrack();
                }
                else
                {
                    audioBytes = Imaging.Vinyl.ExtractAudioBytes(_vinyl, parameters, Imaging.Vinyl.ExtractionOptions.None);
                }
            }
            catch (IndexOutOfRangeException)
            {
                MessageBox.Show("Проверьте правильность всех параметров. Возможно, необходимо их слегка поправить.\n" +
                                "Так же стоит проверить корректность самого изображения.",
                                "Произошла ошибка при извлечении звука",
                                MessageBoxButtons.OK,
                                MessageBoxIcon.Warning);
            }
        }
Ejemplo n.º 2
0
        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);
        }