ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs - C#

Ask software engineering and SDK questions for developers working on Mac OS X, Windows or Linux.
  • Author
  • Message
Offline

Michael Vandemore

  • Posts: 2
  • Joined: Wed Nov 18, 2015 11:25 am

ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs - C#

PostThu Nov 19, 2015 9:36 am

I'm writing a C# application that needs to be able to set any of the the AUX outputs (1-6) to any of the 20 inputs plus Black and Bars.

I have looked at the "SwitcherPanelCSharp" sample program that ships with the product as well as the SDK documentation and I haven't been able to find a good example of how to do this.

Can anyone provide me to a good example of how to set the Input source for the AUX outputs using C#?
Offline
User avatar

JohnBengston

  • Posts: 570
  • Joined: Sun Sep 30, 2012 1:52 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostMon Nov 23, 2015 3:32 pm

Download slightly modified sample from:

http://www.justmacros.tv/downloads/other/SwitcherPanelCSharp_With6AUX_Combos.zip

Image

As mentioned in private exchange there are 4 steps which I'll cover in 4 follow on posts.

• Define Aux Monitors / callback
• Add Monitor callback to each Aux("Input")
• Handle Changes to Aux Sources
• Handle Changes to the Combo
Offline
User avatar

JohnBengston

  • Posts: 570
  • Joined: Sun Sep 30, 2012 1:52 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostMon Nov 23, 2015 3:40 pm

So to define a monitor for the AUX change callback is fairly simple, you can just copy another as they are all very similar, here is what I did.

Image

I've defined a property AuxNumber, but it's not really necessary they way I am going to use this, but if you wanted to be super-streamlined, it might be worth passing the Aux Number in the event.

Otherwise it's simply implementing the one function required by the IBMDSwitcherInputCallback interface.

In that function we call any event handlers we have will attach from the form.
Offline
User avatar

JohnBengston

  • Posts: 570
  • Joined: Sun Sep 30, 2012 1:52 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostMon Nov 23, 2015 3:51 pm

So we need to attach these events to the IBMDSwitcherInputAux, and I choose to do that when we first connect to the ATEM, so in the Switcher connected function.

Image

So what I am doing here is getting the type of the Input and if it's actually an AUXOutput-Input, We create a New MonitorObject and attach an Event Handler in this (form)context, we then pass this new object to AddCallBack of the input object (cast as an AuxOutput).

Finally you'#ll see I add the monitor object to a Pointer List - Is actually fairly pointless as I didn't clean this list up "OnDisconnect" - Why? - Coz there ain't a disconnect button, you can only disconnect by closing the window, and in which case, I'll leave Windows to clean it up - this is just pure lazyness on my part - you should do better!!! ;)

Image
Offline
User avatar

JohnBengston

  • Posts: 570
  • Joined: Sun Sep 30, 2012 1:52 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostMon Nov 23, 2015 4:30 pm

So then you need to populate the Combo boxes with their possible sources and set the value to the current AUX.

BMD have nicely done most of this for us in the routine "UpdatePopupItems", so we just add our Combo Boxes - and in fact I add a test to ensure we are not adding the AUXOutputs as available Inputs for TX/Prog or AUX Source selected.

Image

So that was easy, now we need have an Event Handler from Part2 update the Combo boxes, this is done with two routines.

Firstly our event handler "OnAuxSourceChanged", super-simple - one line calling a function "UpdateAuxSourceCombos()", but we do it using Invoke to avoid any thread scoping issues. Again this can be copy-pasted-tweaked from the LongName Input example provided by BMD.

Image

The "UpdateAuxSourceCombos" routine again enumerates the inputs, identifies the Aux-Output-Inputs, calls "GetSourceInput", finds the relevenat Combo Box and sets the value.

Image

Like I said before, you could do it a bit more precisely, because you do actually know which AUX number and hence Combo needs updating, but since it's just 6 controls and 6 AUX SDK calls, I decided may as well update them all. If ATEMs had a 1000 AUXs, it might be worth streamlining a bit.

You could also probably be a bit more efficient by using Control Arrays, but I did it this way - feel free to improve upon.....

So we now have ComboBoxs with all the available inputs, and they are updating when changes are made in the BMD Software, so the final bit to add is an OnChange handler on the Combo to call into the API and Set the AUX Output values.
Offline
User avatar

JohnBengston

  • Posts: 570
  • Joined: Sun Sep 30, 2012 1:52 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostMon Nov 23, 2015 4:44 pm

I use just one handler for all 6 boxes - half an eye on the fact I should be using a Control Array, and really a dynamic one at that given there are different numbers of AUXs on different ATEM models, but since this post was about a 2ME, and my inherent laziness when it comes to C# - that's half the point isn't it :lol: , the sample is like it is.

Image

So you see I do a bit of string manipulation to pickup the AUX number from the senders name, and then pickup the new Source ID from the Combo data pairs.

Now all we need to do is re-iterate the Inputs - identify the Auxs - keep count so we know when we have the right one, and then Cast the input to an AuxOutput interface, and call the SetInputSource method.

Done, works.....

Some notes: some of the interfaces used have been deprecated by BMD, and you may want to update to the "_ver_6_5".... whatever versions..... but essentially this is the answer to your question.
I know the code added could be better / more efficient more suited to OOD, but I mostly wanted to copy paste from the existing BMD stuff, and hey.... I already spent a long time creating a very efficient and optimised wrapper of this API. ;)
Offline

Michael Vandemore

  • Posts: 2
  • Joined: Wed Nov 18, 2015 11:25 am

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostTue Nov 24, 2015 7:55 am

John:

This is really great, I can't tell you how much I appreciate the time and effort you put into it.

Thanks again,

Mike

Important
One note to anyone else who reads this thread, this example requires you use Install ATEM v6.6.1.msi in order to run the example. (even though I bought my units in November, 2015, they shipped with Install ATEM 6.5.1.msi) You'll have to update the ATEM firmware using ATEM Setup Utility and connecting with a USB cable. It will automatically detect if the firmware is out of date and patch it. After that it's smooth sailing. :)
Last edited by Michael Vandemore on Wed Nov 25, 2015 8:23 am, edited 1 time in total.
Offline
User avatar

JohnBengston

  • Posts: 570
  • Joined: Sun Sep 30, 2012 1:52 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostTue Nov 24, 2015 11:16 am

If you are not "Michael Vandemore", as he already know about this, This update to the example was made to the Black Magic Design ATEM Sample: Windows\Samples\SwitcherPanelCSharp from version 6.6.

It actually won't work on earlier versions, reason given on:

http://forum.blackmagicdesign.com/viewtopic.php?f=12&t=42142

I can modify a version for earlier firmware if you need it.
Offline

Michael Valentine

  • Posts: 6
  • Joined: Sun Nov 01, 2015 9:55 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostFri Jan 22, 2016 3:46 pm

JohnBengston wrote:If you are not "Michael Vandemore", as he already know about this, This update to the example was made to the Black Magic Design ATEM Sample: Windows\Samples\SwitcherPanelCSharp from version 6.6.

I can modify a version for earlier firmware if you need it.


Hi John,

Is it possible to see a version that works in 6.3 at all?
Offline
User avatar

JohnBengston

  • Posts: 570
  • Joined: Sun Sep 30, 2012 1:52 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostSun Jan 24, 2016 1:27 pm

Yeah man, I'll try to do that next week, sorry I can't do anything quicker, but as mentioned above it's a mini-pain-in-the-ar53.

As mentioned on the link on my previous post, due to the way BMD reuse names and some times GUIDs and/or the IDL files/headers/exports from the DLL - it's very tricky to have a single code base for old firmware and new firmware, such that someone with 6.3 can re-compile code written against 6.6 without making changes to code and/or project settings. Thus in order to do this I need to revert an ATEM, which I can't really do at the moment. I got bored trying to explain how much of a problem this is to Nick, and just gave up. (I got the usual BMD response of "Deny and Deflect", which is always fun, but rarely useful!!! ;) )

It'll only take you 10 minutes to change the code yourself.

Each compiler error will be complaining about an interface method not existing, simply swap it out for one of the old equivalents.

Quick explanation:

6.6 SDK IBMDSwitcherInput
Image

So the code you can download from this topic is written against an interface called IBMDSwitcherInput and is defined as above in BMDs file ("%Program Files (x86)%\Blackmagic Design\Blackmagic ATEM Switchers\Developer SDK\Windows\includeBMDSwictherAPI.idl")

So one of the first errors you will be getting will be about calls to "GetPortType" because your "IBMDSwitcherInput" looks like this:

Image

which is how BMD maintain backwards compatibility (kinda), so this interface is now called "IBMDSwitcherInput_v6_5_1", where you obtained the Port Type by calling "GetInt" and passing a "_BMDSwitcherInputPropertyId_v6_5_1" value. In the case of "GetPortType", that first parameter will be "bmdSwitcherInputPropertyIdPortType_v6_5_1" or 0x70727470, as with a 6.3 firmware this CONSTANT will actually just be called "bmdSwitcherInputPropertyIdPortType"

Image

Hence if you change a call to GetPortType( value ) to GetInt( bmdSwitcherInputPropertyIdPortType, value), then that error will go away.

But I hope you see the problem, even if I had written the sample against the 6_5_1 (compatible with your 6.3 - generally speaking) GUIDS / SDK, you still wouldn't have been able to recompile it, as your IDLs won't have the "_V6_5_1" post-fixed to the ends of the names.

If you think this post is insane - I totally agree. But..... just going through your compiler errors swapping calls is all you need to do, and all I'll be doing when I re-install 6.3 on a test ATEM.

BMD would put the following position: "Developers target a particular firmware release", which is of course beyond ridiculous; "Developers target a particular ATEM (the one they are working with) not a firmware version". They have also pointed out "you can download the SDKs separately from the main package", but this is too much trouble as you are required to enter serial numbers of devices, which are invariably out on jobs or buried in racks when you need a download. It would also mean you needed to maintain your own directory structure of IDLs, and setup projects that linked to specific directories, that would have to match between developers machines in order for them to easily exchange code. You'd need to add "LOTS" of compiler directives to switch which firmware release your project was targeting. It's just... all..... way too much hassle!!

Anyway..... apologies again for not being able to do a quick reply to this, I promise you..... It's way more infuriating for me than you, and encourage you to have a go at burning through the changes required yourself, the first few may take you a few minutes, but you WILL quickly catch onto the process and the act of doing it, will help you understand the SDK.

Cheers

John
Offline

Jayanta Mukherjee

  • Posts: 1
  • Joined: Sun Feb 07, 2016 10:59 am

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostSun Feb 07, 2016 11:32 am

Hi,

I am writing in this segment as software developers are involved. Please help me.
I have a query regarding aux out embedded audio ,mean while i am facing a problem using sdi aux output with master audio embedding,I required a desire a audio channel or required audio channels to embedded to the desired aux output. As this very much essential on live music program as certain audio channels are need to be recorded separately. Is this possible to incorporate this feature with its software.
Please advise,,, it is very much required...It might be great feature for this switcher... i.e,this aux ports further can be used as routers.

Jayanta Mukherjee
Offline

Michael Valentine

  • Posts: 6
  • Joined: Sun Nov 01, 2015 9:55 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostSun Feb 07, 2016 9:08 pm

Hi John,

I appreciate you taking the time to go over all this.

I was actually able to change the initial bit of code to use GetInt to grab the Port Type, the issue I was having was actually checking whether or not the Port Type was an Aux Output. The reason being that using GetInt results in a variable of type long so I can't use the code from 6.6 obviously:

Code: Select all
if (inputPortType == BMDSwitcherAPI._BMDSwitcherPortType.bmdSwitcherPortTypeAuxOutput)


Looking through the .idl file I was struggling to find what it should be replaced with.
Offline

Daniel Lee

  • Posts: 3
  • Joined: Wed Sep 04, 2013 1:54 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostMon May 30, 2016 10:22 am

Hi,

Thank you for the detailed description above on the code samples.

I am fairly new at C# programming and I am having some difficulty working through the code samples above. I am working on a simple push button type application to select inputs for each output directly. Its not meant to be scalable but rather really simple for our church volunteers to run the app and just push buttons on the touchscreen.

From the sample code, I can do the following to change program/preview inputs directly:

private void button_Click(object sender, EventArgs e)
{
if (m_mixEffectBlock1 != null)
{
m_mixEffectBlock1.SetInt(_BMDSwitcherMixEffectBlockPropertyId.bmdSwitcherMixEffectBlockPropertyIdPreviewInput, 6);
}
}


Using the sample code with Aux Selections, can you advise how do I call the Aux Output directly and assign an input?

Specifically,
AUXCount++;
if (AUXCount == AuxNumber)
{
IBMDSwitcherInputAux WkAux = (IBMDSwitcherInputAux)input;
WkAux.SetInputSource(inputId);
break;
}

How can I modify the above to create the WkAux object simply for each Aux Input?

Apologies if this seems to be a very simple question but again, I am fairly new to C# and would appreciate any assistance here.

Thanks.

Daniel Lee
Offline

Ian Morrish

  • Posts: 580
  • Joined: Sun Jan 18, 2015 9:24 pm
  • Location: New Zealand

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostMon May 30, 2016 9:35 pm

I create a collection of Aux inputs.
Search for "C# IList" on Google
IList<SwitcherAuxPort> list = new List<SwitcherAuxPort>();

Then while looping through the inputIterator, when I detect it is an Aux input (which is really an output), I Add it to the collection...

list.Add(new SwitcherAuxPort() { Name = AuxName, ID = AuxId, Label = AuxLabel, Source = Source });

SwitcherAuxPort is defined as a simple class with ID, Label, Name and Source values.

You can then define get and set on the Source property.
I'm also very new with C# and unfortunately, dealing with BMD COM based API is probably the hardest way to learn C#.
Regards,
Ian Morrish
Video Integrated Scripting Environment
(Windows PowerShell with ATEM driver + more)
https://ianmorrish.wordpress.com
Offline

Daniel Lee

  • Posts: 3
  • Joined: Wed Sep 04, 2013 1:54 pm

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostTue May 31, 2016 7:28 am

Thanks Ian! I'll give it a buzz and see how it goes.

I come from a programming background which predates objected oriented programming. Trying to reverse engineer the sample code in itself is difficult. much less generating new stuff. At least there is sample code for me to adapt.
Offline

JohnKlok

  • Posts: 1
  • Joined: Mon Oct 02, 2017 11:26 am

Re: ATEM 2 M/E Studio 4K - Selecting Input for AUX Outputs -

PostMon Oct 02, 2017 11:36 am

Hello , I think you should try the functions and IBMDSwitcherInputCallback interface .
Thnks
t-shirt design tool :- https://www.appjetty.com/magento-product-designer.htm

Return to Software Developers

Who is online

Users browsing this forum: roger.magnusson and 10 guests