From 542f76422f9cca033803203f47b47c11aa3d2305 Mon Sep 17 00:00:00 2001 From: MaZderMind Date: Fri, 29 Jan 2016 23:42:28 +0100 Subject: add some more niceness to the audiolevel --- voctogui/lib/audioleveldisplay.py | 28 ++++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) (limited to 'voctogui/lib') diff --git a/voctogui/lib/audioleveldisplay.py b/voctogui/lib/audioleveldisplay.py index ed62313..1d91d35 100644 --- a/voctogui/lib/audioleveldisplay.py +++ b/voctogui/lib/audioleveldisplay.py @@ -36,25 +36,41 @@ class AudioLevelDisplay(object): cr.set_line_width(channel_width) for y in range(0, height): - pct = y / height + pct = self.clamp(((y / height) - 0.6) / 0.42, 0, 1) for channel in range(0, channels): x = (channel * channel_width) + (channel * margin) bright = 0.25 - if y < rms_px[channel]: + if int(y - decay_px[channel]) in range(0, 2): + bright = 1.5 + elif y < rms_px[channel]: bright = 1 - # elif abs(y - peak_px[channel]) < 3: - # bright = 1.5 - elif y < decay_px[channel]: + elif y < peak_px[channel]: bright = 0.75 - cr.set_source_rgb(pct * bright, (1-pct) * bright, 0 * bright) + cr.set_source_rgb(pct * bright, (1-pct) * bright * 0.75, 0 * bright) cr.move_to(x, height-y) cr.line_to(x + channel_width, height-y) cr.stroke() + cr.set_source_rgb(0,0,0) + cr.move_to(x + channel_width, height-y) + cr.line_to(x + channel_width + margin, height-y) + cr.stroke() + + cr.set_source_rgb(1, 1, 1) + for db in [-40, -20, -10, -5, -4, -3, -2, -1]: + text = str(db) + xbearing, ybearing, textwidth, textheight, xadvance, yadvance = ( + cr.text_extents(text)) + + y = self.normalize_db(db) * height + cr.move_to((width-textwidth) / 2, height - y - textheight) + cr.show_text(text) + + return True def normalize_db(self, db): -- cgit v1.2.3