Module:MOS in EDO allperiods: Difference between revisions
m Simplified arg names |
Added generation limits; to be shown in the lead section |
||
| Line 25: | Line 25: | ||
-- If the edo has subset edos (such as 24edo containing 12edo and 8edo), mosses | -- If the edo has subset edos (such as 24edo containing 12edo and 8edo), mosses | ||
-- for those subset edos are skipped, unless show_subsets is set to 1 (true) | -- for those subset edos are skipped, unless show_subsets is set to 1 (true) | ||
function p.moses_in_edo(edo, number_of_periods, show_subsets, | function p.moses_in_edo(edo, number_of_periods, show_subsets, generation_limit, temperaments) | ||
local edo = edo or 12 | local edo = edo or 12 | ||
local number_of_periods = number_of_periods or 1 | local number_of_periods = number_of_periods or 1 | ||
local show_subsets = show_subsets == 1 | local show_subsets = show_subsets == 1 | ||
local | local generation_limit = generation_limit or edo - 1 | ||
local temperaments = temperaments | local temperaments = temperaments | ||
| Line 39: | Line 39: | ||
period_in_edosteps = edo / number_of_periods | period_in_edosteps = edo / number_of_periods | ||
verified_number_of_periods = number_of_periods | verified_number_of_periods = number_of_periods | ||
end | |||
-- Check whether the generation limit is valid | |||
-- Technically, any number above the edo works with showing all generations (rows) | |||
-- If it's -1, then show all generations (period_in_edosteps-1) | |||
if generation_limit == -1 then | |||
generation_limit = period_in_edosteps - 1 | |||
end | end | ||
| Line 76: | Line 83: | ||
local temperament_index = 1 + i - starting_generator | local temperament_index = 1 + i - starting_generator | ||
if show_temperament then | if show_temperament then | ||
result = result .. mosinedo.mos_in_edo_simplified(edo, i, verified_number_of_periods, | result = result .. mosinedo.mos_in_edo_simplified(edo, i, verified_number_of_periods, generation_limit, temperaments[temperament_index]) | ||
else | else | ||
result = result .. mosinedo.mos_in_edo_simplified(edo, i, verified_number_of_periods, | result = result .. mosinedo.mos_in_edo_simplified(edo, i, verified_number_of_periods, generation_limit) | ||
end | end | ||
end | end | ||
| Line 89: | Line 96: | ||
-- Main function variant | -- Main function variant | ||
-- Creates tables for every mos in an edo, for every possible period count | -- Creates tables for every mos in an edo, for every possible period count | ||
function p.moses_in_edo_multi_periods(edo, max_number_of_periods, show_subsets, | function p.moses_in_edo_multi_periods(edo, max_number_of_periods, show_subsets, generation_limit, temperaments) | ||
local edo = edo or 12 | local edo = edo or 12 | ||
local max_number_of_periods = max_number_of_periods or -1 | local max_number_of_periods = max_number_of_periods or -1 | ||
local show_subsets = show_subsets == 1 | local show_subsets = show_subsets == 1 | ||
local | local generation_limit = generation_limit or edo - 1 | ||
local temperaments = temperaments | local temperaments = temperaments | ||
| Line 117: | Line 124: | ||
else | else | ||
max_number_of_periods = math.min(default_max, max_number_of_periods) | max_number_of_periods = math.min(default_max, max_number_of_periods) | ||
end | |||
-- Check whether the generation limit is valid | |||
-- Technically, any number above the edo works with showing all generations (rows) | |||
-- If it's -1, then show all generations (period_in_edosteps-1) | |||
if generation_limit == -1 then | |||
generation_limit = period_in_edosteps - 1 | |||
end | end | ||
| Line 175: | Line 189: | ||
local temperament_index = 1 + i - starting_generator | local temperament_index = 1 + i - starting_generator | ||
if show_temperament then | if show_temperament then | ||
result = result .. mosinedo.mos_in_edo_simplified(edo, i, number_of_periods, | result = result .. mosinedo.mos_in_edo_simplified(edo, i, number_of_periods, generation_limit, temperaments[temperament_index]) | ||
else | else | ||
result = result .. mosinedo.mos_in_edo_simplified(edo, i, number_of_periods, | result = result .. mosinedo.mos_in_edo_simplified(edo, i, number_of_periods, generation_limit) | ||
end | end | ||
end | end | ||
| Line 208: | Line 222: | ||
local show_subsets = tonumber(frame.args["Show Subsets"]) | local show_subsets = tonumber(frame.args["Show Subsets"]) | ||
local max_periods = tonumber(frame.args["Period Limit"]) or -1 | local max_periods = tonumber(frame.args["Period Limit"]) or -1 | ||
local | local generation_limit = tonumber(frame.args["Generation Limit"]) or -1 | ||
local num_periods = tonumber(frame.args["Number of Periods"]) | local num_periods = tonumber(frame.args["Number of Periods"]) | ||
local result = "" | local result = "" | ||
if num_periods ~= nil then | if num_periods ~= nil then | ||
result = p.moses_in_edo(edo, num_periods, show_subsets, | result = p.moses_in_edo(edo, num_periods, show_subsets, generation_limit, temperaments) | ||
else | else | ||
result = p.moses_in_edo_multi_periods(edo, max_periods, show_subsets, | result = p.moses_in_edo_multi_periods(edo, max_periods, show_subsets, generation_limit, temperaments) | ||
end | end | ||