Module:Scale tree: Difference between revisions
Jump to navigation
Jump to search
CompactStar (talk | contribs) No edit summary |
CompactStar (talk | contribs) No edit summary |
||
| Line 18: | Line 18: | ||
local result = "" | local result = "" | ||
local sb_depth = frame.args['sb_depth'] or | local sb_depth = frame.args['sb_depth'] or 5 | ||
local step_ratios = sb.sb_tree_ratios(sb_depth) | local step_ratios = sb.sb_tree_ratios(sb_depth) | ||
Revision as of 22:28, 22 May 2023
local p = {}
local MOS = require('Module:MOS')
local ET = require('Module:ET')
local u = require('Module:Utils')
local rat = require('Module:Rational')
local sb = require('Module:SB tree')
function p.scale_tree(frame)
local mos = MOS.parse(frame.args['tuning'])
local equave = mos.equave
local L = mos.nL
local s = mos.ns
local collapsed_et = ET.new(L, equave)
local abstract_bright_gen = MOS.bright_gen(mos)
local collapsed_bright_steps = abstract_bright_gen['L']
local equalized_et = ET.new(L + s, equave)
local equalized_bright_steps = abstract_bright_gen['L'] + abstract_bright_gen['s']
local result = ""
local sb_depth = frame.args['sb_depth'] or 5
local step_ratios = sb.sb_tree_ratios(sb_depth)
result = '{|class="wikitable"\n'
result = result .. "|-\n"
result = result .. "!Generator (chroma-positive)\n"
result = result .. "!Cents (chroma-positive)\n"
result = result .. "!L\n"
result = result .. "!s\n"
result = result .. "!L/s\n"
result = result .. "!Comments\n"
local i = 1
while i <= #step_ratios do
local step_ratio = step_ratios[i]
local et = ET.new(step_ratio[1] * L + step_ratio[2] * s)
local generator_steps = step_ratio[1] * collapsed_bright_steps + step_ratio[2] * (equalized_bright_steps - collapsed_bright_steps)
local comments = frame.args[("comments_" .. step_ratio[1] .. "_" .. step_ratio[2])] or ""
local l_s = "→ ∞"
if not (step_ratio[1] == 1 and step_ratio[2] == 0) then
l_s = u._round(step_ratio[1] / step_ratio[2], 4)
end
result = result .. "|-\n"
result = result .. "|" .. generator_steps .. ET.backslash_modifier(et) .. "\n"
result = result .. "|" .. u._round(math.log(rat.as_float(et.equave)^(generator_steps / et.size))/math.log(2) * 1200, 6) .. "\n"
result = result .. "|" .. step_ratio[1] .. "\n"
result = result .. "|" .. step_ratio[2] .. "\n"
result = result .. "|" .. l_s .. "\n"
result = result .. "|" .. comments .. "\n"
i = i + 1
end
result = result .. "|}"
return result
end
return p