|
|
| Line 238: |
Line 238: |
| | | |
| return section_entries | | return section_entries |
| end
| |
|
| |
| -- Helper function for a helper function
| |
| -- Determines what mos the given mos descends from
| |
| -- as well as what step ratio that produces this scale
| |
| -- Mosses within the "named range" passed here will return itself
| |
| function p.find_mos_ancestor(input_mos)
| |
| local input_mos = input_mos or mos.new(5, 2)
| |
|
| |
| local z = input_mos.nL
| |
| local w = input_mos.ns
| |
| local generations = 0
| |
|
| |
| -- For an ancestral mos zU wv and descendant xL ys, how many steps of size
| |
| -- L and s can fit inside U and v? (basically the chunking operation)
| |
| local lg_chunk = { nL = 1, ns = 0 }
| |
| local sm_chunk = { nL = 0, ns = 1 }
| |
|
| |
| while (z ~= w) and (z + w > 10) do
| |
| local m1 = math.max(z, w)
| |
| local m2 = math.min(z, w)
| |
|
| |
| -- For use with updating ancestor mos chunks
| |
| local z_prev = z
| |
|
| |
| -- Count how many generations
| |
| generations = generations + 1
| |
|
| |
| -- Update step ratios
| |
| z = m2
| |
| w = m1 - m2
| |
|
| |
| -- Update large chunk
| |
| local prev_lg_chunk = { nL = lg_chunk.nL, ns = lg_chunk.ns }
| |
| lg_chunk.nL = lg_chunk.nL + sm_chunk.nL
| |
| lg_chunk.ns = lg_chunk.ns + sm_chunk.ns
| |
|
| |
| -- Update small chunk
| |
| if z ~= z_prev then
| |
| sm_chunk = prev_lg_chunk
| |
| end
| |
| end
| |
|
| |
| return mos.new(z, w, input_mos.equave), lg_chunk, sm_chunk, generations
| |
| end | | end |
|
| |
|
| Line 297: |
Line 253: |
| -- a larger array. | | -- a larger array. |
| function p.tamnams_information(input_mos) | | function p.tamnams_information(input_mos) |
| local input_mos = input_mos or mos.new(5, 2) | | local input_mos = input_mos or mos.new(12, 5) |
| local scalesig = string.format("%dL %ds", input_mos.nL, input_mos.ns) | | local scalesig = string.format("%dL %ds", input_mos.nL, input_mos.ns) |
| | | |
| Line 324: |
Line 280: |
| elseif not is_within_named_range and notecount > 10 and not is_root_mos then | | elseif not is_within_named_range and notecount > 10 and not is_root_mos then |
| -- Mos is a non-root mos and has a tamnams-named ancestor | | -- Mos is a non-root mos and has a tamnams-named ancestor |
| local ancestor_mos, lg_chunk, sm_chunk, generations = p.find_mos_ancestor(input_mos) | | local ancestor_mos, ratio_1, ratio_2, generations = tamnams.find_ancestor_info(input_mos) |
| local ancestor_scalesig = mos.as_string(ancestor_mos) | | local ancestor_scalesig = mos.as_string(ancestor_mos) |
| local ancestor_long_scalesig = mos.as_long_string(ancestor_mos) | | local ancestor_long_scalesig = mos.as_long_string(ancestor_mos) |
| local ancestor_name = tamnams.lookup_name(ancestor_mos) | | local ancestor_name = tamnams.lookup_name(ancestor_mos) |
|
| |
| -- Helper code for finding mos ancestor and relation to it
| |
| local num1 = lg_chunk.nL + lg_chunk.ns
| |
| local den1 = sm_chunk.nL + sm_chunk.ns
| |
| local num2 = lg_chunk.nL
| |
| local den2 = sm_chunk.nL
| |
| local first_ancestor_step_ratio = ""
| |
| local second_ancestor_step_ratio = ""
| |
| if num1/den1 < num2/den2 then
| |
| first_ancestor_step_ratio = string.format("%d:%d", num1, den1)
| |
| second_ancestor_step_ratio = string.format("%d:%d", num2, den2)
| |
| else
| |
| first_ancestor_step_ratio = string.format("%d:%d", num2, den2)
| |
| second_ancestor_step_ratio = string.format("%d:%d", num1, den1)
| |
| end
| |
| | | |
| -- Step ratio range as text | | -- Step ratio range as text |
| local step_ratio_range = string.format("%s to %s", first_ancestor_step_ratio, second_ancestor_step_ratio) | | local step_ratio_range = string.format("%s:%s to %s:%s", ratio_1[1], ratio_1[2], ratio_2[1], ratio_2[2]) |
| | local range_name = tamnams.lookup_step_ratio_range(ratio_1, ratio_2) |
| | | |
| -- Step ratio range as a named range
| | local step_ratio_range_entry = step_ratio_range == range_name and range_name or string.format("%s (%s)", step_ratio_range, range_name) |
| local named_range = step_ratio_range | |
| if step_ratio_range == "1:1 to 2:1" then
| |
| named_range = named_range .. " (soft-of-basic)"
| |
| elseif step_ratio_range == "2:1 to 1:0" then
| |
| named_range = named_range .. " (hard-of-basic)"
| |
| elseif step_ratio_range == "1:1 to 3:2" then
| |
| named_range = named_range .. " (soft)"
| |
| elseif step_ratio_range == "3:2 to 2:1" then
| |
| named_range = named_range .. " (hyposoft)"
| |
| elseif step_ratio_range == "2:1 to 3:1" then
| |
| named_range = named_range .. " (hypohard)"
| |
| elseif step_ratio_range == "3:1 to 1:0" then
| |
| named_range = named_range .. " (hard)"
| |
| elseif step_ratio_range == "1:1 to 4:3" then
| |
| named_range= named_range .. " (ultrasoft)"
| |
| elseif step_ratio_range == "4:3 to 3:2" then
| |
| named_range = named_range .. " (parasoft)"
| |
| elseif step_ratio_range == "3:2 to 5:3" then
| |
| named_range = named_range .. " (quasisoft)"
| |
| elseif step_ratio_range == "5:3 to 2:1" then
| |
| named_range = named_range .. " (minisoft)"
| |
| elseif step_ratio_range == "2:1 to 5:2" then
| |
| named_range = named_range .. " (minihard)"
| |
| elseif step_ratio_range == "5:2 to 3:1" then
| |
| named_range = named_range .. " (quasihard)"
| |
| elseif step_ratio_range == "3:1 to 4:1" then
| |
| named_range = named_range .. " (parahard)"
| |
| elseif step_ratio_range == "4:1 to 1:0" then
| |
| named_range = named_range .. " (ultrahard)"
| |
| end
| |
| | | |
| local ancestor_entry = string.format("[[%s | %s]]", ancestor_long_scalesig, ancestor_scalesig) | | local ancestor_entry = string.format("[[%s | %s]]", ancestor_long_scalesig, ancestor_scalesig) |
| Line 387: |
Line 299: |
| {string.format("<b>%s</b>", section_header)}, | | {string.format("<b>%s</b>", section_header)}, |
| {"Descends from", ancestor_entry}; | | {"Descends from", ancestor_entry}; |
| {"Ancestor's step ratio range", string.format("%s", named_range)} | | {"Ancestor's step ratio range", string.format("%s", step_ratio_range_entry)} |
| } | | } |
| end | | end |