function db_to_y (db, h)
-- y-axis gain mapping
- if db < -48 then db = -48 end
+ if db < -60 then db = -60 end
if db > 12 then db = 12 end
return -.5 + round (0.2 * h) - h * db / 60
end
end
-- calc height of inline display
- local h = math.ceil (w * 10 / 16) -- use 16:10 aspect
+ local h = 1 | math.ceil (w * 9 / 16) -- use 16:9 aspect, odd number of y pixels
if (h > max_h) then h = max_h end -- but at most max-height
-- ctx is a http://cairographics.org/ context
ctx:rectangle (0, 0, w, h)
ctx:set_source_rgba (.2, .2, .2, 1.0)
ctx:fill ()
+ ctx:rectangle (0, 0, w, h)
+ ctx:clip ();
-- set line width: 1px
-- Note: a cairo pixel at [1,1] spans [0.5->1.5 , 0.5->1.5]