Module:MOS: Difference between revisions
Added mode rotation functions |
m Adopt round function from utils module |
||
| Line 31: | Line 31: | ||
------------------------------- HELPER FUNCTIONS ------------------------------- | ------------------------------- HELPER FUNCTIONS ------------------------------- | ||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||
function p.find_item_in_table(table, item) | function p.find_item_in_table(table, item) | ||
| Line 136: | Line 131: | ||
local d = utils._gcd(nL, ns) | local d = utils._gcd(nL, ns) | ||
if d > 1 then -- use single period mos, with period as new equave | if d > 1 then -- use single period mos, with period as new equave | ||
nL = | nL = utils._round_dec(nL/d) | ||
ns = | ns = utils._round_dec(ns/d) | ||
end | end | ||
local current_L, current_s = 0, 0 | local current_L, current_s = 0, 0 | ||
| Line 160: | Line 155: | ||
local d = utils._gcd(nL, ns) | local d = utils._gcd(nL, ns) | ||
if d > 1 then -- use single period mos, with period as new equave | if d > 1 then -- use single period mos, with period as new equave | ||
nL = | nL = utils._round_dec(nL/d) | ||
ns = | ns = utils._round_dec(ns/d) | ||
end | end | ||
local current_L, current_s = 0, 0 | local current_L, current_s = 0, 0 | ||
| Line 258: | Line 253: | ||
local d = utils._gcd(nL, ns) | local d = utils._gcd(nL, ns) | ||
if d > 1 then -- use single period mos, with period as new equave | if d > 1 then -- use single period mos, with period as new equave | ||
nL = | nL = utils._round_dec(nL/d) | ||
ns = | ns = utils._round_dec(ns/d) | ||
end | end | ||
local min_dist = 2; -- the distance we get will always be <= sqrt(2) | local min_dist = 2; -- the distance we get will always be <= sqrt(2) | ||
| Line 671: | Line 666: | ||
--return p.mode_from_mos(p.new(5,2), -90673) | --return p.mode_from_mos(p.new(5,2), -90673) | ||
--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)) | |||
end | end | ||
return p | return p | ||