Module:MOS in EDO: Difference between revisions
ArrowHead294 (talk | contribs) No edit summary |
m rename |
||
| (21 intermediate revisions by 2 users not shown) | |||
| Line 1: | Line 1: | ||
local p = {} | local p = {} | ||
local mos = require("Module:MOS") | |||
local step_vis = require("Module:Step vis") | |||
local tamnams = require("Module:TAMNAMS") | |||
local utils = require("Module:Utils") | |||
local yesno = require("Module:Yesno") | |||
-- Global variables for cell colors | -- Global variables for cell colors | ||
-- Dark blue for large steps, light blue for small steps | -- Dark blue for large steps, light blue for small steps | ||
-- For mosses that are reversed (starts with s and ends with L), use orange instead | -- For mosses that are reversed (starts with s and ends with L), use orange instead | ||
p.cell_color_none = " | p.cell_color_none = "" -- For cells that don't have a color (default cell color applies) | ||
p.cell_color_perfect_size = " | p.cell_color_perfect_size = "" -- Only applies for steps of an edo | ||
p.cell_color_large = "BDD7EE" | p.cell_color_large = "#BDD7EE" | ||
p.cell_color_small = "DDEBF7" | p.cell_color_small = "#DDEBF7" | ||
p.cell_color_lg_rev = "F8CBAD" | p.cell_color_lg_rev = "#F8CBAD" | ||
p.cell_color_sm_rev = "FCE4D6" | p.cell_color_sm_rev = "#FCE4D6" | ||
-- Helper function | -- Helper function | ||
| Line 60: | Line 64: | ||
end | end | ||
return string.format("%iL %is", large_step_count, small_step_count) | return string.format("%iL %is", large_step_count, small_step_count) | ||
end | end | ||
| Line 150: | Line 154: | ||
return next_step_array | return next_step_array | ||
end | end | ||
| Line 239: | Line 191: | ||
-- Create table, starting with headers | -- Create table, starting with headers | ||
local result = | local result = "{| class=\"wikitable center-all\"\n" | ||
.. "|+ style=\"font-size: 105%; white-space: nowrap;\" | " .. string.format("Generators %i\\%i and %i\\%i\n", gen_in_edosteps, edo, comp_in_edosteps, edo) | |||
.. "|-\n" | |||
.. string.format("! colspan=\"%i\" | Steps\n", edo) | |||
.. "! MOS (name)\n" | |||
.. "! Step ratio\n" | |||
if show_temperament then | if show_temperament then | ||
result = result .. string.format( | result = result .. string.format("! Temperament\n") | ||
end | end | ||
| Line 262: | Line 214: | ||
-- Add the step sizes | -- Add the step sizes | ||
result = result .. | result = result .. "|-\n" | ||
for i = 1, #current_scale do | for i = 1, #current_scale do | ||
local current_step = current_scale[i] | local current_step = current_scale[i] | ||
| Line 286: | Line 238: | ||
if current_step == 1 then | if current_step == 1 then | ||
if large_step_size == small_step_size then | if large_step_size == small_step_size then | ||
result = result .. | result = result .. "| 1\n" | ||
else | else | ||
result = result .. string.format( | result = result .. string.format("| style=\"background-color: %s;\" | 1\n", cell_color) | ||
end | end | ||
else | else | ||
if cell_color == p.cell_color_none then | if cell_color == p.cell_color_none then | ||
result = result .. string.format( | result = result .. string.format("| colspan=\"%i\" | %i\n", current_step, current_step) | ||
else | else | ||
result = result .. string.format( | result = result .. string.format("| style=\"background-color: %s\" colspan=\"%i\" | %i\n", cell_color, current_step, current_step) | ||
end | end | ||
end | end | ||
| Line 304: | Line 256: | ||
-- Get the tamnams name, if there is one | -- Get the tamnams name, if there is one | ||
-- Don't show tamnams names for mosses with 5 notes or fewer (to keep the table from being cluttered) | -- Don't show tamnams names for mosses with 5 notes or fewer (to keep the table from being cluttered) | ||
local tamnams_name = | local tamnams_name = tamnams.lookup_name(scale_sig) | ||
local current_step_count = #current_scale | local current_step_count = #current_scale | ||
| Line 332: | Line 284: | ||
end | end | ||
result = result .. | result = result .. "|}" | ||
return result | return result | ||
| Line 380: | Line 332: | ||
-- Create table, starting with headers | -- Create table, starting with headers | ||
local result = | local result = "{| class=\"wikitable center-all\"\n" | ||
.. "|+ style=\"font-size: 105%; white-space: nowrap;\" | " .. string.format("Generators %i\\%i and %i\\%i\n", gen_in_edosteps, edo, comp_in_edosteps, edo) | |||
.. "|-\n" | |||
.. "! Step visualization\n" | |||
.. "! MOS (name)\n" -- Scale sig (and name) | |||
.. "! Step sizes\n" -- Step sizes | |||
.. "! Step ratio\n" -- Step ratio | |||
if show_temperament then | if show_temperament then | ||
result = result .. | result = result .. "! Temperament\n" -- Temperament, if given | ||
end | end | ||
| Line 402: | Line 354: | ||
-- New row | -- New row | ||
result = result .. | result = result .. "|-\n" | ||
-- Add the step visualization | -- Add the step visualization | ||
local step_vis | local sv = step_vis._step_vis(current_scale) | ||
result = result .. string.format( | result = result .. string.format("| %s\n", sv) | ||
-- Add the scale sig | -- Add the scale sig | ||
-- Also add tamnams name if there is one | -- Also add tamnams name if there is one | ||
local scale_sig = p.mos_step_pattern_to_scale_sig(current_scale) | local scale_sig = p.mos_step_pattern_to_scale_sig(current_scale) | ||
local tamnams_name = | local tamnams_name = tamnams.lookup_name(scale_sig) | ||
local current_step_count = #current_scale | local current_step_count = #current_scale | ||
if large_step_size == small_step_size then | if large_step_size == small_step_size then | ||
| Line 422: | Line 374: | ||
-- Add the step sizes | -- Add the step sizes | ||
result = result .. string.format("| %i, %i\n", current_step_sizes["L"], current_step_sizes["s"]) | result = result .. string.format("| %i, %i\n", current_step_sizes["L"], current_step_sizes["s"]) | ||
-- Add step ratio | -- Add step ratio | ||
| Line 442: | Line 394: | ||
end | end | ||
result = result .. | result = result .. "|}" | ||
return result | return result | ||
| Line 449: | Line 401: | ||
-- Function to be called by a template | -- Function to be called by a template | ||
function p.mos_in_edo_frame(frame) | function p.mos_in_edo_frame(frame) | ||
local edo = tonumber(frame.args["EDO"]) | local edo = tonumber(frame.args["EDO"]) | ||
local gen_in_edosteps = tonumber(frame.args["Generator"]) | local gen_in_edosteps = tonumber(frame.args["Generator"]) | ||
| Line 455: | Line 406: | ||
local number_of_periods = tonumber(frame.args["Periods"]) | local number_of_periods = tonumber(frame.args["Periods"]) | ||
local generation_limit = tonumber(frame.args["Generation Limit"]) | local generation_limit = tonumber(frame.args["Generation Limit"]) | ||
local debugg = yesno(frame.args["debug"]) | |||
local result = p.mos_in_edo_simplified(edo, gen_in_edosteps, number_of_periods, generation_limit, temperament) | |||
-- Debugger option | |||
if debugg == true then | |||
result = "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" | |||
end | |||
return frame:preprocess(result) | |||
end | end | ||
return p | return p | ||