Module:Infobox MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Updated todo
Ganaram inukshuk (talk | contribs)
Switched to build-multilink function
Line 25: Line 25:
['t'] = 3,
['t'] = 3,
}
}
-- Helper function
-- Concatenates the contents of two tables into one
-- This doesn't have a return value; rather, the first table passed has the
-- second table's contents added to it.
function p.concatenate_tables(t1, t2)
for i=1, #t2 do
t1[#t1+1] = t2[i]
end
end


-- Helper function
-- Helper function
Line 107: Line 117:
-- Helper function
-- Helper function
-- Produces section entries for scale sturcture
-- Produces section entries for scale sturcture
-- Section is returned as a jagged array and return value must be merged into
-- a larger array.
function p.scale_structure(input_mos)
function p.scale_structure(input_mos)
local input_mos = input_mos or mos.new(5, 5, 3)
local input_mos = input_mos or mos.new(5, 5, 3)
Line 131: Line 143:
local section_header = "Scale structure"
local section_header = "Scale structure"
return { section_header, section_entries }
local section = {{section_header}}
p.concatenate_tables(section, section_entries)
return section
end
end


-- Helper function
-- Helper function
-- Produces generator ranges for scale
-- Produces generator ranges for scale
-- Section is returned as a jagged array and return value must be merged into
-- a larger array.
function p.generator_sizes(input_mos)
function p.generator_sizes(input_mos)
local input_mos = input_mos or mos.new(5, 2)
local input_mos = input_mos or mos.new(5, 2)
Line 174: Line 190:
}
}
return { section_header, section_entries }
local section = {{section_header}}
p.concatenate_tables(section, section_entries)
return section
end
end


-- Helper function
-- Helper function
-- Produces ranges small and large steps
-- Produces ranges small and large steps
-- Section is returned as a jagged array and return value must be merged into
-- a larger array.
function p.step_sizes(input_mos)
function p.step_sizes(input_mos)
local input_mos = input_mos or mos.new(5, 2)
local input_mos = input_mos or mos.new(5, 2)
Line 212: Line 232:
}
}
return { section_header, section_entries }
local section = {{section_header}}
p.concatenate_tables(section, section_entries)
return section
end
end


Line 269: Line 291:
-- - Scales with a notecount greater than 10 and more than 5 periods don't have
-- - Scales with a notecount greater than 10 and more than 5 periods don't have
--  a tamnams-named ancestor, but will report what nL ns mos they descend from.
--  a tamnams-named ancestor, but will report what nL ns mos they descend from.
-- Section is returned as a jagged array and return value must be merged into
-- a larger array.
function p.tamnams_information(input_mos)
function p.tamnams_information(input_mos)
local input_mos = input_mos or mos.new(7, 7)
local input_mos = input_mos or mos.new(5, 2)
local scalesig = string.format("%dL %ds", input_mos.nL, input_mos.ns)
local scalesig = string.format("%dL %ds", input_mos.nL, input_mos.ns)
Line 313: Line 337:
if section_entries ~= nil then
if section_entries ~= nil then
return { section_header, section_entries }
local section = {{section_header}}
p.concatenate_tables(section, section_entries)
return section
else
else
return nil
return nil
Line 321: Line 347:
-- Helper function
-- Helper function
-- Produces section for related scales
-- Produces section for related scales
-- Section is returned as a jagged array and return value must be merged into
-- a larger array.
function p.related_scales(input_mos)
function p.related_scales(input_mos)
local input_mos = input_mos or mos.new(5, 2)
local input_mos = input_mos or mos.new(5, 2)
Line 349: Line 377:
local section_header = "Related scales"
local section_header = "Related scales"
return { section_header, section_entries }
local section = {{section_header}}
p.concatenate_tables(section, section_entries)
return section
end
end


Line 419: Line 449:
end
end
return { section_header, section_entries }
local section = {{section_header}}
p.concatenate_tables(section, section_entries)
return section
end
end


Line 431: Line 463:
-- Scale structure section
-- Scale structure section
local scale_structure = p.scale_structure(tuning_parsed)
local scale_structure = p.scale_structure(tuning_parsed)
table.insert(sections, scale_structure)
p.concatenate_tables(sections, scale_structure)
-- Interval range section
-- Interval range section
local step_sizes = p.step_sizes(tuning_parsed)
local step_sizes = p.step_sizes(tuning_parsed)
table.insert(sections, step_sizes)
p.concatenate_tables(sections, step_sizes)
-- Generator sizes
-- Generator sizes
local gen_sizes = p.generator_sizes(tuning_parsed)
local gen_sizes = p.generator_sizes(tuning_parsed)
table.insert(sections, gen_sizes)
p.concatenate_tables(sections, gen_sizes)
-- Tamnams info section, if applicable
-- Tamnams info section, if applicable
local tamnams_info = p.tamnams_information(tuning_parsed)
local tamnams_info = p.tamnams_information(tuning_parsed)
if tamnams_info ~= nil then
if tamnams_info ~= nil then
table.insert(sections, tamnams_info)
p.concatenate_tables(sections, tamnams_info)
end
end
-- Related scales section
-- Related scales section
local related_scales = p.related_scales(tuning_parsed)
local related_scales = p.related_scales(tuning_parsed)
table.insert(sections, related_scales)
p.concatenate_tables(sections, related_scales)
-- Equal tunings section
-- Equal tunings section
local equal_tunings = p.equal_tunings(tuning_parsed)
local equal_tunings = p.equal_tunings(tuning_parsed)
table.insert(sections, equal_tunings)
p.concatenate_tables(sections, equal_tunings)


-- Adjacent links
local adjacent_links = p.adjacent_links(tuning_parsed)
local adjacent_links = p.adjacent_links(tuning_parsed)
return infobox.build_multisection(tuning, sections, adjacent_links)
return infobox.build_multilink(tuning, sections, adjacent_links)
--return sections
end
end


Line 508: Line 542:
}
}
return infobox.build("5L 2s (2/1-equivalent)", entries, prev_link, next_link)
return infobox.build_multilink("5L 2s (2/1-equivalent)", entries)
end
end


return p
return p