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

Furcht968 (トーク | 投稿記録)
編集の要約なし
Furcht968 (トーク | 投稿記録)
編集の要約なし
 
(同じ利用者による、間の4版が非表示)
270行目: 270行目:
end
end
return matrices
return matrices
end
-- Given an input mos, produce its modal union.
-- This is a listing of every interval's large and small sizes.
function p.modal_union(input_mos)
local brightest_mode = p.brightest_mode(input_mos)
local darkest_mode  = p.darkest_mode  (input_mos)
local interval_count = p.equave_step_count(input_mos) + 1
local modal_union = {}
for i = 1, interval_count do
local bright_step_seq = string.sub(brightest_mode, 1, i-1)
local dark_step_seq  = string.sub(darkest_mode  , 1, i-1)
local bright_interval = p.interval_from_step_sequence(bright_step_seq)
local dark_interval  = p.interval_from_step_sequence(dark_step_seq  )
if p.interval_eq(bright_interval, dark_interval) then
table.insert(modal_union, bright_interval)
else
table.insert(modal_union, dark_interval  )
table.insert(modal_union, bright_interval)
end
end
return modal_union
end
end


691行目: 717行目:


--------------------------------------------------------------------------------
--------------------------------------------------------------------------------
------------------------ EQUAL-TUNING STRING FUNCTIONS -------------------------
---------------------------- EQUAL-TUNING FUNCTIONS ----------------------------
--------------------------------------------------------------------------------
--------------------------------------------------------------------------------


-- Given a mos and step ratio, return its equal temperament as a string "{steps}\{division}{suffix}".
-- Given a mos and a step ratio, return an equal tuning (or equal division).
function p.et_string(mos, step_ratio, suffix)
-- The step ratio is entered as a 2-element array to allow non-simplified
-- ratios to be entered. (The rational module isn't suitable since it simplifies
-- ratios.)
function p.as_et(mos, step_ratio, suffix)
local suffix = suffix or nil
local suffix = suffix or nil
local et_mos = p.as_et(mos, step_ratio, suffix)
local et_size = mos.nL * step_ratio[1] + mos.ns * step_ratio[2]
return et.as_string(et_mos)
return et.new(et_size, mos.equave, suffix)
end
 
-- Given a mos and a step ratio, return the number of et-steps for its bright
-- generator.
function p.bright_gen_to_et_steps(mos, step_ratio)
return p.interval_to_et_steps(p.bright_gen(mos), step_ratio)
end
 
-- Given a mos and a step ratio, return the number of et-steps for its dark generator.
function p.dark_gen_to_et_steps(mos, step_ratio)
return p.interval_to_et_steps(p.dark_gen(mos), step_ratio)
end
 
-- Given a mos and a step ratio, return the number of et-steps for its period.
function p.period_to_et_steps(mos, step_ratio)
return p.interval_to_et_steps(p.period(mos), step_ratio)
end
 
-- Given a mos and a step ratio, return the number of et-steps for its equave.
function p.equave_to_et_steps(mos, step_ratio)
return p.interval_to_et_steps(p.equave(mos), step_ratio)
end
 
-- Given an interval vector and step ratio, compute the number of et-steps it corresponds to.
function p.interval_to_et_steps(interval, step_ratio)
return interval["L"] * step_ratio[1] + interval["s"] * step_ratio[2]
end
end
--------------------------------------------------------------------------------
------------------------ EQUAL-TUNING STRING FUNCTIONS -------------------------
--------------------------------------------------------------------------------


-- 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).
712行目: 771行目:
return "ed" .. rat.as_ratio(mos.equave)
return "ed" .. rat.as_ratio(mos.equave)
end
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 step ratio, compute the number of et-steps for its dark gen,
-- as a string "{steps}\{division}{suffix}".
function p.dark_gen_to_et_string(mos, step_ratio, suffix)
return p.interval_to_et_string(p.dark_gen(mos), mos, step_ratio, suffix)
end
-- Given a mos and step ratio, compute the number of et-steps for its period,
-- as a string "{steps}\{division}{suffix}".
function p.period_to_et_string(mos, step_ratio, suffix)
return p.interval_to_et_string(p.period(mos), mos, step_ratio, suffix)
end
-- Given a mos, compute the number of et-steps for its period, reduced,
-- as a string "{steps}\{division}{suffix}". Does not reuqire a 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
-- Given a mos and step ratio, compute the number of et-steps for its equave,
-- as a string "{steps}\{division}{suffix}".
function p.equave_to_et_string(mos, step_ratio, suffix)
return p.interval_to_et_string(p.equave(mos), mos, step_ratio, suffix)
end
-- Given an interval vector and step ratio, compute the number of et-steps it
-- corresponds to, as a string "{steps}\{division}{suffix}". Requires info
-- 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