Module:Interval table: Difference between revisions

CompactStar (talk | contribs)
No edit summary
CompactStar (talk | contribs)
No edit summary
Line 6: Line 6:
local ET = require('Module:ET')
local ET = require('Module:ET')


-- Auto-generated list of monzos of 13-limit ratios with numerator and denominator < 50 and within the range 1/1 - 5/1
local monzos_list = {
{0,1,-1,1,0,0},
{0,-1,2,-1,0,0},
{4,0,0,-1,0,0},
{1,-1,0,-1,0,1},
{0,1,1,0,0,-1},
{2,-2,0,1,0,0},
{4,-2,0,0,0,0},
{0,0,1,1,-1,0},
{0,0,0,2,0,-1},
{0,-1,-1,2,0,0},
{0,-2,-1,2,0,0},
{-2,0,0,0,1,0},
{0,-3,0,2,0,0},
{-4,-1,0,2,0,0},
{0,1,1,0,-1,0},
{0,-1,0,2,0,-1},
{2,0,-2,0,1,0},
{0,0,0,2,-1,0},
{2,1,-1,0,0,0},
{-1,3,0,-1,0,0},
{3,1,-1,0,0,0},
{3,-1,0,0,0,0},
{1,2,-1,0,0,0},
{-3,-1,0,2,0,0},
{0,3,0,0,-1,0},
{-5,1,0,0,1,0},
{-2,0,0,0,0,1},
{2,0,0,0,0,0},
{2,-1,-1,0,1,0},
{5,-1,-1,0,0,0},
{1,0,0,0,1,-1},
{4,1,-1,-1,0,0},
{-3,-1,1,1,0,0},
{2,-1,0,0,0,0},
{-5,0,0,2,0,0},
{2,1,0,0,-1,0},
{5,0,0,-1,0,0},
{-1,1,0,0,0,0},
{1,1,1,-1,0,0},
{1,1,0,1,-1,0},
{-1,0,2,-1,0,0},
{5,-2,0,0,0,0},
{-3,0,0,0,0,1},
{0,-1,0,1,0,0},
{4,0,-1,0,0,0},
{-4,0,2,0,0,0},
{1,0,-2,0,0,1},
{3,1,0,-1,0,0},
{-1,3,0,0,0,-1},
{0,1,0,1,0,-1},
{0,1,-2,0,0,1},
{-1,0,0,2,-1,0},
{-2,0,0,2,-1,0},
{-3,1,0,0,1,0},
{2,-1,0,-1,1,0},
{-1,3,0,0,-1,0},
{2,-3,0,0,1,0},
{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{-2,-2,0,2,0,0},
{3,0,1,0,0,-1},
{-3,0,-1,2,0,0},
{1,2,0,-1,0,0},
{1,1,0,1,0,-1},
{0,0,0,0,0,0},
{1,-1,-1,0,1,0},
{3,0,1,0,-1,0},
{-1,2,1,0,-1,0},
{-2,2,1,0,-1,0},
{1,1,-1,0,0,0},
{-1,0,0,1,0,0},
{-2,0,0,1,0,0},
{-1,-1,0,0,1,0},
{1,0,0,1,0,-1},
{5,-3,0,0,0,0},
{0,1,-2,0,1,0},
{-1,0,0,2,0,-1},
{0,-2,2,0,0,0},
{1,-1,-1,0,0,1},
{-1,1,0,-1,0,1},
{0,-1,0,0,0,1},
{0,-2,0,0,0,1},
{-2,1,0,-1,0,1},
{1,0,0,1,-1,0},
{2,-1,-1,1,0,0},
{-1,-1,2,0,0,0},
{-2,-1,2,0,0,0},
{-1,-2,2,0,0,0},
{-4,1,0,0,0,1},
{0,2,-1,0,0,0},
{-3,2,0,0,0,0},
{5,-1,0,-1,0,0},
{1,-1,0,-1,1,0},
{-3,0,1,1,0,0},
{-4,1,0,1,0,0},
{0,0,1,1,0,-1},
{3,-1,1,0,-1,0}
}
local function gcd(a, b)
local function gcd(a, b)
return b==0 and a or gcd(b,a%b)
return b==0 and a or gcd(b,a%b)
Line 250: Line 18:
     end
     end
     return found
     return found
end
-- Generates list of ratios up to a max numerator & denominator, and max ratio size
local function get_ratios_list(max_nd, max_size)
local ratios = {}
local ratio_strings = {}
for i=1,max_nd do
for j=1,max_nd do
t = i/gcd(i,j) .. "/" .. j/gcd(i,j)
if (i/j) >= 1 and (i/j) <= max_size and not table_contains(ratio_strings, t) then
ratios[#ratios + 1] = {i/gcd(i,j),j/gcd(i,j)}
ratio_strings[#ratio_strings + 1] = t
end
end
end
return ratios
end
end


Line 269: Line 54:
local dual_flat_fifth = ET.approximate(et, 3/2, -1)
local dual_flat_fifth = ET.approximate(et, 3/2, -1)
local dual_sharp_fifth = ET.approximate(et, 3/2, 1)
local dual_sharp_fifth = ET.approximate(et, 3/2, 1)
local ratios_list = get_ratios_list(40, 6)


wikitext = wikitext .. '!Steps\n'
wikitext = wikitext .. '!Steps\n'
Line 301: Line 87:
-- In approximate ratios column, show all ratios in the list that are within 1/3 of ET size (33.3 relative cents)
-- In approximate ratios column, show all ratios in the list that are within 1/3 of ET size (33.3 relative cents)
if math.abs(ET.cents(et, i) - (math.log(n/d)/math.log(2)) * 1200) <= (400 / et.size) then
if math.abs(ET.cents(et, i) - (math.log(n/d)/math.log(2)) * 1200) <= (400 / et.size) then
wikitext = wikitext .. '[[' .. n .. '/' .. d .. ']]' .. ', '
wikitext = wikitext .. '[[' .. n .. '/' .. d .. ']]' .. ' '
end
end
end
end
wikitext = wikitext:sub(0, -2) .. '\n'
wikitext = wikitext .. '\n'
end
end