Module:Infobox MOS: Difference between revisions
m bugfix again |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local rat = require( | local rat = require("Module:Rational") | ||
local mos = require( | local mos = require("Module:MOS") | ||
local et = require( | local et = require("Module:ET") | ||
local xp = require( | local xp = require("Module:Xenpaper") | ||
local infobox = require( | local infobox = require("Module:Infobox") | ||
local kbvis = require( | local kbvis = require("Module:Keyboard vis") | ||
local tip = require( | local tip = require("Module:Template input parse") | ||
local tamnams = require( | local tamnams = require("Module:TAMNAMS") | ||
local yesno = require( | 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( | categories = categories .. string.format("[[Category:%s]]", tamnams_name) | ||
end | end | ||
else | else | ||
categories = categories .. | categories = categories .. "[[Category:Nonoctave]]" | ||
end | end | ||
| Line 89: | Line 89: | ||
local adjacent_links = { | local adjacent_links = { | ||
string.format("[[%dL %ds%s | | 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 | | 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  | 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 | | 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  | 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 | | 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 | | 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  | 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( | 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[ | 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[ | local bright_max_in_steps = et.backslash_display(collapsed_ed, bright_gen["L"]) | ||
local dark_min_in_steps | local dark_min_in_steps = et.backslash_display(collapsed_ed, dark_gen["L"]) | ||
local dark_max_in_steps | 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 | local dark_min_in_cents = mos.dark_gen_to_cents(input_mos, {1, 0}) | ||
local dark_max_in_cents | 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 = | 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 = | 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( | 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 | 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 | local sister_scalesig = string.format("[[%s | %s]]", mos.as_long_string(sister_mos), mos.as_string(sister_mos)) | ||
local soft_scalesig | local soft_scalesig = string.format("[[%s | %s]]", mos.as_long_string(soft_child_mos), mos.as_string(soft_child_mos)) | ||
local hard_scalesig | local hard_scalesig = string.format("[[%s | %s]]", mos.as_long_string(hard_child_mos), mos.as_string(hard_child_mos)) | ||
local neutral_scalesig | local neutral_scalesig = string.format("[[%s | %s]]", mos.as_long_string(neutral_mos), mos.as_string(neutral_mos)) | ||
local soft_floght_scalesig | 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 | 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 = | 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 = | 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( | 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[ | local tuning = frame.args["Tuning"] | ||
local other_names = frame.args[ | local other_names = frame.args["othernames"] or nil | ||
local debug_mode = yesno(tonumber(frame.args[ | 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 | end | ||
return p | return p | ||