-- Set up an empty table for duration statistics local durationstatistics = {} for e in eachentry(finenv.Region()) do if e:IsNote() then if durationstatistics[e.Duration] == nil then -- No statistics exists for this duration - create a counter durationstatistics[e.Duration] = 1 else -- Increase the counter for this duration durationstatistics[e.Duration] = durationstatistics[e.Duration] + 1 end end end -- A look-up table for durations. -- Add other values to the table if necessary (can be added as number values as well). -- Quarter Note is 1024, Dotted Quarter Note is 1536, etc local durationtable = { [finale.EIGHTH_NOTE] = "8th Notes", [finale.QUARTER_NOTE] = "Quarter Notes", [finale.HALF_NOTE] = "Half Notes", [finale.WHOLE_NOTE] = "Hole Notes" } -- Report the statistics sorted by duration for key, value in pairsbykeys(durationstatistics) do if durationtable[key] == nil then -- Not a duration with a known "text version" - output EDU value instead print("EDU duration", key, ":", value) else print(durationtable[key], ":", value) end end