polish sound

This commit is contained in:
Chrys 2016-08-03 02:26:44 +02:00
parent 326341f509
commit 8a3ead822a
14 changed files with 33 additions and 27 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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):

View File

@ -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

View File

@ -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

View File

@ -5,6 +5,7 @@ runtime = {
'speechDriver': None,
'screenDriver': None,
'soundDriver': None,
'brailleDriver': None,
'inputManager': None,
'commandManager': None,
'debug':None,

View File

@ -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'',

View File

@ -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'):

View File

@ -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

View File

@ -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):