Module:Infobox MOS: Difference between revisions
m Comments; renamed some variables for consistency |
m Comments |
||
| Line 201: | Line 201: | ||
-- Helper function | -- Helper function | ||
-- Produces section entries for tamnams info | -- Produces section entries for tamnams info | ||
-- Conditions for tamnams info inclusion: | |||
-- - Scale must be octave-equivalent; equave-agnostic names aren't supported right now | |||
-- - Scale must be within the "named range" (IE, it must appear in the mos module's tables for name, prefix, and abbrev) | |||
-- - Octave-equivalent scales with note counts greater than 10 report the closest named mos instead; for nL ns mosses with this condition, it'll say "none" instead | |||
function p.tamnams_information(input_mos) | function p.tamnams_information(input_mos) | ||
local input_mos = input_mos or mos.new(5, 2) | local input_mos = input_mos or mos.new(5, 2) | ||
| Line 209: | Line 213: | ||
local tamnams_abbrev = mos.tamnams_abbrev[scalesig] or "" | local tamnams_abbrev = mos.tamnams_abbrev[scalesig] or "" | ||
local entries_not_blank = tamnams_name ~= "" | |||
return { | local is_octave_equivalent = rat.eq(input_mos.equave, 2) | ||
if entries_not_blank and is_octave_equivalent then | |||
if input_mos.nL + input_mos.ns <= 10 then | |||
return { | |||
{"[[TAMNAMS#Mos_pattern_names | Name]]", tamnams_name}, | |||
{"[[TAMNAMS#Mos_pattern_names | Prefix]]", tamnams_prefix}, | |||
{"[[TAMNAMS#Mos_pattern_names | Abbrev.]]", tamnams_abbrev} | |||
} | |||
elseif input_mos.nL + input_mos.ns > 10 then | |||
local ancestor_mos, lg_chunk, sm_chunk, generations = p.find_mos_ancestor(input_mos) | |||
local ancestor_scalesig = mos.as_string(ancestor_mos) | |||
local ancestor_name = mos.tamnams_name[ancestor_scalesig] or "none" | |||
local ancestor_entry = "none" | |||
if ancestor_name ~= "none" and ancestor_scalesig ~= scalesig then | |||
ancestor_entry = string.format("[[%s]] (%s)", ancestor_scalesig, ancestor_name) | |||
end | |||
return { | |||
{"Descendant of", ancestor_entry} | |||
} | |||
end | end | ||
else | else | ||
return nil | return nil | ||