Skip to content

Commit

Permalink
Bug fixed doing long recordings, vumeter problem
Browse files Browse the repository at this point in the history
  • Loading branch information
Hugo Caloto committed Jan 13, 2014
1 parent f8077a5 commit 6384a71
Showing 1 changed file with 25 additions and 17 deletions.
42 changes: 25 additions & 17 deletions galicaster/classui/audiobar.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def __init__(self):
self.set_homogeneous(True)
self.mute = False
self.vumeter=gtk.ProgressBar()

self.rangeVum = 40
#numbers
label0 = gtk.Label("0 dB")
label1 = gtk.Label("-3")
Expand All @@ -39,14 +39,14 @@ def __init__(self):
label4 = gtk.Label("-24")
label5 = gtk.Label("-40")

# set number's colour
label0.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#D9211D")) #Red
label1.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#D95E1D")) #Orange
label2.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#D95E1D")) #Orange
label3.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#068629")) #Green
label4.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#068629")) #Green
label5.modify_fg(gtk.STATE_NORMAL, gtk.gdk.color_parse("#068629")) #Green

# set number's colour
self.modify_widget_fgcolor (label0, gtk.gdk.color_parse("#D9211D")) # Red
self.modify_widget_fgcolor (label1, gtk.gdk.color_parse("#D95E1D")) # Orange
self.modify_widget_fgcolor (label2, gtk.gdk.color_parse("#D95E1D")) # Orange
self.modify_widget_fgcolor (label3, gtk.gdk.color_parse("#068629")) # Green
self.modify_widget_fgcolor (label4, gtk.gdk.color_parse("#068629")) # Green
self.modify_widget_fgcolor (label5, gtk.gdk.color_parse("#068629")) # Green
labels= [label0,label1,label2,label3,label4,label5]
for label in labels:
label.set_justify(gtk.JUSTIFY_CENTER)
Expand Down Expand Up @@ -90,7 +90,7 @@ def ClearVumeter(self):
self.vumeter.set_fraction(0)

def scale_vumeter(self,data):
rangeVum = 40

data_aux = data
conf = context.get_conf()
dispatcher = context.get_dispatcher()
Expand All @@ -99,11 +99,11 @@ def scale_vumeter(self,data):
if data == "Inf":
valor = 0
else:
if data < -rangeVum:
data = -rangeVum
if data < -self.rangeVum:
data = -self.rangeVum
elif data > 0:
data = 0
valor=(data+rangeVum)/float(rangeVum)
valor=(data+self.rangeVum)/float(self.rangeVum)
if not self.mute:
if data_aux == "Inf" or data_aux < minimum:
dispatcher.emit("audio-mute")
Expand All @@ -113,6 +113,13 @@ def scale_vumeter(self,data):
self.mute = False
return valor


def modify_widget_fgcolor(self, widget, color):
widget.modify_fg(gtk.STATE_NORMAL, color)
widget.modify_fg(gtk.STATE_ACTIVE, color)
widget.modify_fg(gtk.STATE_PRELIGHT, color)
widget.modify_fg(gtk.STATE_SELECTED, color)

class AudioBarClass(gtk.Box):
"""
Status Information of Galicaster
Expand All @@ -132,6 +139,7 @@ def __init__(self, vertical = False):
box.pack_end(self.volume,False,True,0)
builder.connect_signals(self)
self.vumeter=builder.get_object("vumeter")
self.rangeVum = 40

def GetVumeter(self):
return self.vumeter.get_fraction()
Expand All @@ -144,14 +152,14 @@ def ClearVumeter(self):
self.vumeter.set_fraction(0)

def scale_vumeter(self,data):
rangeVum = 40

if data == "Inf":
data = -100
elif data < -rangeVum:
data = -rangeVum
elif data < -self.rangeVum:
data = -self.rangeVum
elif data > 0:
data = 0
valor = (data+rangeVum)/float(rangeVum)
valor = (data+self.rangeVum)/float(self.rangeVum)
return valor

def resize(self,size):
Expand Down

0 comments on commit 6384a71

Please sign in to comment.