Module:Lumatone mapping intro: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| (12 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local ET = require("Module:ET") | local ET = require("Module:ET") | ||
local rat = require("Module:Rational") | |||
local gcd = require("Module:Utils")._gcd | local gcd = require("Module:Utils")._gcd | ||
local yesno = require("Module:Yesno") | local yesno = require("Module:Yesno") | ||
| Line 8: | Line 8: | ||
local tuning = frame.args["edo"] | local tuning = frame.args["edo"] | ||
local et = ET.parse(tuning) or ET.parse(tuning .. "edo") or ET.parse("12edo") | local et = ET.parse(tuning) or ET.parse(tuning .. "edo") or ET.parse("12edo") | ||
local | local debugg = yesno(frame.args["debug"]) | ||
local octave = ET.approximate(et, 2) | local octave = ET.approximate(et, 2) | ||
| Line 16: | Line 16: | ||
local fifth = -octave + twelfth -- 3/2 = [-1 1> | local fifth = -octave + twelfth -- 3/2 = [-1 1> | ||
local fifth_error = ET.cents(et, fifth) - rat.cents(rat.new(3, 2)) | local fifth_error = ET.cents(et, fifth) - rat.cents(rat.new(3, 2)) | ||
local is_far_fifth = (math.abs(fifth_error) / step_size >= 0. | local is_far_fifth = (math.abs(fifth_error) / step_size >= 0.40) | ||
local result = string.format("There are many conceivable ways to map [[%s]] onto the onto the [[Lumatone]] keyboard.", ET.as_string(et)) | local result = (octave == 12 | ||
and "The standard mapping of [[12edo]] onto the [[Lumatone]] agrees with the [[Standard Lumatone mapping for Pythagorean]]." | |||
or string.format("There are many conceivable ways to map [[%s]] onto the onto the [[Lumatone]] keyboard.", ET.as_string(et))) | |||
local rings = gcd(octave, twelfth) | local rings = gcd(octave, twelfth) | ||
if rings > 1 then | if rings > 1 then | ||
-- If the EDO has multiple rings of fifths | -- If the EDO has multiple rings of fifths | ||
result = result .. string.format(" However, | result = result .. string.format(" However, it has %d mutually-exclusive rings of fifths, ", rings) | ||
.. "the [[Standard Lumatone mapping for Pythagorean]] is not one of them." | .. "so the [[Standard Lumatone mapping for Pythagorean]] is not one of them." | ||
if ET.is_highly_composite(et) then | if ET.is_highly_composite(et) then | ||
-- If the EDO has multiple rings of fifths and is highly composite (multiples of 12 especially) | -- If the EDO has multiple rings of fifths and is highly composite (multiples of 12 especially) | ||
| Line 30: | Line 32: | ||
end | end | ||
elseif is_far_fifth == true then | elseif is_far_fifth == true then | ||
-- | -- EDOs with inaccurate fifth (40% or higher relative error) | ||
result = result .. " However, as both of its fifths are about as far away from just as possible, " | result = result .. " However, as both of its fifths are about as far away from just as possible, " | ||
.. "neither the sharp or the flat versions of the [[Standard Lumatone mapping for Pythagorean]] work particularly well." | .. "neither the sharp or the flat versions of the [[Standard Lumatone mapping for Pythagorean]] work particularly well." | ||
elseif octave ~= 12 then | |||
-- If the EDO can be generated entirely by fifths | -- If the EDO can be generated entirely by fifths | ||
result = result .. " Only one, however, agrees with the [[Standard Lumatone mapping for Pythagorean]]." | result = result .. " Only one, however, agrees with the [[Standard Lumatone mapping for Pythagorean]]." | ||
end | end | ||
-- Debugger option | |||
if debugg == true then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | |||
return frame:preprocess(result) | |||
end | end | ||
return p | return p | ||