Create a button to access the default preferences of the compressor.

mamomo wrote on 1/25/2024, 10:21 AM

Hello everyone,

I am working on a project in MAGIX Vegas Pro and was wondering if anyone could help me create a button or shortcut that allows me to assign the default preferences of the track compressor (Soft Limiter) to a specific track. I would like to simplify the process of adjusting the compressor and quickly accessing the preset configurations.

I have explored options in the track mixer and considered the possibility of using custom scripts, but I haven't found a direct solution yet.

Does anyone have any suggestions or faced a similar challenge before? I appreciate any advice or guidance you can provide.

Thanks in advance!

Comments

mark-y wrote on 1/25/2024, 11:41 AM

Only thing I can think of that might speed things up for you is to create a blank project and create a number of audio tracks with the starting compressor settings you would like as your default. Then open that blank project as your template for subsequent new projects.

Not a very elegant solution, I suspect. There's no easy way around those default audio track presets, it gets discussed from time to time.

jetdv wrote on 1/25/2024, 11:42 AM

@mamomo, what script did you try? I'm guessing that scripting is going to be your answer in this case.

wwaag wrote on 1/25/2024, 12:54 PM

@mamomo

There's a tool in HOS, FxAssist that would enable you to do this. Here's a screen grab of the dialog.

The Fx Track Compressor with the Preset Soft Limited could be saved as a Favorite and then applied to either all or selected audio tracks as shown.

Last changed by wwaag on 1/25/2024, 12:55 PM, changed a total of 1 times.

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia RTX4070 graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

rraud wrote on 1/25/2024, 1:00 PM

Aside from the above, If you create an FX chain with the comp/limiter, the comp settings should come up, when you re-open the chainer preset.
A script would probably be best, Writing it would be @jetdv area of expertise.

mamomo wrote on 1/26/2024, 12:34 PM

Thank you very much for the answers...

The truth is that the payment option does not interest me, I think I have already spent a lot on Vegas and also in Vegasaur.

By the way, does anyone know if with Vegasaur could do what I need?

jetdv wrote on 1/26/2024, 12:57 PM

@mamomo, explain your exact needs and we'll write you a quick little script that does that.

Do you want to just pick that one preset on the default Compressor effect on all selected tracks?

Add a compressor with that preset?

Please state your exact needs.

wwaag wrote on 1/26/2024, 4:11 PM

@mamomo

Since you already have Vegasaur, you're in luck.

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia RTX4070 graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

mamomo wrote on 1/28/2024, 12:17 PM

I will try to explain it in another way because it might not have been understood.

There are several processes that I frequently perform, and I like to optimize the workflow to make everything faster.

I need to create a button or shortcut to execute an action, in my case, applying a sound adjustment to the current track or, if all tracks are selected, specifically using the "Soft Limiter" setting of the track compressor.

I know it's an adjustment that is easily done, but as I mentioned, I do it many times, and it would be great to just press a simple button.


wwaag wrote on 1/28/2024, 2:31 PM

This should work for you. Note that it works only for selected audio tracks. Here's a demo.

And the code for the script.

using System;
using ScriptPortal.Vegas;
using System.Windows.Forms;
using System.IO;public class EntryPoint
    {
        public static Vegas myVegas;
        public void FromVegas(Vegas vegas)
        {            
            myVegas = vegas;
            try
            {
                foreach (var track in myVegas.Project.Tracks)
                {
                    //check if track is video or not selected
                    if (track.IsVideo()) continue;
                    if (!track.Selected) continue; 

                   //remove existing track compressor fx
                    for (int i = track.Effects.Count - 1; i >= 0; i--)
                    {
                        var ef = track.Effects[i];
                        if (ef.PlugIn.Name == "Track Compressor")
                        {                            
                            track.Effects.Remove(ef);
                        }
                    }
                   
                    //add new track compressor fx and set preset
                    var presetName = "[Sys] Soft Limiter";
                    PlugInNode plug = myVegas.AudioFX.GetChildByName("Track Compressor");
                    Effect eff = new Effect(plug);
                    track.Effects.Add(eff);
                    eff.Preset = presetName;

                    //update vegas ui
                    myVegas.UpdateUI();                   
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
    }

To install, copy the above code, open any text editor and paste it. Then save it with a .cs extension. You can name it anything you like. Then add it to the script menu folder. Eg. for V21, it would be C:\Program Files\VEGAS\VEGAS Pro 21.0\Script Menu". At that point you can add your own icon, and launch it from the Vegas toolbar or create a keyboard shortcut.

Last changed by wwaag on 1/28/2024, 2:38 PM, changed a total of 2 times.

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia RTX4070 graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

mamomo wrote on 1/29/2024, 1:18 PM

At the moment it does not work for me, the following error appears to me

"The value cannot be void"



Can it be because Vegas is in Spanish?

wwaag wrote on 1/29/2024, 1:21 PM

In your text editor, try changing "Track Compressor" and "[Sys] Soft Limiter" to their Spanish names.

AKA the HappyOtter at https://tools4vegas.com/. System 1: Intel i7-8700k with HD 630 graphics plus an Nvidia RTX4070 graphics card. System 2: Intel i7-3770k with HD 4000 graphics plus an AMD RX550 graphics card. System 3: Laptop. Dell Inspiron Plus 16. Intel i7-11800H, Intel Graphics. Current cameras include Panasonic FZ2500, GoPro Hero11 and Hero8 Black plus a myriad of smartPhone, pocket cameras, video cameras and film cameras going back to the original Nikon S.

jetdv wrote on 1/29/2024, 3:09 PM

@mamomo ( @wwaag ) Change this:

                    //add new track compressor fx and set preset
                     var presetName = "[Sys] Soft Limiter";
                     PlugInNode plug = myVegas.AudioFX.GetChildByName("Track Compressor");
                     Effect eff = new Effect(plug);
                     track.Effects.Add(eff);
                     eff.Preset = presetName;

to:

            //add new track compressor fx and set preset
            PlugInNode plug = myVegas.AudioFX.GetChildByClassID("23c9f225-40ec-11d2-9d36-00c04f8edc1e");
            Effect eff = new Effect(plug);
            track.Effects.Add(eff);
            eff.Preset = eff.Presets[2];

That will find the effect via the ID which is the same in all languages and pick the "second" preset (0 is the first one (Untitled), 1 is the second one [Sys] Default all parameters, and 2 is the third one [Sys] Soft Limiter) which is the standard "[Sys] Soft Limiter" preset.

Track Compressor - 23c9f225-40ec-11d2-9d36-00c04f8edc1e - (Untitled) - 1
Track Compressor - 23c9f225-40ec-11d2-9d36-00c04f8edc1e - [Sys] Default all parameters - 2
Track Compressor - 23c9f225-40ec-11d2-9d36-00c04f8edc1e - [Sys] Soft Limiter - 3
Track Compressor - 23c9f225-40ec-11d2-9d36-00c04f8edc1e - [Sys] 1.5:1 compression starting at -24 dB - 4
Track Compressor - 23c9f225-40ec-11d2-9d36-00c04f8edc1e - [Sys] 2:1 compression starting at -18 dB - 5
Track Compressor - 23c9f225-40ec-11d2-9d36-00c04f8edc1e - [Sys] 3:1 compression starting at -15 dB - 6
Track Compressor - 23c9f225-40ec-11d2-9d36-00c04f8edc1e - [Sys] 6:1 compression starting at -12 dB - 7
Track Compressor - 23c9f225-40ec-11d2-9d36-00c04f8edc1e - [Sys] 10:1 compression starting at -9 dB - 8
Track Compressor - 23c9f225-40ec-11d2-9d36-00c04f8edc1e - [Sys] Limit levels to -6 dB (hard limiter) - 9

By searching for ID and using an alternate method to pick the preset, it can be made to work with all languages.

mamomo wrote on 1/30/2024, 2:56 AM

I have changed those parameters and it doesn't work:

C:\Program Files\VEGAS\VEGAS Pro 21.0\Script Menu\_nivelar sonido.cs(29) : La mejor coincidencia de método sobrecargado para 'ScriptPortal.Vegas.PlugInNode.GetChildByClassID(System.Guid)' tiene algunos argumentos no válidos
C:\Program Files\VEGAS\VEGAS Pro 21.0\Script Menu\_nivelar sonido.cs(29) : Argumento 1: no se puede convertir de 'string' a 'System.Guid'
C:\Program Files\VEGAS\VEGAS Pro 21.0\Script Menu\_nivelar sonido.cs(32) : No se puede convertir implícitamente el tipo 'ScriptPortal.Vegas.EffectPreset' en 'string'


A datalle scheme the preset is called the same as in English, so perhaps the reference you have indicated is not necessary, although it may be that having some own presets, that may affect.

jetdv wrote on 1/30/2024, 9:27 AM

@mamomo - fully debugged now. Change out everything from the "foreach" to the "UpdateUI" lines to be this:

            foreach (var track in myVegas.Project.Tracks)
            {
                //check if track is video or not selected
                if (track.IsVideo()) continue;
                if (!track.Selected) continue;

                //remove existing track compressor fx
                for (int i = track.Effects.Count - 1; i >= 0; i--)
                {
                    var ef = track.Effects[i];
                    if (ef.PlugIn.ClassID.ToString() == "23c9f225-40ec-11d2-9d36-00c04f8edc1e")

                    {
                        track.Effects.Remove(ef);
                    }
                }

                //add new track compressor fx and set preset
                PlugInNode plug = myVegas.AudioFX.GetChildByClassID(new Guid("23c9f225-40ec-11d2-9d36-00c04f8edc1e"));

                Effect eff = new Effect(plug);
                track.Effects.Add(eff);
                eff.Preset = eff.Presets[2].Name;


                //update vegas ui
                myVegas.UpdateUI();

The actual updated lines are bolded above. And it should now work in any language.

mamomo wrote on 1/30/2024, 2:47 PM

Hello all!

I wanted to express my sincere gratitude for the code you provided. It works flawlessly! Your dedication and effort have been immensely helpful to me. I truly appreciate your collaboration and for taking the time to contribute to solving this issue.

Thank you so much again!

mamomo wrote on 9/17/2024, 5:38 AM

Hello everyone,

Although the last script worked very well, it didn't adjust the clip length correctly. So, with the help of Artificial Intelligence, I'm sharing an improved version here. I hope it helps someone else, as it did for me; I use it constantly.

95% speed (slowdown)

using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    Vegas myVegas = null;
    Form dlog = new Form();

    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;
        AdjustPlaybackRate(0.95f); // Aplicar directamente el 95% al abrir la ventana
        dlog.Close(); // Cerrar la ventana automáticamente
    }

    void AdjustPlaybackRate(float rate)
    {
        foreach (Track track in myVegas.Project.Tracks)
        {
            foreach (TrackEvent trackEvent in track.Events)
            {
                if (trackEvent.Selected)
                {
                    // Ajustar tanto audio como video relacionados
                    SyncAndAdjustEvent(trackEvent, rate);
                }
            }
        }
    }

    void SyncAndAdjustEvent(TrackEvent selectedEvent, float rate)
    {
        // Ajustar el evento seleccionado (audio o video)
        AdjustEvent(selectedEvent, rate);

        // Buscar el evento relacionado (audio o video)
        foreach (Track track in myVegas.Project.Tracks)
        {
            foreach (TrackEvent trackEvent in track.Events)
            {
                // Si encontramos un evento relacionado con el seleccionado
                if (trackEvent != selectedEvent && AreEventsLinked(selectedEvent, trackEvent))
                {
                    // Ajustar el evento relacionado para que coincida
                    AdjustEvent(trackEvent, rate, selectedEvent.Length);
                }
            }
        }
    }

    bool AreEventsLinked(TrackEvent event1, TrackEvent event2)
    {
        // Consideramos que los eventos están vinculados si comparten la misma posición de inicio
        return event1.Start == event2.Start && event1.Length == event2.Length;
    }

    void AdjustEvent(TrackEvent trackEvent, float rate, Timecode syncedLength = null)
    {
        // Ajustar eventos de audio
        if (trackEvent.Track.IsAudio())
        {
            trackEvent.AdjustPlaybackRate(rate, true); // Ajustar la tasa de reproducción del audio
            if (syncedLength != null)
            {
                trackEvent.Length = syncedLength; // Sincronizar duración con el video
            }
            else
            {
                // Ajustar la duración del evento de audio
                double newLengthInSeconds = trackEvent.Length.ToMilliseconds() / 1000.0 / rate;
                trackEvent.Length = new Timecode(newLengthInSeconds * 1000);
            }
        }

        // Ajustar eventos de video
        if (trackEvent.Track.IsVideo())
        {
            VideoEvent videoEvent = trackEvent as VideoEvent;
            if (videoEvent != null)
            {
                videoEvent.PlaybackRate = rate; // Ajustar la tasa de reproducción del video
                if (syncedLength != null)
                {
                    videoEvent.Length = syncedLength; // Sincronizar duración con el audio
                }
                else
                {
                    // Ajustar la longitud del evento de video
                    double newLengthInSeconds = videoEvent.Length.ToMilliseconds() / 1000.0 / rate;
                    videoEvent.Length = new Timecode(newLengthInSeconds * 1000);
                }
            }
        }
    }
}

105% speed (accelerate)

using System;
using System.Windows.Forms;
using ScriptPortal.Vegas;

public class EntryPoint
{
    Vegas myVegas = null;
    Form dlog = new Form();

    public void FromVegas(Vegas vegas)
    {
        myVegas = vegas;
        AdjustPlaybackRate(1.05f); // Aplicar directamente el 105% al abrir la ventana
        dlog.Close(); // Cerrar la ventana automáticamente
    }

    void AdjustPlaybackRate(float rate)
    {
        foreach (Track track in myVegas.Project.Tracks)
        {
            foreach (TrackEvent trackEvent in track.Events)
            {
                if (trackEvent.Selected)
                {
                    // Ajustar tanto audio como video relacionados
                    SyncAndAdjustEvent(trackEvent, rate);
                }
            }
        }
    }

    void SyncAndAdjustEvent(TrackEvent selectedEvent, float rate)
    {
        // Ajustar el evento seleccionado (audio o video)
        AdjustEvent(selectedEvent, rate);

        // Buscar el evento relacionado (audio o video)
        foreach (Track track in myVegas.Project.Tracks)
        {
            foreach (TrackEvent trackEvent in track.Events)
            {
                // Si encontramos un evento relacionado con el seleccionado
                if (trackEvent != selectedEvent && AreEventsLinked(selectedEvent, trackEvent))
                {
                    // Ajustar el evento relacionado para que coincida
                    AdjustEvent(trackEvent, rate, selectedEvent.Length);
                }
            }
        }
    }

    bool AreEventsLinked(TrackEvent event1, TrackEvent event2)
    {
        // Consideramos que los eventos están vinculados si comparten la misma posición de inicio
        return event1.Start == event2.Start && event1.Length == event2.Length;
    }

    void AdjustEvent(TrackEvent trackEvent, float rate, Timecode syncedLength = null)
    {
        // Ajustar eventos de audio
        if (trackEvent.Track.IsAudio())
        {
            trackEvent.AdjustPlaybackRate(rate, true); // Ajustar la tasa de reproducción del audio
            if (syncedLength != null)
            {
                trackEvent.Length = syncedLength; // Sincronizar duración con el video
            }
            else
            {
                // Ajustar la duración del evento de audio
                double newLengthInSeconds = trackEvent.Length.ToMilliseconds() / 1000.0 / rate;
                trackEvent.Length = new Timecode(newLengthInSeconds * 1000);
            }
        }

        // Ajustar eventos de video
        if (trackEvent.Track.IsVideo())
        {
            VideoEvent videoEvent = trackEvent as VideoEvent;
            if (videoEvent != null)
            {
                videoEvent.PlaybackRate = rate; // Ajustar la tasa de reproducción del video
                if (syncedLength != null)
                {
                    videoEvent.Length = syncedLength; // Sincronizar duración con el audio
                }
                else
                {
                    // Ajustar la longitud del evento de video
                    double newLengthInSeconds = videoEvent.Length.ToMilliseconds() / 1000.0 / rate;
                    videoEvent.Length = new Timecode(newLengthInSeconds * 1000);
                }
            }
        }
    }
}