Events moved leave audio parts behind

Jack S wrote on 8/19/2024, 4:55 AM

@jetdv Hi Edward. I wonder if you can help me with a problem I have. I can usually figure most things out now but this has me stumped.
Some tools in my application extension require that events are either moved or their lengths changed. I find that, when moved, the video parts of the event get separated from their audio parts because they become ungrouped. Is there a way to ensure that this ungrouping doesn't take place so both parts move or be resized together?
The other option is that I resync them after the move. I've watched your tutorial on resyncing events but that only applied to two video events (part of the same media) and you stated that the event to be resynced had always to be to one on top.
I've tried the resyncing on an ungrouped video event and couldn't get it to work.
I'd appreciate any help you can give me,
Thanks in advance.

My system
Genshin Infinity Gaming PC
Motherboard Gigabyte H610M H: m-ATX w/, USB 3.2, 1 x M.2
Power Supply Corsair RM750X
Intel Core i7-13700K - 16-Core [8P @ 3.4GHz-5.4GHz / 8E @ 2.50GHz-4.20GHz]
30MB Cache + UHD Graphics, Ultimate OC Compatible
Case Fan 4 x CyberPowerPC Hyperloop 120mm ARGB & PWM Fan Kit
CPU Fan CyberPowerPC Master Liquid LITE 360 ARGB AIO Liquid Cooler, Ultimate OC Compatible
Memory 32GB (2 x 16GB) DDR5/5200MHz Corsair Vengeance RGB
MSI GeForce RTX 4060 Ti 8GB - Ray Tracing Technology, DX12, VR Ready, HDMI, DP
System drive 1TB WD Black SN770 M.2 NVMe PCIe SSD - 5150MB/s Read & 4900MB/s Write
Storage 2 x 2TB Seagate BarraCuda SATA-III 6.0Gb/s 7200RPM
Windows 11 Home (x64)
Monitors
Generic Monitor (PHL 222V8) connected to GeForce RTX 4060 Ti
Generic Monitor (SAMSUNG) connected to iGPU

Camcorder
SONY Handycam HDR-XR550VE

Comments

Thiago_Sase wrote on 8/19/2024, 5:26 AM

@Jack S Hello, maybe this script can be a reference to help. For sure @jetdv has a complete solution.

 

using System;
using System.Collections.Generic; // Add this for List<T>
using System.Drawing; // Add this for color and font
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    public void FromVegas(Vegas vegas)
    {
        // Adjustable sizes
        int controlWidth = 160;
        int controlHeight = 25;
        int labelWidth = 80;

        // Create a form
        Form form = new Form();
        form.Text = "Move Event by Frames, Seconds, or Minutes";
        form.StartPosition = FormStartPosition.CenterScreen;
        form.Width = controlWidth + 40;
        form.Height = 200;

        // Set dark theme colors
        form.BackColor = Color.FromArgb(45, 45, 48); // Dark background
        form.ForeColor = Color.White; // White text

        // Set the font to Segoe UI
        Font segoeFont = new Font("Segoe UI", 10, FontStyle.Regular);
        form.Font = segoeFont;

        // Create a label for the ComboBox
        Label typeLabel = new Label();
        typeLabel.Text = "Select unit:";
        typeLabel.Top = 12;
        typeLabel.Left = 10;
        typeLabel.Width = labelWidth;
        form.Controls.Add(typeLabel);

        // Create a ComboBox for selecting frames, seconds, or minutes
        ComboBox typeComboBox = new ComboBox();
        typeComboBox.Top = 10;
        typeComboBox.Left = 90;
        typeComboBox.Width = controlWidth - labelWidth;
        typeComboBox.Items.AddRange(new string[] { "Frames", "Seconds", "Minutes" });
        typeComboBox.SelectedIndex = 0;
        typeComboBox.BackColor = Color.FromArgb(30, 30, 30); // Darker combo box background
        typeComboBox.ForeColor = Color.White;
        form.Controls.Add(typeComboBox);

        // Create a label for input
        Label label = new Label();
        label.Text = "Set Value:";
        label.Top = 50;
        label.Left = 10;
        label.Width = labelWidth;
        form.Controls.Add(label);

        // Create a numeric up-down control for input
        NumericUpDown inputBox = new NumericUpDown();
        inputBox.Top = 48;
        inputBox.Left = 90;
        inputBox.Width = controlWidth - labelWidth;
        inputBox.Minimum = 0;
        inputBox.Maximum = 1000;
        inputBox.BackColor = Color.FromArgb(30, 30, 30); // Darker numeric box background
        inputBox.ForeColor = Color.White;
        form.Controls.Add(inputBox);

        // Create a button to move backward (swapped with forward)
        Button backwardButton = new Button();
        backwardButton.Text = "Move Left";
        backwardButton.Top = 90;
        backwardButton.Left = 10;
        backwardButton.Width = controlWidth;
        backwardButton.Height = controlHeight;
        backwardButton.BackColor = Color.FromArgb(28, 28, 28); // Darker button background
        backwardButton.ForeColor = Color.White;
        backwardButton.FlatStyle = FlatStyle.Flat; // Flat style for a more modern look
        backwardButton.FlatAppearance.BorderSize = 1; // Thin border
        backwardButton.Click += (sender, args) =>
        {
            MoveEventsTogether(vegas, (int)inputBox.Value, typeComboBox.SelectedItem.ToString(), false);
        };
        form.Controls.Add(backwardButton);

        // Create a button to move forward (swapped with backward)
        Button forwardButton = new Button();
        forwardButton.Text = "Move Right";
        forwardButton.Top = 120;
        forwardButton.Left = 10;
        forwardButton.Width = controlWidth;
        forwardButton.Height = controlHeight;
        forwardButton.BackColor = Color.FromArgb(28, 28, 28);
        forwardButton.ForeColor = Color.White;
        forwardButton.FlatStyle = FlatStyle.Flat;
        forwardButton.FlatAppearance.BorderSize = 1;
        forwardButton.Click += (sender, args) =>
        {
            MoveEventsTogether(vegas, (int)inputBox.Value, typeComboBox.SelectedItem.ToString(), true);
        };
        form.Controls.Add(forwardButton);

        // Show the form
        form.ShowDialog();
    }

    void MoveEventsTogether(Vegas vegas, int amount, string type, bool forward)
    {
        Timecode offset;

        if (type == "Frames")
        {
            offset = Timecode.FromFrames(amount);
        }
        else if (type == "Seconds")
        {
            offset = Timecode.FromSeconds(amount);
        }
        else if (type == "Minutes")
        {
            offset = Timecode.FromSeconds(amount * 60); // Convert minutes to seconds
        }
        else
        {
            throw new ArgumentException("Invalid time unit specified.");
        }

        // Iterate over each track
        foreach (Track track in vegas.Project.Tracks)
        {
            // Get a list of all selected events on the track
            var selectedEvents = new List<TrackEvent>();
            foreach (TrackEvent trackEvent in track.Events)
            {
                if (trackEvent.Selected)
                {
                    selectedEvents.Add(trackEvent);
                }
            }

            // Move all selected events and their grouped events together
            foreach (TrackEvent trackEvent in selectedEvents)
            {
                // Move the selected event
                if (forward)
                {
                    trackEvent.Start += offset;
                }
                else
                {
                    trackEvent.Start -= offset;
                }

                // Check if the event is grouped and move all grouped events
                if (trackEvent.IsGrouped)
                {
                    foreach (TrackEvent groupedEvent in trackEvent.Group)
                    {
                        // Skip the selected event since it's already moved
                        if (groupedEvent == trackEvent)
                            continue;

                        if (forward)
                        {
                            groupedEvent.Start += offset;
                        }
                        else
                        {
                            groupedEvent.Start -= offset;
                        }
                    }
                }
            }
        }

        vegas.UpdateUI(); // Refresh UI to reflect changes immediately
    }

}

 

Last changed by Thiago_Sase on 8/19/2024, 5:32 AM, changed a total of 1 times.

OS: Windows 10 22H2
CPU: Intel Core I7 12700
MEMORY: 32GB DDR4 3200MHz
GHAPHIC CARD: RTX 3060 8GB
HARD DRIVES: SSD for System and M.2 for Media Files

jetdv wrote on 8/19/2024, 8:02 AM

@Jack S they should not become "ungrouped" but a script will move events individually so if there are multiple items in the group, only the moved event will be moved. To keep them together, you have to move BOTH of them separately. So you'll need to find some way to find matching events. In the example by Thiago_Sase, it goes through each "grouped" event so they could also be moved.

Jack S wrote on 8/19/2024, 10:19 AM

@jetdv Thanks for responding.
 

To keep them together, you have to move BOTH of them separately.

I thought that might be the case but I had to ask the question.

@Thiago_Sase Thanks for including that script. There's certainly a section of it I can use that'll solve my problem.

I'm much obliged to you both.

My system
Genshin Infinity Gaming PC
Motherboard Gigabyte H610M H: m-ATX w/, USB 3.2, 1 x M.2
Power Supply Corsair RM750X
Intel Core i7-13700K - 16-Core [8P @ 3.4GHz-5.4GHz / 8E @ 2.50GHz-4.20GHz]
30MB Cache + UHD Graphics, Ultimate OC Compatible
Case Fan 4 x CyberPowerPC Hyperloop 120mm ARGB & PWM Fan Kit
CPU Fan CyberPowerPC Master Liquid LITE 360 ARGB AIO Liquid Cooler, Ultimate OC Compatible
Memory 32GB (2 x 16GB) DDR5/5200MHz Corsair Vengeance RGB
MSI GeForce RTX 4060 Ti 8GB - Ray Tracing Technology, DX12, VR Ready, HDMI, DP
System drive 1TB WD Black SN770 M.2 NVMe PCIe SSD - 5150MB/s Read & 4900MB/s Write
Storage 2 x 2TB Seagate BarraCuda SATA-III 6.0Gb/s 7200RPM
Windows 11 Home (x64)
Monitors
Generic Monitor (PHL 222V8) connected to GeForce RTX 4060 Ti
Generic Monitor (SAMSUNG) connected to iGPU

Camcorder
SONY Handycam HDR-XR550VE