Module:Diatonic interval tuning

From Xenharmonic Wiki
Revision as of 13:33, 2 May 2025 by ArrowHead294 (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Documentation for this module may be created at Module:Diatonic interval tuning/doc

local p = {}
local u = require("Module:Utils")
local rat = require("Module:Rational")
local yesno = require("Module:Yesno")

function p.diatune(frame)
	local fifthspan = frame.args["fifthspan"]
	local fifth1 = (4/7) * 1200
	local fifth2 = (15/26) * 1200
	local fifth3 = (11/19) * 1200
	local fifth4 = (18/31) * 1200
	local fifth5 = (7/12) * 1200
	local fifth6 = (17/29) * 1200
	local fifth7 = (10/17) * 1200
	local fifth8 = (13/22) * 1200
	local fifth9 = (3/5) * 1200
	local tuning1 = math.floor((fifth1 * fifthspan % 1200) + 0.5)
	local tuning2 = math.floor((fifth2 * fifthspan % 1200) + 0.5)
	local tuning3 = math.floor((fifth3 * fifthspan % 1200) + 0.5)
	local tuning4 = math.floor((fifth4 * fifthspan % 1200) + 0.5)
	local tuning5 = math.floor((fifth5 * fifthspan % 1200) + 0.5)
	local tuning6 =  math.floor((fifth6 * fifthspan % 1200) + 0.5)
	local tuning7 =  math.floor((fifth7 * fifthspan % 1200) + 0.5)
	local tuning8 =  math.floor((fifth8 * fifthspan % 1200) + 0.5)
	local tuning9 = math.floor((fifth9 * fifthspan % 1200) + 0.5)
	local result = '{| class="wikitable"\n'
		.. '|-\n'
		.. '! Tuning\n'
		.. '! Step ratio\n'
		.. '! EDO\n'
		.. '! Cents\n'
		.. '|-\n'
		.. '| Equalized\n'
		.. '| 1:1\n'
		.. '| [[7edo|7]] \n'
		.. string.format('| %s{{c}}\n', tuning1)
		.. '|-\n'
		.. '| Supersoft\n'
		.. '| 4:3\n'
		.. '| [[26edo|26]]\n'
		.. string.format('| %s{{c}}\n', tuning2)
		.. '|-\n'
		.. '| Soft\n'
		.. '| 3:2\n'
		.. '| [[19edo|19]]\n'
		.. string.format('| %s{{c}}\n', tuning3)
		.. '|-\n'
		.. '| Semisoft\n'
		.. '| 5:3\n'
		.. '| [[31edo|31]]\n'
		.. string.format('| %s{{c}}\n', tuning4)
		.. '|-\n'
		.. '| Basic\n'
		.. '| 2:1\n'
		.. '| [[12edo|12]]\n'
		.. string.format('| %s{{c}}\n', tuning5)
		.. '|-\n'
		.. '| Semihard\n'
		.. '| 5:2\n'
		.. '| [[29edo|29]]\n'
		.. string.format('| %s{{c}}\n', tuning6)
		.. '|-\n'
		.. '| Hard\n'
		.. '| 3:1\n'
		.. '| [[17edo|17]]\n'
		.. string.format('| %s{{c}}\n', tuning7)
		.. '|-\n'
		.. '| Superhard\n'
		.. '| 4:1\n'
		.. '| [[22edo|22]]\n'
		.. string.format('| %s{{c}}\n', tuning8)
		.. '|-\n'
		.. '| Collapsed\n'
		.. '| 1:0\n'
		.. '| [[5edo|5]]\n'
		.. string.format('| %s{{c}}\n', tuning9)
		.. '|}'
	local debugg = yesno(frame.args["debug"])
	return frame:preprocess(debugg == true and "<syntaxhighlight lang=\"wikitext\">" .. result .. "</syntaxhighlight>" or result)
end

return p