From 8a3ead822acdea362a191959b8fe0708ced6dc0e Mon Sep 17 00:00:00 2001 From: Chrys Date: Wed, 3 Aug 2016 02:26:44 +0200 Subject: [PATCH] polish sound --- config/sound/default/soundicons.conf | 4 ++-- .../commands/commands/toggle_braille_enable.py | 4 ++-- .../commands/commands/toggle_output_enable.py | 4 ++-- .../commands/commands/toggle_sound_enable.py | 5 +++-- .../commands/commands/toggle_speech_enable.py | 4 ++-- ...5000-read_line_if_cursor_change_vertical.py | 6 +++--- .../commands/onInput/70000-speak_incomming.py | 2 +- .../onScreenChanged/70000-speak_incomming.py | 2 +- src/fenrir-package/core/outputManager.py | 18 +++++++++--------- src/fenrir-package/core/runtime.py | 1 + src/fenrir-package/core/screenData.py | 2 ++ src/fenrir-package/core/settingsManager.py | 1 - src/fenrir-package/screen/linux.py | 5 ++++- src/fenrir-package/sound/sox.py | 2 +- 14 files changed, 33 insertions(+), 27 deletions(-) diff --git a/config/sound/default/soundicons.conf b/config/sound/default/soundicons.conf index 57398d1d..5c780cda 100644 --- a/config/sound/default/soundicons.conf +++ b/config/sound/default/soundicons.conf @@ -26,8 +26,8 @@ SpeechOff='SpeechOff.opus' BrailleOn='BrailleOn.opus' BrailleOff='BrailleOff.opus' # SoundIcons has turned On or Off -SoundIconsOn='SoundIconsOn.opus' -SoundIconsOff='SoundIconsOff.opus' +SoundOn='SoundOn.opus' +SoundOff='SoundOff.opus' # Set beginnig mark for copy to clipboard PlaceStartCopyMark='PlaceStartCopyMark.opus' # Set end mark for copy to clipboard diff --git a/src/fenrir-package/commands/commands/toggle_braille_enable.py b/src/fenrir-package/commands/commands/toggle_braille_enable.py index 88351815..48e63d74 100644 --- a/src/fenrir-package/commands/commands/toggle_braille_enable.py +++ b/src/fenrir-package/commands/commands/toggle_braille_enable.py @@ -6,10 +6,10 @@ class command(): def run(self, environment): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): - environment['runtime']['outputManager'].presentText(environment, "braille disabled") + environment['runtime']['outputManager'].presentText(environment, "braille disabled",soundIconName='BrailleOff', interrupt=True) environment = environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'))) if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): - environment['runtime']['outputManager'].presentText(environment, "braille enabled") + environment['runtime']['outputManager'].presentText(environment, "braille enabled",soundIconName='BrailleOn', interrupt=True) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/commands/toggle_output_enable.py b/src/fenrir-package/commands/commands/toggle_output_enable.py index 14be86c6..2eb0fae9 100644 --- a/src/fenrir-package/commands/commands/toggle_output_enable.py +++ b/src/fenrir-package/commands/commands/toggle_output_enable.py @@ -7,7 +7,7 @@ class command(): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled') or \ environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled') or \ environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): - environment['runtime']['outputManager'].presentText(environment, "fenrir muted") + environment['runtime']['outputManager'].presentText(environment, "fenrir muted", soundIconName='Accept', interrupt=True) environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled','False') environment = environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled','False') environment = environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled','False') @@ -15,7 +15,7 @@ class command(): environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled','True') environment = environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled','True') environment = environment['runtime']['settingsManager'].setSetting(environment, 'braille', 'enabled','True') - environment['runtime']['outputManager'].presentText(environment, "fenrir unmuted") + environment['runtime']['outputManager'].presentText(environment, "fenrir unmuted", soundIconName='Cancel', interrupt=True) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/commands/toggle_sound_enable.py b/src/fenrir-package/commands/commands/toggle_sound_enable.py index cb5274d4..458cd1e4 100644 --- a/src/fenrir-package/commands/commands/toggle_sound_enable.py +++ b/src/fenrir-package/commands/commands/toggle_sound_enable.py @@ -6,10 +6,11 @@ class command(): def run(self, environment): if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): - environment['runtime']['outputManager'].presentText(environment, "sound disabled") + environment['runtime']['outputManager'].presentText(environment, "sound disabled",soundIconName='SoundOff', interrupt=True) environment = environment['runtime']['settingsManager'].setSetting(environment, 'sound', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'))) + print(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled')) if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): - environment['runtime']['outputManager'].presentText(environment, "sound enabled") + environment['runtime']['outputManager'].presentText(environment, "sound enabled",soundIconName='SoundOn', interrupt=True) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/commands/toggle_speech_enable.py b/src/fenrir-package/commands/commands/toggle_speech_enable.py index 44b05d8e..5edbac45 100644 --- a/src/fenrir-package/commands/commands/toggle_speech_enable.py +++ b/src/fenrir-package/commands/commands/toggle_speech_enable.py @@ -5,11 +5,11 @@ class command(): pass def run(self, environment): - if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): + if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled',soundIconName='SpeechOff', interrupt=True): environment['runtime']['outputManager'].presentText(environment, "speech disabled") environment = environment['runtime']['settingsManager'].setSetting(environment, 'speech', 'enabled', str(not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'))) if environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): - environment['runtime']['outputManager'].presentText(environment, "speech enabled") + environment['runtime']['outputManager'].presentText(environment, "speech enabled",soundIconName='SpeechOn', interrupt=True) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/commands/onInput/55000-read_line_if_cursor_change_vertical.py b/src/fenrir-package/commands/onInput/55000-read_line_if_cursor_change_vertical.py index ccfa5aa0..f0dacf7d 100644 --- a/src/fenrir-package/commands/onInput/55000-read_line_if_cursor_change_vertical.py +++ b/src/fenrir-package/commands/onInput/55000-read_line_if_cursor_change_vertical.py @@ -4,12 +4,12 @@ class command(): def __init__(self): pass def run(self, environment): - #if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']: - # return environment + if environment['screenData']['newDelta'] != environment['screenData']['oldDelta']: + return environment if environment['screenData']['newCursor']['y'] == environment['screenData']['oldCursor']['y']: return environment if environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']].strip(" \t\n") == '': - environment['runtime']['outputManager'].presentText(environment, "blank", True) + environment['runtime']['outputManager'].presentText(environment, "blank", soundIconName='EmptyLine', interrupt=True) else: environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newContentText'].split('\n')[environment['screenData']['newCursor']['y']], True) return environment diff --git a/src/fenrir-package/commands/onInput/70000-speak_incomming.py b/src/fenrir-package/commands/onInput/70000-speak_incomming.py index 2d69cb9b..de918995 100644 --- a/src/fenrir-package/commands/onInput/70000-speak_incomming.py +++ b/src/fenrir-package/commands/onInput/70000-speak_incomming.py @@ -14,7 +14,7 @@ class command(): return environment if ttyChanged: environment['runtime']['outputManager'].playSoundIcon(environment,'ChangeTTY') - environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], ttyChanged) + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], interrupt=ttyChanged) return environment def setCallback(self, callback): diff --git a/src/fenrir-package/commands/onScreenChanged/70000-speak_incomming.py b/src/fenrir-package/commands/onScreenChanged/70000-speak_incomming.py index dfc4070e..46fda75b 100644 --- a/src/fenrir-package/commands/onScreenChanged/70000-speak_incomming.py +++ b/src/fenrir-package/commands/onScreenChanged/70000-speak_incomming.py @@ -13,7 +13,7 @@ class command(): not ttyChanged: return environment - environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], ttyChanged) + environment['runtime']['outputManager'].presentText(environment, environment['screenData']['newDelta'], soundIconName='', interrupt=ttyChanged) return environment def setCallback(self, callback): pass diff --git a/src/fenrir-package/core/outputManager.py b/src/fenrir-package/core/outputManager.py index 8f26b964..d26d9993 100644 --- a/src/fenrir-package/core/outputManager.py +++ b/src/fenrir-package/core/outputManager.py @@ -4,9 +4,10 @@ class outputManager(): def __init__(self): pass def presentText(self, environment, text, interrupt=True, soundIconName = ''): + if self.playSoundIcon(environment, soundIconName, interrupt): + return self.speakText(environment, text, interrupt) self.brailleText(environment, text) - self.playSoundIcon(environment, soundIconName) def speakText(self, environment, text, interrupt=True): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'speech', 'enabled'): @@ -23,10 +24,10 @@ class outputManager(): environment['runtime']['speechDriver'].setVolume(environment['runtime']['settingsManager'].getSettingAsInt(environment, 'speech', 'volume')) environment['runtime']['speechDriver'].speak(text) - def brailleText(self, environment, text, interrupt=True): + def brailleText(self, environment, text, soundIconName = '', interrupt=True): if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'braille', 'enabled'): return - if environment['runtime']['braillehDriver'] == None: + if environment['runtime']['brailleDriver'] == None: return print('braille') def interruptOutput(self, environment): @@ -35,15 +36,14 @@ class outputManager(): def playSoundIcon(self, environment, soundIconName, interrupt=True): if soundIconName == '': - return + return False if not environment['runtime']['settingsManager'].getSettingAsBool(environment, 'sound', 'enabled'): - return + return False if environment['runtime']['soundDriver'] == None: - return - print(soundIconName) - environment['runtime']['soundDriver'].playSoundFile( environment['soundIcons'][soundIconName], interrupt) + return False try: - print(environment['soundIcons'][soundIconName]) environment['runtime']['soundDriver'].playSoundFile(environment['soundIcons'][soundIconName], interrupt) + return True except: print('no icon there for' + soundIconName) + return False diff --git a/src/fenrir-package/core/runtime.py b/src/fenrir-package/core/runtime.py index 6f000af6..6074042e 100644 --- a/src/fenrir-package/core/runtime.py +++ b/src/fenrir-package/core/runtime.py @@ -5,6 +5,7 @@ runtime = { 'speechDriver': None, 'screenDriver': None, 'soundDriver': None, +'brailleDriver': None, 'inputManager': None, 'commandManager': None, 'debug':None, diff --git a/src/fenrir-package/core/screenData.py b/src/fenrir-package/core/screenData.py index 4643b3e6..d52f9249 100644 --- a/src/fenrir-package/core/screenData.py +++ b/src/fenrir-package/core/screenData.py @@ -4,12 +4,14 @@ screenData = { 'columns': 0, 'lines': 0, 'oldDelta': '', +'oldNegativeDelta': '', 'oldCursorReview':{'x':-1,'y':-1}, 'oldCursor':{'x':0,'y':0}, 'oldContentBytes': b'', 'oldContentText': '', 'oldContentAttrib': b'', 'newDelta': '', +'newNegativeDelta': '', 'newCursorReview':{'x':-1,'y':-1}, 'newCursor':{'x':0,'y':0}, 'newContentBytes': b'', diff --git a/src/fenrir-package/core/settingsManager.py b/src/fenrir-package/core/settingsManager.py index 543479ce..a07318cc 100644 --- a/src/fenrir-package/core/settingsManager.py +++ b/src/fenrir-package/core/settingsManager.py @@ -99,7 +99,6 @@ class settingsManager(): if validSoundIcon: environment['soundIcons'][soundIcon] = FilePath siConfig.close() - print(environment['soundIcons']) return environment def loadSettings(self, environment, settingConfigPath='../../config/settings/settings.conf'): diff --git a/src/fenrir-package/screen/linux.py b/src/fenrir-package/screen/linux.py index 3adce1ce..32c2a169 100644 --- a/src/fenrir-package/screen/linux.py +++ b/src/fenrir-package/screen/linux.py @@ -36,7 +36,7 @@ class screen(): environment['screenData']['oldCursor']['y'] = environment['screenData']['newCursor']['y'] environment['screenData']['oldTTY'] = environment['screenData']['newTTY'] environment['screenData']['oldDelta'] = environment['screenData']['newDelta'] - + environment['screenData']['oldNegativeDelta'] = environment['screenData']['newNegativeDelta'] environment['screenData']['newTTY'] = newTTY environment['screenData']['newContentBytes'] = newContentBytes # get metadata like cursor or screensize @@ -58,6 +58,8 @@ class screen(): environment['screenData']['oldCursor']['y'] = 0 environment['screenData']['oldDelta'] = '' environment['screenData']['newDelta'] = '' + environment['screenData']['oldNegativeDelta'] = '' + environment['screenData']['newNegativeDelta'] = '' # changes on the screen if (environment['screenData']['oldContentText'] != environment['screenData']['newContentText']) and \ @@ -75,5 +77,6 @@ class screen(): diff = difflib.ndiff(re.sub('[ \t]+', ' ', environment['screenData']['oldContentText'][diffStart:]),\ re.sub('[ \t]+', ' ', environment['screenData']['newContentText'][diffStart:])) environment['screenData']['newDelta'] = ''.join(x[2:] for x in diff if x.startswith('+ ')) + environment['screenData']['newNegativeDelta'] = ''.join(x[2:] for x in diff if x.startswith('- ')) return environment diff --git a/src/fenrir-package/sound/sox.py b/src/fenrir-package/sound/sox.py index 8dfaf944..3e7b7fb2 100644 --- a/src/fenrir-package/sound/sox.py +++ b/src/fenrir-package/sound/sox.py @@ -7,7 +7,7 @@ class sound(): def playFrequence(self, frequence, duration, adjustVolume): pass def playSoundFile(self, filePath, interrupt = True): - subprocess.call("play " + filePath, shell=True) + subprocess.call("play -q " + filePath, shell=True) def cancel(self): pass def setCallback(self, callback):