Module:MOS mode degrees: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Adopt new tamnams functions
Ganaram inukshuk (talk | contribs)
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 step matrices for the true modes
local true_step_matrices = mos.modes_to_step_matrices(input_mos)
-- Get the number of mossteps per equave
local equave_step_count = mos.equave_step_count(input_mos)
-- 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 rotational orderings; modmossses shouldn't be ordered by brightness
-- Get the UDPs (with alterations)
local rotational_order = p.calculate_mos_mode_rotational_order(input_mos)
local udps = tamnams.mode_rotation_udps(step_pattern, input_mos)
-- Get closest mode and alterations
-- Equave step count; needed for degree column count
local alterations = p.calculate_modmos_mode_alterations(input_mos, step_pattern)
local equave_step_count = mos.equave_step_count(input_mos)
-- Get mosstep vectors for all modes
local step_matrices = p.calculate_mos_mode_degrees(input_mos, step_patterns)
-- Get row colors
local row_colors = p.calculate_row_colors(input_mos, step_matrices)
-- 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)
.. "\n"
-- Add second row of headers; these are for the scale degrees
-- Add second row of headers
result = result .. "|-\n"
result = result .. "|- class=\"unsortable\"\n"
.. "! class=\"unsortable\" | 0"
.. "! 0"
for i = 1, equave_step_count do
for i = 1, equave_step_count do
result = result .. string.format(" !! class=\"unsortable\" | %d", i)
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", alterations[i], i, step_patterns[i])
.. 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, alterations[i])
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
-- This includes period intervals bold and alterations italicized
for j = 1, #step_matrices[i] do
for j = 1, #step_matrices[i] do
if row_colors[i][j] == p.cell_color_none then
local current_interval = step_matrices[i][j]
result = result .. string.format(" || %s", p.decode_quality(step_matrices[i][j]))
local degree_quality = tamnams.decode_quality(current_interval, input_mos, "shortened")
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(" || style=\"background: %s;\" | ''%s''", row_colors[i][j], p.decode_quality(step_matrices[i][j]))
local cell_color = p.cell_color(current_interval, input_mos)
else
local style_code = cell_color == p.cell_color_none and "" or string.format("style=\"background: %s;\" | ", cell_color)
result = result .. string.format(" || style=\"background: %s;\" | %s", row_colors[i][j], p.decode_quality(step_matrices[i][j]))
end
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