Module:Diatonic: Difference between revisions
From Xenharmonic Reference
No edit summary |
No edit summary |
||
| Line 54: | Line 54: | ||
degree = "octave" | degree = "octave" | ||
end | end | ||
if | if(fifthspan % 7 == 1) then | ||
degree = "fifth" | degree = "fifth" | ||
end | end | ||
if | if(fifthspan % 7 == 2) then | ||
degree = "second" | degree = "second" | ||
end | end | ||
if | if(fifthspan % 7 == 3) then | ||
degree = "sixth" | degree = "sixth" | ||
end | end | ||
if | if(fifthspan % 7 == 4) then | ||
degree = "third" | degree = "third" | ||
end | end | ||
if | if(fifthspan % 7 == 5) then | ||
degree = "seventh" | degree = "seventh" | ||
end | end | ||
if | if(fifthspan % 7 == 6) then | ||
degree = "fourth" | degree = "fourth" | ||
end | end | ||
| Line 80: | Line 80: | ||
degree = 8 | degree = 8 | ||
end | end | ||
if | if(fifthspan % 7 == 1) then | ||
degree = 5 | degree = 5 | ||
end | end | ||
if | if(fifthspan % 7 == 2) then | ||
degree = 2 | degree = 2 | ||
end | end | ||
if | if(fifthspan % 7 == 3) then | ||
degree = 6 | degree = 6 | ||
end | end | ||
if | if(fifthspan % 7 == 4) then | ||
degree = 3 | degree = 3 | ||
end | end | ||
if | if(fifthspan % 7 == 5) then | ||
degree = 7 | degree = 7 | ||
end | end | ||
if | if(fifthspan % 7 == 6) then | ||
degree = 4 | degree = 4 | ||
end | end | ||
| Line 108: | Line 108: | ||
end | end | ||
function p.tuningMin(fifthspan,oct) | |||
tuningx2 = p.degreeAsNumber(fifthspan,oct) - 1 | |||
tuningx1 = 0 | |||
if(degree == 2) then | |||
tuningx1 = 1 | |||
end | |||
if(degree == 3) then | |||
tuningx1 = 2 | |||
end | |||
if(degree == 4) then | |||
tuningx1 = 3 | |||
end | |||
if(degree == 5) then | |||
tuningx1 = 3 | |||
end | |||
if(degree == 6) then | |||
tuningx1 = 4 | |||
end | |||
if(degree == 7) then | |||
tuningx1 = 5 | |||
end | |||
if(degree == 8) then | |||
tuningx1 = 5 | |||
end | |||
tuningx1 = tuningx1 + math.floor(fifthspan/7) | |||
return math.min(tuningx1, tuningx2) | |||
end | |||
function p.tuningMax(fifthspan,oct) | |||
tuningx2 = p.degreeAsNumber(fifthspan,oct) - 1 | |||
tuningx1 = 0 | |||
if(degree == 2) then | |||
tuningx1 = 1 | |||
end | |||
if(degree == 3) then | |||
tuningx1 = 2 | |||
end | |||
if(degree == 4) then | |||
tuningx1 = 3 | |||
end | |||
if(degree == 5) then | |||
tuningx1 = 3 | |||
end | |||
if(degree == 6) then | |||
tuningx1 = 4 | |||
end | |||
if(degree == 7) then | |||
tuningx1 = 5 | |||
end | |||
if(degree == 8) then | |||
tuningx1 = 5 | |||
end | |||
tuningx1 = tuningx1 + math.floor(fifthspan/7) | |||
if(tuningx1*240 > tuningx2*(1200/7)) then | |||
return tuningx1 | |||
else | |||
return tuningx2 | |||
end | |||
end | |||
return p | |||
Revision as of 07:59, 16 December 2025
Documentation for this module may be created at Module:Diatonic/doc
local yesno = require("Module:Yesno")
local p = {}
function p.qualityAsName(fifthspan, oct)
quality = "minor"
if(fifthspan>0) then
quality = "major" end
if(fifthspan<2 and fifthspan>-2) then
quality = "perfect"
end
if(fifthspan>5) then
quality = "augmented"
end
if(fifthspan>12) then
quality = "double augmented" end
if(fifthspan>19) then
quality = "triple augmented" end
if(fifthspan<-5) then
quality = "diminished" end
if(fifthspan<-12) then
quality = "double diminished" end
if(fifthspan<-19) then
quality = "triple diminished" end
return quality
end
function p.qualityAsLetter(fifthspan, oct)
quality = "m"
if(fifthspan>0) then
quality = "M" end
if(fifthspan<2 and fifthspan>-2) then
quality = "P"
end
if(fifthspan>5) then
quality = "A"
end
if(fifthspan>12) then
quality = "AA" end
if(fifthspan>19) then
quality = "3A" end
if(fifthspan<-5) then
quality = "d" end
if(fifthspan<-12) then
quality = "dd" end
if(fifthspan<-19) then
quality = "3d" end
return quality
end
function p.degreeAsName(fifthspan,oct)
degree = "unison"
if((yesno(oct) and fifthspan == 0) or fifthspan < 0) then
degree = "octave"
end
if(fifthspan % 7 == 1) then
degree = "fifth"
end
if(fifthspan % 7 == 2) then
degree = "second"
end
if(fifthspan % 7 == 3) then
degree = "sixth"
end
if(fifthspan % 7 == 4) then
degree = "third"
end
if(fifthspan % 7 == 5) then
degree = "seventh"
end
if(fifthspan % 7 == 6) then
degree = "fourth"
end
return degree
end
function p.degreeAsNumber(fifthspan,oct)
degree = 1
if((yesno(oct) and fifthspan == 0) or fifthspan < 0) then
degree = 8
end
if(fifthspan % 7 == 1) then
degree = 5
end
if(fifthspan % 7 == 2) then
degree = 2
end
if(fifthspan % 7 == 3) then
degree = 6
end
if(fifthspan % 7 == 4) then
degree = 3
end
if(fifthspan % 7 == 5) then
degree = 7
end
if(fifthspan % 7 == 6) then
degree = 4
end
return degree
end
function p.enharmonic(fifthspan)
if((yesno(oct) and fifthspan == 0) or fifthspan < 0) then
return (fifthspan+12)
end
return(fifthspan-12)
end
function p.tuningMin(fifthspan,oct)
tuningx2 = p.degreeAsNumber(fifthspan,oct) - 1
tuningx1 = 0
if(degree == 2) then
tuningx1 = 1
end
if(degree == 3) then
tuningx1 = 2
end
if(degree == 4) then
tuningx1 = 3
end
if(degree == 5) then
tuningx1 = 3
end
if(degree == 6) then
tuningx1 = 4
end
if(degree == 7) then
tuningx1 = 5
end
if(degree == 8) then
tuningx1 = 5
end
tuningx1 = tuningx1 + math.floor(fifthspan/7)
return math.min(tuningx1, tuningx2)
end
function p.tuningMax(fifthspan,oct)
tuningx2 = p.degreeAsNumber(fifthspan,oct) - 1
tuningx1 = 0
if(degree == 2) then
tuningx1 = 1
end
if(degree == 3) then
tuningx1 = 2
end
if(degree == 4) then
tuningx1 = 3
end
if(degree == 5) then
tuningx1 = 3
end
if(degree == 6) then
tuningx1 = 4
end
if(degree == 7) then
tuningx1 = 5
end
if(degree == 8) then
tuningx1 = 5
end
tuningx1 = tuningx1 + math.floor(fifthspan/7)
if(tuningx1*240 > tuningx2*(1200/7)) then
return tuningx1
else
return tuningx2
end
end
return p
