Qu

emf

Builtin index · Noise

result = emf(x, fs, [carrier=], [bursts=], [snr=20], [amplitude=], [seed=])

Input: x, fs, carrier, bursts, snr, amplitude, seed · Output: result

What it is

Adds simulated switching/EMI interference to x, a length-N signal vector, given the sample rate fs in Hz: an amplitude-modulated carrier plus damped bursts at each switching edge. carrier (number, Hz) is the switching frequency, default fs / 20. bursts (number, burst events per second) sets how often a ringing transient fires, default carrier / 50. snr (number, dB, default 20) or amplitude (number, raw units) sets the interference level, one or the other, not both. seed (integer, optional) fixes the random draw.

Overloads

One call shape — this function is not overloaded.

CodeInputOutputDescription
result = emf(x, fs, [carrier=], [bursts=], [snr=20], [amplitude=], [seed=])
x vectorAdds simulated switching/EMI interference to x, a length-N signal vector, given the sample rate fs in Hz: an amplitude-modulated carrier plus damped bursts at each switching edge.
fs vectorAdds simulated switching/EMI interference to x, a length-N signal vector, given the sample rate fs in Hz: an amplitude-modulated carrier plus damped bursts at each switching edge.
carrier number, optionalcarrier (number, Hz) is the switching frequency, default fs / 20.
bursts number, optionalbursts (number, burst events per second) sets how often a ringing transient fires, default carrier / 50.
snr number, optional (default 20)snr (number, dB, default 20) or amplitude (number, raw units) sets the interference level, one or the other, not both.
amplitude vector, optionalAdds simulated switching/EMI interference to x, a length-N signal vector, given the sample rate fs in Hz: an amplitude-modulated carrier plus damped bursts at each switching edge.
seed optionalseed (integer, optional) fixes the random draw.
result vector
Returns a length-N vector, x plus the interference.

Examples

From the documentation, and run by the build -- the output and the figure below are what the engine actually produced. Simplest first.

fs = 1000
t = (0 to 999) / fs
clean = sin(2 * pi * 7 * t)

h = hum(clean, fs, freq = 50, harmonics = 3, snr = 6)
e = emf(clean, fs, carrier = 150, snr = 6)
print("hum {measure_snr(clean, h):.2f} dB, emf {measure_snr(clean, e):.2f} dB")
output
hum 6.00 dB, emf 6.00 dB

from noise

How it works

emf(x, fs, carrier = , bursts = , snr = ) — electromagnetic interference, which is two things at once: a modulated carrier at the switching frequency, and a damped ring at each switching edge. A method tested against only one of those fails on the other.

From the note above this builtin in the interpreter, where the reasoning was written down as it was built.