「モジュール:MOS」の版間の差分

Furcht968 (トーク | 投稿記録)
編集の要約なし
Furcht968 (トーク | 投稿記録)
編集の要約なし
733行目: 733行目:
------------------------ EQUAL-TUNING STRING FUNCTIONS -------------------------
------------------------ EQUAL-TUNING STRING FUNCTIONS -------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
-- Given a mos and step ratio, return its equal temperament as a string "{steps}\{division}{suffix}".
function p.et_string(mos, step_ratio, suffix)
local suffix = suffix or nil
local et_mos = p.as_et(mos, step_ratio, suffix)
return et.as_string(et_mos)
end


-- Given a mos, return its equal temperament suffix as a string (edo, edt, edf, or ed-p/q).
-- Given a mos, return its equal temperament suffix as a string (edo, edt, edf, or ed-p/q).
754行目: 747行目:
end
end


-- Given a mos and step ratio, return its equal temperament as a string "{steps}\{division}{suffix}".
function p.et_string(mos, step_ratio, suffix)
local suffix = suffix or nil
local et_mos = p.as_et(mos, step_ratio, suffix)
return et.as_string(et_mos)
end
-- Given a mos and step ratio, compute the number of et-steps for its bright gen
-- as a string "{steps}\{division}{suffix}".
function p.bright_gen_to_et_string(mos, step_ratio, suffix)
return p.interval_to_et_string(p.bright_gen(mos), mos, step_ratio, suffix)
end


-- Given a mos and a step ratio, return the number of et-steps for its bright
-- Given a mos and step ratio, compute the number of et-steps for its dark gen,
-- generator.
-- as a string "{steps}\{division}{suffix}".
function p.bright_gen_to_et_steps(mos, step_ratio)
function p.dark_gen_to_et_string(mos, step_ratio, suffix)
return p.interval_to_et_steps(p.bright_gen(mos), step_ratio)
return p.interval_to_et_string(p.dark_gen(mos), mos, step_ratio, suffix)
end
end


-- Given a mos and a step ratio, return the number of et-steps for its dark generator.
-- Given a mos and step ratio, compute the number of et-steps for its period,
function p.dark_gen_to_et_steps(mos, step_ratio)
-- as a string "{steps}\{division}{suffix}".
return p.interval_to_et_steps(p.dark_gen(mos), step_ratio)
function p.period_to_et_string(mos, step_ratio, suffix)
return p.interval_to_et_string(p.period(mos), mos, step_ratio, suffix)
end
end


-- Given a mos and a step ratio, return the number of et-steps for its period.
-- Given a mos, compute the number of et-steps for its period, reduced,
function p.period_to_et_steps(mos, step_ratio)
-- as a string "{steps}\{division}{suffix}". Does not reuqire a step ratio.
return p.interval_to_et_steps(p.period(mos), step_ratio)
-- NOTE: no such function for returning only the number of steps is needed since
-- that's the same as period_count().
function p.reduced_period_to_et_string(mos, suffix)
return p.interval_to_et_string({["L"] = 1, ["s"] = 1}, p.root(mos), {1,0}, suffix)
end
end


-- Given a mos and a step ratio, return the number of et-steps for its equave.
-- Given a mos and step ratio, compute the number of et-steps for its equave,
function p.equave_to_et_steps(mos, step_ratio)
-- as a string "{steps}\{division}{suffix}".
return p.interval_to_et_steps(p.equave(mos), step_ratio)
function p.equave_to_et_string(mos, step_ratio, suffix)
return p.interval_to_et_string(p.equave(mos), mos, step_ratio, suffix)
end
end


-- Given an interval vector and step ratio, compute the number of et-steps it corresponds to.
-- Given an interval vector and step ratio, compute the number of et-steps it
function p.interval_to_et_steps(interval, step_ratio)
-- corresponds to, as a string "{steps}\{division}{suffix}". Requires info
return interval["L"] * step_ratio[1] + interval["s"] * step_ratio[2]
-- about the mos itself.
function p.interval_to_et_string(interval, mos, step_ratio, suffix)
local suffix = suffix or nil
local mos_et = p.as_et(mos, step_ratio, suffix)
return et.backslash_display(mos_et, p.interval_to_et_steps(interval, step_ratio))
end
end