Module:MOS mode degrees: Difference between revisions
m Update todo |
Adopt functions provided by other templates; begin work on rewriting modmos function |
||
| Line 4: | Line 4: | ||
local mosnot = require('Module:MOS notation') | local mosnot = require('Module:MOS notation') | ||
local et = require('Module:ET') | local et = require('Module:ET') | ||
local tip = require('Module:Template input parse') | |||
local tamnams = require('Module:TAMNAMS') | local tamnams = require('Module:TAMNAMS') | ||
local p = {} | local p = {} | ||
| Line 19: | Line 20: | ||
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 590: | Line 578: | ||
local use_default_mode_names = use_default_mode_names == 1 | local use_default_mode_names = use_default_mode_names == 1 | ||
-- Get the modes as strings | -- Get the modes as strings and step vectors | ||
local step_patterns = mos.modes_by_brightness(input_mos) | local step_patterns = mos.modes_by_brightness(input_mos) | ||
local step_matrices = mos.modes_to_step_matrices(input_mos) | |||
-- Get the scale sig | -- Get the scale sig | ||
| Line 599: | Line 588: | ||
local brightness_order = p.calculate_mos_mode_brightness_order(input_mos) | local brightness_order = p.calculate_mos_mode_brightness_order(input_mos) | ||
local rotational_order = p.calculate_mos_mode_rotational_order(input_mos) | local rotational_order = p.calculate_mos_mode_rotational_order(input_mos) | ||
-- Equave step count | -- Equave step count; needed for degree column count | ||
local equave_step_count = mos.equave_step_count(input_mos) | local equave_step_count = mos.equave_step_count(input_mos) | ||
| Line 655: | Line 641: | ||
result = result .. string.format('| %s%s\n', style_code, degree_quality) | result = result .. string.format('| %s%s\n', style_code, degree_quality) | ||
end | end | ||
end | end | ||
| Line 683: | Line 658: | ||
local use_default_mode_names = use_default_mode_names == 1 | local use_default_mode_names = use_default_mode_names == 1 | ||
-- Get the modes | -- Get the modes and step matrices for the modmos | ||
local | local step_patterns = mos.mode_rotations(step_pattern) | ||
local step_matrices = mos.mode_rotations_to_step_matrices(step_pattern) | |||
-- Get the | -- Get the step matrices for the true modes | ||
local | local true_step_matrices = mos.modes_to_step_matrices(input_mos) | ||
local | |||
-- 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 | ||
| Line 701: | Line 678: | ||
-- Get mosstep vectors for all modes | -- Get mosstep vectors for all modes | ||
local | local step_matrices = p.calculate_mos_mode_degrees(input_mos, step_patterns) | ||
-- Get row colors | -- Get row colors | ||
local row_colors = p.calculate_row_colors(input_mos, | local row_colors = p.calculate_row_colors(input_mos, step_matrices) | ||
-- Create table | -- Create table | ||
| Line 716: | Line 693: | ||
-- Add mode names if present | -- Add mode names if present | ||
local mode_names_given = (mode_names ~= nil and #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\n' | result = result .. '! rowspan="2" class="unsortable" | Mode names\n' | ||
| Line 722: | Line 699: | ||
-- Add header for scale degrees | -- Add header for scale degrees | ||
result = result .. string.format('! colspan="%d" class="unsortable" | Scale degree (%sdegree)\n', | 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; these are for the scale degrees | ||
result = result .. "|-\n" | result = result .. "|-\n" | ||
for i = 1, | for i = 1, equave_step_count + 1 do | ||
result = result .. string.format('! class="unsortable" |%d\n', i-1) | result = result .. string.format('! class="unsortable" |%d\n', i-1) | ||
end | end | ||
-- Add table contents | -- Add table contents | ||
for i = 1, # | for i = 1, #step_patterns do | ||
result = result .. "|-\n" | result = result .. "|-\n" | ||
-- Add brightness order (as UDP), rotational order, and step pattern | -- Add brightness order (as UDP), rotational order, and step pattern | ||
result = result .. string.format('| %s\n| %s\n| %s\n', alterations[i], i, | result = result .. string.format('| %s\n| %s\n| %s\n', alterations[i], i, step_patterns[i]) | ||
-- Add mode name if given | -- Add mode name if given | ||
| Line 748: | Line 725: | ||
-- Add scale degrees with cell coloring | -- Add scale degrees with cell coloring | ||
-- This includes period intervals bold and alterations italicized | -- This includes period intervals bold and alterations italicized | ||
for j = 1, # | 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('| %s\n', p.decode_quality( | result = result .. string.format('| %s\n', 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('| style="background: #%s" | \'\'%s\'\'\n', row_colors[i][j], p.decode_quality( | result = result .. string.format('| style="background: #%s" | \'\'%s\'\'\n', row_colors[i][j], p.decode_quality(step_matrices[i][j])) | ||
else | else | ||
result = result .. string.format('| style="background: #%s" | %s\n', row_colors[i][j], p.decode_quality( | result = result .. string.format('| style="background: #%s" | %s\n', row_colors[i][j], p.decode_quality(step_matrices[i][j])) | ||
end | end | ||
end | end | ||
| Line 811: | Line 788: | ||
use_default_names = 1 | use_default_names = 1 | ||
else | else | ||
mode_names = | mode_names = tip.parse_entries(frame.args['Mode Names']) | ||
end | end | ||
end | end | ||