Module:MOS notation: Difference between revisions

Ganaram inukshuk (talk | contribs)
m Fixed bug with generating degree name for multi-diminished mosdegrees (rep took in a negative value)
Ganaram inukshuk (talk | contribs)
m Clarified comments, renamed params; genchain_length_per_period -> chain_length_per_period, refers to the number of elements in the resulting chain rather than generators stacked from the root
Line 96: Line 96:
-- 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?
-- - upd_gens_per_period - This is either the value u or d for the UDP of up|dp, and is
--  This is either the value u or d for the UDP of up|dp.
--  used to calculate the number of initial notes that don't have accidentals.
-- - genchain_length_per_period - how many generators should the genchain extend after the root?
--   Note that this is per period, so it's necessary to "simplify" the UDP like a fraction.
-- - chain_length_per_period - the number of notes in the resulting chain. NOTE: if working
--   in terms of "generators stacked after the root", add 1 to that value.
-- - 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_nomacc_chain(input_mos, genchain_init_per_period, genchain_length_per_period, going_up)
function p.mos_nomacc_chain(input_mos, upd_gens_per_period, chain_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 genchain_init_per_period = genchain_init_per_period or 5
local upd_gens_per_period = upd_gens_per_period or 5
local genchain_length_per_period = genchain_length_per_period or 14
local chain_length_per_period = chain_length_per_period or 14
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 155: Line 157:
-- Create the genchain
-- Create the genchain
local genchain = { }
local genchain = { }
for j = 1, genchain_length_per_period do
for j = 1, chain_length_per_period do


-- Convert the accumulator into an index
-- Convert the accumulator into an index
Line 162: Line 164:
-- Add accidentals
-- Add accidentals
-- This is negative if the genchain is descending
-- This is negative if the genchain is descending
-- The genchain_init_per_period refers to the value u (or d for descending chains) in
-- The upd_gens_per_period refers to the value u (or d for descending chains) in
-- the UDP of up|dp. The first u notes reached by stacking up that many generators from the
-- the UDP of up|dp. The first u notes reached by stacking up that many generators from the
-- root don't have accidentals, but the number of notes that don't have accidentals
-- root don't have accidentals, but the number of notes that don't have accidentals
-- is actually u+1, since the root doesn't have accidentals either.
-- is actually u+1, since the root doesn't have accidentals either.
local accidentals_to_add = 0
local accidentals_to_add = 0
if j > genchain_init_per_period + 1 then
if j > upd_gens_per_period + 1 then
accidentals_to_add = math.ceil((j - genchain_init_per_period - 1) / mossteps_per_period)
accidentals_to_add = math.ceil((j - upd_gens_per_period - 1) / mossteps_per_period)
end
end
if not going_up then
if not going_up then
Line 193: Line 195:
end
end


-- Helper function that converts a scale degree given as a quantity of mossteps
-- Helper function that decodes a scale degree given as a quantity of mossteps
-- and a numeric quality (0=perf, 1=maj, -1=min, 2=aug, -2=dim, etc) into a
-- and a numeric quality (0=perf, 1=maj, -1=min, 2=aug, -2=dim, etc) into a
-- scale degree
-- scale degree
Line 290: Line 292:
-- The following name rules are followed, and numeric values described above are used:
-- The following name rules are followed, and numeric values described above are used:
-- - If an interval is the period (including the unison and equave), then the quality is perfect.
-- - If an interval is the period (including the unison and equave), then the quality is perfect.
-- - If an interval class is the bright gen, then the qualities are perfect (large size) and diminished (small size).
-- - For all other intervals, there are two sizes of major (large size) and minor (small size).
-- - If an interval class is the dark gen, then the qualities are augmented (large size) and perfect (small size).
-- - For bright generators of non-nL-ns mosses, the sizes are perfect and diminished instead.
-- - For all other intervals and for generators of an nL ns mos, then the qualities are major (large size) and minor (small size).
-- - For dark generators of non-nL-ns mosses, the sizes are augmented and perfect instead.
-- - Alterations indicate raising the large size or lowering the small size by a chroma, and are also denoted numerically.
-- - Generators of nL ns mosses use the terms major and minor instead.
-- - Intervals whose large and small sizes feature already-augmented/diminished intervals will have the proper values to denote 2x-augmented and 2x-diminished intervals.
-- - Alterations denote raising a large interval by a chroma, or lowering a small interval by a chroma.
--  For example, a dark gen has a large size of augmented, so altering it by adding a chroma makes it 2x-augmented.
--   Since non-nL-ns mosses have augmented dark gen and diminished bright gen already, alterations
function p.mos_degree_chain(input_mos, genchain_length_per_period, going_up)
--  for those are 2x-augmented and 2x-diminished intervals; these are encoded accoringly.
-- Params are as follows:
-- - input_mos: the input mos itself
-- - chain_length_per_period: the number of degrees in the resulting chain.  
--  NOTE: if working in terms of "generators stacked after the root", add 1 to that value.
-- - going_up - whether the chain is built on stacking up or down; true for up, false for down
function p.mos_degree_chain(input_mos, chain_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 genchain_length_per_period = genchain_length_per_period or 10
local chain_length_per_period = chain_length_per_period or 10
local going_up = false
local going_up = false
]]--
]]--
Line 318: Line 326:
local chain_for_period = {}
local chain_for_period = {}


for i = 1, genchain_length_per_period do
for i = 1, chain_length_per_period do
-- Calculate mossteps
-- Calculate mossteps