Module:Infobox ET: Difference between revisions
Jump to navigation
Jump to search
First draft, includes prime factorization, step size and fifth |
m Bug fixing |
||
Line 6: | Line 6: | ||
local tuning = frame.args['tuning'] | local tuning = frame.args['tuning'] | ||
local size, equave = i.parse_ET(tuning) | local size, equave = i.parse_ET(tuning) | ||
if | if equave == 2 then | ||
tuning = size | tuning = size | ||
end | end | ||
Line 22: | Line 22: | ||
'">\n' .. | '">\n' .. | ||
'{| width="100%" style="border-collapse: collapse;"\n' .. | '{| width="100%" style="border-collapse: collapse;"\n' .. | ||
'|+ ' .. frame.args['tuning'] .. '\n' .. | '|+ style="font-weight: bold" | ' .. frame.args['tuning'] .. '\n' .. | ||
'|-\n' .. | '|-\n' .. | ||
'| style="text-align:right; padding-right: 0.25em" | Prime factorization\n' .. | '| style="text-align:right; padding-right: 0.25em" | Prime factorization\n' .. | ||
Line 31: | Line 31: | ||
'|-\n' .. | '|-\n' .. | ||
'| style="text-align:right; padding-right: 0.25em" | Fifth\n' .. | '| style="text-align:right; padding-right: 0.25em" | Fifth\n' .. | ||
'| style="background-color: white; padding-left: 0.25em; font-weight: bold" | ' .. fifth .. '\\' .. tuning .. ' (' .. i._to_cents(fifth, 6) .. '{{cent}})\n' .. | '| style="background-color: white; padding-left: 0.25em; font-weight: bold" | ' .. u._round(fifth, 0) .. '\\' .. tuning .. ' (' .. i._to_cents(fifth, 6) .. '{{cent}})\n' .. | ||
'|}</div>' | '|}</div>' | ||
end | end | ||
return p | return p |
Revision as of 03:31, 22 August 2022
Note: Do not invoke this module directly; use the corresponding template instead: Template:Infobox ET.
This module automatically fills in information about a specified equal temperament tuning.
local p = {}
local i = require('Module:Interval')
local u = require('Module:Utils')
function p.infobox_ET(frame)
local tuning = frame.args['tuning']
local size, equave = i.parse_ET(tuning)
if equave == 2 then
tuning = size
end
local step_size = i._backslash_ratio('1\\' .. tuning)
local fifth = math.log(1.5)/math.log(equave)*size
return '<div style="\n' ..
'border: 1px solid #999;\n' ..
'margin: 0;\n' ..
'margin-left: 1em;\n' ..
'margin-bottom: 0.5em;\n' ..
'padding: 0.5em;\n' ..
'background-color: #f0f0f0;\n' ..
'min-width: 15em;\n' ..
'float: right;\n' ..
'">\n' ..
'{| width="100%" style="border-collapse: collapse;"\n' ..
'|+ style="font-weight: bold" | ' .. frame.args['tuning'] .. '\n' ..
'|-\n' ..
'| style="text-align:right; padding-right: 0.25em" | Prime factorization\n' ..
'| style="background-color: white; padding-left: 0.25em; font-weight: bold" | ' .. u._prime_factorization(size) .. '\n' ..
'|-\n' ..
'| style="text-align:right; padding-right: 0.25em" | Step size\n' ..
'| style="background-color: white; padding-left: 0.25em; font-weight: bold" | ' .. i._to_cents(step_size, 6) .. '{{cent}}\n' ..
'|-\n' ..
'| style="text-align:right; padding-right: 0.25em" | Fifth\n' ..
'| style="background-color: white; padding-left: 0.25em; font-weight: bold" | ' .. u._round(fifth, 0) .. '\\' .. tuning .. ' (' .. i._to_cents(fifth, 6) .. '{{cent}})\n' ..
'|}</div>'
end
return p