Module:Infobox MOS: Difference between revisions
m todo |
create helper function for adding the equave as superscript text to a section header; drop rat module |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local mos = require("Module:MOS") | local mos = require("Module:MOS") | ||
local xp = require("Module:Xenpaper") | local xp = require("Module:Xenpaper") | ||
| Line 18: | Line 17: | ||
t1[#t1 + 1] = t2[i] | t1[#t1 + 1] = t2[i] | ||
end | end | ||
end | |||
-- Helper function | |||
-- Annotates a section header with the equave as superscript text. | |||
function p.annotate_section_header(input_mos, section_header) | |||
local et_suffix = mos.et_suffix(input_mos) | |||
return (et_suffix == "edo" | |||
and string.format('<div style=\"margin-top: 0.6em;\"><b>%s</b></div>', section_header) | |||
or string.format('<div style=\"margin-top: 0.6em;\"><b>%s</b><sup><abbr title=\"In steps of %s\">(%s)</sup></div>', section_header, et_suffix, et_suffix) | |||
) | |||
end | end | ||
| Line 51: | Line 60: | ||
-- If the mos is octave-equivalent, add appropriate tamnams-named categories | -- If the mos is octave-equivalent, add appropriate tamnams-named categories | ||
-- Otherwise, add to nonoctave category | -- Otherwise, add to nonoctave category | ||
if | if mos.is_octave_equivalent(input_mos) then | ||
-- Caveats: | -- Caveats: | ||
-- - Only octave-equivalent mos names are used as categories. | -- - Only octave-equivalent mos names are used as categories. | ||
| Line 108: | Line 117: | ||
local input_mos = input_mos or mos.new(5, 2) | local input_mos = input_mos or mos.new(5, 2) | ||
local equave_as_string = | local equave_as_string = mos.equave_as_string(input_mos) | ||
local equave_in_cents = | local equave_in_cents = mos.equave_to_cents(input_mos) | ||
local number_of_periods = mos.period_count(input_mos) | local number_of_periods = mos.period_count(input_mos) | ||
| Line 154: | Line 163: | ||
local dark_max_in_cents = mos.dark_gen_to_cents(input_mos, {1, 1}) | local dark_max_in_cents = mos.dark_gen_to_cents(input_mos, {1, 1}) | ||
local section_header = | local section_header = p.annotate_section_header(input_mos, "Generator size") | ||
local section_entries = { | local section_entries = { | ||
{section_header}, | {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)}, | ||
} | } | ||
| Line 192: | Line 196: | ||
local tamnams_abbrev = tamnams.lookup_abbrev(input_mos) | local tamnams_abbrev = tamnams.lookup_abbrev(input_mos) | ||
local is_octave_equivalent = | local is_octave_equivalent = mos.is_octave_equivalent(input_mos) | ||
local is_within_named_range = tamnams_name ~= nil and notecount <= 10 | local is_within_named_range = tamnams_name ~= nil and notecount <= 10 | ||
local is_root_mos = input_mos.nL == input_mos.ns | local is_root_mos = input_mos.nL == input_mos.ns | ||
| Line 307: | Line 311: | ||
-- Includes xenpaper links | -- Includes xenpaper links | ||
function p.equal_tunings(input_mos) | function p.equal_tunings(input_mos) | ||
local input_mos = input_mos or mos.new(5, 2 | local input_mos = input_mos or mos.new(5, 2) | ||
local bright_gen = mos.bright_gen(input_mos) | local bright_gen = mos.bright_gen(input_mos) | ||
| Line 323: | Line 327: | ||
} | } | ||
local section_header = | local section_header = p.annotate_section_header(input_mos, "Equal tunings") | ||
local section_entries = {{section_header}} | |||
for i = 1, #step_ratios do | for i = 1, #step_ratios do | ||
local step_ratio = step_ratios[i] | local step_ratio = step_ratios[i] | ||