Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathexpression_playback.lua
More file actions
Latest commit
158 lines (149 loc) · 5.89 KB
/
Copy pathexpression_playback.lua
File metadata and controls
158 lines (149 loc) · 5.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
functionplugindef()
finaleplugin.RequireSelection=false
finaleplugin.Author="Carl Vine"
finaleplugin.AuthorURL="http://carlvine.com/lua/"
finaleplugin.Copyright="https://creativecommons.org/licenses/by/4.0/"
finaleplugin.Version="0.08"
finaleplugin.Date="2024/07/28"
finaleplugin.Notes=[[
Change the assigned playback layer and position for all expressions
in the current selection.
Layers __1__-__4__ are the _standard_ playback layers.
Layer numbers __0__, __5__ and __6__ are interpreted respectively
as __Current__, __Chord__ and __Expression__ Layers for playback.
Hold down _Shift_ when starting the script to repeat the same action
as last time without a confirmation dialog.
]]
return"Expression Playback...",
"Expression Playback",
"Change the assigned playback layer for all expressions in the current selection"
end
localstart_options= { -- "Begin Playback At:" (ordered)
{ "Alignment Point",
"Beginning of Measure",
"Position in Measure"
}, -- + corresponding index of EXPRESSION_PLAYBACK_STARTPOINTS:
{ finale.EXPRPLAYSTART_ALIGNMENTPOINT,
finale.EXPRPLAYSTART_BEGINNINGOFMEASURE,
finale.EXPRPLAYSTART_POSINMEASURE
}
}
localspecial_layer= {
[0] ="(\"Current\" Layer)",
[5] ="(Chord Layer)",
[6] ="(Expression Layer)",
}
localc= { -- user config values
layer=0,
start_at=0, -- {start_options} chosen index (0-based)
window_pos_x=false,
window_pos_y=false,
}
localhotkey= { -- customise hotkeys (lowercase only)
start_at="z",
show_info="q",
}
localconfiguration=require("library.configuration")
localmixin=require("library.mixin")
localutils=require("library.utils")
locallibrary=require("library.general_library")
localscript_name=library.calc_script_name()
localname=plugindef():gsub("%.%.%.", "")
localrefocus_document=false-- set to true if utils.show_notes_dialog is used
localfunctiondialog_set_position(dialog)
ifc.window_pos_xandc.window_pos_ythen
dialog:StorePosition()
dialog:SetRestorePositionOnlyData(c.window_pos_x, c.window_pos_y)
dialog:RestorePosition()
end
end
localfunctiondialog_save_position(dialog)
dialog:StorePosition()
c.window_pos_x=dialog.StoredX
c.window_pos_y=dialog.StoredY
configuration.save_user_settings(script_name, c)
end
localfunctionuser_dialog()
localy=0
localy_off=finenv.UI():IsOnMac() and3or0
localx_off=54-- horiz offset for Layer Number and Radio Group
localsave=c.layer
localdialog=mixin.FCXCustomLuaWindow():SetTitle(name)
localfunctionflip_radio()
localradio=dialog:GetControl("start_at")
radio:SetSelectedItem((radio:GetSelectedItem() +1) %3)
end
localfunctionshow_info()
utils.show_notes_dialog(dialog, "About " ..name, 300, 155)
refocus_document=true
end
localfunctioncstat(x, wide, str, id)
dialog:CreateStatic(x, y, id):SetWidth(wide):SetText(str)
end
cstat(0, 190, "Assign Playback of All Expressions")
y=y+22
cstat(0, x_off, "to Layer:")
dialog:CreateEdit(x_off, y-y_off, "layer"):SetInteger(save):SetWidth(20)
:AddHandleCommand(function(self)
locals=self:GetText():lower()
ifs:find("[^0-6]") then
ifs:find(hotkey.start_at) thenflip_radio()
elseifs:find(hotkey.show_info) thenshow_info()
end
else
save=tonumber(s:sub(-1)) or0
dialog:GetControl("data"):SetText(special_layer[save] or"")
end
self:SetInteger(save):SetKeyboardFocus()
end)
cstat(x_off+28, 110, (special_layer[save] or""), "data")
y=y+22
cstat(0, 160, "Begin Playback At:")
dialog:CreateButton(165, y, "q"):SetText("?"):SetWidth(20)
:AddHandleCommand(function() show_info() end)
y=y+16
locallabels=finale.FCStrings()
labels:CopyFromStringTable(start_options[1])
dialog:CreateRadioButtonGroup(x_off, y, 3, "start_at")
:SetText(labels):SetWidth(130)
:SetSelectedItem(c.start_at)
y=y+14
cstat(x_off/2, 50, "[" ..hotkey.start_at.."]")
dialog:CreateOkButton()
dialog:CreateCancelButton()
dialog_set_position(dialog)
dialog:RegisterInitWindow(function()
localq=dialog:GetControl("q")
q:SetFont(q:CreateFontInfo():SetBold(true)) end)
dialog:RegisterHandleOkButtonPressed(function()
c.layer=dialog:GetControl("layer"):GetInteger()
c.start_at=dialog:GetControl("start_at"):GetSelectedItem() -- 0-based
end)
dialog:RegisterCloseWindow(function(self) dialog_save_position(self) end)
return (dialog:ExecuteModal() ==finale.EXECMODAL_OK)
end
localfunctionplayback_layer()
iffinenv.Region():IsEmpty() then
finenv.UI():AlertError(
"Please select some music\nbefore running this script",
name.." Error")
return
end
configuration.get_user_settings(script_name, c, true)
localqim=finenv.QueryInvokedModifierKeys
localmod_key=qimand (qim(finale.CMDMODKEY_ALT) orqim(finale.CMDMODKEY_SHIFT))
ifmod_keyoruser_dialog() then
localstart_option=start_options[2][c.start_at+1] -- user choice -> actual index
localexpressions=finale.FCExpressions()
expressions:LoadAllForRegion(finenv.Region())
forexpineach(expressions) do
ifexp.StaffGroupID==0then-- exclude "Staff List" expressions
exp.PlaybackLayerAssignment=c.layer
exp.PlaybackStart=start_option
exp:Save()
end
end
end
ifrefocus_documentthenfinenv.UI():ActivateDocumentWindow() end
end
playback_layer()