Module:MOS intervals: Difference between revisions

Ganaram inukshuk (talk | contribs)
No edit summary
Ganaram inukshuk (talk | contribs)
Added support for mos prefixes, added option to use ordinals (as 5L 2s uses ordinal names)
Line 1: Line 1:
local mos = require('Module:MOS')
local mos = require('Module:MOS')
local rat = require('Module:Rational')
local rat = require('Module:Rational')
local mosnot = require('Module:MOS notation')
local p = {}
local p = {}


Line 62: Line 63:
-- Get the scale sig
-- Get the scale sig
local scale_sig = mos.as_string(input_mos)
local scale_sig = mos.as_string(input_mos)
-- Is there a mos prefix? Should ordinals be used?
-- For 5L 2s, that would be no to prefixes and yes to ordinals, by default.
-- For any other mos, that would be yes to prefixes and no to ordinals, by
-- default. The default prefix is "mos".
local mos_prefix = "mos"
local use_ordinals = false
if scale_sig == "5L 2s" then
use_ordinals = true
mos_prefix = ""
end
if string.len(frame.args['Interval Notation']) > 0 then
use_ordinals = frame.args['Interval Notation'] == "ordinals"
end
if frame.args['MOS Prefix'] == "NONE" then
mos_prefix = ""
elseif string.len(frame.args['MOS Prefix']) > 0 then
mos_prefix = frame.args['MOS Prefix']
end
-- Create the table, starting with the headers
-- Create the table, starting with the headers
Line 78: Line 98:
-- First row is the unison
-- First row is the unison
result = result .. "|-\n"
result = result .. "|-\n"
result = result .. "|'''0-mosstep (unison)'''\n"
if use_ordinals and mos_prefix == "" then
result = result .. "|'''1st (unison)'''\n"
elseif use_ordinals and mos_prefix ~= "" then
result = result .. "|'''" .. mos_prefix .. "-1st (unison)'''\n"
else
result = result .. "|'''0-" .. mos_prefix .. "step (unison)'''\n"
end
result = result .. "|0\n"
result = result .. "|0\n"
result = result .. "|Perfect\n"
result = result .. "|Perfect\n"
Line 100: Line 126:
result = result .. "|-\n"
result = result .. "|-\n"
if i % steps_per_period == steps_per_bright_gen and not is_nL_ns then
if i % steps_per_period == steps_per_bright_gen and not is_nL_ns then
result = result .. "|'''" .. i .. "-mosstep'''\n"
if use_ordinals and mos_prefix == "" then
result = result .. "|'''" .. mosnot.ordinal_number(i + 1) .. "'''\n"
elseif use_ordinals and mos_prefix ~= "" then
result = result .. "|'''" .. mos_prefix .. "-" .. mosnot.ordinal_number(i + 1) .. "'''\n"
else
result = result .. "|'''" .. i .. "-" .. mos_prefix .. "step'''\n"
end
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, i) .. "\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, i) .. "\n"
result = result .. "|Perfect\n"
result = result .. "|Perfect\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(darkest_mode, i) .. "\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(darkest_mode, i) .. "\n"
result = result .. "|Diminished\n"
result = result .. "|Diminished\n"
elseif i % steps_per_period == steps_per_dark_gen and not is_nL_ns then
elseif i % steps_per_period == steps_per_dark_gen and not is_nL_ns then
result = result .. "|'''" .. i .. "-mosstep'''\n"
if use_ordinals and mos_prefix == "" then
result = result .. "|'''" .. mosnot.ordinal_number(i + 1) .. "'''\n"
elseif use_ordinals and mos_prefix ~= "" then
result = result .. "|'''" .. mos_prefix .. "-" .. mosnot.ordinal_number(i + 1) .. "'''\n"
else
result = result .. "|'''" .. i .. "-" .. mos_prefix .. "step'''\n"
end
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, i) .. "\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, i) .. "\n"
result = result .. "|Augmented\n"
result = result .. "|Augmented\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(darkest_mode, i) .. "\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(darkest_mode, i) .. "\n"
result = result .. "|Perfect\n"
result = result .. "|Perfect\n"
elseif i % steps_per_period == 0 and i ~= mossteps_per_equave then
elseif i % steps_per_period == 0 and i ~= mossteps_per_equave then
result = result .. "|'''" .. i .. "-mosstep (period)'''\n"
if use_ordinals and mos_prefix == "" then
result = result .. "|'''" .. mosnot.ordinal_number(i + 1) .. "'''\n"
elseif use_ordinals and mos_prefix ~= "" then
result = result .. "|'''" .. mos_prefix .. "-" .. mosnot.ordinal_number(i + 1) .. "'''\n"
else
result = result .. "|'''" .. i .. "-" .. mos_prefix .. "step (period)'''\n"
end
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, i) .. "\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, i) .. "\n"
result = result .. "|Perfect\n"
result = result .. "|Perfect\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(darkest_mode, i) .. "\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(darkest_mode, i) .. "\n"
result = result .. "|Perfect\n"
result = result .. "|Perfect\n"
else
else
result = result .. "|" .. i .. "-mosstep\n"
if use_ordinals and mos_prefix == "" then
result = result .. "|" .. mosnot.ordinal_number(i + 1) .. "\n"
elseif use_ordinals and mos_prefix ~= "" then
result = result .. "|" .. mos_prefix .. "-" .. mosnot.ordinal_number(i + 1) .. "\n"
else
result = result .. "|" .. i .. "-" .. mos_prefix .. "step (period)\n"
end
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, i) .. "\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, i) .. "\n"
result = result .. "|Major\n"
result = result .. "|Major\n"
Line 128: Line 181:
-- Manually add the last row of the table (this is for the equave)
-- Manually add the last row of the table (this is for the equave)
result = result .. "|-\n"
result = result .. "|-\n"
result = result .. "|'''" .. steps_per_equave .. "-mosstep (equave)'''\n"
if use_ordinals and mos_prefix == "" then
result = result .. "|'''" .. mosnot.ordinal_number(steps_per_equave + 1) .. "'''\n"
elseif use_ordinals and mos_prefix ~= "" then
result = result .. "|'''" .. mos_prefix .. "-" .. mosnot.ordinal_number(steps_per_equave + 1) .. "'''\n"
else
result = result .. "|'''" .. steps_per_equave .. "-" .. mos_prefix .. "step "
end
-- Is the equave 2/1?
if rat.eq(input_mos.equave, 2) then
result = result .. "(octave)'''\n"
else
result = result .. "(equave)'''\n"
end
-- Add the last cells
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, steps_per_equave) .. "\n"
result = result .. "|" .. p.mos_interval_to_step_count_string(brightest_mode, steps_per_equave) .. "\n"
result = result .. "|Perfect\n"
result = result .. "|Perfect\n"