make adjust Volume work
This commit is contained in:
parent
562ab419d7
commit
29dbceee5a
@ -23,7 +23,10 @@ class fenrirManager():
|
|||||||
raise RuntimeError('Cannot Initialize. Maybe the configfile is not available or not parseable')
|
raise RuntimeError('Cannot Initialize. Maybe the configfile is not available or not parseable')
|
||||||
except RuntimeError:
|
except RuntimeError:
|
||||||
raise
|
raise
|
||||||
self.environment['runtime']['outputManager'].playFrequence(500, 1, interrupt=True)
|
for m in range(1, 280):
|
||||||
|
if m % 4 ==0:
|
||||||
|
self.environment['runtime']['outputManager'].playFrequence(m * 40, 0.2, interrupt=True)
|
||||||
|
time.sleep(0.3)
|
||||||
#self.environment['runtime']['outputManager'].presentText(_("Start Fenrir"), soundIcon='ScreenReaderOn', interrupt=True)
|
#self.environment['runtime']['outputManager'].presentText(_("Start Fenrir"), soundIcon='ScreenReaderOn', interrupt=True)
|
||||||
signal.signal(signal.SIGINT, self.captureSignal)
|
signal.signal(signal.SIGINT, self.captureSignal)
|
||||||
signal.signal(signal.SIGTERM, self.captureSignal)
|
signal.signal(signal.SIGTERM, self.captureSignal)
|
||||||
|
@ -310,9 +310,16 @@ class outputManager():
|
|||||||
self.env['runtime']['soundDriver'].setVolume(self.env['runtime']['settingsManager'].getSettingAsFloat('sound', 'volume'))
|
self.env['runtime']['soundDriver'].setVolume(self.env['runtime']['settingsManager'].getSettingAsFloat('sound', 'volume'))
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("outputManager.playSoundIcon::setVolume: " + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("outputManager.playSoundIcon::setVolume: " + str(e),debug.debugLevel.ERROR)
|
||||||
|
adjustVolume = 0.0
|
||||||
|
try:
|
||||||
|
adjustVolume = 1.0 - (frequence / 20000)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
if adjustVolume > 9.0:
|
||||||
|
adjustVolume = 9.0
|
||||||
|
|
||||||
try:
|
try:
|
||||||
self.env['runtime']['soundDriver'].playFrequence(frequence, duration, interrupt)
|
self.env['runtime']['soundDriver'].playFrequence(frequence, duration, adjustVolume, interrupt)
|
||||||
return True
|
return True
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.env['runtime']['debug'].writeDebugOut("outputManager.playSoundIcon::playSoundFile: " + str(e),debug.debugLevel.ERROR)
|
self.env['runtime']['debug'].writeDebugOut("outputManager.playSoundIcon::playSoundFile: " + str(e),debug.debugLevel.ERROR)
|
||||||
|
@ -21,7 +21,7 @@ class soundDriver():
|
|||||||
self.cancel()
|
self.cancel()
|
||||||
self._isInitialized = False
|
self._isInitialized = False
|
||||||
|
|
||||||
def playFrequence(self, frequence, duration, adjustVolume = 0, interrupt=True):
|
def playFrequence(self, frequence, duration, adjustVolume = 0.0, interrupt=True):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
if interrupt:
|
if interrupt:
|
||||||
|
@ -23,7 +23,7 @@ class driver(soundDriver):
|
|||||||
self._initialized = False
|
self._initialized = False
|
||||||
print('Sound Debug Driver: Shutdown')
|
print('Sound Debug Driver: Shutdown')
|
||||||
|
|
||||||
def playFrequence(self, frequence, duration, adjustVolume = 0, interrupt=True):
|
def playFrequence(self, frequence, duration, adjustVolume = 0.0, interrupt=True):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
if interrupt:
|
if interrupt:
|
||||||
|
@ -26,19 +26,17 @@ class driver(soundDriver):
|
|||||||
self.frequenceCommand = 'play -q -v fenrirVolume -n -c1 synth fenrirDuration sine fenrirFrequence'
|
self.frequenceCommand = 'play -q -v fenrirVolume -n -c1 synth fenrirDuration sine fenrirFrequence'
|
||||||
self._initialized = True
|
self._initialized = True
|
||||||
|
|
||||||
def playFrequence(self, frequence, duration, adjustVolume = 0, interrupt=True):
|
def playFrequence(self, frequence, duration, adjustVolume = 0.0, interrupt=True):
|
||||||
print('drin')
|
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
if interrupt:
|
if interrupt:
|
||||||
self.cancel()
|
self.cancel()
|
||||||
popenFrequenceCommand = shlex.split(self.frequenceCommand)
|
popenFrequenceCommand = shlex.split(self.frequenceCommand)
|
||||||
for idx, word in enumerate(popenFrequenceCommand):
|
for idx, word in enumerate(popenFrequenceCommand):
|
||||||
word = word.replace('fenrirVolume', str(self.volume))
|
word = word.replace('fenrirVolume', str(self.volume * adjustVolume))
|
||||||
word = word.replace('fenrirDuration', str(duration))
|
word = word.replace('fenrirDuration', str(duration))
|
||||||
word = word.replace('fenrirFrequence', str(frequence))
|
word = word.replace('fenrirFrequence', str(frequence))
|
||||||
popenFrequenceCommand[idx] = word
|
popenFrequenceCommand[idx] = word
|
||||||
print(popenFrequenceCommand)
|
|
||||||
self.proc = subprocess.Popen(popenFrequenceCommand, stdin=None, stdout=None, stderr=None, shell=False)
|
self.proc = subprocess.Popen(popenFrequenceCommand, stdin=None, stdout=None, stderr=None, shell=False)
|
||||||
self.soundType = 'frequence'
|
self.soundType = 'frequence'
|
||||||
def playSoundFile(self, filePath, interrupt = True):
|
def playSoundFile(self, filePath, interrupt = True):
|
||||||
|
@ -92,13 +92,13 @@ class driver(soundDriver):
|
|||||||
self._player.set_property('uri', 'file://%s' % fileName)
|
self._player.set_property('uri', 'file://%s' % fileName)
|
||||||
self._player.set_state(Gst.State.PLAYING)
|
self._player.set_state(Gst.State.PLAYING)
|
||||||
|
|
||||||
def playFrequence(self, frequence, duration, adjustVolume = 0, interrupt=True):
|
def playFrequence(self, frequence, duration, adjustVolume = 0.0, interrupt=True):
|
||||||
if not self._initialized:
|
if not self._initialized:
|
||||||
return
|
return
|
||||||
if interrupt:
|
if interrupt:
|
||||||
self.cancel()
|
self.cancel()
|
||||||
duration = duration * 1000
|
duration = duration * 1000
|
||||||
self._source.set_property('volume', self.volume - adjustVolume)
|
self._source.set_property('volume', self.volume * adjustVolume)
|
||||||
self._source.set_property('freq', frequence)
|
self._source.set_property('freq', frequence)
|
||||||
self._pipeline.set_state(Gst.State.PLAYING)
|
self._pipeline.set_state(Gst.State.PLAYING)
|
||||||
GLib.timeout_add(duration, self._onTimeout, self._pipeline)
|
GLib.timeout_add(duration, self._onTimeout, self._pipeline)
|
||||||
|
Loading…
Reference in New Issue
Block a user