Esempio n. 1
0
        Texture2D CursorLineStackFunc(Texture2D _inputTexture)
        {
            if (sourceClip == null)
            {
                return(_inputTexture);
            }

            Color lineFill = new Color(0f, 0f, 0f, 1f);


            int sizeX = _inputTexture.width;
            int sizeY = _inputTexture.height;

            int maxMarkerLength = sizeY / 2;


            float firstPosition = 0 + ImagePreviews.margin.left;
            float lastPosition  = position.width - ImagePreviews.margin.right;

            int relativeX = Mathf.FloorToInt(AudioEditor.relativePosition(LastMousePosition.x, firstPosition, lastPosition) * sizeX);

            for (int y = 0; y < sizeY; y++)
            {
                _inputTexture.SetPixel(relativeX, y, lineFill);
            }


            _inputTexture.Apply();
            return(_inputTexture);
        }
Esempio n. 2
0
        public Texture2D WaveformIconStackFunc(Texture2D _inputTexture)
        {
            Color PrimaryLine   = new Color32(142, 68, 173, 255);
            Color SecondaryLine = new Color32(155, 89, 182, 255);

            int sizeX        = _inputTexture.width;
            int sizeY        = _inputTexture.height;
            int originOffset = sizeY / 2;

            if (sourceClip == null)
            {
                return(_inputTexture);
            }

            float[] audioData = new float[sourceClip.samples * sourceClip.channels];
            sourceClip.GetData(audioData, 0);
            NormalizeDataTable(audioData);

            for (int x = 0; x < sizeX; x++)
            {
                int   sampleIndex  = Mathf.FloorToInt(AudioEditor.relativePosition(x, 0, sizeX) * audioData.Length);
                float scaledSample = audioData[sampleIndex] * originOffset;

                for (int i = 0; Mathf.Abs(i) < Mathf.Abs(scaledSample); i += (int)Mathf.Sign(scaledSample))
                {
                    _inputTexture.SetPixel(x, Mathf.Clamp(i + originOffset, 0, sizeY), SecondaryLine);
                }

                _inputTexture.SetPixel(x, (int)scaledSample + originOffset, PrimaryLine);
            }

            _inputTexture.Apply();
            return(_inputTexture);
        }
Esempio n. 3
0
        Texture2D TimeMarkerStackFunc(Texture2D _inputTexture)
        {
            Color BaseLine      = new Color32(192, 57, 43, 255);
            Color PrimaryLine   = new Color32(192, 57, 43, 255);
            Color SecondaryLine = new Color32(155, 89, 182, 255);

            float startTime       = ZoomSlider.minValue;
            float endTime         = ZoomSlider.maxValue;
            int   sizeX           = _inputTexture.width;
            int   sizeY           = _inputTexture.height;
            int   maxMarkerLength = 15;

            _inputTexture.wrapMode = TextureWrapMode.Clamp;

            float[] Divisions  = new float[] { 60, 30, 15, 5, 1, 0.5f, 0.25f };
            float[] BarLengths = new float[] { 1, .78f, .7f, .6f, .48f, .3f, .2f };
            int     times      = Divisions.Length;

            if (endTime - startTime > 10f)
            {
                times--;
            }
            if (endTime - startTime > 30f)
            {
                times--;
            }
            if (endTime - startTime > 60f)
            {
                times--;
            }

            for (int i = times - 1; i >= 0; i--)
            {
                int Bars = Mathf.FloorToInt(endTime / Divisions[i]);
                for (int x = 1; x <= Bars; x++)
                {
                    int relativeX = Mathf.FloorToInt(AudioEditor.relativePosition(Divisions[i] * x, startTime, endTime) * sizeX);
                    for (int y = sizeY - Mathf.FloorToInt(maxMarkerLength * BarLengths[i]); y < sizeY; y++)
                    {
                        _inputTexture.SetPixel(relativeX, y, Color.Lerp(PrimaryLine, SecondaryLine, ((float)i / times)));
                    }
                }
            }
            for (int x = 0; x < sizeX; x++)
            {
                _inputTexture.SetPixel(x, sizeY - 1, BaseLine);
            }
            for (int y = sizeY - maxMarkerLength; y < sizeY; y++)
            {
                _inputTexture.SetPixel(0, y, PrimaryLine);
            }
            _inputTexture.Apply();
            return(_inputTexture);
        }
Esempio n. 4
0
        public void DrawEffect()
        {
            visible = EditorGUILayout.Foldout(visible, name);
            if (visible)
            {
                GUILayout.BeginVertical();

                enabled = GUILayout.Toggle(enabled, "Enabled");

                GUILayout.BeginHorizontal();
                GUILayout.Label("Trim Start: " + AudioEditor.timeFloatToString(TrimStart));
                TrimStart = Mathf.Min(EditorGUILayout.FloatField(TrimStart), TrimEnd);
                GUILayout.EndHorizontal();


                GUILayout.BeginHorizontal();
                GUILayout.Label("Trim End: " + AudioEditor.timeFloatToString(TrimEnd));
                TrimEnd = Mathf.Max(EditorGUILayout.FloatField(TrimEnd), TrimStart);
                GUILayout.EndHorizontal();

                GUILayout.EndVertical();
            }
        }
Esempio n. 5
0
        static void Init()
        {
            AudioEditor window = (AudioEditor)EditorWindow.GetWindow(typeof(AudioEditor));

            window.Show();
        }