コード例 #1
0
        private WindowReader ProcessData(byte[] data, WindowReader wr)
        {
            float[] dataInt = ConvertFromByteArrayToFloatArray(data);
            wr.PeakEnd = FindPeak(dataInt);
            float[] newData = new float[wr.PeakEnd];
            Array.Copy(dataInt, newData, wr.PeakEnd);

            int d = wr.PeakEnd / 384;

            wr.DataSum = PixelPack(newData, d);

            return(wr);
        }
コード例 #2
0
        private void ReadWav(Segment s)
        {
            FileStream   fr = new FileStream(@"C:\384kHzStereo.wav", FileMode.Open);
            WindowReader wr = new WindowReader();

            wr.Segment = s;
            wr.Segment.CurrentPosition = wr.Segment.Start;
            fr.Seek(wr.Segment.Start, System.IO.SeekOrigin.Begin);

            x = 0;
            y = 0;

            wr.Samples = new byte[wr.Segment.Length];
            fr.Read(wr.Samples, 0, wr.Samples.Length);

            Tuple <byte[], byte[]> data = SplitChannels(wr.Samples);

            if (wr.Segment.Channel == Channel.Left)
            {
                wr = ProcessData(data.Item1, wr);
                GenerateImage(wr.DataSumList, ref leftImage);
            }
            else
            {
                wr = ProcessData(data.Item2, wr);
                GenerateImage(wr.DataSumList, ref rightImage);
            }


            fr.Close();

            if (leftImage != null)
            {
                pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
                pictureBox1.Image    = leftImage;
                pictureBox1.Invalidate();
                pictureBox1.Update();
                pictureBox1.Refresh();
            }

            if (rightImage != null)
            {
                pictureBox2.SizeMode = PictureBoxSizeMode.CenterImage;
                pictureBox2.Image    = rightImage;
                pictureBox2.Invalidate();
                pictureBox2.Update();
                pictureBox2.Refresh();
            }

            //leftImage.Save(@"C:\1.bmp", ImageFormat.Bmp);
        }
コード例 #3
0
        private WindowReader ProcessData(byte[] data, WindowReader wr)
        {
            float[] dataInt = ConvertFromByteArrayToFloatArray(data);
            dataInt      = Invert(dataInt);
            wr.PeakStart = FindPeak(dataInt);
            wr.PeakEnd   = FindPeakLow(dataInt);
            float[] newData = new float[wr.PeakEnd - wr.PeakStart];
            Array.Copy(dataInt, wr.PeakStart, newData, 0, newData.Length);

            d          = (wr.PeakEnd - wr.PeakStart) / 384;
            wr.DataSum = PixelPack(newData, d);

            return(wr);
        }
コード例 #4
0
        private WindowReader ProcessData(byte[] data, WindowReader wr)
        {
            float[] dataInt = ConvertFromByteArrayToFloatArray(data);

            //TODO: Divide by a time frame
            int numberOfColumns = dataInt.Length / 3299;

            if (wr.Segment.Channel == Channel.Left)
            {
                leftImage = new Bitmap(numberOfColumns, 384, PixelFormat.Format32bppRgb);
            }
            else
            {
                rightImage = new Bitmap(numberOfColumns, 384, PixelFormat.Format32bppRgb);
            }

            wr.DataSumList = PixelPack(dataInt, numberOfColumns);

            return(wr);
        }
コード例 #5
0
        private void ReadWav(Segment s)
        {
            FileStream   fr = new FileStream(@"C:\384kHzStereo.wav", FileMode.Open);
            WindowReader wr = null;

            Bitmap leftImage  = null;
            Bitmap rightImage = null;

            if (s.Channel == Channel.Left)
            {
                leftImage = new Bitmap(800, 384, PixelFormat.Format32bppRgb);
            }
            else
            {
                rightImage = new Bitmap(800, 384, PixelFormat.Format32bppRgb);
            }

            x = 0;
            y = 0;

            for (int i = 0; i < 800; i++)
            {
                if (wr == null)
                {
                    wr           = new WindowReader();
                    wr.Segment   = s;
                    wr.PeakStart = 0;
                    wr.Segment.CurrentPosition = wr.Segment.Start;
                    fr.Seek(wr.Segment.Start, System.IO.SeekOrigin.Begin);
                }
                else
                {
                    wr.Segment.CurrentPosition += wr.PeakEnd * 8;
                    fr.Seek(wr.Segment.CurrentPosition, System.IO.SeekOrigin.Begin);
                }

                if (wr.Segment.CurrentPosition + wr.Segment.WindowLength >= wr.Segment.Start + wr.Segment.Length)
                {
                    continue;
                }

                wr.Samples = new byte[wr.Segment.WindowLength];
                fr.Read(wr.Samples, 0, wr.Samples.Length);

                Tuple <byte[], byte[]> data = SplitChannels(wr.Samples);

                if (wr.Segment.Channel == Channel.Left)
                {
                    wr = ProcessData(data.Item1, wr);
                    GenerateImage(wr.DataSum, ref leftImage);
                }
                else
                {
                    wr = ProcessData(data.Item2, wr);
                    GenerateImage(wr.DataSum, ref rightImage);
                }
            }

            fr.Close();

            if (leftImage != null)
            {
                pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
                pictureBox1.Image    = leftImage;
                pictureBox1.Invalidate();
                pictureBox1.Update();
                pictureBox1.Refresh();
            }

            if (rightImage != null)
            {
                pictureBox2.SizeMode = PictureBoxSizeMode.CenterImage;
                pictureBox2.Image    = rightImage;
                pictureBox2.Invalidate();
                pictureBox2.Update();
                pictureBox2.Refresh();
            }

            //leftImage.Save(@"C:\1.bmp", ImageFormat.Bmp);
        }