Module:MOS in EDO allperiods: Difference between revisions

Ganaram inukshuk (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
Added maximum number of periods in code, but not template; more reworks pending
Line 88: Line 88:
-- 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_all_periods(edo, show_subsets, temperaments)
function p.moses_in_edo_all_periods(edo, max_number_of_periods, show_subsets, temperaments)
local edo = edo or 12
local edo = edo or 12
local max_number_of_periods = max_number_of_periods or -1
local show_subsets = show_subsets == 1
local show_subsets = show_subsets == 1
local temperaments = temperaments
local temperaments = temperaments
Line 105: Line 106:
-- header.
-- header.
local multi_period_header_written = false
local multi_period_header_written = false
-- Process max number of periods
-- If -1 was entered, then the maximum is 1 + math.floor(edo / 2), the default max
-- Otherwise, make sure that value doesn't exceed the default max
local default_max = 1 + math.floor(edo / 2)
if max_number_of_periods == -1 then
max_number_of_periods = default_max
else
max_number_of_periods = math.min(default_max, max_number_of_periods)
end
-- Call a for loop that produces a set of tables for each period count
-- Call a for loop that produces a set of tables for each period count
Line 111: Line 122:
-- a degenerate mos, hence the minus 1.
-- a degenerate mos, hence the minus 1.
local result = ""
local result = ""
for j = 1, math.floor(edo / 2) - 1 do
for j = 1, max_number_of_periods do
local number_of_periods = j
local number_of_periods = j
if edo % number_of_periods == 0 then
if edo % number_of_periods == 0 then
Line 190: Line 201:
local result = ""
local result = ""
if frame.args["Number of Periods"] == "All" then
if frame.args["Number of Periods"] == "All" then
result = p.moses_in_edo_all_periods(edo, show_subsets, temperaments)
result = p.moses_in_edo_all_periods(edo, -1, show_subsets, temperaments)
else
else
local number_of_periods = tonumber(frame.args["Number of Periods"])
local number_of_periods = tonumber(frame.args["Number of Periods"])