Module:Diatonic

From Xenharmonic Reference
Revision as of 07:28, 16 December 2025 by Vector (talk | contribs) (Created page with "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(fifthsp...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

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(math.fmod(fifthspan,7) == 1) then
    degree = "fifth"
  end
  if(math.fmod(fifthspan,7) == 2) then
    degree = "second"
  end
  if(math.fmod(fifthspan,7) == 3) then
    degree = "sixth"
  end
  if(math.fmod(fifthspan,7) == 4) then
    degree = "third"
  end
  if(math.fmod(fifthspan,7) == 5) then
    degree = "seventh"
  end
  if(math.fmod(fifthspan,7) == 6) then
    degree = "fourth"
  end
  return degree
end

function p.degreeAsNumber(fifthspan,oct)
  degree = "unison"
  if((yesno(oct) and fifthspan == 0) or fifthspan < 0) then
    degree = "octave" 
  end
  if(math.fmod(fifthspan,7) == 1) then
    degree = "fifth"
  end
  if(math.fmod(fifthspan,7) == 2) then
    degree = "second"
  end
  if(math.fmod(fifthspan,7) == 3) then
    degree = "sixth"
  end
  if(math.fmod(fifthspan,7) == 4) then
    degree = "third"
  end
  if(math.fmod(fifthspan,7) == 5) then
    degree = "seventh"
  end
  if(math.fmod(fifthspan,7) == 6) then
    degree = "fourth"
  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