Module:MOS intervals: Difference between revisions
No edit summary |
ArrowHead294 (talk | contribs) No edit summary |
||
| Line 1: | Line 1: | ||
local mos = require( | local mos = require("Module:MOS") | ||
local rat = require( | local rat = require("Module:Rational") | ||
local ord = require( | local ord = require("Module:Ordinal") | ||
local utils = require( | local utils = require("Module:Utils") | ||
local et = require( | local et = require("Module:ET") | ||
local tamnams = require( | local tamnams = require("Module:TAMNAMS") | ||
local interval_extension = require( | local interval_extension = require("Module:Interval_extension") | ||
local p = {} | local p = {} | ||
| Line 45: | Line 45: | ||
-- Create the table, starting with the headers | -- Create the table, starting with the headers | ||
local result = | local result = "{| class=\"wikitable\"\n" | ||
.. "|+ style=\"font-size: 105%;\" | Intervals of " .. scale_sig .. "\n" | |||
.. "! colspan=\"3\" | Intervals !! rowspan=\"2\" | Steps subtended !! rowspan=\"2\" | Range in cents !! rowspan=\"2\" | Average of [[HE]]<br/>(from [http://www.mikebattagliamusic.com/HE-JS/HE.html HE Calc])\n !! rowspan=\"2\" | Min of [[HE]]\n" | |||
.. '|-\n' | |||
.. '! Generic<sup>[[#mosstep-1|[1]]]</sup> !! Specific<sup>[[#mosstep-2|[2]]]</sup> !! Abbrev.<sup>[[#mosstep-3|[3]]]</sup>\n' | |||
-- Write each row | -- Write each row | ||
for i = 1, #bright_step_matrix do | for i = 1, #bright_step_matrix do | ||
-- Compare the bright and dark intervals. If they're the same, then the | -- Compare the bright and dark intervals. If they're the same, then the | ||
-- current interval class is a period interval. | -- current interval class is a period interval. | ||
| Line 72: | Line 65: | ||
result = result .. "|-\n" | result = result .. "|-\n" | ||
.. string.format("| '''%s-%sstep''' ", i - 1, mos_prefix) | |||
.. string.format("|| %s " , tamnams.interval_quality(current_bright_interval, input_mos, "sentence-case")) | |||
.. string.format("|| %s " , tamnams.interval_quality(current_bright_interval, input_mos, "abbrev", "m")) | |||
.. string.format("|| %s " , mos.interval_as_string(current_bright_interval)) | |||
.. string.format("|| %.1f¢ ", cents) | |||
.. string.format("|| ~%.4f nats ", interval_extension.harmonic_entropy_with_lookup_table(cents)) | |||
.. string.format("|| ~%.4f nats\n", interval_extension.harmonic_entropy_with_lookup_table(cents)) | |||
else | else | ||
-- Calculate the best and average harmonic entropies | -- Calculate the best and average harmonic entropies | ||
| Line 111: | Line 104: | ||
result = result .. "|-\n" | result = result .. "|-\n" | ||
.. string.format("| rowspan=\"2\" | %s-%sstep ", i - 1, mos_prefix) | |||
.. string.format("|| %s " , tamnams.interval_quality(current_dark_interval, input_mos, "sentence-case")) | |||
.. string.format("|| %s " , tamnams.interval_quality(current_dark_interval, input_mos, "abbrev", "m")) | |||
.. string.format("|| %s " , mos.interval_as_string(current_dark_interval)) | |||
.. string.format("|| %s " , dark_interval_range) | |||
.. string.format("|| ~%.4f nats " , he_dark_average) | |||
.. string.format("|| ~%.4f nats\n" , he_dark_best) | |||
.. "|-\n" | |||
.. string.format("| %s " , tamnams.interval_quality(current_bright_interval, input_mos, "sentence-case")) | |||
.. string.format("|| %s " , tamnams.interval_quality(current_bright_interval, input_mos, "abbrev", "m")) | |||
.. string.format("|| %s " , mos.interval_as_string(current_bright_interval)) | |||
.. string.format("|| %s " , bright_interval_range) | |||
.. string.format("|| ~%.4f nats " , he_bright_average) | |||
.. string.format("|| ~%.4f nats\n" , he_bright_best) | |||
end | end | ||
end | end | ||
result = result .. "|}\n" | result = result .. "|}\n" | ||
.. "<span style=\"font-size: 0.75em;\">\n" | |||
.. "# <span id=\"mosstep-1\">Generic intervals are denoted solely by the number of steps they subtend.</span>\n" | |||
.. "# <span id=\"mosstep-2\">Specific intervals denote whether an interval is major, minor, augmented, perfect, or diminished.</span>\n" | |||
.. "# <span id=\"mosstep-3\">Abbreviations can be further shortened to 'ms' if context allows.</span>\n" | |||
.. "</span>" | |||
return result | return result | ||
end | end | ||
| Line 144: | Line 133: | ||
function p.mos_intervals(frame) | function p.mos_intervals(frame) | ||
-- Get input mos | -- Get input mos | ||
local input_mos = mos.parse(frame.args[ | local input_mos = mos.parse(frame.args["Scale Signature"]) | ||
-- Default param for mos prefix | -- Default param for mos prefix | ||
| Line 154: | Line 143: | ||
local mos_abbrev = tamnams.lookup_abbrev(input_mos) | local mos_abbrev = tamnams.lookup_abbrev(input_mos) | ||
if frame.args[ | if frame.args["MOS Prefix"] == "NONE" then | ||
mos_prefix = "" | mos_prefix = "" | ||
mos_abbrev = "" | mos_abbrev = "" | ||
elseif string.len(frame.args[ | elseif string.len(frame.args["MOS Prefix"]) > 0 then | ||
mos_prefix = frame.args[ | mos_prefix = frame.args["MOS Prefix"] | ||
mos_abbrev = frame.args[ | mos_abbrev = frame.args["MOS Prefix"] | ||
end | end | ||
if frame.args[ | if frame.args["MOS Abbrev"] == "NONE" then | ||
mos_abbrev = "" | mos_abbrev = "" | ||
elseif string.len(frame.args[ | elseif string.len(frame.args["MOS Abbrev"]) > 0 then | ||
mos_abbrev = frame.args[ | mos_abbrev = frame.args["MOS Abbrev"] | ||
end | end | ||
return p._mos_intervals(input_mos, mos_prefix, mos_abbrev) | |||
end | end | ||
return p | return p | ||