Created
July 14, 2019 00:31
-
-
Save imorrish/c2aaff66f9986a9c676337a34b190d13 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#add-type -path 'C:\Users\imorrish\Source\Workspaces\VISE_ATEMLib\SwitcherLib\bin\Debug\SwitcherLib.dll' | |
#cd \scripts | |
$Videohub="192.168.1.50" | |
function ConnectToATEM() | |
{ | |
Try{ | |
$ATEMipAddress = (Get-ItemProperty -path 'HKCU:\Software\Blackmagic Design\ATEM Software Control').ipAddress | |
#$DocumentsPath = [Environment]::GetFolderPath("MyDocuments") + '\windowspowershell\SwitcherLib.dll' | |
add-type -path 'SwitcherLib.dll' | |
$Global:atem = New-Object SwitcherLib.Switcher($ATEMipAddress) | |
$atem.Connect() | |
} | |
catch{ | |
write-host "Can't connect to ATEM on $($ATEMipAddrss)." | |
Write-Host "ATEM controle software must be installed and have connected to switcher at least one time" | |
exit | |
} | |
} | |
ConnectToATEM | |
$MEs = $atem.GetMEs() | |
$me1 = $mes[0] | |
[int32]$global:cameraID=1 | |
[double]$global:IrisValue = 1.0 | |
[int]$global:WBValue=57600 | |
function resetcolor{ | |
[double]$global:GainValue = 1.0 | |
[double]$global:GainRed = 1.0 | |
[double]$global:GainGreen = 1.0 | |
[double]$global:GainBlue = 1.0 | |
[double]$global:GammaValue = 0.0 | |
[double]$global:GammaRed = 0.0 | |
[double]$global:GammaGreen = 0.0 | |
[double]$global:GammaBlue = 0.0 | |
[double]$global:LiftValue=0.0 | |
[double]$global:LiftRed=0.0 | |
[double]$global:LiftGreen=0.0 | |
[double]$global:LiftBlue=0.0 | |
[double]$Global:HueValue=0.0 #0-2 0deg-360deg | |
[double]$global:SatValue=1.0 #0-1 | |
[double]$global:ContrastValue=1 | |
} | |
resetcolor | |
# Hash table to hold values for each camera's settings | |
$Global:CameraValues = @{} | |
For($cID=1; $cID -lt 5; $cID++ ){ | |
$Key = [byte]$cID | |
try{ | |
$iris = $atem.GetCameraFStop($cID) | |
} | |
catch{$iris = 0.0} | |
$CameraValues.Add($Key,[PSCustomObject]@{ | |
Name = "Camera$cID" | |
IrisValue = $iris | |
FocusValue = 0.0 | |
GainValue = 1.0 | |
GainRed = 1.0 | |
GainGreen = 1.0 | |
GainBlue = 1.0 | |
GammaValue = 0.0 | |
GammaRed = 0.0 | |
GammaGreen = 0.0 | |
GammaBlue = 0.0 | |
LiftValue=0.0 | |
LiftRed = 0.0 | |
LiftGreen = 0.0 | |
LiftBlue = 0.0 | |
HueValue=0.0 | |
SatValue=1.0 | |
ContrastValue=1 | |
WBValue=57600 | |
}) | |
#set each camera to RGB rather than YRGB (Luma Mix) | |
$atem.CameraLuma($cID,0.0) | |
} | |
function resetCameraValues($ID){ | |
$Global:CameraValues[[byte]$ID].GainValue = 1 | |
$Global:CameraValues[[byte]$ID].GainRed = 1 | |
$Global:CameraValues[[byte]$ID].GainGreen = 1 | |
$Global:CameraValues[[byte]$ID].GainBlue = 1 | |
$Global:CameraValues[[byte]$ID].GammaValue = 0 | |
$Global:CameraValues[[byte]$ID].GammaRed = 0 | |
$Global:CameraValues[[byte]$ID].GammaGreen = 0 | |
$Global:CameraValues[[byte]$ID].GammaBlue = 0 | |
$Global:CameraValues[[byte]$ID].LiftValue = 0 | |
$Global:CameraValues[[byte]$ID].LiftBlue = 0 | |
$Global:CameraValues[[byte]$ID].LiftBlue = 0 | |
$Global:CameraValues[[byte]$ID].LiftBlue = 0 | |
$Global:CameraValues[[byte]$ID].HueValue = 0 | |
$Global:CameraValues[[byte]$ID].SatValue = 1 | |
} | |
function hubCommand($cmd){ | |
if($videohub -ne ""){.\send-tcprequest.ps1 -remoteHost $videohub -port 9990 -inputObject $cmd} | |
} | |
#Get the CMD DV-1 midi controller | |
Import-Module ".\PeteBrown.PowerShellMidi.dll" | |
[string]$MMMidiInID = "" | |
$MMinputDevices = Get-MidiInputDeviceInformation | |
$MMinputDevices | |
foreach ($MMdevice in $MMinputDevices) | |
{ | |
#if ($device.Name -eq "CMD Micro") | |
if ($MMdevice.Name -eq "CMD DV-1 [1]") | |
{ | |
$MMMidiInID = $MMdevice.Id | |
write-host $MMdevice.Id | |
} | |
} | |
[string]$mmMidiOutID = "" | |
$mmoutputDevices = Get-MidiOutputDeviceInformation | |
$mmoutputDevices | |
foreach ($mmdevice in $mmoutputDevices) | |
{ | |
#if ($device.Name -eq "CMD Micro") | |
if ($mmdevice.Name -eq "CMD DV-1 [0]") | |
{ | |
$mmMidiOutID = $mmdevice.Id | |
write-host $mmdevice.Id | |
} | |
} | |
[PeteBrown.PowerShellMidi.MidiInputPort]$mminputPort = Get-MidiInputPort -id $mmMidiInID | |
$mmoutputPort = Get-MidiOutputPort -id $mmMidiOutID | |
# set this to false if you don't want the input port to translate a zero velocity note on message into a note off message | |
$mminputPort.TranslateZeroVelocityNoteOnMessage = $true; | |
# this is just an identifier for our own use. It can be anything, but must be unique for each event subscription. | |
$mmnoteOnSourceId = "mmNoteOnMessageReceivedID" | |
$mmnoteOffSourceId = "mmNoteOffMessageReceivedID" | |
$mmcontrolChangeSourceId = "mmControlChangeMessageReceivedID" | |
$mmpitchBendChangeSourceId = "mmPitchBendChangeMessageReceivedID" | |
# remove the event if we are running this more than once in the same session. | |
Unregister-Event -SourceIdentifier $mmnoteOnSourceId -ErrorAction SilentlyContinue | |
Unregister-Event -SourceIdentifier $mmnoteOffSourceId -ErrorAction SilentlyContinue | |
Unregister-Event -SourceIdentifier $mmcontrolChangeSourceId -ErrorAction SilentlyContinue | |
Unregister-Event -SourceIdentifier $mmpitchBendChangeSourceId -ErrorAction SilentlyContinue | |
# register for the event | |
function mmHandleNoteOn($note){ | |
write-host $note | |
switch($note){ | |
{64,65,66,67 -contains $_}{ [byte]$camera = ($note-63);$atem.CameraAutoFocus($camera); write-host "Autofocus camera $($note-63)"} | |
{68,69,70,71 -contains $_}{ [byte]$camera = ($note-67);$atem.CameraAutoExposure($camera)} | |
{72,73,74,75 -contains $_}{ | |
[byte]$camera = ($note-71); | |
$atem.CameraColorReset($camera); | |
resetCameraValues $note-71 | |
if ($global:cameraID -eq ($note-71)){resetcolor} | |
} | |
92{changecamera 1;break} | |
93{changecamera 2;break} | |
94{changecamera 3;break} | |
95{changecamera 4;break} | |
88{changecamera 5;break} | |
89{changecamera 6;break} | |
90{changecamera 7;break} | |
91{changecamera 8;break} | |
{72,73,74,75 -contains $_}{ | |
[byte]$camera = ($note-71); | |
$atem.CameraColorReset($camera); | |
break; | |
} | |
84{ # camera tab | |
[Clicker]::LeftClickAtPoint(-1051, 1158) | |
} | |
85{ # toggle single/muti camera settings view | |
[Clicker]::LeftClickAtPoint(-1680, 765) | |
} | |
} | |
} | |
Unregister-Event $mmnoteOnSourceId -ErrorAction SilentlyContinue | |
$job5 = Register-ObjectEvent -InputObject $mminputPort -EventName NoteOnMessageReceived -SourceIdentifier $mmnoteOnSourceId -Action {mmHandleNoteOn $event.sourceEventArgs.Note} | |
#Unregister-Event $mmnoteOnSourceId -ErrorAction SilentlyContinue | |
function changecamera([byte]$ID){ | |
Write-Host "Changing to camera ID$ID" | |
#save current camera values to hash table | |
$Global:CameraValues[[byte]$Global:CameraID].IrisValue = $global:IrisValue | |
$Global:CameraValues[[byte]$Global:CameraID].FocusValue = $global:FocusValue | |
$Global:CameraValues[[byte]$Global:CameraID].GainValue = $global:GainValue | |
$Global:CameraValues[[byte]$Global:CameraID].GainRed = $global:GainRed | |
$Global:CameraValues[[byte]$Global:CameraID].GainGreen = $global:GainGreen | |
$Global:CameraValues[[byte]$Global:CameraID].GainBlue = $global:GainBlue | |
$Global:CameraValues[[byte]$Global:CameraID].GammaValue = $global:GammaValue | |
$Global:CameraValues[[byte]$Global:CameraID].GammaRed = $global:GammaRed | |
$Global:CameraValues[[byte]$Global:CameraID].GammaGreen = $global:GammaGreen | |
$Global:CameraValues[[byte]$Global:CameraID].GammaBlue = $global:GammaBlue | |
$Global:CameraValues[[byte]$Global:CameraID].LiftValue = $global:LiftValue | |
$Global:CameraValues[[byte]$Global:CameraID].LiftBlue = $global:LiftRed | |
$Global:CameraValues[[byte]$Global:CameraID].LiftBlue = $global:LiftGreen | |
$Global:CameraValues[[byte]$Global:CameraID].LiftBlue = $global:LiftBlue | |
$Global:CameraValues[[byte]$Global:CameraID].HueValue = $Global:HueValue | |
$Global:CameraValues[[byte]$Global:CameraID].SatValue = $global:SatValue | |
$Global:CameraValues[[byte]$Global:CameraID].WBValue = $global:WBValue | |
#turn off blue led | |
switch($Global:cameraID){ | |
1{Send-MidiNoteOnMessage -Channel 6 -Note 92 -Port $mmoutputPort -Velocity 0} | |
2{Send-MidiNoteOnMessage -Channel 6 -Note 93 -Port $mmoutputPort -Velocity 0} | |
3{Send-MidiNoteOnMessage -Channel 6 -Note 94 -Port $mmoutputPort -Velocity 0} | |
4{Send-MidiNoteOnMessage -Channel 6 -Note 95 -Port $mmoutputPort -Velocity 0} | |
5{Send-MidiNoteOnMessage -Channel 6 -Note 88 -Port $mmoutputPort -Velocity 0} | |
6{Send-MidiNoteOnMessage -Channel 6 -Note 89 -Port $mmoutputPort -Velocity 0} | |
7{Send-MidiNoteOnMessage -Channel 6 -Note 90 -Port $mmoutputPort -Velocity 0} | |
8{Send-MidiNoteOnMessage -Channel 6 -Note 91 -Port $mmoutputPort -Velocity 0} | |
} | |
#load new camera value | |
$global:IrisVale = $Global:CameraValues[$ID].IrisVale | |
$global:FocusVale = $Global:CameraValues[$ID].FocusVale | |
$global:GainValue = $Global:CameraValues[$ID].GainValue | |
$global:GainRed = $Global:CameraValues[$ID].GainRed | |
$global:GainGreen = $Global:CameraValues[$ID].GainGreen | |
$global:GainBlue = $Global:CameraValues[$ID].GainBlue | |
$global:GammaValue = $Global:CameraValues[$ID].GammaValue | |
$global:GammaRed = $Global:CameraValues[$ID].GammaRed | |
$global:GammaGreen = $Global:CameraValues[$ID].GammaGreen | |
$global:GammaBlue = $Global:CameraValues[$ID].GammaBlue | |
$global:LiftValue = $Global:CameraValues[$ID].LiftValue | |
$global:LiftRed = $Global:CameraValues[$ID].LiftRed | |
$global:LiftGreen = $Global:CameraValues[$ID].LiftGreen | |
$global:LiftBlue = $Global:CameraValues[$ID].LiftBlue | |
$Global:HueValue = $Global:CameraValues[$ID].HueValue | |
$global:SatValue = $Global:CameraValues[$ID].SatValue | |
$global:WBValue = $Global:CameraValues[$ID].WBValue | |
$Global:CameraID = $ID | |
switch($Global:cameraID){ | |
1{Send-MidiNoteOnMessage -Channel 6 -Note 92 -Port $mmoutputPort -Velocity 1 | |
[Clicker]::LeftClickAtPoint(-1309, 550)} | |
2{Send-MidiNoteOnMessage -Channel 6 -Note 93 -Port $mmoutputPort -Velocity 1 | |
[Clicker]::LeftClickAtPoint(-1243, 550)} | |
3{Send-MidiNoteOnMessage -Channel 6 -Note 94 -Port $mmoutputPort -Velocity 1 | |
[Clicker]::LeftClickAtPoint(-1179, 550)} | |
4{Send-MidiNoteOnMessage -Channel 6 -Note 95 -Port $mmoutputPort -Velocity 1 | |
[Clicker]::LeftClickAtPoint(-1114, 550)} | |
5{Send-MidiNoteOnMessage -Channel 6 -Note 88 -Port $mmoutputPort -Velocity 1} | |
6{Send-MidiNoteOnMessage -Channel 6 -Note 89 -Port $mmoutputPort -Velocity 1} | |
7{Send-MidiNoteOnMessage -Channel 6 -Note 90 -Port $mmoutputPort -Velocity 1} | |
8{Send-MidiNoteOnMessage -Channel 6 -Note 91 -Port $mmoutputPort -Velocity 1} | |
} | |
#switch Video Hub monitor port | |
$hubcommand = @" | |
VIDEO OUTPUT ROUTING: | |
12 {0} | |
`r`n | |
"@ -f ($Global:cameraID-1) | |
hubCommand $hubcommand | |
} | |
function mmHandleControlChange($controller, $Value) | |
{ | |
#Chroma Key values (Hue, Gain, Y Sup, Lift | |
#Write-host "Controll $($event.sourceEventArgs.Controller)" | |
#Write-host "value $($event.sourceEventArgs.Value)" | |
Write-host "Controll $($controller)" | |
Write-host "value $($Value)" | |
switch($controller){ | |
{64..67 -contains $_}{#Iris | |
$camerairis = $atem.GetCameraFStop($controller-63) | |
if($Value -eq 65) | |
{#increase value | |
$camerairis = $camerairis - 0.1 | |
if($camerairis -lt 1){$camerairis = 1} | |
$atem.CameraFStop(($controller-63),$camerairis) | |
} | |
else{#decrease value | |
$camerairis = $camerairis + 0.1 | |
if($camerairis -gt 10){$camerairis = 10} | |
$atem.CameraFStop(($controller-63),$camerairis) | |
} | |
$global:IrisVale = $camerairis | |
Write-Host " Iris changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $camerairis -ForegroundColor Red | |
Send-MidiControlChangeMessage -Channel 6 -Port $mmoutputPort -Value (IrisLED (11-$camerairis)) -Controller $controller #-Value 8 | |
break; | |
} | |
{36..39 -contains $_}{ #Lift | |
[byte]$camera = ($controller-35) | |
$lift = $Global:CameraValues[$camera].LiftValue | |
if($Value -eq 65) | |
{#increase value | |
$lift = $lift + 0.01 | |
if($lift -gt 0.2){$lift= 0.2} | |
} | |
else{#decrease value | |
$lift = $lift - 0.01 | |
if($lift -lt -0.2){$lift = -0.2} | |
} | |
$atem.CameraColorLiftMaster($controller-35,$lift) | |
$Global:CameraValues[$camera].LiftValue = $lift | |
Write-Host " Lift changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $lift -ForegroundColor Red | |
Send-MidiControlChangeMessage -Channel 6 -Port $mmoutputPort -Value (scale $lift -0.2 0.2 1 16) -Controller $controller | |
break; | |
} | |
{20,21,22,23 -contains $_}{ #WB | |
[byte]$camera = ($controller-19) | |
$wb = $Global:CameraValues[$camera].WBValue | |
if($Value -eq 65) | |
{#increase value | |
$wb = $wb + 50 | |
if($wb -gt 6000){$wb= 6000} | |
} | |
else{#decrease value | |
$wb = $wb - 50 | |
if($wb-lt 2500){$wb = 2500} | |
} | |
$atem.CameraWB($camera,$wb,1) | |
$Global:CameraValues[$camera].WBValue = $wb | |
Write-Host " WB changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $global:WBValue -ForegroundColor Red | |
Send-MidiControlChangeMessage -Channel 6 -Port $mmoutputPort -Value (scale $wb 2500 6000 1 16) -Controller $controller #-Value 8 | |
break; | |
} | |
{24,25,26,27-contains $_}{ #Saturation | |
[byte]$camera = ($controller-23) | |
$sat = $Global:CameraValues[$camera].SatValue | |
if($Value -eq 65) | |
{#increase value | |
$sat = $sat + 0.01 | |
if($sat -gt 2){$sat= 2} | |
} | |
else{#decrease value | |
$sat = $sat - 0.01 | |
if($sat-lt 0){$sat = 0} | |
} | |
$atem.CameraColorHueSat($camera,$Global:CameraValues[$camera].HueValue,$sat) | |
$Global:CameraValues[$camera].SatValue = $sat | |
Write-Host " Saturation changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $sat -ForegroundColor Red | |
Send-MidiControlChangeMessage -Channel 6 -Port $mmoutputPort -Value (scale $sat 0 2 1 16) -Controller $controller #-Value 8 | |
break; | |
} | |
{28,29,30,31 -contains $_}{ #Hue | |
[byte]$camera = ($controller-27) | |
$hue = $Global:CameraValues[$camera].HueValue | |
if($Value -eq 65) | |
{#increase value | |
$hue = $hue + 0.01 | |
if($hue -gt 1){$hue= 1} | |
} | |
else{#decrease value | |
$hue = $hue - 0.01 | |
if($hue-lt -1){$hue = -1} | |
} | |
$atem.CameraColorHueSat($camera,$hue,$Global:CameraValues[$camera].SatValue) | |
$Global:CameraValues[$camera].HueValue = $hue | |
Write-Host " Hue changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $hue -ForegroundColor Red | |
Send-MidiControlChangeMessage -Channel 6 -Port $mmoutputPort -Value (scale $hue -1 1 1 16) -Controller $controller #-Value 8 | |
break; | |
} | |
{32,33,34,35 -contains $_}{ #Contrast | |
[byte]$camera = ($controller-31) | |
$contrast = $Global:CameraValues[$camera].ContrastValue | |
if($Value -eq 65) | |
{#increase value | |
$contrast = $contrast + 0.01 | |
if($contrast -gt 2){$contrast= 2} | |
} | |
else{#decrease value | |
$contrast = $contrast - 0.01 | |
if($contrast-lt 0){$contrast = 0} | |
} | |
$atem.CameraColorContrast($camera,0.5,$Contrast) | |
$Global:CameraValues[$camera].ContrastValue = $contrast | |
Write-Host " Contrast changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $contrast -ForegroundColor Red | |
Send-MidiControlChangeMessage -Channel 6 -Port $mmoutputPort -Value (scale $contrast 0 2 1 16) -Controller $controller #-Value 8 | |
break; | |
} | |
40{ # Lift Master | |
[byte]$camera = $global:cameraID | |
$lift = $Global:CameraValues[$camera].LiftValua | |
if($Value -eq 65) | |
{#increase value | |
$lift = $lift + 0.01 | |
if($lift -gt 4){$lift= 4} | |
} | |
else{#decrease value | |
$lift = $lift - 0.01 | |
if($lift -lt -4){$lift = -4} | |
} | |
$atem.CameraColorLiftMaster($camera,$lift) | |
$Global:CameraValues[$camera].LiftValue = $lift | |
Write-Host " Lift Master changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $lift -ForegroundColor Red | |
Send-MidiControlChangeMessage -Channel 6 -Port $mmoutputPort -Value (scale $lift -4 4 1 16) -Controller $controller #-Value 8 | |
break; | |
} | |
41{ # Lift Red | |
[byte]$camera = $global:cameraID | |
[double]$red = $Global:CameraValues[$camera].LiftRed | |
if($Value -eq 65) | |
{#increase value | |
$red = $red + 0.02 | |
if($red -gt 4){$red= 4} | |
} | |
else{#decrease value | |
$red = $red - 0.02 | |
if($red-lt -4){$red = -4} | |
} | |
$atem.CameraColorLift($camera,$red,$Global:CameraValues[$camera].LiftGreen,$Global:CameraValues[$camera].LiftBlue) | |
$Global:CameraValues[$camera].LiftRed=$red | |
Write-Host " Lift Red changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $red -ForegroundColor Red | |
break; | |
} | |
42{ #Lift Green | |
[byte]$camera = $global:cameraID | |
[double]$green = $Global:CameraValues[$camera].LiftGreen | |
if($Value -eq 65) | |
{#increase value | |
$green = $green + 0.02 | |
if($green -gt 4){$green= 4} | |
} | |
else{#decrease value | |
$green = $green - 0.02 | |
if($green-lt -4){$green = -4} | |
} | |
$atem.CameraColorLift($camera,$Global:CameraValues[$camera].LiftRed,$green,$Global:CameraValues[$camera].LiftBlue) | |
$Global:CameraValues[$camera].LiftGreen=$green | |
Write-Host " LiftGreen changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $green -ForegroundColor Red | |
break; | |
} | |
43{ #Lift Blue | |
[byte]$camera = $global:cameraID | |
[double]$blue = $Global:CameraValues[$camera].LiftBlue | |
if($Value -eq 65) | |
{#increase value | |
$blue = $blue + 0.02 | |
if($blue -gt 4){$blue= 4} | |
} | |
else{#decrease value | |
$blue = $blue - 0.02 | |
if($blue-lt -4){$blue = -4} | |
} | |
$atem.CameraColorLift($camera,$Global:CameraValues[$camera].LiftRed,$Global:CameraValues[$camera].LiftGreen,$blue) | |
$Global:CameraValues[$camera].LiftBlue=$blue | |
Write-Host " Lift Blue changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $blue -ForegroundColor Red | |
break; | |
} | |
44{ # Gamma Master | |
[byte]$camera = $global:cameraID | |
$gamma = $Global:CameraValues[$camera].GammaValua | |
if($Value -eq 65) | |
{#increase value | |
$gamma = $gamma + 0.01 | |
if($gamma -gt 4){$gamma= 4} | |
} | |
else{#decrease value | |
$gamma = $gamma - 0.01 | |
if($gamma -lt -4){$gamma = -4} | |
} | |
$atem.CameraColorGammaMaster($camera,$gamma) | |
$Global:CameraValues[$camera].GammaValue = $gamma | |
} | |
45{ # Gamma Red | |
[byte]$camera = $global:cameraID | |
[double]$red = $Global:CameraValues[$camera].GammaRed | |
if($Value -eq 65) | |
{#increase value | |
$red = $red + 0.01 | |
if($red -gt 4){$red= 4} | |
} | |
else{#decrease value | |
$red = $red - 0.01 | |
if($red-lt -4){$red = -4} | |
} | |
$atem.CameraColorGamma($camera,$red,$Global:CameraValues[$camera].GammaGreen,$Global:CameraValues[$camera].GammaBlue) | |
$Global:CameraValues[$camera].GammaRed=$red | |
Write-Host " Gamma Red changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $red -ForegroundColor Red | |
break; | |
} | |
46{ #Gama Green | |
[byte]$camera = $global:cameraID | |
[double]$green = $Global:CameraValues[$camera].GammaGreen | |
if($Value -eq 65) | |
{#increase value | |
$green = $green + 0.01 | |
if($green -gt 4){$green= 4} | |
} | |
else{#decrease value | |
$green = $green - 0.01 | |
if($green-lt -4){$green = -4} | |
} | |
$atem.CameraColorGamma($camera,$Global:CameraValues[$camera].GammaRed,$green,$Global:CameraValues[$camera].GammaBlue) | |
$Global:CameraValues[$camera].GammaGreen=$green | |
Write-Host " Gamma Green changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $green -ForegroundColor Red | |
break; | |
} | |
47{ #Gama Blue | |
[byte]$camera = $global:cameraID | |
[double]$blue = $Global:CameraValues[$camera].GammaBlue | |
if($Value -eq 65) | |
{#increase value | |
$blue = $blue + 0.01 | |
if($blue -gt 4){$blue= 4} | |
} | |
else{#decrease value | |
$blue = $blue - 0.01 | |
if($blue-lt -4){$blue = -4} | |
} | |
$atem.CameraColorGamma($camera,$Global:CameraValues[$camera].GammaRed,$Global:CameraValues[$camera].GammaGreen,$blue) | |
$Global:CameraValues[$camera].GammaBlue=$blue | |
Write-Host " Gamma Blue changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $blue -ForegroundColor Red | |
break; | |
} | |
48{ # Gain Master | |
[byte]$camera = $global:cameraID | |
$gain = $Global:CameraValues[$camera].GainValue | |
if($Value -eq 65) | |
{#increase value | |
$gain = $gain + 0.01 | |
if($gain -gt 4){$gain= 4} | |
} | |
else{#decrease value | |
$gain = $gain - 0.01 | |
if($gain -lt 0){$gain = 0} | |
} | |
$atem.CameraColorGainMaster($camera,$gain) | |
$Global:CameraValues[$camera].GainValue = $gain | |
} | |
49{ # Gain Red | |
[byte]$camera = $global:cameraID | |
[double]$red = $Global:CameraValues[$camera].GainRed | |
if($Value -eq 65) | |
{#increase value | |
$red = $red + 0.01 | |
if($red -gt 4){$red= 4} | |
} | |
else{#decrease value | |
$red = $red - 0.01 | |
if($red-lt -4){$red = -4} | |
} | |
$atem.CameraColorGain($camera,$red,$Global:CameraValues[$camera].GainGreen,$Global:CameraValues[$camera].GainBlue) | |
$Global:CameraValues[$camera].GainRed=$red | |
Write-Host " Gain Red changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $red -ForegroundColor Red | |
break; | |
} | |
50{ #Gain Green | |
[byte]$camera = $global:cameraID | |
[double]$green = $Global:CameraValues[$camera].GainGreen | |
if($Value -eq 65) | |
{#increase value | |
$green = $green + 0.01 | |
if($green -gt 4){$green= 4} | |
} | |
else{#decrease value | |
$green = $green - 0.01 | |
if($green-lt -4){$green = -4} | |
} | |
$atem.CameraColorGain($camera,$Global:CameraValues[$camera].GainRed,$green,$Global:CameraValues[$camera].GainBlue) | |
$Global:CameraValues[$camera].GainGreen=$green | |
Write-Host " Gain Green changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $green -ForegroundColor Red | |
break; | |
} | |
51{ #Gain Blue | |
[byte]$camera = $global:cameraID | |
[double]$blue = $Global:CameraValues[$camera].GainBlue | |
if($Value -eq 65) | |
{#increase value | |
$blue = $blue + 0.01 | |
if($blue -gt 4){$blue= 4} | |
} | |
else{#decrease value | |
$blue = $blue - 0.01 | |
if($blue-lt 0){$blue = 0} | |
} | |
$atem.CameraColorGain($camera,$Global:CameraValues[$camera].GainRed,$Global:CameraValues[$camera].GainGreen,$blue) | |
$Global:CameraValues[$camera].GainBlue=$blue | |
Write-Host " Gain Blue changed: " -NoNewline -ForegroundColor DarkGray; Write-Host $blue -ForegroundColor Red | |
break; | |
} | |
} | |
} | |
Unregister-Event -SourceIdentifier $mmcontrolChangeSourceId -ErrorAction SilentlyContinue | |
$job7 = Register-ObjectEvent -InputObject $mminputPort -EventName ControlChangeMessageReceived -SourceIdentifier $mmcontrolChangeSourceId -Action {mmHandleControlChange $event.sourceEventArgs.Controller $event.sourceEventArgs.Value} | |
function IrisLED($value){ | |
#write-host $value | |
normalize $value 1 16 | |
} | |
function LiftLED($value){ | |
#write-host $value | |
$normalized = ((($value - 1) * ($max - $min)) / (10 - 1)) + 1 | |
#$normalized = (($max- $min) / ($max - $min)*($value -$min)+$min) | |
return [math]::round($normalized) | |
} | |
function normalize($value, $min, $max) { | |
#$normalized = [math]::Round(($value - $min) / ($max - $min),4) | |
#$normalized = (($value - $min) / ($max - $min)) | |
$normalized = ((($value - 1) * ($max - $min)) / (10 - 1)) + 1 | |
#$normalized = (($max- $min) / ($max - $min)*($value -$min)+$min) | |
return [math]::round($normalized) | |
} | |
function scale($value, $originalMin, $originalMax, $newMin, $NewMax){ | |
$scaled = ((($value - $originalMin) / ( $originalMax-$originalMin)) * ($NewMax-$newMin)) + $newMin | |
return [math]::round($scaled) | |
} | |
$cSource = @' | |
using System; | |
using System.Drawing; | |
using System.Runtime.InteropServices; | |
using System.Windows.Forms; | |
public class Clicker | |
{ | |
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms646270(v=vs.85).aspx | |
[StructLayout(LayoutKind.Sequential)] | |
struct INPUT | |
{ | |
public int type; // 0 = INPUT_MOUSE, | |
// 1 = INPUT_KEYBOARD | |
// 2 = INPUT_HARDWARE | |
public MOUSEINPUT mi; | |
} | |
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms646273(v=vs.85).aspx | |
[StructLayout(LayoutKind.Sequential)] | |
struct MOUSEINPUT | |
{ | |
public int dx ; | |
public int dy ; | |
public int mouseData ; | |
public int dwFlags; | |
public int time; | |
public IntPtr dwExtraInfo; | |
} | |
//This covers most use cases although complex mice may have additional buttons | |
//There are additional constants you can use for those cases, see the msdn page | |
const int MOUSEEVENTF_MOVED = 0x0001 ; | |
const int MOUSEEVENTF_LEFTDOWN = 0x0002 ; | |
const int MOUSEEVENTF_LEFTUP = 0x0004 ; | |
const int MOUSEEVENTF_RIGHTDOWN = 0x0008 ; | |
const int MOUSEEVENTF_RIGHTUP = 0x0010 ; | |
const int MOUSEEVENTF_MIDDLEDOWN = 0x0020 ; | |
const int MOUSEEVENTF_MIDDLEUP = 0x0040 ; | |
const int MOUSEEVENTF_WHEEL = 0x0080 ; | |
const int MOUSEEVENTF_XDOWN = 0x0100 ; | |
const int MOUSEEVENTF_XUP = 0x0200 ; | |
const int MOUSEEVENTF_ABSOLUTE = 0x8000 ; | |
const int screen_length = 0x10000 ; | |
//https://msdn.microsoft.com/en-us/library/windows/desktop/ms646310(v=vs.85).aspx | |
[System.Runtime.InteropServices.DllImport("user32.dll")] | |
extern static uint SendInput(uint nInputs, INPUT[] pInputs, int cbSize); | |
public static void LeftClickAtPoint(int x, int y) | |
{ | |
//Move the mouse | |
INPUT[] input = new INPUT[3]; | |
input[0].mi.dx = x*(65535/System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width); | |
input[0].mi.dy = y*(65535/System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height); | |
input[0].mi.dwFlags = MOUSEEVENTF_MOVED | MOUSEEVENTF_ABSOLUTE; | |
//Left mouse button down | |
input[1].mi.dwFlags = MOUSEEVENTF_LEFTDOWN; | |
//Left mouse button up | |
input[2].mi.dwFlags = MOUSEEVENTF_LEFTUP; | |
SendInput(3, input, Marshal.SizeOf(input[0])); | |
} | |
} | |
'@ | |
Add-Type -TypeDefinition $cSource -ReferencedAssemblies System.Windows.Forms,System.Drawing | |
#Send a click at a specified point | |
function clickMouse($xpos, $ypos){ | |
[Clicker]::LeftClickAtPoint($xpos,$ypos) | |
} | |
$atem.camera |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment