comparison Convert Pitch Scheme.cs @ 4:d32ae6be32a4

*: mass rename files committer: GitHub <noreply@github.com>
author Paper <37962225+mrpapersonic@users.noreply.github.com>
date Mon, 23 Jan 2023 23:35:06 -0500
parents convert_pitch_scheme.cs@32af787f8cb8
children
comparison
equal deleted inserted replaced
3:958615460fe5 4:d32ae6be32a4
1 /* NOTE: Requires VEGAS 16 or higher. */
2
3 using ScriptPortal.Vegas;
4 using System;
5 using System.Windows.Forms;
6 using System.Collections.Generic;
7
8 public class EntryPoint {
9 private Dictionary<string, int> stretchAttributes = new Dictionary<string, int>
10 {
11 {"Pro", 0},
12 {"Efficient", 1},
13 {"Soloist (Monophonic)", 2},
14 {"Soloist (Speech)", 3},
15 {"A01. Music 1 (minimum flange, may echo)", 4},
16 {"A02. Music 2", 5},
17 {"A03. Music 3 (less echo)", 6},
18 {"A04. Music 4 (fast, good for bass)", 7},
19 {"A05. Music 5", 8},
20 {"A06. Music 6", 9},
21 {"A07. Speech 1", 10},
22 {"A08. Speech 2", 11},
23 {"A09. Speech 3 (fast)", 12},
24 {"A10. Solo instruments 1", 13},
25 {"A11. Solo instruments 2", 14},
26 {"A12. Solo instruments 3", 15},
27 {"A13. Solo instruments 4 (less echo)", 16},
28 {"A14. Solo instruments 5", 17},
29 {"A15. Solo instruments 6", 18},
30 {"A16. Solo instruments 7 (fast)", 19},
31 {"A17. Drums, unpitched (minimum echo)", 20},
32 {"A18. Drums (better for toms)", 21},
33 {"A19. Drums (tiny echo)", 22}
34 };
35 public void FromVegas(Vegas vegas) {
36 int stretchAttribute = Prompt.GetOptions(stretchAttributes);
37 foreach (var track in vegas.Project.Tracks) {
38 foreach (var trackEvent in track.Events) {
39 if (trackEvent.Selected && trackEvent.IsAudio()) {
40 AudioEvent audio = trackEvent as AudioEvent;
41 if ((stretchAttribute >= 0) && (stretchAttribute <= 3)) {
42 audio.Method = (TimeStretchPitchShift)2; /* pitch shift method; 0 is elastique, 1 is acid style, 2 is classic, and 3 is none */
43 audio.ElastiqueAttribute = (ElastiqueStretchAttributes)stretchAttribute;
44 } else if (stretchAttribute >= 4) {
45 audio.Method = (TimeStretchPitchShift)0;
46 audio.ClassicAttribute = (ClassicStretchAttributes)stretchAttribute-4;
47 }
48 }
49 }
50 }
51 }
52 }
53
54 class Prompt
55 {
56 public static int GetOptions(Dictionary<string,int> stretchAttributes)
57 {
58 Form prompt = new Form() {
59 Width = 300,
60 Height = 103,
61 FormBorderStyle = FormBorderStyle.FixedSingle,
62 MaximizeBox = false,
63 MinimizeBox = false,
64 ShowIcon = false,
65 Text = "made by paper"
66 };
67 ComboBox
68 inputValue = new ComboBox()
69 {
70 Left = 7,
71 Top = 10,
72 Width = (prompt.Width - 30)
73 };
74 Button
75 confirmation = new Button()
76 {
77 Text = "OK",
78 Left = 7,
79 Width = (prompt.Width - 30),
80 Top = 35,
81 DialogResult = DialogResult.OK
82 };
83
84 inputValue.BeginUpdate();
85 inputValue.DataSource = new BindingSource(stretchAttributes, null);
86 inputValue.DisplayMember = "Key";
87 inputValue.ValueMember = "Value";
88 inputValue.EndUpdate();
89
90 inputValue.DropDownStyle = ComboBoxStyle.DropDownList;
91
92 prompt.Controls.Add(inputValue);
93 prompt.Controls.Add(confirmation);
94 prompt.AcceptButton = confirmation;
95
96 confirmation.Click += (sender, e) =>
97 {
98 prompt.Close();
99 };
100
101 if (prompt.ShowDialog() == DialogResult.OK)
102 {
103 return inputValue.SelectedIndex;
104 }
105 else
106 {
107 return -1;
108 }
109 }
110 }