Module:MOS gamut: Difference between revisions
Capitalized keys (mossteps and chromas) in accordance to changes to mos notation module |
ArrowHead294 (talk | contribs) mNo edit summary |
||
| Line 1: | Line 1: | ||
local mos = require( | local mos = require("Module:MOS") | ||
local rat = require( | local rat = require("Module:Rational") | ||
local mosm = require( | local mosm = require("Module:MOS modes") | ||
local et = require( | local et = require("Module:ET") | ||
local mosnot = require( | local mosnot = require("Module:MOS notation") | ||
local utils = require( | local utils = require("Module:Utils") | ||
local p = {} | local p = {} | ||
| Line 114: | Line 114: | ||
-- How many esteps are the bright and dark generators? | -- How many esteps are the bright and dark generators? | ||
local bright_gen = mos.bright_gen(input_mos) | local bright_gen = mos.bright_gen(input_mos) | ||
local esteps_per_bright_gen = bright_gen[ | local esteps_per_bright_gen = bright_gen["L"] * num + bright_gen["s"] * den | ||
local esteps_per_dark_gen = esteps_per_period - esteps_per_bright_gen | local esteps_per_dark_gen = esteps_per_period - esteps_per_bright_gen | ||
| Line 125: | Line 125: | ||
-- Convert the notationally agnostic form into a form that uses given notation | -- Convert the notationally agnostic form into a form that uses given notation | ||
local note = ascending_genchain[j][i] | local note = ascending_genchain[j][i] | ||
local note_symbol = string.sub(note_symbols, note[ | local note_symbol = string.sub(note_symbols, note["Mossteps"] + 1, note["Mossteps"] + 1) | ||
local chroma_count = note[ | local chroma_count = note["Chromas"] | ||
local note_name = note_symbol .. string.rep(chroma_plus_symbol, chroma_count) | local note_name = note_symbol .. string.rep(chroma_plus_symbol, chroma_count) | ||
| Line 138: | Line 138: | ||
-- Convert the notationally agnostic form into a form that uses given notation | -- Convert the notationally agnostic form into a form that uses given notation | ||
local note = descending_genchain[j][i] | local note = descending_genchain[j][i] | ||
local note_symbol = string.sub(note_symbols, note[ | local note_symbol = string.sub(note_symbols, note["Mossteps"] + 1, note["Mossteps"] + 1) | ||
local chroma_count = note[ | local chroma_count = note["Chromas"] * -1 | ||
local note_name = note_symbol .. string.rep(chroma_minus_symbol, chroma_count) | local note_name = note_symbol .. string.rep(chroma_minus_symbol, chroma_count) | ||
| Line 161: | Line 161: | ||
function p.mos_gamut_frame(frame) | function p.mos_gamut_frame(frame) | ||
-- Default parameters for input mos and step ratio (5L 2s and 2:1 step ratio) | -- Default parameters for input mos and step ratio (5L 2s and 2:1 step ratio) | ||
local input_mos_unparsed = frame.args[ | local input_mos_unparsed = frame.args["Scale Signature"] | ||
local input_mos = mos.parse(input_mos_unparsed) or mos.new(2, 5, 2) | local input_mos = mos.parse(input_mos_unparsed) or mos.new(2, 5, 2) | ||
-- Step ratio | -- Step ratio | ||
local step_ratio = { 2, 1 } | local step_ratio = { 2, 1 } | ||
if string.len(frame.args[ | if string.len(frame.args["Step Ratio"]) > 0 then | ||
step_ratio = mosnot.parse_step_ratio(frame.args[ | step_ratio = mosnot.parse_step_ratio(frame.args["Step Ratio"]) | ||
end | end | ||
| Line 187: | Line 187: | ||
udp = { 5, 1 } | udp = { 5, 1 } | ||
end | end | ||
if string.len(frame.args[ | if string.len(frame.args["UDP"]) > 0 then | ||
udp = mosnot.parse_udp(frame.args[ | udp = mosnot.parse_udp(frame.args["UDP"]) | ||
end | end | ||
local generators_up = udp[1] | local generators_up = udp[1] | ||
| Line 194: | Line 194: | ||
-- Get notation: naturals (or nominals), sharp symbol, and flat symbol | -- Get notation: naturals (or nominals), sharp symbol, and flat symbol | ||
local notation_default = { [ | local notation_default = { ["Naturals"] = string.sub("JKLMNOPQRSTUVWXYZ", 1, mossteps_per_equave), ["Sharp"] = "&", ["Flat"] = "@" } | ||
if scale_sig == "5L 2s" then | if scale_sig == "5L 2s" then | ||
notation_default[ | notation_default["Naturals"] = "CDEFGAB" | ||
notation_default[ | notation_default["Sharp"] = "#" | ||
notation_default[ | notation_default["Flat"] = "b" | ||
end | end | ||
local notation = mosnot.parse_notation(frame.args[ | local notation = mosnot.parse_notation(frame.args["Notation"]) or notation_default | ||
local note_symbols = notation[ | local note_symbols = notation["Naturals"] | ||
local chroma_plus_symbol = notation[ | local chroma_plus_symbol = notation["Sharp"] | ||
local chroma_minus_symbol = notation[ | local chroma_minus_symbol = notation["Flat"] | ||
-- Get the gamut | -- Get the gamut | ||