aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMaZderMind <git@mazdermind.de>2016-01-29 23:42:28 +0100
committerMaZderMind <git@mazdermind.de>2016-01-29 23:42:28 +0100
commit542f76422f9cca033803203f47b47c11aa3d2305 (patch)
treec85e77eae1dfa53b66635ca4a3ff0f784a757003
parentb7ff4eae91b010e29f03a68e842bb342fd65480c (diff)
add some more niceness to the audiolevel
-rw-r--r--voctogui/lib/audioleveldisplay.py28
1 files changed, 22 insertions, 6 deletions
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):