Module:MOS: Difference between revisions

Ganaram inukshuk (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
Removed ancestor function as it's now in the tamnams module
Line 668: Line 668:
local equave_steps = p.equave_to_et_steps(mos, step_ratio)
local equave_steps = p.equave_to_et_steps(mos, step_ratio)
return interval_steps * rat.cents(mos.equave) / equave_steps
return interval_steps * rat.cents(mos.equave) / equave_steps
end
--------------------------------------------------------------------------------
------------ UNUSED FUNCTIONS OR FUNCTIONS TO MOVE TO OTHER MODULES ------------
--------------------------------------------------------------------------------
-- Given a mos, find the ancestor mos with a target note count (default 10)
-- or less; to be moved to tamnams module
-- Module:Infobox MOS is the only module that uses this function.
function p.find_ancestor(mos, target_note_count)
local mos = mos or p.new(5, 2)
local target_note_count = target_note_count or 10
local z = mos.nL
local w = mos.ns
while (z ~= w) and (z + w > target_note_count) do
local m1 = math.max(z, w)
local m2 = math.min(z, w)
-- For use with updating ancestor mos chunks
local z_prev = z
-- Update step ratios
z = m2
w = m1 - m2
end
return p.new(z, w, mos.equave)
end
end