Module:TAMNAMS: Difference between revisions
Consolidated helper functions; rewrote preprocess functions; interval_quality() and degree_quality() added |
Bugfixed code for applying APd for root mosses |
||
| Line 376: | Line 376: | ||
local is_bright_gen = step_count % mos.period_step_count(input_mos) == mos.bright_gen_step_count(input_mos) | 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) | 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; | -- Special case: APd does not apply to a root mos's (nL ns) generators; | ||
-- instead, it's Mm. | -- instead, it's Mm. | ||
local is_root_mos = input_mos.nL == input_mos.ns | 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_bright_gen and not is_root_mos) | |||
-- Get chroma count and adjust as needed | -- Get chroma count and adjust as needed | ||
local chroma_count = 0 | local chroma_count = 0 | ||
if | 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 | else | ||
-- Chroma count 0 is the large size, and -1 the small size; these are | -- Chroma count 0 is the large size, and -1 the small size; these are | ||
| Line 510: | Line 507: | ||
function p.tester() | function p.tester() | ||
local input_mos = mos.new(4,4) | |||
local brightest_mode = mos.brightest_mode(input_mos) | |||
local interval_qualities = {} | |||
local input_mos = mos.new | |||
for i = 1, #brightest_mode + 1 do | |||
local substring = string.sub(brightest_mode, 0, i - 1) | |||
local interval_vector = mos.interval_from_step_sequence(substring) | |||
local interval_quality = p.interval_quality(interval_vector, input_mos, "abbrev") | |||
table.insert(interval_qualities, interval_quality) | |||
end | |||
return interval_qualities | |||
local | |||
return | |||
end | end | ||
return p | return p | ||