「モジュール:TAMNAMS」の版間の差分
編集の要約なし タグ: 手動差し戻し |
編集の要約なし |
||
| 988行目: | 988行目: | ||
return differences | return differences | ||
end | end | ||
-- 日本語対応用 | |||
function p.degree_quality_japanese(interval, input_mos) | |||
-- Get the step count of the interval. The sum of L's and s's will always | |||
-- determine what k-mosstep the interval is. | |||
local step_count = mos.interval_step_count(interval) | |||
-- Decode the quality | |||
local quality = p.decode_quality(interval, input_mos) | |||
return string.format("%s%d度", quality, step_count) | |||
end | |||
function p.decode_quality_japanese(interval, input_mos) | |||
-- Normalize the interval so negative values aren't being used. | |||
local interval = mos.normalize_interval(interval) | |||
-- Get the step count of the interval. The sum of L's and s's will always | |||
-- determine what k-mosstep the interval is. | |||
local step_count = mos.interval_step_count(interval) | |||
-- Determine what "special" type the interval is so that the designations | |||
-- of augmented/perfect/diminished (APd) apply, skipping major/minor (Mm). | |||
-- If it's the period or equave, then it's a multiple of the period. | |||
-- If it's any one of the gens, then reducing it should produce that gen. | |||
local is_period = step_count % mos.period_step_count(input_mos) == 0 | |||
local is_bright_gen = step_count % mos.period_step_count(input_mos) == mos.bright_gen_step_count(input_mos) | |||
local is_dark_gen = step_count % mos.period_step_count(input_mos) == mos.dark_gen_step_count(input_mos) | |||
-- Special case: APd does not apply to a root mos's (nL ns) generators; | |||
-- instead, it's Mm. | |||
local is_root_mos = input_mos.nL == input_mos.ns | |||
-- Is perfectable? This is for intervals for which maj/min does not apply. | |||
local is_perfectable = is_period or (is_bright_gen and not is_root_mos) or (is_dark_gen and not is_root_mos) | |||
-- Get chroma count and adjust as needed | |||
local chroma_count = 0 | |||
if is_period then | |||
-- Chroma count 0 is the perfect size. This interval does not appear | |||
-- as any other size across all mos modes. | |||
chroma_count = mos.interval_chroma_count(interval, input_mos) | |||
elseif is_bright_gen and not is_root_mos then | |||
-- Chroma count 0 is the large size, and -1 the small size; these | |||
-- are perfect and diminished respectively. | |||
chroma_count = mos.interval_chroma_count(interval, input_mos) | |||
elseif is_dark_gen and not is_root_mos then | |||
-- Chroma count 0 is the large size, and -1 the small size; these | |||
-- are augmented and perfect respectively. Since the perfect size | |||
-- corresponds to a chroma count of -1, pass in -1 as the 3rd arg. | |||
chroma_count = mos.interval_chroma_count(interval, input_mos, -1) | |||
else | |||
-- Chroma count 0 is the large size, and -1 the small size; these are | |||
-- major and minor respectively. | |||
chroma_count = mos.interval_chroma_count(interval, input_mos) | |||
end | |||
-- Get absolute value of chroma count | |||
local chroma_abs = math.abs(chroma_count) | |||
local quality = "" | |||
if is_perfectable then | |||
-- Get the quality for perfectable intervals | |||
if chroma_count < 0 then | |||
quality = "減" | |||
elseif chroma_count > 0 then | |||
quality = "増" | |||
else | |||
quality = "完全" | |||
end | |||
else | |||
-- Get the quality for nonperfectable intervals | |||
-- Is the interval major? If not, decrement chroma_abs by 1 | |||
local is_positive = chroma_count >= 0 | |||
chroma_abs = is_positive and chroma_abs or chroma_abs - 1 | |||
if chroma_abs > 0 and is_positive then | |||
quality = "増" | |||
elseif chroma_abs > 0 and not is_positive then | |||
quality = "減" | |||
else | |||
quality = is_positive and "長" or "短" | |||
end | |||
if chroma_abs > 1 then | |||
quality = string.format("%d× %s", chroma_abs, quality) | |||
end | |||
end | |||
return quality | |||
end | |||
-------------------------------------------------------------------------------- | -------------------------------------------------------------------------------- | ||