Module:Mediants: Difference between revisions
Created page with "local mos = require("Module:MOS") local p = {} function p.find_mediants_by_depth(start_ratio_1, start_ratio_2, depth) local start_ratio_1 = start_ratio_1 or {1, 1} local st..." |
m Comments, testing |
||
| Line 1: | Line 1: | ||
local mos = require("Module:MOS") | local mos = require("Module:MOS") | ||
local p = {} | local p = {} | ||
-- Module for finding mediants, either by search depth or by search function. | |||
function p.find_mediants_by_depth(start_ratio_1, start_ratio_2, depth) | function p.find_mediants_by_depth(start_ratio_1, start_ratio_2, depth) | ||
| Line 47: | Line 49: | ||
if num_den_sum <= max_sum then | if num_den_sum <= max_sum then | ||
new_ratio_added = true | new_ratio_added = true | ||
table.insert(ratios, mediant) | table.insert(ratios, mediant) | ||
| Line 101: | Line 83: | ||
local func = p.int_limit_filter | local func = p.int_limit_filter | ||
local ratios = p.find_mediants_by_filter({1,1}, {1,0}, func, | local ratios = p.find_mediants_by_filter({1,1}, {1,0}, func, 15) | ||
local generators = {} | local generators = {} | ||
for i = 1, #ratios do | for i = 1, #ratios do | ||
local input_mos = mos.new(5,2) | local input_mos = mos.new(5,2) | ||
local gen = mos.bright_gen_to_cents(input_mos, ratios[i]) | local gen = mos.bright_gen_to_cents(input_mos, ratios[i]) | ||
local | local edo = ratios[i][1] * 5 + ratios[i][2] * 2 | ||
local new_string = string.format("%s:%s\t%sedo\t%.3f", ratios[i][1], ratios[i][2], edo, gen) | |||
table.insert(generators, new_string) | |||
end | end | ||