Module:Diatonic interval category: Difference between revisions
From Xenharmonic Reference
No edit summary |
No edit summary |
||
| (11 intermediate revisions by the same user not shown) | |||
| Line 3: | Line 3: | ||
function p.expandIQ(frame) | function p.expandIQ(frame) | ||
f = tonumber(frame.args[1]) | local f = tonumber(frame.args[1]) | ||
o = tonumber(frame.args[2]) | local 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) | |||
local f = d.enharmonic(tonumber(frame.args[1]),frame.args[2]) | |||
local o = tonumber(frame.args[2]) | |||
if (d.qualityAsName(f,o) == "major") then | if (d.qualityAsName(f,o) == "major") then | ||
return "major (wider)" | return "major (wider)" | ||
| Line 15: | Line 28: | ||
function p.generator(frame) | function p.generator(frame) | ||
f = tonumber(frame.args[1]) | local f = tonumber(frame.args[1]) | ||
o = tonumber(frame.args[2]) | local o = tonumber(frame.args[2]) | ||
if(f == 1) then | |||
return "1 fifth" | |||
end | |||
if(f == -1) then | |||
return "1 fourth" | |||
end | |||
b = "no fifths" | |||
if(f > 0) then | if(f > 0) then | ||
b = f .. " fifths octave-reduced" | |||
end | end | ||
if(f < 0) then | if(f < 0) then | ||
b = math.abs(f) .. " fourths octave-reduced" | |||
end | end | ||
if(math.abs(f) > 6) then | |||
b = b .. " (and as such is not found in the diatonic scale)" | |||
end | |||
return b | |||
end | |||
function p.generator2(frame) | |||
local f = d.enharmonic(tonumber(frame.args[1]),frame.args[2]) | |||
local o = tonumber(frame.args[2]) | |||
if(f == 1) then | |||
return "1 fifth" | |||
end | |||
if(f == -1) then | |||
return "1 fourth" | |||
end | |||
b = "no fifths" | |||
if(f > 0) then | |||
b = f .. " fifths octave-reduced" | |||
end | |||
if(f < 0) then | |||
b = math.abs(f) .. " fourths octave-reduced" | |||
end | |||
if(math.abs(f) > 6) then | |||
b = b .. " (and as such is not found in the diatonic scale)" | |||
end | |||
return b | |||
end | end | ||
function p.tuning(frame) | function p.tuning(frame) | ||
f = tonumber(frame.args[1]) | local f = tonumber(frame.args[1]) | ||
o = tonumber(frame.args[2]) | local o = tonumber(frame.args[2]) | ||
k1 = d.tuning5(f,o) * (1200/5) | k1 = d.tuning5(f,o) * (1200/5) | ||
k2 = math. | 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) | |||
local f = d.enharmonic(tonumber(frame.args[1]),frame.args[2]) | |||
local 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 | if (k1 > k2) then | ||
return k2 .. " to " .. k1 .. "cents (" .. d.tuning7(f,o) .. "\7 to " .. d.tuning5(f,o) .. "\5)" | return k2 .. " to " .. k1 .. " cents (" .. d.tuning7(f,o) .. "\\7 to " .. d.tuning5(f,o) .. "\\5)" | ||
end | end | ||
return k1 .. " to " .. k2 .. "cents (" .. d.tuning5(f,o) .. "\5 to " .. d.tuning7(f,o) .. "\7)" | return k1 .. " to " .. k2 .. " cents (" .. d.tuning5(f,o) .. "\\5 to " .. d.tuning7(f,o) .. "\\7)" | ||
end | end | ||
function p.s(i) | |||
if(i == 1) then | |||
return "" | |||
end | |||
return "s" | |||
end | |||
function p.diatonic_interval_category(frame) | function p.diatonic_interval_category(frame) | ||
f = tonumber(frame.args[1]) | local f = tonumber(frame.args[1]) | ||
o = tonumber(frame.args[2]) | local o = tonumber(frame.args[2]) | ||
str = " | str = "The " .. 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 labeled \"" .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. "\" if it is reasonably mapped to " .. d.tuning7(f,o) .. " step".. p.s(d.tuning7(f,o)).." of the [[diatonic]] scale and " .. d.tuning7(f,o)+d.tuning5(f,o) .. " step".. p.s(d.tuning7(f,o)+d.tuning5(f,o)).." of the dodecatonic chromatic scale. \n \nThe " .. d.qualityAsName(d.enharmonic(f,o),o) .. " " .. d.degreeAsName(d.enharmonic(f,o),o) .. " (" .. d.qualityAsLetter(d.enharmonic(f,o),o) .. d.degreeAsNumber(d.enharmonic(f,o),o) .. ") is enharmonic with the " .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. ", ranging from " .. p.tuning2(frame) .. ". It is generated by stacking " .. p.generator2(frame) .. ". <br>An interval in just intonation may be labeled \"" .. d.qualityAsName(d.enharmonic(f,o),o) .. " " .. d.degreeAsName(d.enharmonic(f,o),o) .. "\" if it is reasonably mapped to ''" .. d.tuning7(d.enharmonic(f,o),o) .. "'' step".. p.s(d.tuning7(d.enharmonic(f,o),o)).." of the [[diatonic]] scale and " .. d.tuning7(d.enharmonic(f,o),o)+d.tuning5(d.enharmonic(f,o),o) .. " step".. p.s(d.tuning7(d.enharmonic(f,o),o)+d.tuning5(d.enharmonic(f,o),o)).." of the dodecatonic chromatic scale." | ||
return str | return str | ||
Latest revision as of 09:03, 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)
local f = tonumber(frame.args[1])
local 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)
local f = d.enharmonic(tonumber(frame.args[1]),frame.args[2])
local 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)
local f = tonumber(frame.args[1])
local o = tonumber(frame.args[2])
if(f == 1) then
return "1 fifth"
end
if(f == -1) then
return "1 fourth"
end
b = "no fifths"
if(f > 0) then
b = f .. " fifths octave-reduced"
end
if(f < 0) then
b = math.abs(f) .. " fourths octave-reduced"
end
if(math.abs(f) > 6) then
b = b .. " (and as such is not found in the diatonic scale)"
end
return b
end
function p.generator2(frame)
local f = d.enharmonic(tonumber(frame.args[1]),frame.args[2])
local o = tonumber(frame.args[2])
if(f == 1) then
return "1 fifth"
end
if(f == -1) then
return "1 fourth"
end
b = "no fifths"
if(f > 0) then
b = f .. " fifths octave-reduced"
end
if(f < 0) then
b = math.abs(f) .. " fourths octave-reduced"
end
if(math.abs(f) > 6) then
b = b .. " (and as such is not found in the diatonic scale)"
end
return b
end
function p.tuning(frame)
local f = tonumber(frame.args[1])
local 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)
local f = d.enharmonic(tonumber(frame.args[1]),frame.args[2])
local 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)
local f = tonumber(frame.args[1])
local o = tonumber(frame.args[2])
str = "The " .. 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 labeled \"" .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. "\" if it is reasonably mapped to " .. d.tuning7(f,o) .. " step".. p.s(d.tuning7(f,o)).." of the [[diatonic]] scale and " .. d.tuning7(f,o)+d.tuning5(f,o) .. " step".. p.s(d.tuning7(f,o)+d.tuning5(f,o)).." of the dodecatonic chromatic scale. \n \nThe " .. d.qualityAsName(d.enharmonic(f,o),o) .. " " .. d.degreeAsName(d.enharmonic(f,o),o) .. " (" .. d.qualityAsLetter(d.enharmonic(f,o),o) .. d.degreeAsNumber(d.enharmonic(f,o),o) .. ") is enharmonic with the " .. d.qualityAsName(f,o) .. " " .. d.degreeAsName(f,o) .. ", ranging from " .. p.tuning2(frame) .. ". It is generated by stacking " .. p.generator2(frame) .. ". <br>An interval in just intonation may be labeled \"" .. d.qualityAsName(d.enharmonic(f,o),o) .. " " .. d.degreeAsName(d.enharmonic(f,o),o) .. "\" if it is reasonably mapped to ''" .. d.tuning7(d.enharmonic(f,o),o) .. "'' step".. p.s(d.tuning7(d.enharmonic(f,o),o)).." of the [[diatonic]] scale and " .. d.tuning7(d.enharmonic(f,o),o)+d.tuning5(d.enharmonic(f,o),o) .. " step".. p.s(d.tuning7(d.enharmonic(f,o),o)+d.tuning5(d.enharmonic(f,o),o)).." of the dodecatonic chromatic scale."
return str
end
return p
