Module:MOS gamut: Difference between revisions
Genchain function now produces a genchain that is agnostic of notation; the other functions provide notation if none was passed in |
m Simplified names, so it's note['Nk'] and note['nc'] instead of note.index and note.chroma |
||
| Line 73: | Line 73: | ||
--local root = string.sub(note_names, 1, 1) | --local root = string.sub(note_names, 1, 1) | ||
--local genchain = { root } | --local genchain = { root } | ||
local root = { | local root = { ['Nk'] = 0, ['nc'] = 0 } | ||
local genchain = { root } | local genchain = { root } | ||
| Line 94: | Line 94: | ||
end | end | ||
-- Get the final note name | -- Get the final note name N(k)+nc | ||
local note_name = { | local note_name = {} | ||
note_name | note_name['Nk'] = index -- The N(k) in N(k) notation | ||
note_name | note_name['nc'] = accidentals_to_add -- How many chromas to add or subtract | ||
-- Add the note name | -- Add the note name | ||
| Line 113: | Line 113: | ||
function p.mos_gamut(input_mos, generators_up, step_ratio, note_symbols, chroma_plus_symbol, chroma_minus_symbol) | function p.mos_gamut(input_mos, generators_up, step_ratio, note_symbols, chroma_plus_symbol, chroma_minus_symbol) | ||
-- 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 = input_mos or mos.new(5, | local input_mos = input_mos or mos.new(5, 2, 2) | ||
local step_ratio = step_ratio or { 2, 1 } | local step_ratio = step_ratio or { 2, 1 } | ||
| Line 229: | Line 229: | ||
-- 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['Nk'] + 1, note['Nk'] + 1) | ||
local chroma_count = note | local chroma_count = note['nc'] | ||
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 242: | Line 242: | ||
-- 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['Nk'] + 1, note['Nk'] + 1) | ||
local chroma_count = note | local chroma_count = note['nc'] * -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) | ||