Module:MOS in EDO allperiods: Difference between revisions
mNo edit summary |
Created a variant function that populates an entire page |
||
Line 84: | Line 84: | ||
return result | return result | ||
end | |||
-- Main function variant | |||
-- Creates tables for every mos in an edo, for every possible period count | |||
function p.moses_in_edo_all_periods(edo, show_subsets, temperaments) | |||
local edo = edo or 36 | |||
local show_subsets = show_subsets == 1 | |||
local temperaments = temperaments | |||
-- Include temperament names? | |||
local show_temperament = temperaments ~= nil and #temperaments == math.floor(period_in_edosteps / verified_number_of_periods / 2) | |||
-- Temporarily disable entry of temperament names | |||
-- Temperament names will be entered as a set of key-value pairs instead of an array | |||
show_temperament = false | |||
-- Call a for loop that produces a set of tables for each period count | |||
for j = 1, math.ceil(math.sqrt(edo)) do | |||
local j = number_of_periods | |||
if edo % number_of_periods == 0 then | |||
-- Calculate the starting genpair | |||
-- If the generator and its complement are the same, skip that genpair by | |||
-- incrementing the starting generator by 1 | |||
local starting_generator = math.ceil(period_in_edosteps / 2) | |||
local complement = period_in_edosteps - starting_generator | |||
if starting_generator == complement then | |||
starting_generator = starting_generator + 1 | |||
end | |||
-- Add a section header | |||
if number_of_periods == 1 then | |||
result = result .. string.format("== Single-period MOS scales ==\n") | |||
else | |||
result = result .. string.format("== %i-period MOS scales ==\n", number_of_periods) | |||
end | |||
-- Add a table for each genpair | |||
local result = "" | |||
for i = starting_generator, period_in_edosteps - 1 do | |||
-- Calculate current generators | |||
local gen = i | |||
local comp = period_in_edosteps - gen | |||
-- Skip mosses that are supported by subset edos; this happens if the | |||
-- gen and comp have a gcd > 1; if show_subsets is set to true, then | |||
-- show them anyway. | |||
local gcd = utils._gcd(gen, comp) | |||
local add_table = gcd == 1 or show_subsets | |||
-- Add table | |||
if add_table then | |||
-- TODO: Rewrite code here for entry of temperaments as a set of | |||
-- key-value pairs | |||
local temperament_index = 1 + i - starting_generator | |||
if show_temperament then | |||
result = result .. mosinedo.mos_in_edo(edo, i, verified_number_of_periods, temperaments[temperament_index]) | |||
else | |||
result = result .. mosinedo.mos_in_edo(edo, i, verified_number_of_periods) | |||
end | |||
end | |||
end | |||
end | |||
end | |||
return result | |||
end | end | ||
Line 90: | Line 155: | ||
local edo = tonumber(frame.args["EDO"]) | local edo = tonumber(frame.args["EDO"]) | ||
local temperaments = p.parse_entries(frame.args["Temperaments"]) | local temperaments = p.parse_entries(frame.args["Temperaments"]) | ||
local show_subsets = tonumber(frame.args["Show Subsets"]) | local show_subsets = tonumber(frame.args["Show Subsets"]) | ||
local result = p.moses_in_edo(edo, number_of_periods, show_subsets, temperaments) | if frame.args["Number of Periods"] == "All" then | ||
local result = p.moses_in_edo_all_periods(edo, show_subsets, temperaments) | |||
else | |||
local number_of_periods = tonumber(frame.args["Number of Periods"]) | |||
local result = p.moses_in_edo(edo, number_of_periods, show_subsets, temperaments) | |||
end | |||
return result | return result |