Module:MOS: Difference between revisions
Reorganization; added moar functions |
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 | -- 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 ( | -- Mossteps larger than the equave (eg, the minor 9th in non-xen music theory) | ||
-- | -- 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 -------------------------------- | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- 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 -------------------------- | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
-- 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. | ||