Module:MOS mode degrees: Difference between revisions
ArrowHead294 (talk | contribs) mNo edit summary |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| Line 1: | Line 1: | ||
local mos = require( | local mos = require("Module:MOS") | ||
local rat = require( | local rat = require("Module:Rational") | ||
local utils = require( | local utils = require("Module:Utils") | ||
local mosnot = require( | local mosnot = require("Module:MOS notation") | ||
local et = require( | local et = require("Module:ET") | ||
local tip = require( | local tip = require("Module:Template input parse") | ||
local tamnams = require( | local tamnams = require("Module:TAMNAMS") | ||
local p = {} | local p = {} | ||
| Line 16: | Line 16: | ||
p.cell_color_none = "NONE" -- For cells that don't have a color (default cell color applies) | p.cell_color_none = "NONE" -- For cells that don't have a color (default cell color applies) | ||
p.cell_color_perfect_size = "NONE" -- Only applies for periods, including the root and equave | p.cell_color_perfect_size = "NONE" -- Only applies for periods, including the root and equave | ||
p.cell_color_lg_altered_size = "BDD7EE" | p.cell_color_lg_altered_size = "#BDD7EE" | ||
p.cell_color_large_size = "DDEBF7" | p.cell_color_large_size = "#DDEBF7" | ||
p.cell_color_small_size = "FCE4D6" | p.cell_color_small_size = "#FCE4D6" | ||
p.cell_color_sm_altered_size = "F8CBAD" | p.cell_color_sm_altered_size = "#F8CBAD" | ||
-- Helper function | -- Helper function | ||
| Line 686: | Line 686: | ||
-- Create table | -- Create table | ||
local result = '{| class="wikitable sortable"\n' | local result = '{| class="wikitable sortable"\n' | ||
local result = result .. string.format("|+ Scale degree qualities of %s modes (step pattern of %s)\n", scale_sig, step_pattern) | local result = result .. string.format("|+ style=\"font-size: 105%%;\" | Scale degree qualities of %s modes (step pattern of %s)\n", scale_sig, step_pattern) | ||
-- Add table headers for first row | -- Add table headers for first row | ||
.. "! rowspan=\"2\" | UDP and alterations !! rowspan=\"2\" | Rotational Order !! rowspan=\"2\" | Step pattern" | |||
-- Add mode names if present | -- Add mode names if present | ||
local mode_names_given = (mode_names ~= nil and #mode_names == #step_patterns) or use_default_mode_names | local mode_names_given = (mode_names ~= nil and #mode_names == #step_patterns) or use_default_mode_names | ||
if mode_names_given then | if mode_names_given then | ||
result = result .. | result = result .. "!! rowspan=\"2\" class=\"unsortable\" | Mode names" | ||
end | end | ||
-- Add header for scale degrees | -- Add header for scale degrees | ||
result = result .. string.format( | result = result .. string.format(" !! colspan=\"%d\" class=\"unsortable\" | Scale degree (%sdegree)", equave_step_count + 1, mos_prefix) | ||
.. "\n" | |||
-- Add second row of headers; these are for the scale degrees | -- Add second row of headers; these are for the scale degrees | ||
result = result .. "|-\n" | result = result .. "|-\n" | ||
for i = 1, equave_step_count | .. "! class=\"unsortable\" | 0" | ||
result = result .. string.format( | for i = 1, equave_step_count do | ||
result = result .. string.format(" !! class=\"unsortable\" | %d", i) | |||
end | end | ||
result = result .. "\n" | |||
-- Add table contents | -- Add table contents | ||
| Line 713: | Line 715: | ||
-- Add brightness order (as UDP), rotational order, and step pattern | -- Add brightness order (as UDP), rotational order, and step pattern | ||
.. string.format("| %s || %s || %s", alterations[i], i, step_patterns[i]) | |||
-- Add mode name if given | -- Add mode name if given | ||
if mode_names_given then | if mode_names_given then | ||
if use_default_mode_names then | if use_default_mode_names then | ||
result = result .. string.format( | result = result .. string.format(" || %s %s", scale_sig, alterations[i]) | ||
else | else | ||
result = result .. string.format( | result = result .. string.format(" || %s", mode_names[i]) | ||
end | end | ||
end | end | ||
| Line 728: | Line 730: | ||
for j = 1, #step_matrices[i] do | for j = 1, #step_matrices[i] do | ||
if row_colors[i][j] == p.cell_color_none then | if row_colors[i][j] == p.cell_color_none then | ||
result = result .. string.format( | result = result .. string.format(" || %s", p.decode_quality(step_matrices[i][j])) | ||
elseif row_colors[i][j] == p.cell_color_lg_altered_size or row_colors[i][j] == p.cell_color_sm_altered_size then | elseif row_colors[i][j] == p.cell_color_lg_altered_size or row_colors[i][j] == p.cell_color_sm_altered_size then | ||
result = result .. string.format( | result = result .. string.format(" || style=\"background: %s;\" | ''%s''", row_colors[i][j], p.decode_quality(step_matrices[i][j])) | ||
else | else | ||
result = result .. string.format( | result = result .. string.format(" || style=\"background: %s;\" | %s", row_colors[i][j], p.decode_quality(step_matrices[i][j])) | ||
end | end | ||
end | end | ||
result = result .. "\n" | |||
end | end | ||
-- End of table | -- End of table | ||
result = result .. "|}" | result = result .. "|}" | ||
return result | return result | ||
end | end | ||
| Line 749: | Line 751: | ||
function p.mos_mode_degrees(frame) | function p.mos_mode_degrees(frame) | ||
-- Default param for input mos is 5L 2s | -- Default param for input mos is 5L 2s | ||
local input_mos = mos.parse(frame.args[ | local input_mos = mos.parse(frame.args["Scale Signature"]) or mos.new(2, 5, 2) | ||
-- Get the scale sig; for calculating the mos prefix | -- Get the scale sig; for calculating the mos prefix | ||
| Line 759: | Line 761: | ||
-- If not left blank, use the prefix passed in instead | -- If not left blank, use the prefix passed in instead | ||
local mos_prefix = "mos" | local mos_prefix = "mos" | ||
if frame.args[ | if frame.args["MOS Prefix"] == "NONE" then | ||
mos_prefix = "" | mos_prefix = "" | ||
elseif string.len(frame.args[ | elseif string.len(frame.args["MOS Prefix"]) == 0 then | ||
mos_prefix_lookup = tamnams.lookup_prefix(input_mos) or "" | mos_prefix_lookup = tamnams.lookup_prefix(input_mos) or "" | ||
if string.len(mos_prefix_lookup) ~= 0 then | if string.len(mos_prefix_lookup) ~= 0 then | ||
| Line 767: | Line 769: | ||
end | end | ||
else | else | ||
mos_prefix = frame.args[ | mos_prefix = frame.args["MOS Prefix"] | ||
end | end | ||
-- Get the step pattern | -- Get the step pattern | ||
local step_pattern = frame.args[ | local step_pattern = frame.args["MODMOS Step Pattern"] | ||
-- Get the mode names | -- Get the mode names | ||
| Line 785: | Line 787: | ||
-- If using default mode names (scalesig+udp), those names are auto-added by the relevant function | -- If using default mode names (scalesig+udp), those names are auto-added by the relevant function | ||
local use_default_names = 0 | local use_default_names = 0 | ||
if #frame.args[ | if #frame.args["Mode Names"] ~= 0 then | ||
if frame.args[ | if frame.args["Mode Names"] == "Default" then | ||
use_default_names = 1 | use_default_names = 1 | ||
else | else | ||
mode_names = tip.parse_entries(frame.args[ | mode_names = tip.parse_entries(frame.args["Mode Names"]) | ||
end | end | ||
end | end | ||