Beispiel #1
0
        public static byte[] ExtractAudioBytes(Vinyl vinyl, ExtractionParameters parameters, ExtractionOptions options)
        {
            int startX = vinyl.FindStartX(parameters.Center);

            vinyl._trackedLastExtraction = options.HasFlag(ExtractionOptions.SaveTrack);

            if (vinyl._trackedLastExtraction)
            {
                vinyl._trackBitmap = vinyl._recordImage.GetOriginal();
            }

            int centerX = parameters.Center.X;
            int centerY = parameters.Center.Y;

            if (vinyl._trackedLastExtraction)
            {
                vinyl.MarkTrack(centerX, centerY, Color.Red);
            }

            var audioBytes = new byte[vinyl.SamplesCount(startX)];

            double lapRadiusDelta = parameters.TrackWidth + parameters.GapWidth;

            double outerRadius = centerX - startX - (int)(vinyl.TrackWidth / 2);
            double radius      = outerRadius;

            double angle = Math.PI;

            double samplesCount = radius * 4;

            double angleDelta  = (Math.PI * 2) / samplesCount;
            double radiusDelta = (lapRadiusDelta / samplesCount);

            int lapcount = 0;

            for (int i = 0; i < audioBytes.Length; i++)
            {
                if (angle < -Math.PI)
                {
                    radius = outerRadius - ++lapcount * lapRadiusDelta;

                    angle = Math.PI;
                }

                int x = (int)Math.Round(centerX + radius * Math.Cos(angle));
                int y = (int)Math.Round(centerY + radius * Math.Sin(angle));

                audioBytes[i] = vinyl._recordImage[x, y];

                if (vinyl._trackedLastExtraction)
                {
                    vinyl.MarkTrack(x, y, Color.Red);
                }

                radius -= radiusDelta;
                angle  -= angleDelta;
            }

            return(audioBytes);
        }
Beispiel #2
0
        public static byte[] ExtractAudioBytes(Vinyl vinyl, ExtractionOptions options)
        {
            var parameters = new ExtractionParameters
            {
                Center     = vinyl.Center,
                GapWidth   = vinyl.GapWidth,
                TrackWidth = vinyl.TrackWidth
            };

            return(ExtractAudioBytes(vinyl, parameters, options));
        }
Beispiel #3
0
 public static byte[] ExtractAudioBytes(Vinyl vinyl)
 {
     return(ExtractAudioBytes(vinyl, ExtractionOptions.None));
 }