changeset 1:32af787f8cb8

Migrate files from gist committer: GitHub <noreply@github.com>
author Paper <37962225+mrpapersonic@users.noreply.github.com>
date Mon, 23 Jan 2023 23:25:44 -0500
parents 08b074facb6b
children f3e30ce83303
files README.md add_dynamics.cs convert_pitch_scheme.cs disable_resample.cs screenflip.cs screenflip_vert.cs
diffstat 6 files changed, 239 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/README.md	Mon Jan 23 23:24:30 2023 -0500
+++ b/README.md	Mon Jan 23 23:25:44 2023 -0500
@@ -1,2 +1,5 @@
-# vegas-scripts
-My Vegas Pro scripts
+Hi, this is where I put (most of) my Vegas Pro scripts
+
+Each file assumes that you're using version 14 or up. There is one *major* exception, which is the disable resample script. It doesn't make the check because resample can be disabled project-wide in 14 and up anyway, so I've just made it 13-compatible from the get-go
+
+But if you do use a Sony version of Vegas, you can just remove the `#define VER_GEQ_14` and it'll work just fine
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/add_dynamics.cs	Mon Jan 23 23:25:44 2023 -0500
@@ -0,0 +1,35 @@
+#define VER_GEQ_14 // remove this for vegas 13
+#if VER_GEQ_14
+using ScriptPortal.Vegas;
+#else
+using Sony.Vegas;
+#endif
+using System.Windows.Forms;
+
+public class EntryPoint {
+    string DynamicsID = "{00000008-0F56-11D2-9887-00A0C969725B}";
+    public void FromVegas(Vegas vegas) {
+        foreach (PlugInNode plugin in vegas.AudioFX) {
+            if (plugin.Name == "ExpressFX Dynamics" && plugin.UniqueID == DynamicsID) {
+                foreach (Track track in vegas.Project.Tracks) {
+                    foreach (TrackEvent trackEvent in track.Events) {
+                        if (trackEvent.Selected && trackEvent.IsAudio()) {
+                            AudioEvent audio = trackEvent as AudioEvent;
+                            foreach (Effect effect in audio.Effects) {
+                                if (effect.PlugIn.UniqueID == DynamicsID) {
+                                    audio.Effects.Remove(effect);
+                                }
+                            }
+                            Effect DynamicsPlugin = audio.Effects.AddEffect(plugin);
+                            foreach (Preset preset in DynamicsPlugin.Presets) {
+                                if (preset.Name == "preset") {
+                                    DynamicsPlugin.CurrentPreset = preset;
+                                }
+                            }
+                        }
+                    }
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/convert_pitch_scheme.cs	Mon Jan 23 23:25:44 2023 -0500
@@ -0,0 +1,110 @@
+/* NOTE: Requires VEGAS 16 or higher. */
+
+using ScriptPortal.Vegas;
+using System;
+using System.Windows.Forms;
+using System.Collections.Generic;
+
+public class EntryPoint {
+    private Dictionary<string, int> stretchAttributes = new Dictionary<string, int>
+    {
+        {"Pro", 0},
+        {"Efficient", 1},
+        {"Soloist (Monophonic)", 2},
+        {"Soloist (Speech)", 3},
+        {"A01. Music 1 (minimum flange, may echo)", 4},
+        {"A02. Music 2", 5},
+        {"A03. Music 3 (less echo)", 6},
+        {"A04. Music 4 (fast, good for bass)", 7},
+        {"A05. Music 5", 8},
+        {"A06. Music 6", 9},
+        {"A07. Speech 1", 10},
+        {"A08. Speech 2", 11},
+        {"A09. Speech 3 (fast)", 12},
+        {"A10. Solo instruments 1", 13},
+        {"A11. Solo instruments 2", 14},
+        {"A12. Solo instruments 3", 15},
+        {"A13. Solo instruments 4 (less echo)", 16},
+        {"A14. Solo instruments 5", 17},
+        {"A15. Solo instruments 6", 18},
+        {"A16. Solo instruments 7 (fast)", 19},
+        {"A17. Drums, unpitched (minimum echo)", 20},
+        {"A18. Drums (better for toms)", 21},
+        {"A19. Drums (tiny echo)", 22}
+    };
+    public void FromVegas(Vegas vegas) {
+        int stretchAttribute = Prompt.GetOptions(stretchAttributes);
+        foreach (var track in vegas.Project.Tracks) {
+            foreach (var trackEvent in track.Events) {
+                if (trackEvent.Selected && trackEvent.IsAudio()) {
+                    AudioEvent audio = trackEvent as AudioEvent;
+                    if ((stretchAttribute >= 0) && (stretchAttribute <= 3)) {
+                        audio.Method = (TimeStretchPitchShift)2; /* pitch shift method; 0 is elastique, 1 is acid style, 2 is classic, and 3 is none */
+                        audio.ElastiqueAttribute = (ElastiqueStretchAttributes)stretchAttribute;
+                    } else if (stretchAttribute >= 4) {
+                        audio.Method = (TimeStretchPitchShift)0;
+                        audio.ClassicAttribute = (ClassicStretchAttributes)stretchAttribute-4;
+                    }
+                }
+            }
+        }
+    }
+}
+
+class Prompt
+{
+    public static int GetOptions(Dictionary<string,int> stretchAttributes)
+    {
+        Form prompt = new Form() {
+            Width = 300,
+            Height = 103,
+            FormBorderStyle = FormBorderStyle.FixedSingle,
+            MaximizeBox = false,
+            MinimizeBox = false,
+            ShowIcon = false,
+            Text = "made by paper"
+        };
+        ComboBox
+        inputValue = new ComboBox()
+        {
+            Left = 7,
+            Top = 10,
+            Width = (prompt.Width - 30)
+        };
+        Button
+        confirmation = new Button()
+        {
+            Text = "OK",
+            Left = 7,
+            Width = (prompt.Width - 30),
+            Top = 35,
+            DialogResult = DialogResult.OK
+        };
+
+        inputValue.BeginUpdate();
+        inputValue.DataSource = new BindingSource(stretchAttributes, null);
+        inputValue.DisplayMember = "Key";
+        inputValue.ValueMember = "Value";
+        inputValue.EndUpdate();
+
+        inputValue.DropDownStyle = ComboBoxStyle.DropDownList;
+
+        prompt.Controls.Add(inputValue);
+        prompt.Controls.Add(confirmation);
+        prompt.AcceptButton = confirmation;
+
+        confirmation.Click += (sender, e) =>
+        {
+            prompt.Close();
+        };
+
+        if (prompt.ShowDialog() == DialogResult.OK)
+        {
+            return inputValue.SelectedIndex;
+        }
+        else
+        {
+            return -1;
+        }
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/disable_resample.cs	Mon Jan 23 23:25:44 2023 -0500
@@ -0,0 +1,15 @@
+using Sony.Vegas;
+
+public class EntryPoint {
+	public void FromVegas(Vegas vegas) {
+		foreach (Track track in vegas.Project.Tracks) {
+			if (track.IsVideo()) {
+				foreach (TrackEvent evnt in track.Events) {
+					VideoEvent videoEvent = (VideoEvent)evnt;
+					VideoResampleMode VRMode = VideoResampleMode.Disable;
+					videoEvent.ResampleMode = VRMode;
+				}
+			}
+		}
+	}
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screenflip.cs	Mon Jan 23 23:25:44 2023 -0500
@@ -0,0 +1,33 @@
+#define VER_GEQ_14 // remove this for vegas 13
+#if VER_GEQ_14
+using ScriptPortal.Vegas;
+#else
+using Sony.Vegas;
+#endif
+using System.Windows.Forms;
+
+public class EntryPoint {
+    public void FromVegas(Vegas vegas) {
+        foreach (Track track in vegas.Project.Tracks) {
+            int count = 1;
+            foreach (TrackEvent trackEvent in track.Events) {
+                if (trackEvent.Selected && trackEvent.IsVideo()) {
+                    VideoEvent video = trackEvent as VideoEvent;
+                    foreach (VideoMotionKeyframe keyframe in video.VideoMotion.Keyframes) {
+                        VideoMotionVertex tl = keyframe.TopLeft, 
+                                          tr = keyframe.TopRight, 
+                                          bl = keyframe.BottomLeft, 
+                                          br = keyframe.BottomRight;
+                        VideoMotionBounds bh = new VideoMotionBounds(tl, tr, br, bl);
+                        if (count == 2)
+                            bh = new VideoMotionBounds(tr, tl, bl, br);
+                        keyframe.Bounds = bh;
+                    }
+                    if (count == 2)
+                        count = 0;
+                    count += 1;
+                }
+            }
+        }
+    }
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/screenflip_vert.cs	Mon Jan 23 23:25:44 2023 -0500
@@ -0,0 +1,41 @@
+#define VER_GEQ_14 // remove this for vegas 13
+#if VER_GEQ_14
+using ScriptPortal.Vegas;
+#else
+using Sony.Vegas;
+#endif
+using System.Windows.Forms;
+
+public class EntryPoint {
+    public void FromVegas(Vegas vegas) {
+        foreach (Track track in vegas.Project.Tracks) {
+            int count = 1;
+            foreach (TrackEvent trackEvent in track.Events) {
+                if (trackEvent.Selected && trackEvent.IsVideo()) {
+                    VideoEvent video = trackEvent as VideoEvent;
+                    foreach (VideoMotionKeyframe keyframe in video.VideoMotion.Keyframes) {
+                        VideoMotionVertex tl = keyframe.TopLeft, 
+                                          tr = keyframe.TopRight, 
+                                          bl = keyframe.BottomLeft, 
+                                          br = keyframe.BottomRight;
+                        VideoMotionBounds bh = new VideoMotionBounds(tl, tr, br, bl);
+                        switch (count) {
+                            case 2:
+                                keyframe.Bounds = new VideoMotionBounds(tr, tl, bl, br);
+                                break;
+                            case 3:
+                                keyframe.Bounds = new VideoMotionBounds(br, bl, tl, tr);
+                                break;
+                            case 4:
+                                keyframe.Bounds = new VideoMotionBounds(bl, br, tr, tl);
+                                break;
+                        }
+                        if (count == 4)
+                            count = 0;
+                        count += 1;
+                    }
+                }
+            }
+        }
+    }
+}