Button/Script help

Apologies if this has been raised before, but several searches haven’t come up with a complete answer for me.
I have created a gui button that will lower the player volume on first press by -12db; on the second press will restore the volume to 0db. It works a treat, but sounds awful (as you might expect).
I came across a script (written by shorty, I think) which would smooth out the sound, but was designed for the encoder mic switch. So, my question, how to I get this to work with my button, please?

Here is the code

var
i, target, delay : integer;

procedure OnEncoderInputToggle(Input: TEncoderInput; NewState: boolean);
begin
target := -12; // set your target duck range here
delay := 100; // set the delay betwee steps here to smoothen the fade

if (Input = eiMic) and (NewState = false) then begin
for i := (target) to 0 do
begin
ExecuteCommand('PLAYER 1-1 VOLUME ’ + IntToStr(i));
Sleep(delay);
end;
end
else if (Input = eiMic) and (NewState = true) then begin
for i := 0 downto (target) do
begin
ExecuteCommand('PLAYER 1-1 VOLUME ’ + IntToStr(i));
Sleep(delay);
end;
end;
end;

Please make sure to mark code as such.

Try the following:

const
  TARGET := -12; // set your target duck range here
  DELAY  := 100; // set the delay between steps here to smoothen the fade

var
  i: integer;

procedure OnExecuteCommand(Command: string);
begin
  if Command = 'RAISE VOLUME PLAYER 1-1' then
  begin
    for i := (TARGET) to 0 do
    begin
      ExecuteCommand('PLAYER 1-1 VOLUME ' + IntToStr(i));
      Sleep(DELAY);
    end;
  end
  else if Command = 'LOWER VOLUME PLAYER 1-1' then
  begin
    for i := 0 downto (TARGET) do
    begin
      ExecuteCommand('PLAYER 1-1 VOLUME ' + IntToStr(i));
      Sleep(DELAY);
    end;
  end;
end;

(Untested.)

Make your button use the commands RAISE VOLUME PLAYER 1-1 and LOWER VOLUME PLAYER 1-1.

1 Like

Thank you Tondose. I saved the code as volume.mls and added it to the background scripts in the config.
When I start Mairlist it has an error loading background script file address :[Error] (2:10): is (‘=’) expected

Change the respective lines to

  TARGET = -12; // set your target duck range here
  DELAY  = 100; // set the delay between steps here to smoothen the fade

please.

2 Likes

That’s all sorted: Vielen Dank

Hello again.
Having this successfully working (thanks again, Tondose) has me wondering if it would be possible to use this one procedure for more than one instance?
For example, is there a way to pass a different string such as ‘RAISE VOLUME PLAYER 1-2’ instead of 'RAISE VOLUME PLAYER 1-1’and have the command processed as 'PLAYER 1-2 VOLUME ', please.

Would it be unfavourable to duck both players simultaneously?

No, not at all.
I was just wondering if there is a way to pass different strings to the procedure.
As you may have realised my scripting skills are very very basic. :grinning:

I should have mentioned that I operate different instances: one “normal” and one for VT work. I’ve already successfully adapted the script to use with the VT layout but requires a separate .mls file.

You cn make use of the ISVT and NOVT commands. See the wiki for details.

As far as I know both instances are using different configs, if set up properly. So if you just copy the .mls and activate each for the special instance they should be only accessed by the assigned configuration.

If you choose it as a background script for the VT instance only it should work independently of the playout instance…

Hi Stefan.
Yes, you are correct about the instances. Agreed, it makes sense to keep the VT one separate.
Thanks for the advice.

1 Like

Thanks, I’ll look into it.