Module:Infobox MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
adopt mos operation functions
Ganaram inukshuk (talk | contribs)
simplify code for generator size function
Line 141: Line 141:
-- a larger array.
-- a larger array.
function p.generator_sizes(input_mos)
function p.generator_sizes(input_mos)
local input_mos = input_mos or mos.new(5, 2)
local input_mos = input_mos or mos.new(5, 2,3)
local number_of_periods = mos.period_step_count(input_mos)
local bright_gen = mos.bright_gen(input_mos)
local dark_gen  = mos.dark_gen  (input_mos)
local equalized_ed = mos.mos_to_et_as_string(input_mos, {1, 1}, "")
local collapsed_ed = mos.mos_to_et_as_string(input_mos, {1, 0}, "")
local bright_min_in_steps = mos.bright_gen_to_et_steps_as_string(input_mos, {1, 1}, "")
local bright_min_in_steps = mos.bright_gen_to_et_steps_as_string(input_mos, {1, 1}, "")
Line 162: Line 154:
local section_header = "Generator size"
local section_header = "Generator size"
local equave_annotation = ""
local et_suffix = mos.mos_to_et_suffix(input_mos)
if rat.eq(input_mos.equave, 3) then
local section_header = (et_suffix == "edo"
equave_annotation = "<sup><abbr title=\"In steps of edt\">(edt)</sup>"
and string.format('<div style=\"margin-top: 0.6em;\"><b>Generator size</b></div>')
elseif rat.eq(input_mos.equave, rat.new(3,2)) then
or  string.format('<div style=\"margin-top: 0.6em;\"><b>Generator size</b><sup><abbr title=\"In steps of %s\">(%s)</sup></div>', et_suffix, et_suffix))
equave_annotation = "<sup><abbr title=\"In steps of edf\">(edf)</sup>"
elseif not rat.eq(input_mos.equave, 2) then
local equave_as_ratio = rat.as_ratio(input_mos.equave)
equave_annotation = string.format("<sup><abbr title=\"In steps of ed%s\">(ed%s)</sup>", equave_as_ratio, equave_as_ratio)
end
local section_entries = {
local section_entries = {
{string.format("<div style=\"margin-top: 0.6em;\"><b>%s</b>%s</div>", section_header, equave_annotation)},
{section_header},
{"[[Bright]]", string.format("%s to %s (%.1f{{c}} to %.1f{{c}})", bright_min_in_steps, bright_max_in_steps, bright_min_in_cents, bright_max_in_cents)},
{"[[Bright]]", string.format("%s to %s (%.1f{{c}} to %.1f{{c}})", bright_min_in_steps, bright_max_in_steps, bright_min_in_cents, bright_max_in_cents)},
{"[[Dark]]", string.format("%s to %s (%.1f{{c}} to %.1f{{c}})", dark_min_in_steps, dark_max_in_steps, dark_min_in_cents, dark_max_in_cents)},
{"[[Dark]]", string.format("%s to %s (%.1f{{c}} to %.1f{{c}})", dark_min_in_steps, dark_max_in_steps, dark_min_in_cents, dark_max_in_cents)},