diff --git a/src/fenrir-package/soundDriver/sox.py b/src/fenrir-package/soundDriver/sox.py index 3ca55810..12cbfca9 100644 --- a/src/fenrir-package/soundDriver/sox.py +++ b/src/fenrir-package/soundDriver/sox.py @@ -3,17 +3,24 @@ import subprocess class driver(): def __init__(self): - self.volume = 1.0; + self.proc = None + self.volume = 1.0 + self.soundType = '' def initialize(self, environment): return environment def shutdown(self, environment): return environment def playFrequence(self, frequence, duration, adjustVolume): - pass + self.soundType = 'frequence' def playSoundFile(self, filePath, interrupt = True): + if interrupt: + self.cancel() self.proc = subprocess.Popen("play -q -v " + str(self.volume ) + ' ' + filePath, shell=True) + self.soundType = 'file' def cancel(self): - pass + if self.soundType == 'file': + self.proc.kill() + self.soundType = '' def setCallback(self, callback): pass def setVolume(self, volume):