Module:MOS degrees: Difference between revisions
No edit summary |
all bugs fixed hopefully |
||
| Line 39: | Line 39: | ||
-- To be used in conjunction with the genchain function | -- To be used in conjunction with the genchain function | ||
function p.mosstep_and_chroma_to_note_name(mossteps, chromas, note_symbol, chroma_symbol) | function p.mosstep_and_chroma_to_note_name(mossteps, chromas, note_symbol, chroma_symbol) | ||
local note_name = note_symbol | local note_name = note_symbol .. string.rep(chroma_symbol, math.abs(chromas)) | ||
return note_name | return note_name | ||
end | end | ||
| Line 68: | Line 63: | ||
degree_name = "Diminished " .. degree_name | degree_name = "Diminished " .. degree_name | ||
elseif quality < -2 then | elseif quality < -2 then | ||
degree_name = (math.abs(quality) - 1) .. "× diminished" .. degree_name | degree_name = (math.abs(quality) - 1) .. "× diminished " .. degree_name | ||
end | end | ||
| Line 183: | Line 178: | ||
-- Format the result as a table | -- Format the result as a table | ||
function p.mos_degrees_frame(frame) | function p.mos_degrees_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 = mos.parse(frame.args['Scale Signature']) or mos.new(2, 5, 2) | local input_mos = mos.parse(frame.args['Scale Signature']) or mos.new(2, 5, 2) | ||
| Line 236: | Line 230: | ||
chroma_minus_symbol = frame.args['Flat Symbol'] | chroma_minus_symbol = frame.args['Flat Symbol'] | ||
end | end | ||
--[[ | |||
-- Override values for testing | -- Override values for testing | ||
local input_mos = mos.new(5, 2, 2) | local input_mos = mos.new(5, 2, 2) | ||
| Line 245: | Line 239: | ||
local chroma_plus_symbol = "#" | local chroma_plus_symbol = "#" | ||
local chroma_minus_symbol = "b" | local chroma_minus_symbol = "b" | ||
]]-- | |||
-- Get the number of mossteps per period and equave | -- Get the number of mossteps per period and equave | ||
| Line 304: | Line 299: | ||
-- raising any other root by one period. Repeat for all other periods. | -- raising any other root by one period. Repeat for all other periods. | ||
-- For the last period, add the perfect root as the perfect equave. | -- For the last period, add the perfect root as the perfect equave. | ||
local test_output | |||
for i = 1, periods_per_equave do | for i = 1, periods_per_equave do | ||
-- Add degrees from ascending chain | -- Add degrees from ascending chain | ||
for j = 1, | for j = 1, asc_chain_length do | ||
local note = asc_genchain[i][j] | local note = asc_genchain[i][j] | ||
local mossteps = note['mossteps'] | local mossteps = note['mossteps'] | ||
| Line 313: | Line 309: | ||
-- Find the note name | -- Find the note name | ||
local | local note_symbol = string.sub(note_symbols, mossteps + 1, mossteps + 1) | ||
local note_name = p.mosstep_and_chroma_to_note_name(mossteps, chromas, note_symbol, chroma_plus_symbol) | |||
-- Find the degree name | -- Find the degree name | ||
-- If the degree is the 0-mosdegree, say it's the unison instead | -- If the degree is the 0-mosdegree, say it's the unison instead | ||
local degree_name = p.mosstep_and_quality_to_degree(mossteps, quality) | local degree_name = p.mosstep_and_quality_to_degree(mossteps, quality) | ||
degree_name = degree_name:gsub("0-mosstep", "unison") | if mossteps == 0 then | ||
degree_name = degree_name:gsub("0-mosstep", "unison") | |||
end | |||
-- Find the estep count | -- Find the estep count | ||
local estep_count = ((j - 1) * esteps_per_bright_gen) % esteps_per_period + ( | local estep_count = ((j - 1) * esteps_per_bright_gen) % esteps_per_period + (i - 1) * esteps_per_period | ||
-- Find the cent value | -- Find the cent value | ||
| Line 333: | Line 332: | ||
-- on whether this is the last period or not | -- on whether this is the last period or not | ||
local stop_value = 1 | local stop_value = 1 | ||
if i | if i ~= periods_per_equave then | ||
stop_value = stop_value + 1 | stop_value = stop_value + 1 | ||
end | end | ||
-- Add degrees from descending chain | -- Add degrees from descending chain | ||
for j = | for j = des_chain_length, stop_value, -1 do | ||
local note = des_genchain[i][j] | local note = des_genchain[i][j] | ||
local mossteps = note['mossteps'] | local mossteps = note['mossteps'] | ||
local chromas = note['chromas'] | local chromas = note['chromas'] | ||
local quality = | local quality = des_degrees[i][j]['quality'] | ||
-- Find the note name | -- Find the note name | ||
-- If the mosstep is the root of the period, add a period to it | -- If the mosstep is the root of the period, add a period to it | ||
local note_symbol = string.sub(note_symbols, mossteps + 1, mossteps + 1) | |||
if mossteps % mossteps_per_period == 0 then | if mossteps % mossteps_per_period == 0 then | ||
mossteps = mossteps + mossteps_per_period | mossteps = mossteps + mossteps_per_period | ||
end | end | ||
local note_name = p.mosstep_and_chroma_to_note_name(mossteps, chromas, | local note_name = p.mosstep_and_chroma_to_note_name(mossteps, chromas, note_symbol, chroma_minus_symbol) | ||
-- Find the degree name | -- Find the degree name | ||
-- If the degree corresponds to the equave, say it's the equave | -- If the degree corresponds to the equave, say it's the equave | ||
local degree_name = p.mosstep_and_quality_to_degree(mossteps, quality) | local degree_name = p.mosstep_and_quality_to_degree(mossteps, quality) | ||
local equave_degree_name = (input_mos.nL + input_mos.ns) .. "-mosstep" | local equave_degree_name = "" .. (input_mos.nL + input_mos.ns) .. "-mosstep" | ||
-- Find the estep count | -- Find the estep count | ||
local estep_count = ((j - 1) * esteps_per_dark_gen) % esteps_per_period + ( | local estep_count = ((j - 1) * esteps_per_dark_gen) % esteps_per_period + (i - 1) * esteps_per_period | ||
-- Find the cent value | -- Find the cent value | ||