Module:Infobox MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
m bugfix again
ArrowHead294 (talk | contribs)
mNo edit summary
Line 1: Line 1:
local p = {}
local p = {}
local rat = require('Module:Rational')
local rat = require("Module:Rational")
local mos = require('Module:MOS')
local mos = require("Module:MOS")
local et = require('Module:ET')
local et = require("Module:ET")
local xp = require('Module:Xenpaper')
local xp = require("Module:Xenpaper")
local infobox = require('Module:Infobox')
local infobox = require("Module:Infobox")
local kbvis = require('Module:Keyboard vis')
local kbvis = require("Module:Keyboard vis")
local tip = require('Module:Template input parse')
local tip = require("Module:Template input parse")
local tamnams = require('Module:TAMNAMS')
local tamnams = require("Module:TAMNAMS")
local yesno = require('Module:Yesno')
local yesno = require("Module:Yesno")


-- TODO:
-- TODO:
Line 21: Line 21:
function p.concatenate_tables(t1, t2)
function p.concatenate_tables(t1, t2)
for i=1, #t2 do
for i=1, #t2 do
t1[#t1+1] = t2[i]
t1[#t1 + 1] = t2[i]
end
end
end
end
Line 67: Line 67:
if tamnams_name ~= nil then
if tamnams_name ~= nil then
categories = categories .. string.format('[[Category:%s]]', tamnams_name)
categories = categories .. string.format("[[Category:%s]]", tamnams_name)
end
end
else
else
categories = categories .. '[[Category:Nonoctave]]'
categories = categories .. "[[Category:Nonoctave]]"
end
end
Line 89: Line 89:
local adjacent_links = {
local adjacent_links = {
string.format("[[%dL %ds%s |  %dL %ds%s]]", input_mos.nL-1, input_mos.ns-1, equave_as_long_string, input_mos.nL-1, input_mos.ns-1, equave_as_string),
string.format("[[%dL %ds%s | ↖ %dL %ds%s]]", input_mos.nL - 1, input_mos.ns - 1, equave_as_long_string, input_mos.nL - 1, input_mos.ns - 1, equave_as_string),
string.format("[[%dL %ds%s | %dL %ds%s]]", input_mos.nL , input_mos.ns-1, equave_as_long_string, input_mos.nL , input_mos.ns-1, equave_as_string),
string.format("[[%dL %ds%s | ↑%dL %ds%s]]", input_mos.nL , input_mos.ns-1, equave_as_long_string, input_mos.nL, input_mos.ns - 1, equave_as_string),
string.format("[[%dL %ds%s | %dL %ds%s ]]", input_mos.nL+1, input_mos.ns-1, equave_as_long_string, input_mos.nL+1, input_mos.ns-1, equave_as_string),
string.format("[[%dL %ds%s | %dL %ds%s ↗]]", input_mos.nL + 1, input_mos.ns - 1, equave_as_long_string, input_mos.nL + 1, input_mos.ns - 1, equave_as_string),
string.format("[[%dL %ds%s |  %dL %ds%s]]", input_mos.nL-1, input_mos.ns , equave_as_long_string, input_mos.nL-1, input_mos.ns , equave_as_string),
string.format("[[%dL %ds%s | ← %dL %ds%s]]", input_mos.nL - 1, input_mos.ns, equave_as_long_string, input_mos.nL - 1, input_mos.ns, equave_as_string),
string.format("[[%dL %ds%s | %dL %ds%s ]]", input_mos.nL+1, input_mos.ns , equave_as_long_string, input_mos.nL+1, input_mos.ns , equave_as_string),
string.format("[[%dL %ds%s | %dL %ds%s →]]", input_mos.nL + 1, input_mos.ns, equave_as_long_string, input_mos.nL + 1, input_mos.ns, equave_as_string),
string.format("[[%dL %ds%s |  %dL %ds%s]]", input_mos.nL-1, input_mos.ns+1, equave_as_long_string, input_mos.nL-1, input_mos.ns+1, equave_as_string),
string.format("[[%dL %ds%s | ↙ %dL %ds%s]]", input_mos.nL - 1, input_mos.ns + 1, equave_as_long_string, input_mos.nL - 1, input_mos.ns + 1, equave_as_string),
string.format("[[%dL %ds%s | %dL %ds%s]]", input_mos.nL , input_mos.ns+1, equave_as_long_string, input_mos.nL , input_mos.ns+1, equave_as_string),
string.format("[[%dL %ds%s | ↓%dL %ds%s]]", input_mos.nL, input_mos.ns + 1, equave_as_long_string, input_mos.nL, input_mos.ns + 1, equave_as_string),
string.format("[[%dL %ds%s | %dL %ds%s ]]", input_mos.nL+1, input_mos.ns+1, equave_as_long_string, input_mos.nL+1, input_mos.ns+1, equave_as_string),
string.format("[[%dL %ds%s | %dL %ds%s ↘]]", input_mos.nL + 1, input_mos.ns + 1, equave_as_long_string, input_mos.nL + 1, input_mos.ns + 1, equave_as_string),
}
}
Line 137: Line 137:
if input_mos.nL + input_mos.ns <= 40 then
if input_mos.nL + input_mos.ns <= 40 then
local brightest_mode = mos.brightest_mode(input_mos)
local brightest_mode = mos.brightest_mode(input_mos)
step_pattern = string.format('<abbr title="Brightest mode">%s</abbr><br><abbr title="Darkest mode">%s</abbr>', brightest_mode, string.reverse(brightest_mode))
step_pattern = string.format("<abbr title=\"Brightest mode\">%s</abbr><br><abbr title=\"Darkest mode\">%s</abbr>", brightest_mode, string.reverse(brightest_mode))
end
end
Line 166: Line 166:
local collapsed_ed = et.new(input_mos.nL, input_mos.equave, "")
local collapsed_ed = et.new(input_mos.nL, input_mos.equave, "")
local bright_min_in_steps = et.backslash_display(equalized_ed, bright_gen['L'] + bright_gen['s'])
local bright_min_in_steps = et.backslash_display(equalized_ed, bright_gen["L"] + bright_gen["s"])
local bright_max_in_steps = et.backslash_display(collapsed_ed, bright_gen['L'])
local bright_max_in_steps = et.backslash_display(collapsed_ed, bright_gen["L"])
local dark_min_in_steps   = et.backslash_display(collapsed_ed, dark_gen['L'])
local dark_min_in_steps = et.backslash_display(collapsed_ed, dark_gen["L"])
local dark_max_in_steps   = et.backslash_display(equalized_ed, dark_gen['L'] + dark_gen['s'])
local dark_max_in_steps = et.backslash_display(equalized_ed, dark_gen["L"] + dark_gen["s"])
local bright_min_in_cents = mos.bright_gen_to_cents(input_mos, {1, 1})
local bright_min_in_cents = mos.bright_gen_to_cents(input_mos, {1, 1})
local bright_max_in_cents = mos.bright_gen_to_cents(input_mos, {1, 0})
local bright_max_in_cents = mos.bright_gen_to_cents(input_mos, {1, 0})
local dark_min_in_cents   = mos.dark_gen_to_cents(input_mos, {1, 0})
local dark_min_in_cents = mos.dark_gen_to_cents(input_mos, {1, 0})
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 = "Generator size"
local section_header = "Generator size"
local equave_annotation = ""
local equave_annotation = ""
if rat.eq(input_mos.equave, 3) then
if rat.eq(input_mos.equave, 3) then
equave_annotation = '<sup><abbr title="In steps of edt">(edt)</sup>'
equave_annotation = "<sup><abbr title=\"In steps of edt\">(edt)</sup>"
elseif rat.eq(input_mos.equave, rat.new(3,2)) then
elseif rat.eq(input_mos.equave, rat.new(3,2)) then
equave_annotation = '<sup><abbr title="In steps of edf">(edf)</sup>'
equave_annotation = "<sup><abbr title=\"In steps of edf\">(edf)</sup>"
elseif not rat.eq(input_mos.equave, 2) then
elseif not rat.eq(input_mos.equave, 2) then
local equave_as_ratio = rat.as_ratio(input_mos.equave)
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)
equave_annotation = string.format("<sup><abbr title=\"In steps of ed%s\">(ed%s)</sup>", equave_as_ratio, equave_as_ratio)
end
end
Line 266: Line 266:
-- Adds a section for scale names
-- Adds a section for scale names
function p.other_names(other_names)
function p.other_names(other_names)
local other_names = other_names or { "p-chromatic", "hard diatonic" }
local other_names = other_names or {"p-chromatic", "hard diatonic"}
local section_header = "Other names"
local section_header = "Other names"
Line 304: Line 304:
local hard_floght_mos = mos.new(input_mos.nL, input_mos.ns*2+input_mos.nL, input_mos.equave)
local hard_floght_mos = mos.new(input_mos.nL, input_mos.ns*2+input_mos.nL, input_mos.equave)
local parent_scalesig = string.format("[[%s | %s]]", mos.as_long_string(parent_mos   ), mos.as_string(parent_mos   ))
local parent_scalesig = string.format("[[%s | %s]]", mos.as_long_string(parent_mos), mos.as_string(parent_mos))
local sister_scalesig = string.format("[[%s | %s]]", mos.as_long_string(sister_mos   ), mos.as_string(sister_mos   ))
local sister_scalesig = string.format("[[%s | %s]]", mos.as_long_string(sister_mos), mos.as_string(sister_mos))
local soft_scalesig   = string.format("[[%s | %s]]", mos.as_long_string(soft_child_mos), mos.as_string(soft_child_mos))
local soft_scalesig = string.format("[[%s | %s]]", mos.as_long_string(soft_child_mos), mos.as_string(soft_child_mos))
local hard_scalesig   = string.format("[[%s | %s]]", mos.as_long_string(hard_child_mos), mos.as_string(hard_child_mos))
local hard_scalesig = string.format("[[%s | %s]]", mos.as_long_string(hard_child_mos), mos.as_string(hard_child_mos))
local neutral_scalesig   = string.format("[[%s | %s]]", mos.as_long_string(neutral_mos), mos.as_string(neutral_mos))
local neutral_scalesig = string.format("[[%s | %s]]", mos.as_long_string(neutral_mos), mos.as_string(neutral_mos))
local soft_floght_scalesig   = string.format("[[%s | %s]]", mos.as_long_string(soft_floght_mos), mos.as_string(soft_floght_mos))
local soft_floght_scalesig = string.format("[[%s | %s]]", mos.as_long_string(soft_floght_mos), mos.as_string(soft_floght_mos))
local hard_floght_scalesig   = string.format("[[%s | %s]]", mos.as_long_string(hard_floght_mos), mos.as_string(hard_floght_mos))
local hard_floght_scalesig = string.format("[[%s | %s]]", mos.as_long_string(hard_floght_mos), mos.as_string(hard_floght_mos))
local number_of_periods = mos.period_step_count(input_mos)
local number_of_periods = mos.period_step_count(input_mos)
Line 370: Line 370:
local equave_annotation = ""
local equave_annotation = ""
if rat.eq(input_mos.equave, 3) then
if rat.eq(input_mos.equave, 3) then
equave_annotation = '<sup><abbr title="In steps of edt">(edt)</sup>'
equave_annotation = "<sup><abbr title=\"In steps of edt\">(edt)</sup>"
elseif rat.eq(input_mos.equave, rat.new(3,2)) then
elseif rat.eq(input_mos.equave, rat.new(3,2)) then
equave_annotation = '<sup><abbr title="In steps of edf">(edf)</sup>'
equave_annotation = "<sup><abbr title=\"In steps of edf\">(edf)</sup>"
elseif not rat.eq(input_mos.equave, 2) then
elseif not rat.eq(input_mos.equave, 2) then
local equave_as_ratio = rat.as_ratio(input_mos.equave)
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)
equave_annotation = string.format("<sup><abbr title=\"In steps of ed%s\">(ed%s)</sup>", equave_as_ratio, equave_as_ratio)
end
end
Line 409: Line 409:
local tuning_parsed = mos.parse(tuning)
local tuning_parsed = mos.parse(tuning)
local other_names_parsed = tip.parse_entries(other_names_unparsed) or tip.parse_entries(other_names_unparsed, ',')
local other_names_parsed = tip.parse_entries(other_names_unparsed) or tip.parse_entries(other_names_unparsed, ",")
local sections = {}
local sections = {}
Line 459: Line 459:
function p.infobox_MOS(frame)
function p.infobox_MOS(frame)
local tuning = frame.args['Tuning']
local tuning = frame.args["Tuning"]
local other_names = frame.args['othernames'] or nil
local other_names = frame.args["othernames"] or nil
local debug_mode = yesno(tonumber(frame.args['debug']), false)
local debug_mode = yesno(tonumber(frame.args["debug"]), false)
local result = p._infobox_mos(tuning, other_names)
local result = p._infobox_mos(tuning, other_names)
Line 470: Line 470:
return result
return result


end
function p.tester()
local prev_link = "5L 1s"
local next_link = "5L 3s"
local entries = {
{"Scale structure"},
{"Brightest mode", "LLLsLLs"},
{"Period (cents)", "2\1 (1200¢)"},
{"Bright generator range", "4\7 (685.7¢) to 3\5 (720¢)"},
{"Dark generator range", "2\5 (480¢) to 3\7 (514.3¢)"},
{"TAMNAMS information"},
{"Name", "diatonic"},
{"Prefix", "dia-"},
{"Abbrev.", "dia."},
{"Related scales"},
{"Parent MOS", "2L 3s"},
{"Sister MOS", "2L 5s"},
{"Daughter MOSes", "7L 5s, 5L 7s"},
{"Neutralized MOS", "3L 4s"},
{"2-Flought MOS", "12L 2s, 5L 9s"},
{"Equal tunings"},
{"Supersoft (L:s = 4:3)", "15\\26 (692.3¢)"},
{"Soft (L:s = 3:2)", "11\\19 (694.7¢)"},
{"Semisoft (L:s = 5:3)", "18\\31 (696.8¢)"},
{"Basic (L:s = 2:1)", "7\\12 (700¢)"},
{"Semihard (L:s = 5:2)", "17\\29 (703.4¢)"},
{"Hard (L:s = 3:1)", "10\\17 (705.9¢)"},
{"Superhard (L:s = 4:1)", "13\\22 (709.1¢)"},
}
--return infobox.build_multilink("5L 2s (2/1-equivalent)", entries)
return p._infobox_mos("7L 16s")
end
end


return p
return p