Skip to content

Instantly share code, notes, and snippets.

@junefrench
Last active February 23, 2016 13:04
Show Gist options
  • Save junefrench/502d0aff5d362870e995 to your computer and use it in GitHub Desktop.
Save junefrench/502d0aff5d362870e995 to your computer and use it in GitHub Desktop.
Generate X32 Snippets for Musical Theatre
"""
Instructions for use
Change channel_count and dca_count as appropriate. (Note that this always assumes that you are using the lowest-numbered channels and dcas for cue control)
Change channels to the list of names of channels you want under cue control.
Change cues to your list of cues, following the examples. the comment in cues documents the syntax.
"""
channel_count = 11
dca_count = 7
channels = [
'Princeton',
'Kate',
'Nicky',
'Rod',
'Trekkie',
'Lucy',
'Brian',
'Christmas',
'Gary',
'Boy Bear',
'Girl Bear'
]
cues = [
# ['CueName', [
# ['DCA1Name', ['ChannelName1', 'ChannelName2', ...]],
# [None, 'ChannelName1'], # (auto-named from channel)
# None, # (placeholder to skip a DCA)
# ...
# ]],
# ...
['Mic Check', []],
['1.0', [
['Guys', ['Princeton', 'Nicky', 'Rod', 'Trekkie', 'Brian', 'Gary', 'Boy Bear']],
['Gals', ['Kate', 'Lucy', 'Christmas', 'Girl Bear']],
]],
['1.1', [
[None, 'Princeton'],
[None, 'Kate'],
[None, 'Brian'],
[None, 'Nicky'],
[None, 'Rod'],
[None, 'Christmas'],
[None, 'Gary'],
]],
['1.2', [
[None, 'Nicky'],
[None, 'Rod'],
]],
['1.3', [
[None, 'Princeton'],
[None, 'Gary'],
['Boxes', []], # TODO add boxes
]],
['1.4', [
[None, 'Princeton'],
[None, 'Kate'],
[None, 'Gary'],
[None, 'Brian'],
[None, 'Christmas'],
]],
['1.4a', [
[None, 'Princeton'],
[None, 'Boy Bear'],
[None, 'Girl Bear'],
]],
['1.5', [
[None, 'Kate'],
[None, 'Trekkie'],
[None, 'Brian'],
[None, 'Gary'],
[None, 'Rod'],
[None, 'Princeton'],
['Thistletwat', ['Girl Bear']],
]],
['1.6', [
[None, 'Rod'],
[None, 'Christmas'],
[None, 'Brian'],
]],
['1.7', [
[None, 'Princeton'],
[None, 'Kate'],
]],
['1.8/1', [
[None, 'Brian'],
[None, 'Lucy'],
[None, 'Christmas'],
[None, 'Gary'],
[None, 'Trekkie'],
[None, 'Princeton'],
[None, 'Kate'],
]],
['1.8/2', [
None,
[None, 'Lucy'],
None,
[None, 'Boy Bear'],
[None, 'Girl Bear'],
[None, 'Princeton'],
[None, 'Kate'],
]],
['1.9', [
[None, 'Princeton'],
[None, 'Kate'],
[None, 'Gary'],
['Bears', ['Boy Bear', 'Girl Bear']],
[None, 'Brian'],
[None, 'Christmas'],
[None, 'Trekkie'],
]],
['1.10', [
[None, 'Nicky'],
[None, 'Rod'],
[None, 'Princeton'],
[None, 'Kate'],
]],
['1.11', [
[None, 'Princeton'],
[None, 'Kate'],
['Thistletwat', ['Girl Bear']],
]],
['1.12', [
[None, 'Rod'],
[None, 'Nicky'],
[None, 'Princeton'],
[None, 'Kate'],
[None, 'Gary'],
[None, 'Christmas'],
[None, 'Brian'],
]],
['2.1/1', [
[None, 'Princeton'],
[None, 'Boy Bear'],
[None, 'Girl Bear'],
[None, 'Brian'],
]],
['2.1/2', [
[None, 'Princeton'],
[None, 'Brian'],
[None, 'Gary'],
[None, 'Trekkie'],
[None, 'Nicky'],
[None, 'Christmas'],
['Voice', []] # TODO figure out voice?
]],
['2.1/3', [
[None, 'Princeton'],
[None, 'Trekkie'],
['Guys', ['Brian', 'Gary', 'Nicky']],
[None, 'Lucy'],
[None, 'Christmas'],
]],
['2.2-2.4', [
[None, 'Princeton'],
[None, 'Kate'],
[None, 'Lucy'],
[None, 'Christmas'],
]],
['2.5', [
[None, 'Nicky'],
[None, 'Brian'],
[None, 'Christmas'],
[None, 'Gary'],
]],
['2.6-2.7', [
[None, 'Princeton'],
[None, 'Kate'],
[None, 'Lucy'],
]],
['2.8', [
[None, 'Nicky'],
[None, 'Rod'],
[None, 'Christmas'],
]],
['2.9', [
[None, 'Princeton'],
[None, 'Nicky'],
[None, 'Kate'],
]],
['2.10', [
[None, 'Princeton'],
[None, 'Nicky'],
[None, 'Gary'],
[None, 'Brian'],
[None, 'Christmas'],
[None, 'Trekkie'],
]],
['2.11/1', [
[None, 'Kate'],
[None, 'Princeton'],
[None, 'Nicky'],
[None, 'Rod'],
[None, 'Brian'],
[None, 'Christmas'],
['Newcomer', []], # TODO newcomer
]],
['2.11/2', [
[None, 'Kate'],
[None, 'Lucy'],
[None, 'Boy Bear'],
[None, 'Girl Bear'],
[None, 'Trekkie'],
[None, 'Christmas'],
['Rest', ['Nicky', 'Rod', 'Princeton', 'Gary']],
]],
['2.11/3', [
[None, 'Kate'],
[None, 'Princeton'],
[None, 'Gary'],
[None, 'Nicky'],
[None, 'Trekkie'],
None,
['Rest', ['Rod', 'Lucy', 'Girl Bear', 'Boy Bear', 'Christmas', 'Brian']],
]],
['Curtain', []],
]
def make_cues():
assert len(channels) == channel_count
for cue_no in range(len(cues)):
cue = cues[cue_no]
cue_name = cue[0]
dcas = cue[1]
assert len(dcas) <= dca_count
with open('{num:02}.snp'.format(num=cue_no), 'w+') as cue_file:
cue_file.write('#2.1# "%s"\n' % cue_name)
_channel_groups = [0b00000000 for _ in range(channel_count)]
_dcas = []
for dca_no in range(dca_count):
if dca_no < len(dcas):
dca = dcas[dca_no]
if dca is None:
_dcas.append(None)
else:
if dca[0] is None:
dca_name = dca[1]
dca_channels = [channels.index(dca[1])]
else:
dca_name = dca[0]
dca_channels = map(channels.index, dca[1])
for channel_index in dca_channels:
_channel_groups[channel_index] |= (0b00000001 << dca_no)
_dcas.append(dca_name)
else:
_dcas.append(None)
for channel_no in range(channel_count):
cue_file.write('/ch/{chan:02}/grp/dca %{grp:08b}\n'.format(
chan=channel_no+1,
grp=_channel_groups[channel_no]))
cue_file.write('/ch/{chan:02}/mix/on {onoff}\n'.format(
chan=channel_no+1,
onoff='ON' if _channel_groups[channel_no] != 0b00000000 else 'OFF'))
for dca_no in range(dca_count):
cue_file.write('/dca/{dca}/config/name "{name}"\n'.format(
dca=dca_no+1,
name="" if _dcas[dca_no] is None else _dcas[dca_no]))
cue_file.write('/dca/{dca}/config/color "{name}"\n'.format(
dca=dca_no+1,
name="OFF" if _dcas[dca_no] is None else "CY"))
cue_file.write('/dca/{dca}/on {onoff}\n'.format(
dca=dca_no+1,
onoff='ON' if _dcas[dca_no] is not None else 'OFF'))
if __name__ == '__main__':
make_cues()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment