Module:MOS mode degrees: Difference between revisions
m Adopt new tamnams functions |
Adopted tamnams helper functions for modmos function |
||
| Line 640: | Line 640: | ||
local step_patterns = mos.mode_rotations(step_pattern) | local step_patterns = mos.mode_rotations(step_pattern) | ||
local step_matrices = mos.mode_rotations_to_step_matrices(step_pattern) | local step_matrices = mos.mode_rotations_to_step_matrices(step_pattern) | ||
-- Get the scale sig | -- Get the scale sig | ||
local scale_sig = mos.as_string(input_mos) | local scale_sig = mos.as_string(input_mos) | ||
-- Get | -- Get the UDPs (with alterations) | ||
local | local udps = tamnams.mode_rotation_udps(step_pattern, input_mos) | ||
-- | -- Equave step count; needed for degree column count | ||
local equave_step_count = mos.equave_step_count(input_mos) | |||
local | |||
-- Create table | -- Create table | ||
| Line 675: | Line 663: | ||
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 .. "!! rowspan=\"2\" class=\"unsortable\" | Mode names" | result = result .. " !! rowspan=\"2\" class=\"unsortable\" | Mode names" | ||
end | end | ||
-- Add header for scale degrees | -- Add header for scale degrees | ||
result = result .. string.format(" !! colspan=\"%d\" class=\"unsortable\" | Scale degree (%sdegree)", equave_step_count + 1, mos_prefix) | result = result .. string.format(" !! colspan=\"%d\" class=\"unsortable\" | Scale degree (%sdegree)\n", equave_step_count + 1, mos_prefix) | ||
-- Add second row of headers | -- Add second row of headers | ||
result = result .. "|-\n" | result = result .. "|- class=\"unsortable\"\n" | ||
.. "! | .. "! 0" | ||
for i = 1, equave_step_count do | for i = 1, equave_step_count do | ||
result = result .. string.format(" !! | result = result .. string.format(" !! %d", i) | ||
end | end | ||
| Line 696: | Line 683: | ||
-- 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", | .. string.format("| %s || %s || %s", udps[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(" || %s %s", scale_sig, | result = result .. string.format(" || %s %s", scale_sig, udps[i]) | ||
else | else | ||
result = result .. string.format(" || %s", mode_names[i]) | result = result .. string.format(" || %s", mode_names[i]) | ||
| Line 708: | Line 695: | ||
-- Add scale degrees with cell coloring | -- Add scale degrees with cell coloring | ||
for j = 1, #step_matrices[i] do | for j = 1, #step_matrices[i] do | ||
local current_interval = step_matrices[i][j] | |||
local degree_quality = tamnams.decode_quality(current_interval, input_mos, "shortened") | |||
local cell_color = p.cell_color(current_interval, input_mos) | |||
local style_code = cell_color == p.cell_color_none and "" or string.format("style=\"background: %s;\" | ", cell_color) | |||
result = result .. string.format(" || %s%s", style_code, degree_quality) | |||
end | end | ||
result = result .. "\n" | result = result .. "\n" | ||
end | end | ||
| Line 724: | Line 709: | ||
-- End of table | -- End of table | ||
result = result .. "|}" | result = result .. "|}" | ||
return result | return result | ||
end | end | ||