Module:MOS interval HE: Difference between revisions

Ganaram inukshuk (talk | contribs)
Created page with "local mos = require("Module:MOS") local rat = require("Module:Rational") local et = require("Module:ET") local tamnams = require("Module:TAMNAMS") local interval_extension = r..."
 
Ganaram inukshuk (talk | contribs)
Stripped down to mainly harmonic entropy
Line 6: Line 6:
local yesno = require("Module:Yesno")
local yesno = require("Module:Yesno")
local p = {}
local p = {}
-- TODO:
-- - Move harmonic entropy to separate module/template pair????


-- Main function; to be called by wrapper
-- Main function; to be called by wrapper
Line 54: Line 51:
-- Create table headers
-- Create table headers
result = result
result = result
.. "! colspan=\"3\" | Intervals"
.. "! Interval"
.. "!! rowspan=\"2\" | Steps subtended"
.. "!! Range in cents"
.. "!! rowspan=\"2\" | Range in cents"
.. "!! Average of [[HE]]<br/>(from [http://www.mikebattagliamusic.com/HE-JS/HE.html HE Calc])\n"
.. "!! rowspan=\"2\" | Average of [[HE]]<br/>(from [http://www.mikebattagliamusic.com/HE-JS/HE.html HE Calc])\n"
.. "!! Min of [[HE]]\n"
.. "!! rowspan=\"2\" | Min of [[HE]]\n"
.. "|-\n" -- Start of second row of header cells
.. "! Generic"
.. "!! Specific"
.. "!! Abbrev.\n"
-- Write each row
-- Write each row
Line 78: Line 70:
result = result .. "|-\n"
result = result .. "|-\n"
.. string.format("| '''%s-%sstep''' ", i - 1, mos_prefix)
.. string.format("|| %s " , tamnams.interval_quality(current_bright_interval, input_mos, "sentence-case", mos_prefix))
.. string.format("|| %s " , tamnams.interval_quality(current_bright_interval, input_mos, "sentence-case", mos_prefix))
.. string.format("|| %s " , tamnams.interval_quality(current_bright_interval, input_mos, "abbrev"      , mos_abbrev))
.. string.format("|| %s " , mos.interval_as_string(current_bright_interval))
.. string.format("|| %.1f¢ ", cents)
.. string.format("|| %.1f¢ ", cents)
.. string.format("|| ~%.4f nats ", interval_extension.harmonic_entropy_with_lookup_table(cents))
.. string.format("|| ~%.4f nats ", interval_extension.harmonic_entropy_with_lookup_table(cents))
Line 117: Line 106:
result = result .. "|-\n"
result = result .. "|-\n"
.. string.format("| rowspan=\"2\" | %s-%sstep ", i - 1, mos_prefix)
.. string.format("|| %s " , tamnams.interval_quality(current_dark_interval, input_mos, "sentence-case", mos_prefix))
.. string.format("|| %s " , tamnams.interval_quality(current_dark_interval, input_mos, "sentence-case", mos_prefix))
.. string.format("|| %s " , tamnams.interval_quality(current_dark_interval, input_mos, "abbrev"      , mos_abbrev))
.. string.format("|| %s " , mos.interval_as_string(current_dark_interval))
.. string.format("|| %s " , dark_interval_range)
.. string.format("|| %s " , dark_interval_range)
.. string.format("|| ~%.4f nats " , he_dark_average)
.. string.format("|| ~%.4f nats " , he_dark_average)
Line 126: Line 112:
.. "|-\n"
.. "|-\n"
.. string.format("| %s "  , tamnams.interval_quality(current_bright_interval, input_mos, "sentence-case", mos_prefix))
.. string.format("| %s "  , tamnams.interval_quality(current_bright_interval, input_mos, "sentence-case", mos_prefix))
.. string.format("|| %s " , tamnams.interval_quality(current_bright_interval, input_mos, "abbrev"      , mos_abbrev))
.. string.format("|| %s " , mos.interval_as_string(current_bright_interval))
.. string.format("|| %s " , bright_interval_range)
.. string.format("|| %s " , bright_interval_range)
.. string.format("|| ~%.4f nats " , he_bright_average)
.. string.format("|| ~%.4f nats " , he_bright_average)
Line 136: Line 120:
result = result .. "|}"
result = result .. "|}"


return result
end
function p.mos_intervals_description(input_mos, mos_prefix)
local input_mos = input_mos or mos.new(5,2)
local mos_prefix = mos_prefix or "dia"
local scalesig = mos.as_string(input_mos)
-- How many periods?
-- What are the period intervals?
local period_count = mos.period_count(input_mos)
local period_interval = mos.period(input_mos)
local period_intervals = {}
for i = 1, period_count + 1 do
local interval = mos.interval_mul(period_interval, i-1)
table.insert(period_intervals, interval)
end
-- As a sentence piece
local period_intervals_as_text = ""
if #period_intervals == 2 then
period_intervals_as_text = string.format("%s and %s", tamnams.interval_quality(period_intervals[1], input_mos, "none", mos_prefix), tamnams.interval_quality(period_intervals[2], input_mos, "none", mos_prefix))
else
for i = 1, period_count do
period_intervals_as_text = period_intervals_as_text
.. string.format("%s, ", tamnams.interval_quality(period_intervals[i], input_mos, "none", mos_prefix))
end
period_intervals_as_text = period_intervals_as_text
.. string.format("and %s", tamnams.interval_quality(period_intervals[period_count + 1], input_mos, "none", mos_prefix))
end
local result = string.format("The intervals of %s are named after the number of mossteps (L and s) they subtend.", scalesig)
local period_interval_desc = ""
if period_count == 1 then
period_interval_desc = "the root and " .. (rat.eq(input_mos.equave, 2) and "octave" or "equave")
else
period_interval_desc = "the period intervals"
end
result = result
.. string.format(" Each interval, apart from %s (%s), has two varieties, or sizes, each.", period_interval_desc, period_intervals_as_text)
result = result
.. " Interval varieties are named major and minor for the large and small sizes, respectively"
.. (input_mos.nL == input_mos.ns and "." or ", and augmented, perfect, and diminished for the scale's generators.")
return result
return result
end
end