Module:MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
Reorganization; added moar functions
Ganaram inukshuk (talk | contribs)
Comments
Line 12: Line 12:
local et = require('Module:ET') -- Used for unused function
local et = require('Module:ET') -- Used for unused function
local p = {}
local p = {}
-- Naming scheme for function names:
-- - Functions related to mosses don't have any special names.
-- - Functions related to a mos's modes generally end with "mode".
-- - Functions related to a mos's generators, equave, or period contain the
--  corresponding interval as part of its name.
-- - Functions related to intervals generally begin with "interval".
-- - Interval complement/reduce functions end with "complement" and "reduce".
-- - Functions that produce strings generally have the phrase "as string".
-- - Functions that "count" something generally end with "count".
-- - If a function requires an interval and mos as input, the interval(s) come
--  after the mos.


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
Line 72: Line 84:


-- Given an interval as a vector of L's and s's, produce a string "iL + js",
-- Given an interval as a vector of L's and s's, produce a string "iL + js",
-- where i and j are the qualtities for L and s.
-- where i and j are the quantities for L and s.
function p.interval_as_string(interval)
function p.interval_as_string(interval)
local L_string = ""
local L_string = ""
Line 102: Line 114:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


-- Find the brightest true-mos mode of a mos.
-- Find the brightest (true-mos) mode of a mos.
-- Calculation is based on the definition of a Christoffel word, as the closest
-- Calculation is based on the definition of a Christoffel word, as the closest
-- integer approximation to line y = #s/#L*x.
-- integer approximation to line y = #s/#L*x.
Line 226: Line 238:
-- The step_count param is the number of mossteps in the interval. EG, in 5L 2s,
-- The step_count param is the number of mossteps in the interval. EG, in 5L 2s,
-- the large 2-mosstep is "LL", so the corresponding vector has L=2, s=0.
-- the large 2-mosstep is "LL", so the corresponding vector has L=2, s=0.
-- Mossteps larger than the equave (analogous to the minor 9th in standard
-- Mossteps larger than the equave (eg, the minor 9th in non-xen music theory)
-- notation) are allowed.
-- are allowed.
-- The size param is a value that denotes whether the interval is the large size
-- The size param is a value that denotes whether the interval is the large size
-- (0) or the small size (-1). This can exceed the range of [-1, 0] to represent
-- (0) or the small size (-1). This can exceed the range of [-1, 0] to represent
Line 284: Line 296:
------------------------------- COUNT FUNCTIONS --------------------------------
------------------------------- COUNT FUNCTIONS --------------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Rule for input order: if an interval-related function requires a mos as part
-- of its input, it should come after the interval vectors.


-- Given a mos, compute the number of steps in its bright gen (L's plus s's).
-- Given a mos, compute the number of steps in its bright gen (L's plus s's).
Line 333: Line 343:
----------------------- INTERVAL ARITHMETIC FUNCTIONS --------------------------
----------------------- INTERVAL ARITHMETIC FUNCTIONS --------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Note: interval arithmetic includes stacking and reducing intervals.
-- Size comparisons between intervals can't be done using abstract steps, unless
-- the intervals are the same number of mossteps (EG, a large k-step is larger
-- than a small k-step, an augmented k-step is larger than a large k-step).
-- Rule for input order for count functions applies here.


-- Add two intervals together by adding their respective vectors.
-- Add two intervals together by adding their respective vectors.
Line 365: Line 370:
return interval_vector
return interval_vector
end
end
--------------------------------------------------------------------------------
---------------------- COMPLEMENT AND REDUCE FUNCTIONS -------------------------
--------------------------------------------------------------------------------


-- Given an interval vector and a mos, find its period complement.
-- Given an interval vector and a mos, find its period complement.