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')
|
||||
except RuntimeError:
|
||||
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)
|
||||
signal.signal(signal.SIGINT, 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'))
|
||||
except Exception as e:
|
||||
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:
|
||||
self.env['runtime']['soundDriver'].playFrequence(frequence, duration, interrupt)
|
||||
self.env['runtime']['soundDriver'].playFrequence(frequence, duration, adjustVolume, interrupt)
|
||||
return True
|
||||
except Exception as e:
|
||||
self.env['runtime']['debug'].writeDebugOut("outputManager.playSoundIcon::playSoundFile: " + str(e),debug.debugLevel.ERROR)
|
||||
|
@ -21,7 +21,7 @@ class soundDriver():
|
||||
self.cancel()
|
||||
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:
|
||||
return
|
||||
if interrupt:
|
||||
|
@ -23,7 +23,7 @@ class driver(soundDriver):
|
||||
self._initialized = False
|
||||
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:
|
||||
return
|
||||
if interrupt:
|
||||
|
@ -26,19 +26,17 @@ class driver(soundDriver):
|
||||
self.frequenceCommand = 'play -q -v fenrirVolume -n -c1 synth fenrirDuration sine fenrirFrequence'
|
||||
self._initialized = True
|
||||
|
||||
def playFrequence(self, frequence, duration, adjustVolume = 0, interrupt=True):
|
||||
print('drin')
|
||||
def playFrequence(self, frequence, duration, adjustVolume = 0.0, interrupt=True):
|
||||
if not self._initialized:
|
||||
return
|
||||
if interrupt:
|
||||
self.cancel()
|
||||
popenFrequenceCommand = shlex.split(self.frequenceCommand)
|
||||
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('fenrirFrequence', str(frequence))
|
||||
popenFrequenceCommand[idx] = word
|
||||
print(popenFrequenceCommand)
|
||||
self.proc = subprocess.Popen(popenFrequenceCommand, stdin=None, stdout=None, stderr=None, shell=False)
|
||||
self.soundType = 'frequence'
|
||||
def playSoundFile(self, filePath, interrupt = True):
|
||||
|
@ -92,13 +92,13 @@ class driver(soundDriver):
|
||||
self._player.set_property('uri', 'file://%s' % fileName)
|
||||
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:
|
||||
return
|
||||
if interrupt:
|
||||
self.cancel()
|
||||
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._pipeline.set_state(Gst.State.PLAYING)
|
||||
GLib.timeout_add(duration, self._onTimeout, self._pipeline)
|
||||
|
Loading…
Reference in New Issue
Block a user