Update genericDriver.py

This commit is contained in:
chrys87 2018-03-13 09:17:05 +01:00 committed by GitHub
parent 60c4940a5d
commit 2493761bc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -6,6 +6,7 @@
from core import debug from core import debug
import subprocess import subprocess
import shlex
from core.soundDriver import soundDriver from core.soundDriver import soundDriver
class driver(soundDriver): class driver(soundDriver):
@ -30,19 +31,25 @@ class driver(soundDriver):
return return
if interrupt: if interrupt:
self.cancel() self.cancel()
popenFrequenceCommand = self.frequenceCommand.replace('fenrirVolume', str(self.volume + adjustVolume )) popenFrequenceCommand = shlex.split(self.frequenceCommand)
popenFrequenceCommand = popenFrequenceCommand.replace('fenrirFreqDuration', str(duration)) for idx, word in enumerate(popenFrequenceCommand):
popenFrequenceCommand = popenFrequenceCommand.replace('fenrirFrequence', str(frequence)) word = word.replace('fenrirVolume', str(self.volume + adjustVolume ))
self.proc = subprocess.Popen(popenFrequenceCommand, shell=True) word = word.replace('fenrirFreqDuration', str(duration))
word = word.replace('fenrirFrequence', str(frequence))
popenFrequenceCommand[idx] = word
self.proc = subprocess.Popen(popenFrequenceCommand, shell=False)
self.soundType = 'frequence' self.soundType = 'frequence'
def playSoundFile(self, filePath, interrupt = True): def playSoundFile(self, filePath, interrupt = True):
if not self._initialized: if not self._initialized:
return return
if interrupt: if interrupt:
self.cancel() self.cancel()
popenSoundFileCommand = self.soundFileCommand.replace('fenrirVolume', str(self.volume )) popenSoundFileCommand = shlex.split(self.soundFileCommand)
popenSoundFileCommand = popenSoundFileCommand.replace('fenrirSoundFile', filePath) for idx, word in enumerate(popenSoundFileCommand):
self.proc = subprocess.Popen(popenSoundFileCommand, shell=True) word = word.replace('fenrirVolume', str(self.volume ))
word = word.replace('fenrirSoundFile', str(filePath))
popenSoundFileCommand[idx] = word
self.proc = subprocess.Popen(popenSoundFileCommand, shell=False)
self.soundType = 'file' self.soundType = 'file'
def cancel(self): def cancel(self):
if not self._initialized: if not self._initialized: