Module:MOS tuning spectrum: Difference between revisions
No edit summary |
Ratios -> Step Ratios; adopt mos module functions |
||
| Line 1: | Line 1: | ||
local MOS = require("Module: | local mos = require("Module:MOS") | ||
local rat = require("Module:Rational") | |||
local ET = require("Module:ET") | local ET = require("Module:ET") | ||
local mediants = require("Module:Mediants") | local mediants = require("Module:Mediants") | ||
local tip = require("Module:Template input parse") | |||
local utils = require("Module:Utils") | local utils = require("Module:Utils") | ||
local yesno = require("Module:yesno") | local yesno = require("Module:yesno") | ||
| Line 14: | Line 15: | ||
default_ratios, default_depths = mediants.find_mediants({{1,1}, {1,0}}, default_depth); | default_ratios, default_depths = mediants.find_mediants({{1,1}, {1,0}}, default_depth); | ||
local input_mos = args["Input MOS"] or | local input_mos = args["Input MOS"] or mos.new(5, 2) | ||
local depth = args["Depth"] or 5 | local depth = args["Depth"] or 5 | ||
local comments = args["Comments"] or {} | local comments = args["Comments"] or {} | ||
local step_ratios = args["Ratios"] or default_ratios | local step_ratios = args["Step Ratios"] or default_ratios | ||
local depths = args["Depths"] or default_depths | local depths = args["Depths"] or default_depths | ||
| Line 24: | Line 25: | ||
local s = input_mos.ns -- Small steps in mos | local s = input_mos.ns -- Small steps in mos | ||
local n = utils._gcd(L, s) -- Number of periods | local n = utils._gcd(L, s) -- Number of periods | ||
-- What is the equave suffix (edo, edt, edf, ed-p/q) | -- What is the equave suffix (edo, edt, edf, ed-p/q) | ||
| Line 40: | Line 40: | ||
-- Default comments for TAMNAMS-named step ratios | -- Default comments for TAMNAMS-named step ratios | ||
local default_comments = {} | local default_comments = {} | ||
local mos_as_string = | local mos_as_string = mos.as_string(input_mos) | ||
default_comments["1/1"] = string.format("'''Equalized %s'''", mos_as_string) | default_comments["1/1"] = string.format("'''Equalized %s'''", mos_as_string) | ||
default_comments["4/3"] = string.format("'''Supersoft %s'''", mos_as_string) | default_comments["4/3"] = string.format("'''Supersoft %s'''", mos_as_string) | ||
| Line 63: | Line 63: | ||
comments_header_text = comments_header_text .. "<sup><abbr title=\"Every tuning produces a proper scale.\">(always proper)</abbr></sup>" | comments_header_text = comments_header_text .. "<sup><abbr title=\"Every tuning produces a proper scale.\">(always proper)</abbr></sup>" | ||
elseif s == n and n > 1 then | elseif s == n and n > 1 then | ||
comments_header_text = comments_header_text .. "<sup><abbr title=\"Every true- | comments_header_text = comments_header_text .. "<sup><abbr title=\"Every true-mos tuning produces a proper scale.\">(always proper)</abbr></sup>" | ||
end | end | ||
| Line 90: | Line 90: | ||
for i = 1, #step_ratios do | for i = 1, #step_ratios do | ||
local step_ratio = step_ratios[i] | local step_ratio = step_ratios[i] | ||
local et = mos.mos_to_et(mos, step_ratio) | |||
local et = | |||
-- Calculate the bright gen and cent value | -- Calculate the bright gen and cent value | ||
local bright_generator_steps = step_ratio | local bright_generator_steps = mos.bright_gen_to_et_steps(input_mos, step_ratio) | ||
local bright_generator_cents = | local bright_generator_cents = mos.bright_gen_to_cents(input_mos, step_ratio) | ||
-- Calculate dark generator step count and cent value | -- Calculate dark generator step count and cent value | ||
local dark_generator_steps = | local dark_generator_steps = mos.dark_gen_to_et_steps(input_mos, step_ratio) | ||
local dark_generator_cents = | local dark_generator_cents = mos.dark_gen_to_cents(input_mos, step_ratio) | ||
-- New row | -- New row | ||
| Line 155: | Line 153: | ||
-- Parse scalesig | -- Parse scalesig | ||
local input_mos = | local input_mos = mos.parse(args["Scale Signature"]) | ||
args["Input MOS"] = input_mos | args["Input MOS"] = input_mos | ||
args["Scale Signature"] = nil | args["Scale Signature"] = nil | ||
| Line 163: | Line 161: | ||
args["Depth"] = tonumber(args["Depth"]) | args["Depth"] = tonumber(args["Depth"]) | ||
-- | -- Parse initial ratios | ||
local | local first_ratio = args["First Step Ratio"] or {1,1} | ||
local last_ratio = args["Last Step Ratio" ] or {1,0} | |||
args["Ratios"] = | |||
-- Then generate mediants and depths | |||
local step_ratios, depths | |||
step_ratios, depths = mediants.find_mediants({first_ratio, last_ratio}, depth) | |||
args["Step Ratios"] = step_ratios | |||
args["Depths"] = depths | args["Depths"] = depths | ||
-- Transfer comments from args to comments | -- Transfer comments from args to comments | ||
local comments = {} | local comments = {} | ||
for i = 1, # | for i = 1, #step_ratios do | ||
local key = | local key = step_ratios[i][1] .. "/" .. step_ratios[i][2] | ||
if args[key] ~= nil then | if args[key] ~= nil then | ||
comments[key] = args[key] | comments[key] = args[key] | ||