Module:Infobox interval: Difference between revisions
Jump to navigation
Jump to search
mNo edit summary |
mNo edit summary |
||
| Line 70: | Line 70: | ||
table.insert(infobox_data, { | table.insert(infobox_data, { | ||
'Norms', | 'Norms', | ||
'[[Tenney height|< | '[[Tenney height|log<sub>2</sub> n⋅d]]: ' .. u._round(rat.tenney_height(ratio), 6) .. '<br/>' | ||
.. '[[Weil height| | .. '[[Weil height|max(n, d)]]: ' .. u._round(rat.weil_height(ratio), 6) .. '<br/>' | ||
.. '[[Benedetti height| | .. '[[Benedetti height|n⋅d]]: ' .. u._round(rat.benedetti_height(ratio), 6) | ||
}) | }) | ||
Revision as of 17:26, 10 October 2022
- This module should not be invoked directly; use its corresponding template instead: Template:Infobox interval.
This module generates an infobox providing information about a given interval.
| Introspection summary for Module:Infobox interval | ||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
| |||||||||||||||||||||
No function descriptions were provided. The Lua code may have further information.
local p = {}
local rat = require('Module:Rational')
local u = require('Module:Utils')
local i = require('Module:Interval')
local infobox = require('Module:Infobox')
function p.infobox_interval(frame)
local debug_mode = frame.args['debug'] ~= nil
-- TODO: better input parsing + irrational intervals
local ratio_arg = frame.args['Ratio'] or '2/1'
local ratio = rat.parse(ratio_arg) or rat.new(2)
local ratio_str = rat.as_ratio(ratio)
local ratio_ket = rat.as_ket(ratio, frame)
local ratio_approx = rat.as_float(ratio)
local ratio_cents = rat.cents(ratio)
local infobox_data = {}
local cats = '[[Category:Rational intervals]]'
table.insert(infobox_data, {
'Ratio',
ratio_str
})
-- TODO: factorisation
table.insert(infobox_data, {
'[[Monzo]]',
ratio_ket
})
table.insert(infobox_data, {
'Size in [[cent]]s',
i._to_cents(ratio_approx, 8)
})
local name = frame.args['Name']
if name and #name > 0 then
local caption = 'Name'
if name:match(',') then caption = 'Names' end
table.insert(infobox_data, {
caption,
name
})
else
cats = cats .. '[[Category:Todo:add interval name]]'
table.insert(infobox_data, {
'Name(s)',
'<abbr title="missing value for parameter \'Name\'">\'\'missing\'\'</abbr></span><sup>[[Template:Infobox Interval| ? ]]</sup>'
})
end
-- TODO: compute?
local colour_name = frame.args['Color name']
if colour_name and #colour_name > 0 then
table.insert(infobox_data, {
'[[Color notation|Color name]]',
colour_name
})
end
-- TODO: compute
local FJS_name = frame.args['FJS name']
if FJS_name and #FJS_name > 0 then
table.insert(infobox_data, {
'[[Functional Just System|FJS name]]',
FJS_name
})
end
table.insert(infobox_data, {
'Norms',
'[[Tenney height|log<sub>2</sub> n⋅d]]: ' .. u._round(rat.tenney_height(ratio), 6) .. '<br/>'
.. '[[Weil height|max(n, d)]]: ' .. u._round(rat.weil_height(ratio), 6) .. '<br/>'
.. '[[Benedetti height|n⋅d]]: ' .. u._round(rat.benedetti_height(ratio), 6)
})
table.insert(infobox_data, {
'[[Harmonic entropy]]',
'~' .. u._round(i.harmonic_entropy(ratio_cents), 6)
})
local sound = frame.args['Sound']
if sound and #sound > 0 then
cats = cats .. '[[Category:Pages with internal sound examples]]'
table.insert(infobox_data, {
'[[File:' .. sound .. '|270px]]<br/><small>[[:File:' .. sound .. '|[sound info]]]</small>'
})
end
table.insert(infobox_data, {
'<small>[https://www.yacavone.net/xen-calc/?q=' .. ratio_str .. ' open this interval in \'\'xen-calc\'\']</small>'
})
local s = infobox.build(
'<u>Interval information</u>',
infobox_data
)
if not debug_mode then
s = s .. cats
end
return s
end
return p