Module:MOS intervals: Difference between revisions

ArrowHead294 (talk | contribs)
mNo edit summary
Ganaram inukshuk (talk | contribs)
Removed harmonic entropy, as it's now in its own template
Line 3: Line 3:
local et = require("Module:ET")
local et = require("Module:ET")
local tamnams = require("Module:TAMNAMS")
local tamnams = require("Module:TAMNAMS")
local interval_extension = require("Module:Interval_extension")
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 32: Line 29:
local bright_gen_step_count = mos.bright_gen_step_count(input_mos)
local bright_gen_step_count = mos.bright_gen_step_count(input_mos)
local dark_gen_step_count = mos.dark_gen_step_count(input_mos)
local dark_gen_step_count = mos.dark_gen_step_count(input_mos)
-- Setup for harmonic entropy
local step_ratios = {
{ 4, 3 },
{ 3, 2 },
{ 5, 3 },
{ 2, 1 },
{ 5, 2 },
{ 3, 1 },
{ 4, 1 },
}
-- Create the table
-- Create the table
Line 57: Line 43:
.. "!! rowspan=\"2\" | Steps subtended"
.. "!! rowspan=\"2\" | Steps subtended"
.. "!! rowspan=\"2\" | Range in cents"
.. "!! rowspan=\"2\" | Range in cents"
.. "!! rowspan=\"2\" | Average of [[HE]]<br/>(from [http://www.mikebattagliamusic.com/HE-JS/HE.html HE Calc])\n"
.. "!! rowspan=\"2\" | Min of [[HE]]\n"
.. "|-\n" -- Start of second row of header cells
.. "|-\n" -- Start of second row of header cells
.. "! Generic"
.. "! Generic"
Line 83: Line 67:
.. string.format("|| %s " , mos.interval_as_string(current_bright_interval))
.. 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))
else
else
-- Calculate the best and average harmonic entropies
local he_dark_average = 0
local he_bright_average = 0
local he_dark_best = 1000
local he_bright_best = 1000
for i = 1, #step_ratios do
local step_ratio = step_ratios[i]
local he_dark = interval_extension.harmonic_entropy_with_lookup_table(mos.interval_to_cents(current_dark_interval, input_mos, step_ratio))
local he_bright = interval_extension.harmonic_entropy_with_lookup_table(mos.interval_to_cents(current_bright_interval, input_mos, step_ratio))
he_dark_average = he_dark_average + he_dark / #step_ratios
he_bright_average = he_bright_average + he_bright / #step_ratios
if he_dark_best > he_dark then
he_dark_best = he_dark
end
if he_bright_best > he_bright then
he_bright_best = he_bright
end
end
-- Calculate the cent values min and max for the current intervals
-- Calculate the cent values min and max for the current intervals
local sm_min_cents = mos.interval_to_cents(current_dark_interval, input_mos, {1,1})
local sm_min_cents = mos.interval_to_cents(current_dark_interval, input_mos, {1,1})
Line 122: Line 85:
.. string.format("|| %s " , mos.interval_as_string(current_dark_interval))
.. 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\n" , he_dark_best)
.. "|-\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))
Line 129: Line 90:
.. string.format("|| %s " , mos.interval_as_string(current_bright_interval))
.. 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_best)
end
end
result = result .. "\n"
result = result .. "\n"