Module:Interval table: Difference between revisions
CompactStar (talk | contribs) No edit summary |
CompactStar (talk | contribs) No edit summary |
||
| Line 5: | Line 5: | ||
local ud = require('Module:Ups and downs notation') | local ud = require('Module:Ups and downs notation') | ||
local ET = require('Module:ET') | local ET = require('Module:ET') | ||
-- Create list of ratios up to a max numerator & denominator, and max ratio size | |||
local function get_ratios_list(max_nd, max_size) | |||
local ratios = {} | |||
for i=1,max_nd do | |||
for j=1,max_nd do | |||
if i/j >= 1 and i/j <= max_size then | |||
ratios.append({i,j}) | |||
end | |||
end | |||
end | |||
return ratios | |||
end | |||
-- Utility fuunction to get specific note name with ud.get_note_names_table | |||
-- (this is essentially what "Template:Ups and downs note name" does) | |||
local function ud_note(et, fifth, step) | local function ud_note(et, fifth, step) | ||
| Line 20: | Line 36: | ||
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(50, 6) | |||
wikitext = wikitext .. '!Steps\n' | wikitext = wikitext .. '!Steps\n' | ||
| Line 28: | Line 45: | ||
wikitext = wikitext .. '![[Ups and downs notation]]<br>(dual sharp fifth ' .. dual_sharp_fifth .. '\\' .. et.size .. ')\n' | wikitext = wikitext .. '![[Ups and downs notation]]<br>(dual sharp fifth ' .. dual_sharp_fifth .. '\\' .. et.size .. ')\n' | ||
else | else | ||
wikitext = wikitext .. '![[Ups and downs notation]]\n' | |||
wikitext = wikitext .. '![[Ups and downs notation]]\n' | wikitext = wikitext .. '![[Ups and downs notation]]\n' | ||
end | end | ||
end | end | ||
wikitext = wikitext .. '!Approximate ratios\n' | |||
for i=0,et.size do | for i=0,et.size do | ||
| Line 43: | Line 63: | ||
wikitext = wikitext .. '|' .. ud_note(et, fifth, i) .. '\n' | wikitext = wikitext .. '|' .. ud_note(et, fifth, i) .. '\n' | ||
end | end | ||
end | |||
wikitext = wikitext .. '|' | |||
for j=1,ratios_list.size do | |||
local n = ratios_list[j][1] | |||
local d = ratios_list[j][2] | |||
-- Show all ratios within 1/3 of ET size in approximate ratios | |||
if math.abs(et.size - u._cents(n/d)) <= (et.size/3) then | |||
wikitext = wikitext .. '[[' .. n .. '/' .. d .. ']]' .. ', ' | |||
end | |||
wikitext = wikitext:slice(0, -2) .. '\n' | |||
end | end | ||
end | end | ||
wikitext = wikitext .. '|}' | wikitext = wikitext .. '|}' | ||