Added mute option to siggen
This commit is contained in:
parent
60afface35
commit
a1bcae508b
@ -68,6 +68,7 @@ class SiggenMessage(Enum):
|
|||||||
newSiggenData = auto() # Forward new equalizer settings
|
newSiggenData = auto() # Forward new equalizer settings
|
||||||
ready = auto() # Send out once, once the signal generator is ready with
|
ready = auto() # Send out once, once the signal generator is ready with
|
||||||
# pre-generating data.
|
# pre-generating data.
|
||||||
|
mute = auto() # Mute / unmute siggen
|
||||||
|
|
||||||
# These messages are send back to the main thread over the pipe
|
# These messages are send back to the main thread over the pipe
|
||||||
error = auto()
|
error = auto()
|
||||||
@ -87,6 +88,9 @@ class SiggenData:
|
|||||||
# The data type to output
|
# The data type to output
|
||||||
dtype: np.dtype
|
dtype: np.dtype
|
||||||
|
|
||||||
|
# Muted?
|
||||||
|
muted: bool
|
||||||
|
|
||||||
# Level of output signal [dBFS]el
|
# Level of output signal [dBFS]el
|
||||||
level_dB: float
|
level_dB: float
|
||||||
|
|
||||||
@ -146,6 +150,9 @@ class SiggenProcess(mp.Process):
|
|||||||
signaltype = siggendata.signaltype
|
signaltype = siggendata.signaltype
|
||||||
signaltypedata = siggendata.signaltypedata
|
signaltypedata = siggendata.signaltypedata
|
||||||
|
|
||||||
|
# Muted state
|
||||||
|
self.muted = siggendata.muted
|
||||||
|
|
||||||
if signaltype == SignalType.Periodic:
|
if signaltype == SignalType.Periodic:
|
||||||
freq, = signaltypedata
|
freq, = signaltypedata
|
||||||
siggen = pyxSiggen.sineWave(fs, freq, level_dB)
|
siggen = pyxSiggen.sineWave(fs, freq, level_dB)
|
||||||
@ -181,6 +188,9 @@ class SiggenProcess(mp.Process):
|
|||||||
if np.issubdtype(dtype, np.integer):
|
if np.issubdtype(dtype, np.integer):
|
||||||
bitdepth_fixed = dtype.itemsize * 8
|
bitdepth_fixed = dtype.itemsize * 8
|
||||||
signal *= 2 ** (bitdepth_fixed - 1) - 1
|
signal *= 2 ** (bitdepth_fixed - 1) - 1
|
||||||
|
if self.muted:
|
||||||
|
# Mute it
|
||||||
|
signal *= 0
|
||||||
try:
|
try:
|
||||||
self.dataq.put(signal.astype(dtype))
|
self.dataq.put(signal.astype(dtype))
|
||||||
except ValueError:
|
except ValueError:
|
||||||
@ -253,6 +263,8 @@ class SiggenProcess(mp.Process):
|
|||||||
if msg == SiggenMessage.endProcess:
|
if msg == SiggenMessage.endProcess:
|
||||||
logging.debug("Signal generator caught 'endProcess' message. Exiting.")
|
logging.debug("Signal generator caught 'endProcess' message. Exiting.")
|
||||||
return 0
|
return 0
|
||||||
|
elif msg == SiggenMessage.mute:
|
||||||
|
self.muted = data
|
||||||
elif msg == SiggenMessage.adjustVolume:
|
elif msg == SiggenMessage.adjustVolume:
|
||||||
level_dB = data
|
level_dB = data
|
||||||
logging.debug(f"Signal generator caught 'adjustVolume' message. New volume = {level_dB:.1f} dB FS")
|
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))
|
self.pipe.send((SiggenMessage.adjustVolume, new_level))
|
||||||
|
|
||||||
|
def mute(self, mute):
|
||||||
|
self.pipe.send((SiggenMessage.mute, mute))
|
||||||
|
|
||||||
def setEqData(self, eqdata):
|
def setEqData(self, eqdata):
|
||||||
self.pipe.send((SiggenMessage.newEqSettings, eqdata))
|
self.pipe.send((SiggenMessage.newEqSettings, eqdata))
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user