diff --git a/lasp/lasp_siggen.py b/lasp/lasp_siggen.py index 7a0a2b0..a8cfada 100644 --- a/lasp/lasp_siggen.py +++ b/lasp/lasp_siggen.py @@ -68,6 +68,7 @@ class SiggenMessage(Enum): newSiggenData = auto() # Forward new equalizer settings ready = auto() # Send out once, once the signal generator is ready with # pre-generating data. + mute = auto() # Mute / unmute siggen # These messages are send back to the main thread over the pipe error = auto() @@ -87,6 +88,9 @@ class SiggenData: # The data type to output dtype: np.dtype + # Muted? + muted: bool + # Level of output signal [dBFS]el level_dB: float @@ -146,6 +150,9 @@ class SiggenProcess(mp.Process): signaltype = siggendata.signaltype signaltypedata = siggendata.signaltypedata + # Muted state + self.muted = siggendata.muted + if signaltype == SignalType.Periodic: freq, = signaltypedata siggen = pyxSiggen.sineWave(fs, freq, level_dB) @@ -181,6 +188,9 @@ class SiggenProcess(mp.Process): if np.issubdtype(dtype, np.integer): bitdepth_fixed = dtype.itemsize * 8 signal *= 2 ** (bitdepth_fixed - 1) - 1 + if self.muted: + # Mute it + signal *= 0 try: self.dataq.put(signal.astype(dtype)) except ValueError: @@ -253,6 +263,8 @@ class SiggenProcess(mp.Process): if msg == SiggenMessage.endProcess: logging.debug("Signal generator caught 'endProcess' message. Exiting.") return 0 + elif msg == SiggenMessage.mute: + self.muted = data elif msg == SiggenMessage.adjustVolume: level_dB = data logging.debug(f"Signal generator caught 'adjustVolume' message. New volume = {level_dB:.1f} dB FS") @@ -320,6 +332,9 @@ class Siggen: """ self.pipe.send((SiggenMessage.adjustVolume, new_level)) + def mute(self, mute): + self.pipe.send((SiggenMessage.mute, mute)) + def setEqData(self, eqdata): self.pipe.send((SiggenMessage.newEqSettings, eqdata))