Module:Infobox MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Fixed (hopefully) rounding issue with cent values for generators
Ganaram inukshuk (talk | contribs)
Added section for large/small step sizes, as some mos pages previously had this info
Line 134: Line 134:
-- Helper function
-- Helper function
-- Produces generator ranges for scale
-- Produces generator ranges for scale
function p.generator_ranges(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)
Line 170: Line 170:
{"[[Bright]]", string.format("%s to %s (%.1f¢ to %.1f¢)", bright_min_in_steps, bright_max_in_steps, bright_min_in_cents, bright_max_in_cents)},
{"[[Bright]]", string.format("%s to %s (%.1f¢ to %.1f¢)", bright_min_in_steps, bright_max_in_steps, bright_min_in_cents, bright_max_in_cents)},
{"[[Dark]]", string.format("%s to %s (%.1f¢ to %.1f¢)", dark_min_in_steps, dark_max_in_steps, dark_min_in_cents, dark_max_in_cents)},
{"[[Dark]]", string.format("%s to %s (%.1f¢ to %.1f¢)", dark_min_in_steps, dark_max_in_steps, dark_min_in_cents, dark_max_in_cents)},
}
return { section_header, section_entries }
end
-- Helper function
-- Produces ranges small and large steps
function p.step_sizes(input_mos)
local input_mos = input_mos or mos.new(5, 2)
local equalized_ed = et.new(input_mos.nL + input_mos.ns, input_mos.equave, "")
local collapsed_ed = et.new(input_mos.nL, input_mos.equave, "")
-- Large and small steps
-- The small step lower bound is basically zero (when collapsed).
-- The upper bound for a small step and the lower bound for a large step
-- are the same.
-- The upper bound of a large step is when the step ratio is collapsed.
local small_step_min_in_steps = et.backslash_display(collapsed_ed, 0)
local large_step_min_in_steps = et.backslash_display(equalized_ed, 1)
local large_step_max_in_steps = et.backslash_display(collapsed_ed, 1)
local small_step_min_in_cents = et.cents(collapsed_ed, 0)
local large_step_min_in_cents = et.cents(equalized_ed, 1)
local large_step_max_in_cents = et.cents(collapsed_ed, 1)
local section_header = "Step sizes"
if rat.eq(input_mos.equave, 3) then
section_header = section_header .. " (in steps of edt)"
elseif rat.eq(input_mos.equave, rat.new(3,2)) then
section_header = section_header .. " (in steps of edf)"
elseif not rat.eq(input_mos.equave, 2) then
section_header = string.format("%s (in steps of ed%s)", section_header, rat.as_ratio(input_mos.equave))
end
local section_entries = {
{"Large step", string.format("%s to %s (%.1f¢ to %.1f¢)", small_step_min_in_steps, large_step_min_in_steps, small_step_min_in_cents, large_step_min_in_cents)},
{"Small step", string.format("%s to %s (%.1f¢ to %.1f¢)", large_step_min_in_steps, large_step_max_in_steps, large_step_min_in_cents, large_step_max_in_cents)}
}
}
Line 393: Line 431:
table.insert(sections, scale_structure)
table.insert(sections, scale_structure)
-- Gen ranges section
-- Interval range section
local gen_ranges = p.generator_ranges(tuning_parsed)
local step_sizes = p.step_sizes(tuning_parsed)
table.insert(sections, gen_ranges)
table.insert(sections, step_sizes)
-- Generator sizes
local gen_sizes = p.generator_sizes(tuning_parsed)
table.insert(sections, gen_sizes)
-- Tamnams info section, if applicable
-- Tamnams info section, if applicable