Module:MOS tunings: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| (22 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | |||
local et = require("Module:ET") | |||
local jira = require("Module:JI ratios") | |||
local mos = require("Module:MOS") | local mos = require("Module:MOS") | ||
local tamnams = require("Module:TAMNAMS") | local tamnams = require("Module:TAMNAMS") | ||
local | local tip = require("Module:Template input parse") | ||
local yesno = require("Module:Yesno") | local yesno = require("Module:Yesno") | ||
-- Rewritten/simplified module replacement for Module:MOS degrees | -- Rewritten/simplified module replacement for Module:MOS degrees | ||
| Line 12: | Line 13: | ||
-- TODO: | -- TODO: | ||
-- - Relegate JI ratio input to sorting entered ratios; this is to decouple | |||
-- ratio search from ratio sorting/filtering. | |||
-- - Diatonic interval category lookup? | -- - Diatonic interval category lookup? | ||
| Line 154: | Line 157: | ||
-- Preprocess JI ratios | -- Preprocess JI ratios | ||
local modal_union = mos.modal_union(input_mos) | local modal_union = mos.modal_union(input_mos) | ||
local sorted_ji_ratios, search_info = p.preprocess_ji_ratios(input_mos, modal_union, step_ratios, ji_ratios, tolerance) | --local sorted_ji_ratios, search_info = p.preprocess_ji_ratios(input_mos, modal_union, step_ratios, ji_ratios, tolerance) | ||
-- Create table | -- Create table | ||
| Line 161: | Line 164: | ||
-- Table caption | -- Table caption | ||
result = result .. "|+ style=\"font-size: 105%; white-space: nowrap;\" | " .. string.format("%s of %s\n", step_ratio_range, scale_sig) | result = result .. "|+ style=\"font-size: 105%; white-space: nowrap;\" | " .. string.format("%s of %s\n", step_ratio_range, scale_sig) | ||
.. "|-\n" | |||
-- First row of headers | -- First row of headers | ||
-- First two headers span two rows | -- First two headers span two rows | ||
result = result .. "! rowspan=\"2\" class=\"unsortable\" | Scale degree\n" | result = result | ||
.. "! rowspan=\"2\" class=\"unsortable\" | Scale degree\n" | |||
.. "! rowspan=\"2\" class=\"unsortable\" | Abbrev.\n" | |||
-- Headers for tunings; these span two cols | -- Headers for tunings; these span two cols | ||
| Line 176: | Line 181: | ||
end | end | ||
local et_as_string = et.as_string(mos. | local et_as_string = et.as_string(mos.as_et(input_mos, step_ratios[i])) | ||
local header_text = string.format("%s<br />[[%s]]", step_ratio_as_text, et_as_string) | local header_text = string.format("%s<br />[[%s]]", step_ratio_as_text, et_as_string) | ||
result = result .. string.format("! colspan=\"2\" | %s\n", header_text) | result = result .. string.format("! colspan=\"2\" | %s\n", header_text) | ||
| Line 182: | Line 187: | ||
-- Headers for JI ratios; this spans two rows | -- Headers for JI ratios; this spans two rows | ||
-- Commented out, pending rewrite | |||
--[[ | |||
if #ji_ratios ~= 0 then | if #ji_ratios ~= 0 then | ||
result = result .. "! rowspan=\"2\" class=\"unsortable\" | Approx. ratios*\n" | result = result .. "! rowspan=\"2\" class=\"unsortable\" | Approx. ratios*\n" | ||
end | end | ||
]]-- | |||
result = result .. "|-\n" | result = result .. "|-\n" | ||
| Line 203: | Line 211: | ||
result = result | result = result | ||
.. "|-\n" | .. "|-\n" | ||
.. string.format("| %s | .. string.format("| %s\n", degree_name) | ||
.. string.format("| %s\n", degree_abbrev) | |||
-- Add cells for each interval's tunings | -- Add cells for each interval's tunings | ||
| Line 212: | Line 221: | ||
result = result | result = result | ||
--.. string.format("\n| %s\\%s\n| %.1f", step_count, input_mos.nL * step_ratio[1] + input_mos.ns * step_ratio[2], cents) | |||
--.. string.format(" | .. string.format("| style=\"border-right: none;\" | %s\\%s\n", step_count, input_mos.nL * step_ratio[1] + input_mos.ns * step_ratio[2]) | ||
.. string.format(" | .. string.format("| style=\"border-left: none;\" | %.1f\n", cents) | ||
end | end | ||
-- Add cells for JI ratios | -- Add cells for JI ratios | ||
--[[ | |||
-- Commented out, pending rewrite | |||
if #ji_ratios ~= 0 then | if #ji_ratios ~= 0 then | ||
-- Ratios link to their respective pages, and are comma-delimited. | -- Ratios link to their respective pages, and are comma-delimited. | ||
local ratios_as_text = jira.ratios_as_string(sorted_ji_ratios[i], true, ", ") | local ratios_as_text = jira.ratios_as_string(sorted_ji_ratios[i], true, ", ") | ||
result = result .. " | result = result .. "| style=\"text-align: left;\" | " .. string.format("%s\n", ratios_as_text) | ||
end | end | ||
]]-- | |||
end | end | ||
-- End of table, plus footnotes | -- End of table, plus footnotes | ||
result = result .. "|} | result = result .. "|}" | ||
--[[ | |||
-- Commented out, pending rewrite | |||
if #ji_ratios ~= 0 then | if #ji_ratios ~= 0 then | ||
result = result .. string.format("<span style=\"font-size: 0.75em;\">* | -- Make footnote text smaller than the rest of the text to avoid confusion with paragraph text | ||
result = result .. string.format("<span style=\"font-size: 0.75em;\">* %s</span>", footnotes) | |||
end | end | ||
]]-- | |||
return result | return result | ||
| Line 284: | Line 298: | ||
if unparsed == "" then | if unparsed == "" then | ||
search_args = {["Int Limit"] = | search_args = {["Int Limit"] = 50, ["Tenney Height"] = 8; ["Complements Only"] = true} -- Defualt search args if no args were passed in | ||
ratios = jira.search_by_args_within_equave(equave, search_args) | ratios = jira.search_by_args_within_equave(equave, search_args) | ||
elseif unparsed == "NONE" then | elseif unparsed == "NONE" then | ||
| Line 310: | Line 324: | ||
local step_ratios = p.parse_step_ratios(frame.args["Step Ratios"]) | local step_ratios = p.parse_step_ratios(frame.args["Step Ratios"]) | ||
local tolerance = tonumber(frame.args["Tolerance"]) | local tolerance = tonumber(frame.args["Tolerance"]) | ||
local debugg = yesno(frame.args["debug"]) | |||
local ji_ratios, footnotes = p.parse_ji_ratios(frame.args["JI Ratios"], input_mos.equave) | --local ji_ratios, footnotes = p.parse_ji_ratios(frame.args["JI Ratios"], input_mos.equave) | ||
local result = p._mos_tunings(input_mos, mos_prefix, mos_abbrev, step_ratios, ji_ratios, tolerance, footnotes, is_collapsed) | |||
if debugg == true then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | |||
return frame:preprocess(result) | |||
end | end | ||