Module:MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Adopt round function from utils module
Ganaram inukshuk (talk | contribs)
Bugfixes; added functions to produce step matrices (listings of every mode's listings of interval vectors)
Line 228: Line 228:
end
end


-- Convert a mode (as a string of steps) into a step matrix. This is a listing
--------------------------------------------------------------------------------
-- of every interval's step vector in the mode.
---------------------------- STEP MATRIX FUNCTIONS -----------------------------
--------------------------------------------------------------------------------
 
-- Convert a single mode (as a string) into a step matrix. This is a listing of
-- every interval's step vector in the mode.
function p.mode_to_step_matrix(mode_string)
function p.mode_to_step_matrix(mode_string)
local matrix = {}
local matrix = {}
Line 238: Line 242:
end
end
return matrix
return matrix
end
-- Given a mos, produce every step matrix for every mode. Modes are listed in
-- order of brightness.
function p.modes_to_step_matrices(mos)
local modes = p.modes_by_brightness(mos)
local matrices = {}
for i = 1, #modes do
table.insert(matrices, p.mode_to_step_matrix(modes[i]))
end
return matrices
end
-- Given a single mode (as a string), produce the step matrices for each
-- rotation of that mode. Modes are listed in order of rotation.
function p.mode_rotations_to_step_matrices(mode_string)
local modes = p.mode_rotations(mode_string)
local matrices = {}
for i = 1, #modes do
table.insert(matrices, p.mode_to_step_matrix(modes[i]))
end
return matrices
end
end


Line 667: Line 693:
--return p.mode_to_step_matrix(p.brightest_mode(p.new(5,4)))
--return p.mode_to_step_matrix(p.brightest_mode(p.new(5,4)))
--return p.mode_rotations("LssLLssL")
--return p.mode_rotations("LssLLssL")
return p.brightest_mode(p.new(5,2))
return p.mode_rotations_to_step_matrices("LLsLsAs")
end
end


return p
return p