vMix Forums
	 » 
	General
	 » 
	General Discussion
	 » 
	Trigger Scripts from Multiview Layer Toggle On/Off
	 
	
        
            
            
    
        
	Rank: Member
  Groups: Registered
 Joined: 5/18/2023(UTC) Posts: 16  Location: Colorado Thanks: 4 times Was thanked: 1 time(s) in 1 post(s)
  
	 
	
     | 
    
        
            
		      
                As part of my live shows, I have 3 hosts and up to 3 guests, all remote via vMix Call.
  I have a 3-Up multiview arrangement that I use to put up various combinations of hosts and guests.
  I also have a Green Room that when I take our guests off Program, get routed to Audio Bus C (Green Room Mix), Removed from Audio Bus A (Master Mix) and then the Video Call Audio Source is set to C also. I do the reverse for when they are 'Live'.
  Sample Script for 3 Hosts on Screen in Multiview:
  Function=SetLayer&Input=3-Up&Value=1,Host 1 Call Function=SetLayer&Input=3-Up&Value=2,Host 1 L3rd Static
  Function=SetLayer&Input=3-Up&Value=3,Host 3 Call Function=SetLayer&Input=3-Up&Value=4,Host 3 L3rd Static
  Function=SetLayer&Input=3-Up&Value=5,Host 2 Call Function=SetLayer&Input=3-Up&Value=6,Host 2 L3rd Static
  Function=AudioBusOn&Value=A&Input=Host 1 Call Function=AudioBusOn&Value=A&Input=Host 2 Call Function=AudioBusOn&Value=A&Input=Host 3 Call
  Function=AudioBusOff&Value=C&Input=Host 1 Call Function=AudioBusOff&Value=C&Input=Host 2 Call Function=AudioBusOff&Value=C&Input=Host 3 Call
  Function=VideoCallAudioSource&Value=BusA&Input=Host 1 Call Function=VideoCallAudioSource&Value=BusA&Input=Host 2 Call Function=VideoCallAudioSource&Value=BusA&Input=Host 3 Call[/i][/i][/i]
  The problem is that I have to have every arrangement accounted for and I use almost an entire Streamdeck page to account for all the variations between Hosts and Guests. I also have the reverse scripts set for taking them off screen, so it ends up resulting in a ton of scripts and buttons. But, it does work! So it isn't the worst set up.
  Is there a way I can dynamically trigger scripts based on who is Live and who is turned Off in the Multiview input?
  Thanks in advance for any help and please let me know if I can provide more information!
 
  
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
            
        
            
            
    
        
	Rank: Advanced Member
  Groups: Registered
 Joined: 12/27/2012(UTC) Posts: 5,451  Location: Belgium Thanks: 311 times Was thanked: 1008 time(s) in 830 post(s)
  
	 
	
     | 
    
        
            
		      
                Originally Posted by: Video-Chopper  As part of my live shows, I have 3 hosts and up to 3 guests, all remote via vMix Call.
  I have a 3-Up multiview arrangement that I use to put up various combinations of hosts and guests.
  I also have a Green Room that when I take our guests off Program, get routed to Audio Bus C (Green Room Mix), Removed from Audio Bus A (Master Mix) and then the Video Call Audio Source is set to C also. I do the reverse for when they are 'Live'.
  Sample Script for 3 Hosts on Screen in Multiview:
  Function=SetLayer&Input=3-Up&Value=1,Host 1 Call Function=SetLayer&Input=3-Up&Value=2,Host 1 L3rd Static
  Function=SetLayer&Input=3-Up&Value=3,Host 3 Call Function=SetLayer&Input=3-Up&Value=4,Host 3 L3rd Static
  Function=SetLayer&Input=3-Up&Value=5,Host 2 Call Function=SetLayer&Input=3-Up&Value=6,Host 2 L3rd Static
  Function=AudioBusOn&Value=A&Input=Host 1 Call Function=AudioBusOn&Value=A&Input=Host 2 Call Function=AudioBusOn&Value=A&Input=Host 3 Call
  Function=AudioBusOff&Value=C&Input=Host 1 Call Function=AudioBusOff&Value=C&Input=Host 2 Call Function=AudioBusOff&Value=C&Input=Host 3 Call
  Function=VideoCallAudioSource&Value=BusA&Input=Host 1 Call Function=VideoCallAudioSource&Value=BusA&Input=Host 2 Call Function=VideoCallAudioSource&Value=BusA&Input=Host 3 Call[/i][/i][/i]
  The problem is that I have to have every arrangement accounted for and I use almost an entire Streamdeck page to account for all the variations between Hosts and Guests. I also have the reverse scripts set for taking them off screen, so it ends up resulting in a ton of scripts and buttons. But, it does work! So it isn't the worst set up.
  Is there a way I can dynamically trigger scripts based on who is Live and who is turned Off in the Multiview input?
  Thanks in advance for any help and please let me know if I can provide more information!
 
   consider vb.met scripting and using API.FUnctions for your commands that way you can add logic to your scripts . See "scripting for dummies" post for ideas  
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
    
        
            
            
    
        
	Rank: Member
  Groups: Registered
 Joined: 5/18/2023(UTC) Posts: 16  Location: Colorado Thanks: 4 times Was thanked: 1 time(s) in 1 post(s)
  
	 
	
     | 
    
        
            
		      
                Thanks...I have combed through the Scripting for Dummies and have tried almost 100 different scripts using API functions and various VB.Net scripts.
  I have not seen any API functions that can identify multiview layer status in realtime as it changes, which seems to be the ultimate hang up.
  If you know of anything specific I can look into, that would be super helpful!!
  
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
            
        
            
            
    
        
	Rank: Advanced Member
  Groups: Registered
 Joined: 11/23/2020(UTC) Posts: 217  Location: Wichita Thanks: 11 times Was thanked: 29 time(s) in 25 post(s)
  
	 
	
     | 
    
        
            
		      
                Originally Posted by: Video-Chopper  Thanks...I have combed through the Scripting for Dummies and have tried almost 100 different scripts using API functions and various VB.Net scripts.
  I have not seen any API functions that can identify multiview layer status in realtime as it changes, which seems to be the ultimate hang up.
  If you know of anything specific I can look into, that would be super helpful!!
   That's because you should be using Triggers, set it up with triggers on each input(s) using the "OnTransitionIn" trigger calling your script to bring the guests audio on and the "OnTransitionOut" to call the script to turn their audio off.  It's possible that EVERYTHING you are doing could in fact be done in a series of OnTansitionIn and OnTransitionOut triggers on each input and no script needed. How to do it depends on which you think would work best for you.  
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
    
        
            
            
    
        
	Rank: Member
  Groups: Registered
 Joined: 5/18/2023(UTC) Posts: 16  Location: Colorado Thanks: 4 times Was thanked: 1 time(s) in 1 post(s)
  
	 
	
     | 
    
        
            
		      
                Hey Roy!
  I currently do have the inputs set up with these scripts so that the audio routing is done automatically, and for single host shots, it works perfectly.
  What I would like to accomplish is to have the Multiview input layer with my assorted arrangements recognize who is 'active' and then route the audio accordingly without me having to have a streamdeck button and preset for each possible arrangement (host 1/host 2/host 3, host 1/host 2/guest 1, so on so forth).
  All the issue lies within the Multiview layer; i would love to get rid of all these additional layout variations and just have a couple buttons for swapping out hosts/guests and let the scripts dictate who should be where audio wise.
  Certainly open to other workflows though too! 
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
            
        
            
            
    
        
	Rank: Member
  Groups: Registered
 Joined: 5/18/2023(UTC) Posts: 16  Location: Colorado Thanks: 4 times Was thanked: 1 time(s) in 1 post(s)
  
	 
	
     | 
    
        
            
		      
                I am still struggling with this one...I would love some tips, advice or some code to point me in the right direction! I would gladly pay for someone's time to explain this functionality to me as well. 
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
    
        
            
            
    
        
	Rank: Advanced Member
  Groups: Registered
 Joined: 11/23/2020(UTC) Posts: 217  Location: Wichita Thanks: 11 times Was thanked: 29 time(s) in 25 post(s)
  
	 
	
     | 
    
        
            
		      
                Originally Posted by: Video-Chopper  I am still struggling with this one...I would love some tips, advice or some code to point me in the right direction! I would gladly pay for someone's time to explain this functionality to me as well.  Triggers don't activate for an input in a Multiview layer but if the Multiview layer is of a Mix instead of an input then which guest is active is controlled at the Mix and triggers will be activated for a mix so: Your Multiview should be displaying Mixes (Only available from the UpArrow part of the "Add Input" button) instead of specific inputs. Each "Mix" would occupy one of the "Guest" layers and then you would have buttons to assign each "Guest" input to the Mix that occupies the "Guest" layer you want them on in the Multiview and that way the triggers will be triggered when the "Guest" is added to the mix and that will also place them into the multiview layer and of course the trigger will also active when the guest is removed from the mix. Essentially you need to add a layer of complexity to get the functionality you need.  
            
	  
         
     | 
    
        
              1 user thanked Roy Sinclair for this useful post.  
     | 
    
        
     | 
    | 
        
	
     | 
        
        
        
            
        
            
            
    
        
	Rank: Member
  Groups: Registered
 Joined: 5/18/2023(UTC) Posts: 16  Location: Colorado Thanks: 4 times Was thanked: 1 time(s) in 1 post(s)
  
	 
	
     | 
    
        
            
		      
                Eureka! I think I got it!! In conjunction with doggy's Mix Preview script, this allows you to dynamically trigger scripts based on the Mix Input Preview. The only thing left to figure out is how to set it up before taking the input to Program, without the audio going live -- ie, preset the Multiview Input and then let it 'auto' route the audio after it hits program...but that is for another day. Quote:'Dynamically trigger scripts for inputs based on Mix Input Previews Dim oldPreview(5) As String ' To store the last preview input for each Mix Input Dim x As New System.Xml.XmlDocument
  Do While True     x.LoadXml(API.XML())
      ' Loop through each Mix Input (2, 3, 4, 5 in this example)     For Each MixNumber As Integer In New Integer() {2, 3, 4, 5}         ' Try to get the node first before accessing its properties         Dim node = x.SelectSingleNode("//mix[@number='" & MixNumber & "']/preview")
          If node IsNot Nothing Then             Dim currentPreview As String = node.InnerText
              ' Compare with old preview input             If oldPreview(MixNumber) <> currentPreview Then                 ' Set the script name to start based on the current Preview                 Dim scriptName As String = ""
                  Select Case currentPreview                     Case "1"                         scriptName = "Host 1 Audio In"                     Case "2"                         scriptName = "Host 2 Audio In"                     Case "3"                         scriptName = "Host 3 Audio In"                     Case "4"                         scriptName = "Guest 1 Audio In"                     Case Else                         ' Here, you can specify separate Audio Out scripts for each host and guest                         Select Case oldPreview(MixNumber)                             Case "1"                                 scriptName = "Host 1 Audio Out"                             Case "2"                                 scriptName = "Host 2 Audio Out"                             Case "3"                                 scriptName = "Host 3 Audio Out"                             Case "4"                                 scriptName = "Guest 1 Audio Out"                             Case Else                                 scriptName = "Generic Audio Out" ' Fallback generic audio out script                         End Select                 End Select
                  ' Run the script                 API.Function("ScriptStart", Value := scriptName)
                  ' Update old preview input                 oldPreview(MixNumber) = currentPreview             End If         Else             ' Handle the case where the node was not found             Console.WriteLine("Node not found for Mix " & MixNumber)         End If     Next
      Sleep(500) ' Wait for half a second before the next iteration Loop
   LETS F-ING GOOOO!!!!!!! SO PROUD OF MYSELF RIGHT NOW!!! Thank you to everyone who pointed me in the right direction!!  
            
	  
         
     | 
    | 
         
             
     | 
    
         
            
         
     | 
    | 
        
	
     | 
        
        
        
    
                           
	vMix Forums
	 » 
	General
	 » 
	General Discussion
	 » 
	Trigger Scripts from Multiview Layer Toggle On/Off
	 
	
    
        Forum Jump
         
	
    
    You cannot post new topics in this forum.
	
	You cannot reply to topics in this forum.
	
	You cannot delete your posts in this forum.
	
	You cannot edit your posts in this forum.
	
	You cannot create polls in this forum.
	
	You cannot vote in polls in this forum.
	
	
    
    
        Important Information:
        The vMix Forums uses cookies. By continuing to browse this site, you are agreeing to our use of cookies.
        
        
More Details
        Close