Module:MOS: Difference between revisions
as_et_string -> et_string |
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 | -- 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. | -- 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 | ||
-- 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 | -- 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 | -- (where s mod p = 0), then there will be p modes. If the mode has one step | ||
-- | -- type, then there is only one mode. | ||
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 | -- 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. | 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 | ||