Module:Diatonic interval category: Difference between revisions
From Xenharmonic Reference
No edit summary |
No edit summary |
||
| Line 102: | Line 102: | ||
f = tonumber(frame.args[1]) | f = tonumber(frame.args[1]) | ||
o = tonumber(frame.args[2]) | o = tonumber(frame.args[2]) | ||
str = "A " .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. " (" .. d.qualityAsLetter(f,o) .. d.degreeAsNumber(f,o) .. "), as a diatonic interval category, is an interval that spans " .. (d.degreeAsNumber(f,o)-1) .. " step".. p.s(d.degreeAsNumber(f,o)-1).." of the diatonic scale with the " .. p.expandIQ(frame) .. " quality. It is generated by stacking " .. p.generator(frame) .. ", and depending on the specific tuning it ranges from " .. p.tuning(frame) .. " | str = "A " .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. " (" .. d.qualityAsLetter(f,o) .. d.degreeAsNumber(f,o) .. "), as a diatonic interval category, is an interval that spans " .. (d.degreeAsNumber(f,o)-1) .. " step".. p.s(d.degreeAsNumber(f,o)-1).." of the diatonic scale with the " .. p.expandIQ(frame) .. " quality. It is generated by stacking " .. p.generator(frame) .. ", and depending on the specific tuning it ranges from " .. p.tuning(frame) .. "<br>An interval in just intonation may be called a " .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. " if it is reasonably mapped to " .. d.tuning7(f,o) .. " steps of the [[diatonic]] scale and " .. d.tuning7(f,o)+d.tuning5(f,o) .. " steps of the dodecatonic chromatic scale. \n \nThe " .. d.qualityAsName(d.enharmonic(f),o) .. " " .. d.degreeAsName(d.enharmonic(f),o) .. " (" .. d.qualityAsLetter(d.enharmonic(f),o) .. d.degreeAsNumber(d.enharmonic(f),o) .. ") is enharmonic with the " .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. ", ranging from " | ||
return str | return str | ||
Revision as of 08:35, 16 December 2025
Documentation for this module may be created at Module:Diatonic interval category/doc
local p = {}
local d = require("Module:Diatonic")
function p.expandIQ(frame)
f = tonumber(frame.args[1])
o = tonumber(frame.args[2])
if (d.qualityAsName(f,o) == "major") then
return "major (wider)"
end
if (d.qualityAsName(f,o) == "minor") then
return "minor (narrower)"
end
return d.qualityAsName(f,o)
end
function p.expandIQ2(frame)
f = d.enharmonic(tonumber(frame.args[1]))
o = tonumber(frame.args[2])
if (d.qualityAsName(f,o) == "major") then
return "major (wider)"
end
if (d.qualityAsName(f,o) == "minor") then
return "minor (narrower)"
end
return d.qualityAsName(f,o)
end
function p.generator(frame)
f = tonumber(frame.args[1])
o = tonumber(frame.args[2])
if(f == 1) then
return "1 fifth"
end
if(f == -1) then
return "1 fourth"
end
if(f > 0) then
return f .. " fifths octave-reduced"
end
if(f < 0) then
return math.abs(f) .. " fourths octave-reduced"
end
return "no fifths"
end
function p.generator2(frame)
f = d.enharmonic(tonumber(frame.args[1]))
o = tonumber(frame.args[2])
if(f == 1) then
return "1 fifth"
end
if(f == -1) then
return "1 fourth"
end
if(f > 0) then
return f .. " fifths octave-reduced"
end
if(f < 0) then
return math.abs(f) .. " fourths octave-reduced"
end
return "no fifths"
end
function p.tuning(frame)
f = tonumber(frame.args[1])
o = tonumber(frame.args[2])
k1 = d.tuning5(f,o) * (1200/5)
k2 = math.ceil(d.tuning7(f,o) * (1200/7)-0.5)
if (k1 > k2) then
return k2 .. " to " .. k1 .. " cents (" .. d.tuning7(f,o) .. "\\7 to " .. d.tuning5(f,o) .. "\\5)"
end
return k1 .. " to " .. k2 .. " cents (" .. d.tuning5(f,o) .. "\\5 to " .. d.tuning7(f,o) .. "\\7)"
end
function p.tuning2(frame)
f = d.enharmonic(tonumber(frame.args[1]))
o = tonumber(frame.args[2])
k1 = d.tuning5(f,o) * (1200/5)
k2 = math.ceil(d.tuning7(f,o) * (1200/7)-0.5)
if (k1 > k2) then
return k2 .. " to " .. k1 .. " cents (" .. d.tuning7(f,o) .. "\\7 to " .. d.tuning5(f,o) .. "\\5)"
end
return k1 .. " to " .. k2 .. " cents (" .. d.tuning5(f,o) .. "\\5 to " .. d.tuning7(f,o) .. "\\7)"
end
function p.s(i)
if(i == 1) then
return ""
end
return "s"
end
function p.diatonic_interval_category(frame)
f = tonumber(frame.args[1])
o = tonumber(frame.args[2])
str = "A " .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. " (" .. d.qualityAsLetter(f,o) .. d.degreeAsNumber(f,o) .. "), as a diatonic interval category, is an interval that spans " .. (d.degreeAsNumber(f,o)-1) .. " step".. p.s(d.degreeAsNumber(f,o)-1).." of the diatonic scale with the " .. p.expandIQ(frame) .. " quality. It is generated by stacking " .. p.generator(frame) .. ", and depending on the specific tuning it ranges from " .. p.tuning(frame) .. "<br>An interval in just intonation may be called a " .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. " if it is reasonably mapped to " .. d.tuning7(f,o) .. " steps of the [[diatonic]] scale and " .. d.tuning7(f,o)+d.tuning5(f,o) .. " steps of the dodecatonic chromatic scale. \n \nThe " .. d.qualityAsName(d.enharmonic(f),o) .. " " .. d.degreeAsName(d.enharmonic(f),o) .. " (" .. d.qualityAsLetter(d.enharmonic(f),o) .. d.degreeAsNumber(d.enharmonic(f),o) .. ") is enharmonic with the " .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. ", ranging from "
return str
end
return p
