12
12
13
13
function dyn_above ()
14
14
local region = finenv .Region ()
15
- local start_msr = region .StartMeasure
16
- local end_msr = region .EndMeasure
17
- local start_staff = region .StartStaff
18
- local end_staff = region .EndStaff
15
+ local start_msr = region .StartMeasure
16
+ local end_msr = region .EndMeasure
17
+ local start_staff = region .StartStaff
18
+ local end_staff = region .EndStaff
19
19
local measures = finale .FCMeasures ()
20
20
measures :LoadRegion (region )
21
21
local sysstaves = finale .FCSystemStaves ()
@@ -29,101 +29,91 @@ function dyn_above()
29
29
local baseline = finale .FCBaseline ()
30
30
baseline .Mode = finale .BASELINEMODE_EXPRESSIONABOVE
31
31
baseline :LoadDefaultForMode (finale .BASELINEMODE_EXPRESSIONABOVE )
32
- baseline_off = baseline .VerticalOffset
33
- print (" Above Staff Baseline is" ,baseline_off )
34
- local move_by = - 84
32
+ local baseline_off = baseline .VerticalOffset
33
+ print (" Above Staff Baseline is" , baseline_off )
35
34
local e_vert_target = 0
36
35
local h_vert_target = 0
37
- local sys_ref_line = 0
38
36
local vocal_dynamic_offset = 36 -- Distance above reference line to place dynamics, in absence of other entries
39
37
40
- function metrics (sys_region )
41
- print (" metrics function called" )
42
- local highest = 0
43
- local hairpins = 0
44
- measures :LoadRegion (sys_region )
45
- for msr in each (measures ) do
46
- print (" Analyzing measure" ,msr .ItemNo )
47
- cell = finale .FCCell (msr .ItemNo , sys_region .StartStaff )
38
+ local function metrics (sys_region )
39
+ print (" metrics function called" )
40
+ local highest = 0
41
+ local hairpins
42
+ measures :LoadRegion (sys_region )
43
+ local cellmetrics , staff_scale
44
+ for msr in each (measures ) do
45
+ print (" Analyzing measure" , msr .ItemNo )
46
+ local cell = finale .FCCell (msr .ItemNo , sys_region .StartStaff )
48
47
cellmetrics = cell :CreateCellMetrics ()
49
48
-- **** May need to account for cellmetrics:GetStaffScaling()...
50
49
staff_scale = cellmetrics :GetStaffScaling () / 10000
51
50
if cellmetrics .ReferenceLinePos + vocal_dynamic_offset > highest then
52
51
highest = cellmetrics .ReferenceLinePos + vocal_dynamic_offset
53
52
end
54
- end -- for msr..
53
+ end -- for msr..
55
54
for entry in eachentry (sys_region ) do
56
55
local e_metrics = finale .FCEntryMetrics ()
57
56
e_metrics :Load (entry )
58
- local e_highest = e_metrics :GetTopPosition () / staff_scale
59
- if e_highest + vocal_dynamic_offset > highest then
60
- highest = e_highest + vocal_dynamic_offset
61
- end
57
+ local e_highest = e_metrics :GetTopPosition () / staff_scale
58
+ if e_highest + vocal_dynamic_offset > highest then
59
+ highest = e_highest + vocal_dynamic_offset
60
+ end
62
61
end
63
- hairpins = highest - cellmetrics .ReferenceLinePos + 12
62
+ hairpins = highest - cellmetrics .ReferenceLinePos + 12
64
63
65
- return highest , hairpins
66
- end -- function metrics
64
+ return highest , hairpins
65
+ end -- function metrics
67
66
68
- function expr_move (staff_region , e_vert_target ) -- luacheck: ignore e_vert_target
69
- local expressions = finale .FCExpressions ()
70
- expressions :LoadAllForRegion (staff_region )
71
- for e in each (expressions ) do
72
- local dynamic = false
73
- local sed = e :CreateTextExpressionDef ()
74
- local cat_ID = sed :GetCategoryID ()
75
- local cd = finale .FCCategoryDef ()
76
- if cd :Load (cat_ID ) then
77
- local cat_name = cd :CreateName ()
78
- -- print(cat_name.LuaString)
79
- if cat_name .LuaString == " Dynamics" then
80
- dynamic = true
67
+ local function expr_move (staff_region , e_vert_target ) -- luacheck: ignore e_vert_target
68
+ local expressions = finale .FCExpressions ()
69
+ expressions :LoadAllForRegion (staff_region )
70
+ for e in each (expressions ) do
71
+ local dynamic = false
72
+ local sed = e :CreateTextExpressionDef ()
73
+ local cat_ID = sed :GetCategoryID ()
74
+ local cd = finale .FCCategoryDef ()
75
+ if cd :Load (cat_ID ) then
76
+ local cat_name = cd :CreateName ()
77
+ -- print(cat_name.LuaString)
78
+ if cat_name .LuaString == " Dynamics" then
79
+ dynamic = true
80
+ end
81
81
end
82
- end
83
- if dynamic == true then
84
- print (" VerticalPos" ,e .VerticalPos )
85
- local e_metric = finale .FCPoint (0 , 0 )
86
- cell = finale .FCCell (e .Measure , e .Staff )
87
- cellmetrics = cell :CreateCellMetrics ()
88
- ---- CHANGE ME!
89
- -- e_vert_target = cellmetrics.ReferenceLinePos + baseline_off + move_by - 12 -- vert_target could be calculated somehwere else...
90
- ----
91
- print (" Vertical Target is" ,e_vert_target )
92
- e :CalcMetricPos (e_metric )
93
- print (" Expression Y is" ,e_metric .Y )
94
- e :SetVerticalPos (e .VerticalPos + (e_vert_target - e_metric .Y ))
95
- e :Save ()
96
- end -- if dynamic == true
97
- end -- for e...
98
- end -- func expr_move
82
+ if dynamic == true then
83
+ print (" VerticalPos" ,e .VerticalPos )
84
+ local e_metric = finale .FCPoint (0 , 0 )
85
+ print (" Vertical Target is" ,e_vert_target )
86
+ e :CalcMetricPos (e_metric )
87
+ print (" Expression Y is" ,e_metric .Y )
88
+ e :SetVerticalPos (e .VerticalPos + (e_vert_target - e_metric .Y ))
89
+ e :Save ()
90
+ end -- if dynamic == true
91
+ end -- for e...
92
+ end -- func expr_move
99
93
100
94
101
- function hairpin_move (staff_region , h_vert_target ) -- luacheck: ignore h_vert_target
95
+ local function hairpin_move (staff_region , h_vert_target ) -- luacheck: ignore h_vert_target
102
96
local ssmm = finale .FCSmartShapeMeasureMarks ()
103
97
ssmm :LoadAllForRegion (staff_region , true )
104
98
for mark in each (ssmm ) do
105
99
local smart_shape = mark :CreateSmartShape ()
106
100
if smart_shape :IsHairpin () then
107
101
print (" found hairpin" )
108
- local left_seg = smart_shape :GetTerminateSegmentLeft ()
109
- local right_seg = smart_shape :GetTerminateSegmentRight ()
110
- -- left_seg:SetEndpointOffsetY(baseline_off + move_by)
111
- -- right_seg:SetEndpointOffsetY(baseline_off + move_by)
112
- left_seg :SetEndpointOffsetY (h_vert_target )
113
- right_seg :SetEndpointOffsetY (h_vert_target )
102
+ local left_seg = smart_shape :GetTerminateSegmentLeft ()
103
+ local right_seg = smart_shape :GetTerminateSegmentRight ()
104
+ left_seg :SetEndpointOffsetY (h_vert_target )
105
+ right_seg :SetEndpointOffsetY (h_vert_target )
114
106
115
- smart_shape :Save ()
116
-
107
+ smart_shape :Save ()
117
108
end
118
109
end
119
- end -- func hairpin_move
110
+ end -- func hairpin_move
120
111
121
- function analyze_staves ()
122
- for i = start_staffsys .ItemNo , end_staffsys .ItemNo , 1 do
123
- print (" Analyzing staffsys" ,i )
124
- staffsys :Load (i )
125
- local sys_region_start = 0
126
- local sys_region_end = 0
112
+ local function analyze_staves ()
113
+ for i = start_staffsys .ItemNo , end_staffsys .ItemNo , 1 do
114
+ print (" Analyzing staffsys" ,i )
115
+ staffsys :Load (i )
116
+ local sys_region_start , sys_region_end
127
117
if start_msr > staffsys .FirstMeasure then
128
118
sys_region_start = start_msr
129
119
else
@@ -143,19 +133,13 @@ function analyze_staves()
143
133
sys_region :SetEndStaff (j )
144
134
e_vert_target , h_vert_target = metrics (sys_region )
145
135
print (" vert_target for staff" ,j ," is" ,e_vert_target )
146
- expr_move (sys_region , e_vert_target )
147
- hairpin_move (sys_region , h_vert_target )
136
+ expr_move (sys_region , e_vert_target )
137
+ hairpin_move (sys_region , h_vert_target )
148
138
end -- for j = start_staff...
139
+ end -- for i...
140
+ end -- function
149
141
150
- end -- for i...
151
- end -- function
152
-
153
- analyze_staves ()
154
-
155
- --[[
156
- expr_move()
157
- hairpin_move()
158
- ]]
142
+ analyze_staves ()
159
143
160
144
end -- function
161
145
0 commit comments