Module:MOS tunings: Difference between revisions

Ganaram inukshuk (talk | contribs)
Added "rounding" to step ratio range lookup
Ganaram inukshuk (talk | contribs)
Added checks for hard/soft-of-basic without needing the boundary points of 1:0 or 1:1
Line 126: Line 126:
local lower_ratio = p.step_ratio_floor(step_ratios[1])
local lower_ratio = p.step_ratio_floor(step_ratios[1])
local upper_ratio = p.step_ratio_ceil (step_ratios[#step_ratios])
local upper_ratio = p.step_ratio_ceil (step_ratios[#step_ratios])
-- If one ratio corresponds to the endpoint of a named hardness range
-- but the other ratio exceeds that of a smaller range, default to the
-- largest range that would accommodate it.
-- 2:1 to (L:s > 3:1) = hard-of-basic
-- 4:1 and up = ultrahard
-- (L:s < 3:2) to 2:1 = soft-of-basic
-- 4:3 and lower = ultrasoft
if (lower_ratio[1]/lower_ratio[2] == 2/1 and upper_ratio[1]/upper_ratio[2] > 3/1)
or lower_ratio[1]/lower_ratio[2] == 4/1 then
upper_ratio = {1,0}
elseif (upper_ratio[1]/upper_ratio[2] == 2/1 and lower_ratio[1]/lower_ratio[2] < 3/1)
or upper_ratio[1]/upper_ratio[2] == 4/3 then
lower_ratio = {1,1}
end
step_ratio_range = tamnams.lookup_step_ratio_range(lower_ratio, upper_ratio)
step_ratio_range = tamnams.lookup_step_ratio_range(lower_ratio, upper_ratio)
if step_ratio_range ~= nil then
if step_ratio_range ~= nil then
step_ratio_range = p.capitalize_first(step_ratio_range) .. " Tunings"
step_ratio_range = p.capitalize_first(step_ratio_range) .. " Tunings"