[tuxdroid-svn] r752 - in software/gadgets/sound_monitor/trunk: . audio_monitor audio_monitor/Script
Status: Beta
Brought to you by:
ks156
Author: Paul_R Date: 2007-12-06 11:29:13 +0100 (Thu, 06 Dec 2007) New Revision: 752 Modified: software/gadgets/sound_monitor/trunk/audio_monitor.tgf software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/conf/other.glade software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/conf/other.pyp software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/widget/other.pyp software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/main.pyp software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/notify.pyp software/gadgets/sound_monitor/trunk/audio_monitor/Strings/fr_ALL.xml software/gadgets/sound_monitor/trunk/audio_monitor/about.xml software/gadgets/sound_monitor/trunk/audio_monitor/settings.xml software/gadgets/sound_monitor/trunk/audio_monitor/strings.xml Log: * Added two line in the graph when events occurs. * Added a file chooser to specify where the .wav files must be stored. Modified: software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/conf/other.glade =================================================================== (Binary files differ) Modified: software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/conf/other.pyp =================================================================== --- software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/conf/other.pyp 2007-12-05 16:28:39 UTC (rev 751) +++ software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/conf/other.pyp 2007-12-06 10:29:13 UTC (rev 752) @@ -1,4 +1,6 @@ bindtextdomain("params", "") +import commands +import os class Window(SimpleGladeApp): def __init__(self, @@ -9,16 +11,27 @@ def new(self): - self.measure = _me.get_param('measure') self.updates_commons() - def updates_commons(self): - txt = "%s : %s" % (_me.string('name_to_read'), - _me.string('gui_conf_window_title')) + txt = "%s : %s" % (_me.string('name_to_read'), _me.string('gui_conf_window_title')) self.get_widget("window1").set_title(txt) - - + self.get_widget('lblLocation').set_label(_me.string('Location')) + self.get_widget('spinSample').set_value(_me.get_param('Sample')) + self.get_widget('lblSample').set_label(_me.string('lblSample')) + if os.path.exists(_me.get_param('Path')): + self.get_widget('fileChooser').set_current_folder(_me.get_param('Path')) + else: + user = commands.getoutput('echo $USER') + self.get_widget('fileChooser').set_current_folder('/home/%s'%user) + _me.set_param('Path', self.get_widget('fileChooser').get_current_folder()) + + def on_fileChooser_current_folder_changed(self, widget, *args): + _me.set_param('Path', widget.get_current_folder()) + + def on_spinSample_changed(self, widget, *args): + _me.set_param('Sample', float(widget.get_text())) + ########################################################### # # On cancel button clicked @@ -35,7 +48,5 @@ # ########################################################### def on_accept_clicked(self, widget, *args): - _me.set_var('notify_delay', int(self.get_widget("delay_spinbutton").get_value())) - self.get_widget("window1").destroy() Modified: software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/widget/other.pyp =================================================================== --- software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/widget/other.pyp 2007-12-05 16:28:39 UTC (rev 751) +++ software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/GUI/widget/other.pyp 2007-12-06 10:29:13 UTC (rev 752) @@ -45,12 +45,12 @@ self.get_widget('chkDogDefault').set_label(_me.string('at_gui_widget_chkDogDefault')) self.get_widget('chkDogDefault').set_active(_me.get_param('chkDogDefault')) - self.get_widget('spinDog').set_value(_me.get_param('spinDog')) + self.get_widget('spinDog').set_value(_me.get_param('DogThreshold')) self.get_widget('chkSpy').set_label(_me.string('at_gui_widget_chkSpy')) self.get_widget('chkSpy').set_active(_me.get_param('chkSpy')) - self.get_widget('spinSpy').set_value(_me.get_param('spinSpy')) + self.get_widget('spinSpy').set_value(_me.get_param('SpyThreshold')) self.get_widget('lblDogLevel').set_text(_me.string('at_gui_widget_lblDogLevel')) self.get_widget('lblSpyLevel').set_text(_me.string('at_gui_widget_lblSpyLevel')) @@ -99,7 +99,14 @@ self.measure.graph_measure = self.graph self.measure.refresh_treeview = self.refresh_treeview self.graph.measure = self.measure - + + if os.path.exists(_me.get_param('Path')): + self.measure.capture_path = _me.get_param('Path') + else: + user = commands.getoutput('echo $USER') + self.measure.capture_path = '/home/%s'%user + _me.set_param('Path', 'home/%s'%user) + self.monitor_id = tux.monitoring.insert(0xF0, self.measure.on_sound_level) tux.micro.on() self.update_value() @@ -139,7 +146,7 @@ def read_sound(self, widget): soundcard = tux.hw.alsa_device tux.micro.off() - tux.sys.shell("aplay -D %s /tmp/__tux-record%d.wav"%(soundcard, self.selected_file)) + tux.sys.shell("aplay -D %s %s/__tux-record%d.wav"%(soundcard, self.measure.capture_path,self.selected_file)) tux.micro.on() ########################################################### @@ -148,8 +155,7 @@ # ########################################################### def on_window1_destroy(self, widget, *args): - if self.measure.num > 1: - os.system('rm /tmp/__tux-record*') + pass def on_cbbType_changed(self, widget, *args): if self.get_widget('cbbType').get_active() == 0: @@ -161,9 +167,11 @@ def on_spinbutton1_changed(self, widget, *args): self.measure.dog_threshold = float(widget.get_text()) + _me.set_param('DogThreshold', float(widget.get_text())) def on_spinbutton2_changed(self, widget, *args): self.measure.spy_threshold = float(widget.get_text()) + _me.set_param('SpyThreshold', float(widget.get_text())) def on_chkSpy_toggled(self, widget, *args): _me.set_param('chkSpy', widget.get_active()) @@ -294,21 +302,36 @@ #and trace the curce self.context.set_line_width(0.6) self.context.set_source_rgb(0.9, 0.6,0) - self.context.move_to(self.rect.x - 2, self.rect.height + 2) + self.context.move_to(self.rect.x - 2, self.rect.height / 2) self.context.line_to(self.rect.x, self.rect.height - (self.measure.val_table_pos[0] * coeff_y)) for i, val in enumerate(self.measure.val_table_pos): - self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height - ((self.measure.RANGE/2 + val) * coeff_y)) + self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height - ((self.measure.RANGE/2 + val) * coeff_y)) self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height + 5) - self.context.move_to(self.rect.x - 2, self.rect.height + 2) + self.context.move_to(self.rect.x - 2, self.rect.height / 2) self.context.line_to(self.rect.x, self.rect.height - (self.measure.val_table_pos[0] * coeff_y)) for i, val in enumerate(self.measure.val_table_pos): self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height - ((self.measure.RANGE/2 - val) * coeff_y)) self.context.line_to(self.rect.x + ((i) * coeff_x), self.rect.height + 5) self.context.stroke() + self.draw_events(coeff_x, coeff_y) - + def draw_events(self, coeff_x, coeff_y): + self.context.set_line_width(2) + for i, val in enumerate(self.measure.event_table): + if val == 1: + self.context.set_source_rgb(1, 0, 0.7) + self.context.move_to(self.rect.x + ((i) * coeff_x), 0) + self.context.line_to(self.rect.x + ((i) * coeff_x), 5) + self.context.stroke() + if val == 2: + self.context.set_source_rgb(1, 0.7, 0) + self.context.move_to(self.rect.x + ((i) * coeff_x), 5) + self.context.line_to(self.rect.x + ((i) * coeff_x), 10) + self.context.stroke() + + def fill(self, coeff_x, coeff_y): #determine the coefficients to adjust the curve in the window space self.context.move_to(self.rect.x - 2, self.rect.height / 2) @@ -334,6 +357,7 @@ self.RANGE = 1024.0 self.sample_backup = self.sample self.val_table_pos = [0] * int(self.sample) + self.event_table = [-1] * int(self.sample) self.dog_threshold = 0 self.spy_threshold = 0 @@ -346,8 +370,10 @@ self.__capture_buffer = [] self.__temp_buffer = [] self.capture_idx = tux.micro.on_buffer.connect(self.__on_capture_buffer) - self.__capture_path = '' + self.capture_path = '' self.num = 1 + self.__start_timeout = True + self.__start_delay = time.time() + 2 self.__capture_start = False self.__stop = False self.__delay_to_stop = time.time() @@ -368,10 +394,14 @@ if self.Increase_control(self.spy_threshold): self.record_sound() - if self.dog_enabled and self.actuator == False: + if self.dog_enabled and self.actuator == False and self.__start_timeout == False: if self.Increase_control(self.dog_threshold): self.notify = True self.actuator = True + + if self.__start_timeout: + if self.__start_delay < time.time(): + self.__start_timeout = False ########################################################### @@ -394,8 +424,17 @@ try: if self.sample_backup != self.sample: self.sample = self.sample_backup - self.val_table_pos = [512] * int(self.sample) + self.val_table_pos = [0] * int(self.sample) + self.event_table = [-1] * int(self.sample) + if self.__capture_start: + self.event_table.append(1) + elif self.actuator: + self.event_table.append(2) + else: + self.event_table.append(-1) + self.event_table.pop(0) + val = (args[1] + args[2] + args[3] + args[4]) self.val_table_pos.append(val) self.val_table_pos.pop(0) @@ -479,7 +518,7 @@ self.__time = act_time[0] + ':' + act_time[1] + ':' + act_time[2] self.__duration = time.time() - self.__capture_path = '/tmp/__tux-record%d.wav'%self.num + self.__capture_path = self.capture_path + '/__tux-record%d.wav'%self.num self.__capture_start = True self.__start_flag = True Modified: software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/main.pyp =================================================================== --- software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/main.pyp 2007-12-05 16:28:39 UTC (rev 751) +++ software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/main.pyp 2007-12-06 10:29:13 UTC (rev 752) @@ -1,28 +1,37 @@ import os +import time def on_standby(): gdg_dict = _me.get_param('dict') for keys in gdg_dict: gadgets[keys].notify.set_active(gdg_dict[keys]) + + gadgets['sound_monitor'].notify.set_active(False) tux.micro.off() tux.cmd.mouth_close() tux.event.on_remote_bt[K_STANDBY] = None tux.monitoring.remove(_me.get_param('monitor_id')) tux.micro.on_buffer.disconnect(_me.get_param('buffer_idx')) + _me.gui('widget').hide_from_main() _me.exit_main_loop() -gdg_dict = {} -for Gdgname in gadgets.keys(): - if Gdgname != 'sound_monitor' and Gdgname != 'Manager': - gdg_dict[Gdgname] = gadgets[Gdgname].get_var('notified') - gadgets[Gdgname].notify.set_active(False) - - -_me.set_param('dict', gdg_dict) -tux.cmd.mouth_open() -tux.event.on_remote_bt[K_STANDBY] = on_standby -_me.gui('widget').show_from_main() -_me.run_main_loop() +def start_gadget(): + gdg_dict = {} + for Gdgname in gadgets.keys(): + if Gdgname != 'sound_monitor' and Gdgname != 'Manager': + gdg_dict[Gdgname] = gadgets[Gdgname].get_var('notified') + gadgets[Gdgname].notify.set_active(False) + + gadgets['sound_monitor'].notify.set_active(True) + + tux.cmd.mouth_open() + _me.set_param('dict', gdg_dict) + tux.event.on_remote_bt[K_STANDBY] = on_standby + _me.gui('widget').show_from_main() + _me.run_main_loop() + +start_gadget() + Modified: software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/notify.pyp =================================================================== --- software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/notify.pyp 2007-12-05 16:28:39 UTC (rev 751) +++ software/gadgets/sound_monitor/trunk/audio_monitor/Scripts/Python/notify.pyp 2007-12-06 10:29:13 UTC (rev 752) @@ -1,4 +1,4 @@ -def notify_checker(): +def notify_checker(): if _me.get_param('measure'): measure = _me.get_param('measure') if measure.notify: @@ -16,7 +16,7 @@ for i in range(5): tux.cmd.sound_play(14) tux.sys.wait(0.7) - tux.sys.wait(1) + tux.sys.wait(0.5) else: path = _me.get_param('dogBehavior') if os.path.exists(path) and os.path.isfile(path): Modified: software/gadgets/sound_monitor/trunk/audio_monitor/Strings/fr_ALL.xml =================================================================== --- software/gadgets/sound_monitor/trunk/audio_monitor/Strings/fr_ALL.xml 2007-12-05 16:28:39 UTC (rev 751) +++ software/gadgets/sound_monitor/trunk/audio_monitor/Strings/fr_ALL.xml 2007-12-06 10:29:13 UTC (rev 752) @@ -1,24 +1,26 @@ <?xml version='1.0' encoding='UTF-8'?> <strings> - <at_gui_widget_lblSpyLevel type='str'>Spy level</at_gui_widget_lblSpyLevel> + <at_gui_widget_lblSpyLevel type='str'>Niveau</at_gui_widget_lblSpyLevel> + <at_gui_widget_chkDog type='str'>Activer le mode chien de garde</at_gui_widget_chkDog> + <at_gui_conf_label13 type='str'>Delay (sec) :</at_gui_conf_label13> + <at_gui_conf_label12 type='str'>Updates</at_gui_conf_label12> + <help_text type='str'> + </help_text> + <vr_Sound type='str'>Sound</vr_Sound> <Play type='str'>Lecture</Play> - <at_gui_widget_cbbRecord type='str'>Sons enregistrés</at_gui_widget_cbbRecord> <at_gui_widget_cbbDog type='str'>Chien de garde</at_gui_widget_cbbDog> - <name_to_read type='str'>Moniteur de son</name_to_read> <at_gui_conf_label6 type='str'>Cancel</at_gui_conf_label6> <at_gui_conf_label5 type='str'>Accept</at_gui_conf_label5> - <at_gui_widget_chkDog type='str'>Activer le mode chien de garde</at_gui_widget_chkDog> - <at_gui_widget_lblDogLevel type='str'>Dog level</at_gui_widget_lblDogLevel> - <Duration type='str'>Durée</Duration> + <at_gui_widget_chkDogDefault type='str'>Utiliser un script :</at_gui_widget_chkDogDefault> + <at_gui_widget_lblDogLevel type='str'>Niveau</at_gui_widget_lblDogLevel> <Time type='str'>Heure</Time> - <at_gui_conf_label13 type='str'>Delay (sec) :</at_gui_conf_label13> - <at_gui_conf_label12 type='str'>Updates</at_gui_conf_label12> - <File type='str'>Fichier</File> - <at_gui_widget_chkDogDefault type='str'>Utiliser un script :</at_gui_widget_chkDogDefault> - <help_text type='str'> - </help_text> <at_gui_widget_cbbSpy type='str'>Mode espion</at_gui_widget_cbbSpy> <speaker_name type='str'>Bruno8k</speaker_name> - <vr_Sound type='str'>Sound</vr_Sound> + <at_gui_widget_cbbRecord type='str'>Sons enregistrés</at_gui_widget_cbbRecord> + <name_to_read type='str'>Moniteur de son</name_to_read> + <File type='str'>Fichier</File> <at_gui_widget_chkSpy type='str'>Activer le mode espion</at_gui_widget_chkSpy> + <Duration type='str'>Durée</Duration> + <lblSample type='str'>Nombre de points : </lblSample> + <Location type='str'>Selectionner ou les sons doivent être sauvés.</Location> </strings> Modified: software/gadgets/sound_monitor/trunk/audio_monitor/about.xml =================================================================== --- software/gadgets/sound_monitor/trunk/audio_monitor/about.xml 2007-12-05 16:28:39 UTC (rev 751) +++ software/gadgets/sound_monitor/trunk/audio_monitor/about.xml 2007-12-06 10:29:13 UTC (rev 752) @@ -1,8 +1,8 @@ <?xml version='1.0' encoding='UTF-8'?> <about> - <gadget_name type='str'>sound_monitor</gadget_name> - <gadget_author type='str'>Paul Rathgeb</gadget_author> <gadget_description type='str'> </gadget_description> + <gadget_author type='str'>Paul Rathgeb</gadget_author> + <gadget_name type='str'>sound_monitor</gadget_name> <gadget_version type='str'>0.0.1</gadget_version> </about> Modified: software/gadgets/sound_monitor/trunk/audio_monitor/settings.xml =================================================================== --- software/gadgets/sound_monitor/trunk/audio_monitor/settings.xml 2007-12-05 16:28:39 UTC (rev 751) +++ software/gadgets/sound_monitor/trunk/audio_monitor/settings.xml 2007-12-06 10:29:13 UTC (rev 752) @@ -1,15 +1,16 @@ <?xml version='1.0' encoding='UTF-8'?> <settings> <parameters> - <spinDog type='int'>30</spinDog> <chkDogBehavior type='bool'>False</chkDogBehavior> + <SpyThreshold type='int'>30</SpyThreshold> <MainScript type='str'>None</MainScript> <chkSpy type='bool'>False</chkSpy> <chkDog type='bool'>True</chkDog> - <Sample type='float'>600.0</Sample> + <Sample type='float'>400.0</Sample> <chkSpyRecord type='bool'>False</chkSpyRecord> <chkDogDefault type='bool'>False</chkDogDefault> - <spinSpy type='int'>40</spinSpy> + <Path type='str'>None</Path> + <DogThreshold type='int'>30</DogThreshold> </parameters> <general> <have_settings_part type='bool'>True</have_settings_part> @@ -25,7 +26,7 @@ </gui_state> <language type='str'>en_US</language> <notified type='bool'>True</notified> - <notify_delay type='int'>10</notify_delay> + <notify_delay type='int'>1</notify_delay> <framework_version type='str'>0.0.0</framework_version> <menu_active type='bool'>True</menu_active> <have_widget_part type='bool'>False</have_widget_part> Modified: software/gadgets/sound_monitor/trunk/audio_monitor/strings.xml =================================================================== --- software/gadgets/sound_monitor/trunk/audio_monitor/strings.xml 2007-12-05 16:28:39 UTC (rev 751) +++ software/gadgets/sound_monitor/trunk/audio_monitor/strings.xml 2007-12-06 10:29:13 UTC (rev 752) @@ -1,24 +1,26 @@ <?xml version='1.0' encoding='UTF-8'?> <strings> <at_gui_widget_lblSpyLevel type='str'>Level</at_gui_widget_lblSpyLevel> + <at_gui_widget_chkDog type='str'>Enable the guard dog mode</at_gui_widget_chkDog> + <at_gui_conf_label13 type='str'>Delay (sec) :</at_gui_conf_label13> + <Location type='str'>Select where the file must be stored.</Location> + <help_text type='str'> + </help_text> + <vr_Sound type='str'>Sound</vr_Sound> <Play type='str'>Play</Play> - <at_gui_widget_cbbRecord type='str'>Recorded files</at_gui_widget_cbbRecord> <at_gui_widget_cbbDog type='str'>Guard dog mode</at_gui_widget_cbbDog> - <name_to_read type='str'>Audio monitor</name_to_read> <at_gui_conf_label6 type='str'>Cancel</at_gui_conf_label6> <at_gui_conf_label5 type='str'>Accept</at_gui_conf_label5> - <at_gui_widget_chkDog type='str'>Enable the guard dog mode</at_gui_widget_chkDog> + <at_gui_widget_chkDogDefault type='str'>Use an external script</at_gui_widget_chkDogDefault> <at_gui_widget_lblDogLevel type='str'>Level</at_gui_widget_lblDogLevel> - <Duration type='str'>Duration</Duration> <Time type='str'>Hour</Time> - <at_gui_conf_label13 type='str'>Delay (sec) :</at_gui_conf_label13> - <at_gui_conf_label12 type='str'>Updates</at_gui_conf_label12> + <at_gui_widget_cbbSpy type='str'>Spy mode</at_gui_widget_cbbSpy> + <speaker_name type='str'>Ryan8k</speaker_name> + <at_gui_widget_cbbRecord type='str'>Recorded files</at_gui_widget_cbbRecord> + <name_to_read type='str'>Audio monitor</name_to_read> <File type='str'>File</File> <at_gui_widget_chkSpy type='str'>Enable the spy mode</at_gui_widget_chkSpy> - <help_text type='str'> - </help_text> - <at_gui_widget_cbbSpy type='str'>Spy mode</at_gui_widget_cbbSpy> - <vr_Sound type='str'>Sound</vr_Sound> - <at_gui_widget_chkDogDefault type='str'>Use an external script</at_gui_widget_chkDogDefault> - <speaker_name type='str'>Ryan8k</speaker_name> + <Duration type='str'>Duration</Duration> + <lblSample type='str'>Sample : </lblSample> + <at_gui_conf_label12 type='str'>Updates</at_gui_conf_label12> </strings> Modified: software/gadgets/sound_monitor/trunk/audio_monitor.tgf =================================================================== (Binary files differ) |