Skip to content

Instantly share code, notes, and snippets.

@randallb
Created May 18, 2012 02:33
Show Gist options
  • Save randallb/2722807 to your computer and use it in GitHub Desktop.
Save randallb/2722807 to your computer and use it in GitHub Desktop.
-- switcher's setLayer args are (layername, shotname)
-- layername can be "text" (aka title) "foreground" "normal" "background" "audio"
-- Defaults for buttons
script button
on top(channelnumber)
my switcher's setLayer("normal", "cam" & channelnumber & "+cg")
my switcher's setLayer("foreground", "Blank Shot")
my switcher's go()
end top
on bottom(channelnumber)
my switcher's setLayer("normal", "cam" & channelnumber)
my switcher's setLayer("background", "Blank Shot")
my switcher's go()
end bottom
on leftTwist(channelnumber)
my switcher's setLayer("background", "cam" & channelnumber & "-lb")
end leftTwist
on rightTwist(channelnumber)
my switcher's setLayer("normal", "cam" & channelnumber & "-rb")
my switcher's go()
end rightTwist
on upSlide(channelnumber)
my switcher's setLayer("foreground", "l3rd-" & channelnumber)
my switcher's go()
end upSlide
on downSlide(channelnumber)
my switcher's setLayer("foreground", "Blank Shot")
my switcher's go()
end downSlide
on rewind(state)
end rewind
on fastForward(state)
end fastForward
on play(state)
if state is "down" then
my switcher's startBroadcast()
end if
if state is "up" then
my switcher's stopBroadcast()
end if
end play
on loop(state)
-- note that "repeat" is a magic word.
end loop
on stopMe(state)
-- Stop is a magic word too.
end stopMe
on recordMe(state)
if state is "down" then
my switcher's startRecord()
end if
if state is "up" then
my switcher's stopRecord()
end if
end recordMe
end script
-- MIDI pipe stuff
on runme(message)
-- transport controls
if (item 1 of message = 176) and (item 2 of message = 101) and (item 3 of message = 127) then
my button's play("down")
end if
if (item 1 of message = 176) and (item 2 of message = 101) and (item 3 of message = 0) then
my button's play("up")
end if
if (item 1 of message = 176) and (item 2 of message = 105) and (item 3 of message = 127) then
my button's recordMe("down")
end if
if (item 1 of message = 176) and (item 2 of message = 105) and (item 3 of message = 0) then
my button's recordMe("up")
end if
if (item 1 of message = 176) and (item 2 of message = 102) and (item 3 of message = 127) then
my button's fastForward("down")
end if
if (item 1 of message = 176) and (item 2 of message = 103) and (item 3 of message = 127) then
my button's loop("down")
end if
if (item 1 of message = 176) and (item 2 of message = 104) and (item 3 of message = 127) then
my button's stopMe("down")
end if
if (item 1 of message = 176) and (item 2 of message = 104) and (item 3 of message = 127) then
my button's rewind("down")
end if
-- Channel 1 block
if (item 1 of message = 176) and (item 2 of message = 11) and (item 3 of message > 0) then
-- do stuff for top button
my button's top(1)
end if
if (item 1 of message = 176) and (item 2 of message = 12) and (item 3 of message > 0) then
-- do stuff for bottom button
my button's bottom(1)
end if
if (item 1 of message = 176) and (item 2 of message = 13) and (item 3 of message = 0) then
-- do stuff left twist
my button's leftTwist(1)
end if
if (item 1 of message = 176) and (item 2 of message = 13) and (item 3 of message = 127) then
-- do stuff right twist
my button's rightTwist(1)
end if
if (item 1 of message = 176) and (item 2 of message = 14) and (item 3 of message = 0) then
-- do stuff down slide
my button's downSlide(1)
end if
if (item 1 of message = 176) and (item 2 of message = 14) and (item 3 of message = 127) then
-- do stuff up slide
my button's upSlide(1)
end if
-- Channel 2 block
if (item 1 of message = 176) and (item 2 of message = 21) and (item 3 of message > 0) then
-- do stuff for top button
my button's top(2)
end if
if (item 1 of message = 176) and (item 2 of message = 22) and (item 3 of message > 0) then
-- do stuff for bottom button
my button's bottom(2)
end if
if (item 1 of message = 176) and (item 2 of message = 23) and (item 3 of message = 0) then
-- do stuff left twist
my button's leftTwist(2)
end if
if (item 1 of message = 176) and (item 2 of message = 23) and (item 3 of message = 127) then
-- do stuff right twist
my button's rightTwist(2)
end if
if (item 1 of message = 176) and (item 2 of message = 24) and (item 3 of message = 0) then
-- do stuff down slide
my button's downSlide(2)
end if
if (item 1 of message = 176) and (item 2 of message = 24) and (item 3 of message = 127) then
-- do stuff up slide
my button's upSlide(2)
end if
-- Channel 3 block
if (item 1 of message = 176) and (item 2 of message = 31) and (item 3 of message > 0) then
-- do stuff for top button
my button's top(3)
end if
if (item 1 of message = 176) and (item 2 of message = 32) and (item 3 of message > 0) then
-- do stuff for bottom button
my button's bottom(3)
end if
if (item 1 of message = 176) and (item 2 of message = 33) and (item 3 of message = 0) then
-- do stuff left twist
my button's leftTwist(3)
end if
if (item 1 of message = 176) and (item 2 of message = 33) and (item 3 of message = 127) then
-- do stuff right twist
my button's rightTwist(3)
end if
if (item 1 of message = 176) and (item 2 of message = 34) and (item 3 of message = 0) then
-- do stuff down slide
my button's downSlide(3)
end if
if (item 1 of message = 176) and (item 2 of message = 34) and (item 3 of message = 127) then
-- do stuff up slide
my button's upSlide(3)
end if
-- Channel 4 block
if (item 1 of message = 176) and (item 2 of message = 41) and (item 3 of message > 0) then
-- do stuff for top button
my button's top(4)
end if
if (item 1 of message = 176) and (item 2 of message = 42) and (item 3 of message > 0) then
-- do stuff for bottom button
my button's bottom(4)
end if
if (item 1 of message = 176) and (item 2 of message = 43) and (item 3 of message = 0) then
-- do stuff left twist
my button's leftTwist(4)
end if
if (item 1 of message = 176) and (item 2 of message = 43) and (item 3 of message = 127) then
-- do stuff right twist
my button's rightTwist(4)
end if
if (item 1 of message = 176) and (item 2 of message = 44) and (item 3 of message = 0) then
-- do stuff down slide
my button's downSlide(4)
end if
if (item 1 of message = 176) and (item 2 of message = 44) and (item 3 of message = 127) then
-- do stuff up slide
my button's upSlide(4)
end if
-- Channel 5 block
if (item 1 of message = 176) and (item 2 of message = 51) and (item 3 of message > 0) then
-- do stuff for top button
my button's top(5)
end if
if (item 1 of message = 176) and (item 2 of message = 52) and (item 3 of message > 0) then
-- do stuff for bottom button
my button's bottom(5)
end if
if (item 1 of message = 176) and (item 2 of message = 53) and (item 3 of message = 0) then
-- do stuff left twist
my button's leftTwist(5)
end if
if (item 1 of message = 176) and (item 2 of message = 53) and (item 3 of message = 127) then
-- do stuff right twist
my button's rightTwist(5)
end if
if (item 1 of message = 176) and (item 2 of message = 54) and (item 3 of message = 0) then
-- do stuff down slide
my button's downSlide(5)
end if
if (item 1 of message = 176) and (item 2 of message = 54) and (item 3 of message = 127) then
-- do stuff up slide
my button's upSlide(5)
end if
-- Channel 6 block
if (item 1 of message = 176) and (item 2 of message = 61) and (item 3 of message > 0) then
-- do stuff for top button
my button's top(6)
end if
if (item 1 of message = 176) and (item 2 of message = 62) and (item 3 of message > 0) then
-- do stuff for bottom button
my button's bottom(6)
end if
if (item 1 of message = 176) and (item 2 of message = 63) and (item 3 of message = 0) then
-- do stuff left twist
my button's leftTwist(6)
end if
if (item 1 of message = 176) and (item 2 of message = 63) and (item 3 of message = 127) then
-- do stuff right twist
my button's rightTwist(6)
end if
if (item 1 of message = 176) and (item 2 of message = 64) and (item 3 of message = 0) then
-- do stuff down slide
my button's downSlide(6)
end if
if (item 1 of message = 176) and (item 2 of message = 64) and (item 3 of message = 127) then
-- do stuff up slide
my button's upSlide(6)
end if
-- Channel 7 block
if (item 1 of message = 176) and (item 2 of message = 71) and (item 3 of message > 0) then
-- do stuff for top button
my button's top(7)
end if
if (item 1 of message = 176) and (item 2 of message = 72) and (item 3 of message > 0) then
-- do stuff for bottom button
my button's bottom(7)
end if
if (item 1 of message = 176) and (item 2 of message = 73) and (item 3 of message = 0) then
-- do stuff left twist
my button's leftTwist(7)
end if
if (item 1 of message = 176) and (item 2 of message = 73) and (item 3 of message = 127) then
-- do stuff right twist
my button's rightTwist(7)
end if
if (item 1 of message = 176) and (item 2 of message = 74) and (item 3 of message = 0) then
-- do stuff down slide
my button's downSlide(7)
end if
if (item 1 of message = 176) and (item 2 of message = 74) and (item 3 of message = 127) then
-- do stuff up slide
my button's upSlide(7)
end if
-- Channel 8 block
if (item 1 of message = 176) and (item 2 of message = 81) and (item 3 of message > 0) then
-- do stuff for top button
my button's top(8)
end if
if (item 1 of message = 176) and (item 2 of message = 82) and (item 3 of message > 0) then
-- do stuff for bottom button
my button's bottom(8)
end if
if (item 1 of message = 176) and (item 2 of message = 83) and (item 3 of message = 0) then
-- do stuff left twist
my button's leftTwist(8)
end if
if (item 1 of message = 176) and (item 2 of message = 83) and (item 3 of message = 127) then
-- do stuff right twist
my button's rightTwist(8)
end if
if (item 1 of message = 176) and (item 2 of message = 84) and (item 3 of message = 0) then
-- do stuff down slide
my button's downSlide(8)
end if
if (item 1 of message = 176) and (item 2 of message = 84) and (item 3 of message = 127) then
-- do stuff up slide
my button's upSlide(8)
end if
-- Channel 9 block
if (item 1 of message = 176) and (item 2 of message = 91) and (item 3 of message > 0) then
-- do stuff for top button
my button's top(9)
end if
if (item 1 of message = 176) and (item 2 of message = 92) and (item 3 of message > 0) then
-- do stuff for bottom button
my button's bottom(9)
end if
if (item 1 of message = 176) and (item 2 of message = 93) and (item 3 of message = 0) then
-- do stuff left twist
my button's leftTwist(9)
end if
if (item 1 of message = 176) and (item 2 of message = 93) and (item 3 of message = 127) then
-- do stuff right twist
my button's rightTwist(9)
end if
if (item 1 of message = 176) and (item 2 of message = 94) and (item 3 of message = 0) then
-- do stuff down slide
my button's downSlide(9)
end if
if (item 1 of message = 176) and (item 2 of message = 94) and (item 3 of message = 127) then
-- do stuff up slide
my button's upSlide(9)
end if
end runme
--Ignore this stuff, it's the methods.
script switcher
property myDoc : "1"
property normal_layer : "1"
property foreground_layer : "1"
property background_layer : "1"
property title_layer : "1"
property audio_layer : "1"
property wirecast : application "Wirecast"
on setup()
tell application "Wirecast"
set my myDoc to last document
set my normal_layer to the layer named "normal" of myDoc
set my foreground_layer to the layer named "foreground" of myDoc
set my background_layer to the layer named "background" of myDoc
set my title_layer to the layer named "text" of myDoc
set my audio_layer to the layer named "audio" of myDoc
set my myDoc's auto live to false
end tell
end setup
on setTransition(anumber, speed)
tell application "Wirecast"
set my myDoc's active transition popup to anumber
set my myDoc's transition speed to speed
end tell
end setTransition
on go()
setup()
tell application "Wirecast"
go my myDoc
end tell
end go
on startBroadcast()
setup()
tell application "Wirecast"
start broadcasting myDoc
end tell
end startBroadcast
on stopBroadcast()
setup()
tell application "Wirecast"
stop broadcasting myDoc
end tell
end stopBroadcast
on startRecord()
setup()
tell application "Wirecast"
start recording myDoc
end tell
end startRecord
on stopRecord()
setup()
tell application "Wirecast"
stop recording myDoc
end tell
end stopRecord
on setLayer(layername, shotname)
setup()
tell application "Wirecast"
set the active shot of the layer named layername of my myDoc to the shot named shotname of my myDoc
end tell
end setLayer
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment