Module:TAMNAMS: Difference between revisions

Undo revision 179333 by ArrowHead294 (talk). Broken
Tag: Undo
ArrowHead294 (talk | contribs)
mNo edit summary
 
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
-- Module for TAMNAMS-related things as it pertains to mosses
local p = {}
-- This module is meant to be used with other modules, not as part of a template
 
local mos = require("Module:MOS")
local mos = require("Module:MOS")
local rat = require("Module:Rational")
local rat = require("Module:Rational")
local p = {}


-- This module should reflect current TAMNAMS standards:
-- TODO
-- - Names for step ratios and ranges (soft, hard, etc)
--Function to parse a UDP and (possibly) scale degrees.
-- - Extended step ratio ranges
--Separate interval/degree lookup into separate functions for for abbrevs and non-abbrev formats.
-- - Naming for intervals and scale degrees (M2ms and M2md)
--Added arbitrary hardness lookup for a single ratio (e.g., passing in 13:8 would return "quasisoft".
-- - Naming for modes (basically UDP)
-- - Naming for select scales


-- TODO?
-- - Function to parse a UDP and (possibly) scale degrees.
-- - Separate interval/degree lookup into separate functions for for abbrevs and
--  non-abbrev formats.
-- - Added arbitrary hardness lookup for a single ratio (EG, passing in 13:8
--  would return "quasisoft".


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 137: Line 128:
["1L 1s"] = "monwd",
["1L 1s"] = "monwd",
["2L 2s"] = "biwd",
["2L 2s"] = "biwd",
["2L 3s"] = "pent",
["1L 5s"] = "amech",
["1L 5s"] = "amech",
["2L 4s"] = "mal",
["2L 4s"] = "mal",
Line 274: Line 266:
-- Mosses for name lookup are entered either as a scalesig or as a mos as
-- Mosses for name lookup are entered either as a scalesig or as a mos as
-- defined in the mos module. If of the latter, it's converted into a textual
-- defined in the mos module. If of the latter, it's converted into a textual
-- scalesig.
-- scalesig. Scalesigs should have a normal space, not a nonbreaking space, as
-- the lookup tables use a normal space.
function p.preprocess_scalesig(input_mos)
function p.preprocess_scalesig(input_mos)
if type(input_mos) == "string" then
if type(input_mos) == "string" then
return input_mos
local parsed_mos = mos.parse(input_mos)
return mos.as_string(parsed_mos, false)
elseif type(input_mos) == "table" then
elseif type(input_mos) == "table" then
return mos.as_string(input_mos)
return mos.as_string(input_mos, false)
else
else
return nil
return nil
Line 822: Line 816:
if alterations ~= nil then
if alterations ~= nil then
for i = 1, #alterations do
for i = 1, #alterations do
alterations_as_string = alterations_as_string .. " " .. alterations[i]
alterations_as_string = alterations_as_string .. " " .. alterations[i]
end
end
end
end
if periods == 1 then
 
return string.format("%s|%s", gens_up_per_period, gens_down_per_period) .. alterations_as_string
return (periods == 1
else
and string.format("%s{{pipe}}%s", gens_up_per_period, gens_down_per_period)
return string.format("%s|%s(%s)", gens_up_per_period * periods, gens_down_per_period * periods, periods) .. alterations_as_string
or string.format("%s{{pipe}}%s(%s)", gens_up_per_period * periods, gens_down_per_period * periods, periods))
end
.. alterations_as_string
end
end


Line 963: Line 957:
-- vectors (a table containing the number of L's and s's for that interval).
-- vectors (a table containing the number of L's and s's for that interval).
function p.differences_between_modes(base_step_matrix, altered_step_matrix)
function p.differences_between_modes(base_step_matrix, altered_step_matrix)
local differences = {}
local differences = {}
for i = 1, #altered_step_matrix do
for i = 1, #altered_step_matrix do
Line 1,001: Line 994:


function p.tester()
function p.tester()
return ""
local input_mos = mos.new(5, 2)
.. p.find_step_ratio_range_for_ratio_pair({1,1},{2,1}) .. "\n"
return p.preprocess_scalesig(input_mos)
.. p.find_step_ratio_range_for_ratio_pair({1,1},{3,2}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({1,1},{4,3}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({4,3},{3,2}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({3,2},{2,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({3,2},{5,3}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({5,3},{2,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({2,1},{5,2}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({5,2},{3,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({2,1},{3,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({3,1},{4,1}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({4,1},{1,0}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({3,1},{1,0}) .. "\n"
.. p.find_step_ratio_range_for_ratio_pair({2,1},{1,0}) .. "\n"
end
end


return p
return p