Exemplo n.º 1
0
        private void DrawWave(float[] samples, int channels)
        {
            TexturePen pen = new TexturePen();

            pen.Connect(OneFullWaveForm.WaveImage);
            pen.BackgroundColor = pen.GetPixelColor(0, 0);
            pen.PenColor        = Color.green;
            pen.PenThinkness    = 1;

            int width       = OneFullWaveForm.WaveImage.width;
            int blocksCount = samples.Length / channels;

            for (int column = 0; column < width; column++)
            {
                float curPlace   = (column + float.Epsilon) / width;
                int   blockBegin = Mathf.RoundToInt(blocksCount * curPlace * channels);
                for (int j = 0; j < channels && blockBegin + j < samples.Length; j++)
                {
                    int row = (int)(0.5f * (1 + samples[blockBegin + j]) * OneFullWaveForm.WaveImage.height);
                    row = Mathf.Clamp(row, 0, OneFullWaveForm.WaveImage.height - 1);
                    pen.DrawPixel(column, row, Color.green);
                    pen.DrawPixel(column, row + 1, Color.green);
                    pen.DrawPixel(column, row - 1, Color.green);
                }
            }
            pen.Apply();
        }
Exemplo n.º 2
0
        private void DrawSilence()
        {
            TexturePen pen = new TexturePen();

            pen.Connect(OneFullWaveForm.WaveImage);
            pen.BackgroundColor = pen.GetPixelColor(0, 0);
            pen.PenColor        = Color.green;

            pen.PenThinkness = 1;
            pen.DrawRow(Mathf.RoundToInt(0.5f * OneFullWaveForm.WaveImage.height));
            pen.Apply();
        }
Exemplo n.º 3
0
        private void GenerateSoundMarkers()
        {
            TexturePen pen = new TexturePen();

            pen.Connect(OneFullWaveForm.MarkersImage);
            pen.BackgroundColor = pen.GetPixelColor(0, 0);
            pen.PenColor        = Color.grey;

            pen.PenThinkness = 5;
            pen.PenColor     = Color.gray;
            MarkerCalculator markersData = OneFullWaveForm.MarkersData;

            for (int i = 0; i < markersData.Count; i++)
            {
                markersData.SetCurrentMarker(i);

                MarkerCalculator.MarkerTypeId markerType = markersData.MarkerType;
                switch (markerType)
                {
                case MarkerCalculator.MarkerTypeId.Start:
                case MarkerCalculator.MarkerTypeId.End:
                    pen.DrawColumn(markersData.PlaceInPixels, 5, Color.white, 100);
                    break;

                case MarkerCalculator.MarkerTypeId.Big:
                    pen.DrawColumn(markersData.PlaceInPixels, 3, Color.gray, 100);
                    break;

                case MarkerCalculator.MarkerTypeId.Middle:
                    pen.DrawColumn(markersData.PlaceInPixels, 1, Color.white, 50);
                    break;

                case MarkerCalculator.MarkerTypeId.Small:
                    pen.DrawColumn(markersData.PlaceInPixels, 1, Color.white, 25);
                    break;

                default:
                    break;
                }
            }


            pen.Apply();
        }