Module:Infobox ET: Difference between revisions
Categorize macrotonal tunings to Category: Macrotonal |
ArrowHead294 (talk | contribs) mNo edit summary |
||
Line 5: | Line 5: | ||
local ET = require("Module:ET") | local ET = require("Module:ET") | ||
local infobox = require("Module:Infobox") | local infobox = require("Module:Infobox") | ||
local yesno = require("Module:Yesno") | |||
-- check whether the input is a non-empty string | -- check whether the input is a non-empty string | ||
Line 28: | Line 29: | ||
local converges = rat.converges(ratio, math.log(interval) / math.log(rat.as_float(et.equave))) | local converges = rat.converges(ratio, math.log(interval) / math.log(rat.as_float(et.equave))) | ||
if et.size > 1 and converges then | if et.size > 1 and converges then | ||
convergement_notice = "<br>(" .. converges .. ")" | convergement_notice = "<br />(" .. converges .. ")" | ||
end | end | ||
Line 34: | Line 35: | ||
convergement_notice = "" | convergement_notice = "" | ||
local link = rat.as_table(ratio)[2] .. et.suffix | local link = rat.as_table(ratio)[2] .. et.suffix | ||
ratio = " (→[[" .. link .. "|" .. rat.as_ratio(ratio, "\\") | ratio = " (→ [[" .. link .. "|" .. rat.as_ratio(ratio, "\\") | ||
if not rat.eq(et.equave, 2) then | if not rat.eq(et.equave, 2) then | ||
ratio = ratio .. et.suffix | ratio = ratio .. et.suffix | ||
Line 45: | Line 46: | ||
local cents = utils._round(ET.cents(et, approx), 6) | local cents = utils._round(ET.cents(et, approx), 6) | ||
return approx .. "\\" .. tuning .. " (" .. cents .. " | return approx .. "\\" .. tuning .. " (" .. cents .. "{{c}})" .. ratio .. convergement_notice | ||
end | end | ||
function p.infobox_ET(frame) | function p.infobox_ET(frame) | ||
-- debug mode will disable the categories | -- debug mode will disable the categories | ||
local debug_mode = frame.args["debug"] | local debug_mode = yesno(frame.args["debug"]) | ||
local categories = "" | local categories = "" | ||
Line 136: | Line 137: | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"Step size", | "Step size", | ||
utils._round(step_size, 6) .. " | utils._round(step_size, 6) .. "{{c}}" .. note_12edo .. " ", | ||
}) | }) | ||
Line 157: | Line 158: | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
"Semitones (A1:m2)", | "Semitones (A1:m2)", | ||
A1 .. ":" .. m2 .. " (" .. A1_cents .. " | A1 .. ":" .. m2 .. " (" .. A1_cents .. "{{c}} : " .. m2_cents .. "{{c}})", | ||
}) | }) | ||
if is_dual_fifth and et.size > 0 then | if is_dual_fifth and et.size > 0 then | ||
Line 222: | Line 223: | ||
if zeta_switch then | if zeta_switch then | ||
if #text > 0 then | if #text > 0 then | ||
text = text .. "<br>" | text = text .. "<br />" | ||
end | end | ||
if not value_provided(zeta_override) then | if not value_provided(zeta_override) then | ||
Line 243: | Line 244: | ||
local result = infobox.build("[[" .. et.suffix .. "|" .. tuning .. "]]", infobox_data, prev_one, next_one) | local result = infobox.build("[[" .. et.suffix .. "|" .. tuning .. "]]", infobox_data, prev_one, next_one) | ||
return frame:preprocess(debug_mode == true and "<pre>" .. result .. "</pre>" or result .. categories) | |||
end | end | ||
return p | return p |