Module:MOS gamut: Difference between revisions
Simplified output so it's the gamut by itself |
m Clarified the genchain function's params (genchain_init and genchain_length) is per period |
||
| Line 13: | Line 13: | ||
-- is a single genchain. | -- is a single genchain. | ||
-- This genchain is agnostic of notation, so in standard notation, instead of | -- This genchain is agnostic of notation, so in standard notation, instead of | ||
-- C, C#/Db, D etc, it's denoted as N(0), N(0)+c/N(1)-c, N(1) | -- C, C#/Db, D etc, it's denoted as N(0), N(0)+c/N(1)-c, N(1), etc | ||
-- | -- N(k) is the note name by itself (or the note name reached by going up g mossteps, where | ||
-- how many | -- g is the gen in mossteps) and nc is how many sharps (flats if n is negative) to add | ||
-- Parameters: | -- Parameters: | ||
-- - input_mos - the mos itself represented as a data structure from Module:MOS | -- - input_mos - the mos itself represented as a data structure from Module:MOS | ||
-- - | -- - genchain_init_per_period - how many named pitches per period are there without accidentals added? | ||
-- This is either the value u or d for the UDP of up|dp. | -- This is either the value u or d for the UDP of up|dp. | ||
-- - | -- - genchain_length_per_period - how many generators should the genchain extend after the root? | ||
-- - going_up - bool; whether the genchain is going up or down; true for up, false for down | -- - going_up - bool; whether the genchain is going up or down; true for up, false for down | ||
function p.mos_genchain(input_mos, | function p.mos_genchain(input_mos, genchain_init_per_period, genchain_length_per_period, going_up) | ||
-- Default parameters for testing | -- Default parameters for testing | ||
--[[ | --[[ | ||
local input_mos = input_mos or mos.new(5, 2, 2) | local input_mos = input_mos or mos.new(5, 2, 2) | ||
local | local genchain_init_per_period = genchain_init_per_period or 5 | ||
local | local genchain_length_per_period = genchain_length_per_period or 10 | ||
local note_symbols = note_symbols or "CDEFGAB" | local note_symbols = note_symbols or "CDEFGAB" | ||
local chroma_symbol = chroma_symbol or "#" | local chroma_symbol = chroma_symbol or "#" | ||
| Line 77: | Line 77: | ||
-- Create the rest of the genchain | -- Create the rest of the genchain | ||
for j = 1, | for j = 1, genchain_length_per_period do | ||
-- Increment the index by the generator | -- Increment the index by the generator | ||
accumulator = accumulator + gen_in_mossteps | accumulator = accumulator + gen_in_mossteps | ||
| Line 87: | Line 87: | ||
-- This is negative if the genchain is descending | -- This is negative if the genchain is descending | ||
local accidentals_to_add = 0 | local accidentals_to_add = 0 | ||
if j > | if j > genchain_init_per_period then | ||
accidentals_to_add = math.ceil((j - | accidentals_to_add = math.ceil((j - genchain_init_per_period) / mossteps_per_period) | ||
end | end | ||
if not going_up then | if not going_up then | ||
| Line 201: | Line 201: | ||
end | end | ||
-- How long are the genchains? | -- How long are the genchains? Length is per period | ||
local ascending_genchain_length = gens_up_per_period + genchain_extend | local ascending_genchain_length = gens_up_per_period + genchain_extend | ||
local descending_genchain_length = gens_down_per_period + genchain_extend | local descending_genchain_length = gens_down_per_period + genchain_extend | ||