Module:Diatonic interval tuning: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
No edit summary
ArrowHead294 (talk | contribs)
mNo edit summary
 
(5 intermediate revisions by 2 users not shown)
Line 6: Line 6:
function p.diatune(frame)
function p.diatune(frame)
local fifthspan = frame.args["fifthspan"]
local fifthspan = frame.args["fifthspan"]
local fifth1 = (47)*1200
local fifth1 = (4/7) * 1200
local fifth2 = (15/26)*1200
local fifth2 = (15/26) * 1200
local fifth3 = (11/19)*1200
local fifth3 = (11/19) * 1200
local fifth4 = (18/31)*1200
local fifth4 = (18/31) * 1200
local fifth5 = (7/12)*1200
local fifth5 = (7/12) * 1200
local fifth6 = (17/29)*1200
local fifth6 = (17/29) * 1200
local fifth7 = (10/17)*1200
local fifth7 = (10/17) * 1200
local fifth8 = (13/22)*1200
local fifth8 = (13/22) * 1200
local fifth9 = (3/5)*1200
local fifth9 = (3/5) * 1200
local tuning1 = fifth1*fifthspan % 1200
local tuning1 = math.floor((fifth1 * fifthspan % 1200) + 0.5)
local tuning2 = fifth2*fifthspan % 1200
local tuning2 = math.floor((fifth2 * fifthspan % 1200) + 0.5)
local tuning3 = fifth3*fifthspan % 1200
local tuning3 = math.floor((fifth3 * fifthspan % 1200) + 0.5)
local tuning4 = fifth4*fifthspan % 1200
local tuning4 = math.floor((fifth4 * fifthspan % 1200) + 0.5)
local tuning5 = fifth5*fifthspan % 1200
local tuning5 = math.floor((fifth5 * fifthspan % 1200) + 0.5)
local tuning6 = fifth6*fifthspan % 1200
local tuning6 = math.floor((fifth6 * fifthspan % 1200) + 0.5)
local tuning7 = fifth7*fifthspan % 1200
local tuning7 = math.floor((fifth7 * fifthspan % 1200) + 0.5)
local tuning8 = fifth8*fifthspan % 1200
local tuning8 = math.floor((fifth8 * fifthspan % 1200) + 0.5)
local tuning9 = fifth9*fifthspan % 1200
local tuning9 = math.floor((fifth9 * fifthspan % 1200) + 0.5)
local out = '{| class="wikitable"\n|-\n!Tuning\n!Step ratio\n!edo\n!Cents\n|-\n|Equalized\n|1:1\n|[[7edo|7]]\n|' .. tuning1 .. 'c\n|-\n|Supersoft\n|4:3\n|[[26edo|26]]\n|' .. tuning2.. 'c\n|-\n|Soft\n|3:2\n|[[19edo|19]]\n|' .. tuning3.. 'c\n|-\n|Semisoft\n|5:3\n|[[31edo|31]]\n|' .. tuning4.. 'c\n|-\n|Basic\n|2:1\n|[[12edo|12]]\n|' .. tuning5.. 'c\n|-\n|Semihard\n|5:2\n|[[29edo|29]]\n|' .. tuning6.. 'c\n|-\n|Hard\n|3:1\n|[[17edo|17]]\n|' .. tuning7.. 'c\n|-\n|Superhard\n|4:1\n|[[22edo|22]]\n|' .. tuning8.. 'c\n|-\n|Equalized\n|1:0\n|[[5edo|5]]\n|' .. tuning9 .. '\n|}'
local result = '{| class="wikitable"\n'
return frame:preprocess(out)
.. '|-\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
end


return p
return p

Latest revision as of 13:33, 2 May 2025

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