Module:Infobox MOS: Difference between revisions
m backslash_display |
Added descendant information |
||
| Line 161: | Line 161: | ||
{"[[Dark]] (cents)", string.format("%s to %s (%.1d¢ to %.1d¢)", dark_min_in_steps, dark_max_in_steps, dark_min_in_cents, dark_max_in_cents)}, | {"[[Dark]] (cents)", string.format("%s to %s (%.1d¢ to %.1d¢)", dark_min_in_steps, dark_max_in_steps, dark_min_in_cents, dark_max_in_cents)}, | ||
} | } | ||
end | |||
-- Helper function for a helper function | |||
-- Determines what mos the given mos descends from | |||
-- as well as what step ratio that produces this scale | |||
function p.find_mos_ancestor(input_mos) | |||
local input_mos = input_mos or mos.new(7, 7) | |||
local z = input_mos.nL | |||
local w = input_mos.ns | |||
local generations = 0 | |||
-- For an ancestral mos zU wv and descendant xL ys, how many steps of size | |||
-- L and s can fit inside U and v? (basically the chunking operation) | |||
local lg_chunk = { nL = 1, ns = 0 } | |||
local sm_chunk = { nL = 0, ns = 1 } | |||
while (z ~= w) and (z + w > 10) do | |||
local m1 = math.max(z, w) | |||
local m2 = math.min(z, w) | |||
-- For use with updating ancestor mos chunks | |||
local z_prev = z | |||
-- Count how many generations | |||
generations = generations + 1 | |||
-- Update step ratios | |||
z = m2 | |||
w = m1 - m2 | |||
-- Update large chunk | |||
local prev_lg_chunk = { nL = lg_chunk.nL, ns = lg_chunk.ns } | |||
lg_chunk.nL = lg_chunk.nL + sm_chunk.nL | |||
lg_chunk.ns = lg_chunk.ns + sm_chunk.ns | |||
-- Update small chunk | |||
if z ~= z_prev then | |||
sm_chunk = prev_lg_chunk | |||
end | |||
end | |||
return mos.new(z, w, input_mos.equave), lg_chunk, sm_chunk, generations | |||
end | end | ||
-- Helper function | -- Helper function | ||
-- Produces section entries for tamnams info | -- Produces section entries for tamnams info | ||
function p.tamnams_information( | function p.tamnams_information(input_mos) | ||
local scalesig = | local input_mos = input_mos or mos.new(5, 2) | ||
local scalesig = string.format("%dL %ds", input_mos.nL, input_mos.ns) | |||
local tamnams_name = mos.tamnams_name[scalesig] or "" | local tamnams_name = mos.tamnams_name[scalesig] or "" | ||
| Line 172: | Line 216: | ||
local tamnams_abbrev = mos.tamnams_abbrev[scalesig] or "" | local tamnams_abbrev = mos.tamnams_abbrev[scalesig] or "" | ||
if | if input_mos.nL + input_mos.ns <= 10 and rat.eq(input_mos.equave, 2) then | ||
return { | return { | ||
{"[[TAMNAMS#Mos_pattern_names | Name]]", tamnams_name}, | {"[[TAMNAMS#Mos_pattern_names | Name]]", tamnams_name}, | ||
| Line 180: | Line 222: | ||
{"[[TAMNAMS#Mos_pattern_names | Abbrev.]]", tamnams_abbrev} | {"[[TAMNAMS#Mos_pattern_names | Abbrev.]]", tamnams_abbrev} | ||
} | } | ||
elseif input_mos.nL + input_mos.ns > 10 and rat.eq(input_mos.equave, 2) then | |||
local ancestor_mos, lg_chunk, sm_chunk, generations = input_mos | |||
local ancestor_scalesig = mos.as_string(ancestor_mos) | |||
local ancestor_name = mos.tamnams_name[ancestor_scalesig] | |||
return { | |||
{"Descendant of", string.format("%s (%s)", ancestor_scalesig, ancestor_name)} | |||
} | |||
else | |||
return nil | |||
end | end | ||
end | end | ||
| Line 285: | Line 337: | ||
local tamnams_info_header = "TAMNAMS information" | local tamnams_info_header = "TAMNAMS information" | ||
local tamnams_info_section = p.tamnams_information( | local tamnams_info_section = p.tamnams_information(tuning_parsed) | ||
if tamnams_info_section ~= nil then | if tamnams_info_section ~= nil then | ||
table.insert(sections, {tamnams_info_header, tamnams_info_section}) | table.insert(sections, {tamnams_info_header, tamnams_info_section}) | ||