Module:MOS tunings: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
Simplified step ratio sorting |
||
| Line 21: | Line 21: | ||
-- Helper function | -- Helper function | ||
-- | -- Given two ratios, return whether the first is less than the second. To be | ||
function p. | -- used as part of step ratio preprocessing by being passed into table.sort. | ||
function p.step_ratio_comparison_function(step_ratio_1, step_ratio_2) | |||
local hardness_1 = step_ratio_1[1] / step_ratio_1[2] | |||
local hardness_2 = step_ratio_2[1] / step_ratio_2[2] | |||
return hardness_1 < hardness_2 | |||
return | |||
end | end | ||
| Line 51: | Line 32: | ||
-- Finds the step ratio range and sorts step ratios | -- Finds the step ratio range and sorts step ratios | ||
function p.preprocess_step_ratios(step_ratios) | function p.preprocess_step_ratios(step_ratios) | ||
local step_ratios = | local step_ratios = table.sort(step_ratios, step_ratio_comparison_function) | ||
local step_ratio_range = "" | local step_ratio_range = "" | ||