Module:MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
as_et_string -> et_string
Ganaram inukshuk (talk | contribs)
mode_from_mos -> mode_by_brightness
Line 284: Line 284:


-- Given a mos, return a mode based on how it's ranked by modal brightness.
-- Given a mos, return a mode based on how it's ranked by modal brightness.
-- Ordering here is based on the number of bright gens going DOWN PER PERIOD:
-- Ordering here is based on the number of BRIGHT GENS DOWN PER PERIOD:
-- 0 is the brightest mode, 1 is 2nd brightest, etc...
-- 0 is the brightest mode, 1 is 2nd brightest, etc...
function p.mode_from_mos(mos, bright_gens_down)
-- To go by darkness, pass in p-d-1 for the 2nd arg, where p is the period count
-- and d is the number of DARK GENS UP PER PERIOD.
function p.mode_by_brightness(mos, bright_gens_down)
return p.rotate_mode(p.brightest_mode(mos), bright_gens_down * p.bright_gen_step_count(mos))
return p.rotate_mode(p.brightest_mode(mos), bright_gens_down * p.bright_gen_step_count(mos))
end
end
--------------------------------------------------------------------------------
--------------------------- MODE ROTATION FUNCTIONS ----------------------------
--------------------------------------------------------------------------------


-- Given a mos, list all modes in descending order of brightness.
-- Given a mos, list all modes in descending order of brightness.
Line 309: Line 307:
end
end


-- List all unique rotations for a mode. Order of modes is by rotation.
-- List all unique rotations for a mode, by order of leftward shifts.
-- Note: there will always be s/p modes, where s is the number of steps in the
-- Note: there will always be s/p modes, where s is the number of steps in the
-- entered mode, and p is the period of repetition. At most, there will be s
-- entered mode, and p is the period of repetition. At most, there will be s
-- modes, but if there is a substring of length p that repeats within the mode
-- modes, but if there is a substring of length p that repeats within the mode
-- (where p divides s with remainder = 0), then there will be p modes. It's also
-- (where s mod p = 0), then there will be p modes. If the mode has one step
-- possible to have only one mode, but this can only happen if there is only one
-- type, then there is only one mode.
-- step size, meaning it's a unary scale (only one step size).
function p.mode_rotations(mode_string)
function p.mode_rotations(mode_string)
local rotations = {}
local rotations = {}
Line 329: Line 326:


-- Rotate a mode by shifting the step sequence to the left. Negative values
-- Rotate a mode by shifting the step sequence to the left. Negative values
-- shift it to the right. Helper function for mode_from_mos().
-- shift it to the right. Helper function for mode_by_brightness().
function p.rotate_mode(mode_string, shift_amt)
function p.rotate_mode(mode_string, shift_amt)
local shift_amt = shift_amt == nil and 1 or shift_amt % #mode_string -- Default is 1
local shift_amt = shift_amt == nil and 1 or shift_amt % #mode_string -- Default is 1
Line 341: Line 338:
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


-- TODO?: renamed to mode_as_step_matrix
-- Convert a single mode (as a string) into a step matrix. This is a listing of
-- Convert a single mode (as a string) into a step matrix. This is a listing of
-- every interval's step vector in the mode.
-- every interval's step vector in the mode.
Line 351: Line 349:
return matrix
return matrix
end
end
-- TODO?: replaces mode_to_step_matrices/mode_rotations_to_step_matrices with
-- one function called modes_as_step_matrices? Encompasses functionality of both
-- functions, but step patterns for either are generated into the same function.


-- Given a mos, produce every step matrix for every mode. Modes are listed in
-- Given a mos, produce every step matrix for every mode. Modes are listed in
Line 870: Line 874:
--return p.as_et(p.new(5,2), {2,1})
--return p.as_et(p.new(5,2), {2,1})
return p.as_string(p.new(5,2)) .. "\n" .. p.as_link(p.new(5,2,3)) .. "\n" .. p.as_long_link(p.new(5,2)) .. "\n" .. p.as_long_link(p.new(5,2,3)) .. "\n" .. p.as_link(p.new(5,0)) .. "\n" .. p.as_link(p.new(5,0,3)) .. "\n" .. p.as_long_link(p.new(5,0)) .. "\n" .. p.as_long_link(p.new(5,0,3))
return  
p.mode_by_brightness(p.new(5,2), 0) .. " " .. p.mode_by_brightness(p.new(5,2), 6-6) .. "\n" ..
p.mode_by_brightness(p.new(5,2), 1) .. " " .. p.mode_by_brightness(p.new(5,2), 6-5) .. "\n" ..
p.mode_by_brightness(p.new(5,2), 2) .. " " .. p.mode_by_brightness(p.new(5,2), 6-4) .. "\n" ..
p.mode_by_brightness(p.new(5,2), 3) .. " " .. p.mode_by_brightness(p.new(5,2), 6-3) .. "\n" ..
p.mode_by_brightness(p.new(5,2), 4) .. " " .. p.mode_by_brightness(p.new(5,2), 6-2) .. "\n" ..
p.mode_by_brightness(p.new(5,2), 5) .. " " .. p.mode_by_brightness(p.new(5,2), 6-1) .. "\n" ..
p.mode_by_brightness(p.new(5,2), 6) .. " " .. p.mode_by_brightness(p.new(5,2), 6-0)
end
end


return p
return p