Audacity PEMF tone generators

Here are two Pulsed Electromagnetic Field (PEMF) waveform generators for Audacity. Output into an amplifier, connect speaker to an electromagnetic coil/loop.

PEMF is recommended by Dr Oz

Glad to see you got it working.

I don’t know about the medical side of this (though I have previously heard of its use with horses), but one thing that occurred to me from the standpoint of physics, is the question of “switching speed”. The generated signal switches between “on” and “off” states virtually instantaneously - actually over a period of 1/44100th second, assuming a sample rate of 44100. As can be seen from the spectrum / spectrograph (below) this produces a “dirty” spectrum that extend right up to the Nyquist frequency (half the sample rate). I wondered what effect that might have on the EMR produced by the apparatus, and if that would have physiological effects on the patient.

If necessary / beneficial, it would be possible to generate pulses with a “cleaner” spectrum by limiting the slew rate of the pulses.

Feel free to experiment with better ways to drive the magnetic coil. Let me know if you find something.

My wife had chronic back pain and a very expensive PEMF machine took the pain away. The machines are too expensive for us to buy.

A microphone has a small coil in it so it could pick up and record the magnetic pulses (in Audacity of course). The device was driving the magnet at a constant frequency and changing the pulse rate. After doing some google-scholar research on PEMF it seems that cells and molecules respond differently to different magnetic frequencies. Audacity + amplifier is much more flexible at creating pulses than a hardware-based solution. The hardware-based solution was fixed in it’s frequency choices. The down-side to using Audacity + Amplifier is that the magnetic field is much smaller than a hardware-based generator. i.e. PEMF machine - microphone could pick up the pulse 4ft above the coil VS Audacity + Amp is only 2.5ft.

However, in the end Audacity + Amplifier based machine still does the trick.

With the Audacity PEMF List Nyquist plugin I could play back a pulse and at the same time use a microphone record how the magnet responded to the amplified audio pulse on a 2nd track.

I also like to use xoscope at 10-20ms to visually see the pulses live - if the AMP or the audio-out is over-driven I can see a clean DC clean pulse “fall apart” into a distorted AC signal.

Here are some snips on research showing Electromagnetic Pulses can have both positive and negative effects on cells.

Here is a PEMF machine recorded with a mic.
Audacity PEMF generator (top track) ~0.33ms duty cycle creates DC wave magnet duty (bottom track) - recorded with mic.
Audacity PEMF generator (top track) with about ~1ms magnet duty
Audacity PEMF ~2ms magnet duty starts to create an AC wave form (bottom track)
The Audacity PEMF waves are working for it’s indented use. I may still tinker with the pwl envelope.

I’ve also found that duty cycle needs to scale in relation to magnet frequency or be fixed to around 1ms. When the duty cycle gets near 3ms long, the magnet looses the DC pulse and creates an AC waveform. Also the Amplifier has troubles with longer magnet duty cycles.

This is interesting - there appears to be an “echo”. What could be causing that?

Like Steve, I can only speak from a physics/programmers point of view.
Some observations:

  1. The duration control in pemf-v1 is somewhat confusing with those minutes values, especially since screen reader users don’t “see” the unit text (seconds).

  2. You’re using ‘pwl’ in your code.
    This function works at 1/20 of the sampling rate. Thus, at 1 Hz it will be slanted, that is the table starts off with a jump from 0 to 1 but will decay linearly 1, 0.9, 0.8,…0.1, 0.0.
    Thus, I would use either (

set-control-srate *sound-srate*)

or envelope the table creation with ‘control-srate-abs’.

Like Steve has mentioned, I would then change the slu in a controlled fashion:

  • within the pwl function itself (adding offset to start and duty to give a linear transition)
  • same as above but with pwe instead or taking the square root of the generated pulse (will be rounder)
  • with ‘snd-chase’, this gives a trapezoidal pulse like with pwl itself
  • with ‘snd-avg’ gives a pseudo-Gaussian pulse.
  • a raised cosine as impulse or impulse-response for convolution.
  • same as above but with a Gaussian impulse, adjustable from perfect rectangle to bell shape to spike.
  • with ‘lp’, a 6 dB/octave lowpass filter.

The purpose is not necessarily to decrease the spectrum bandwidth (how does it translate to a magnet anyway) but to remove some load for the amplifier and prevent overshooting.

  1. Instead of
(seqrep (i dur)...

, I would use

(stretch-abs dur...

The former is to expensive since it zips 1 second pieces together.


Thanks for all the feedback and support.

steve: I ran Plot Spectrum frequency analysis on the expensive pemf machine. It is much cleaner than the square pulse that I created.
Here is one cycle from the original machine. The 0.008s works out to be 120Hz on the magnet.
I’m now trying to work out a way to clean up the Audacity pulse in my pwl. From the start of the wav

  • 00005 samples to 0.1
  • 00138 samples to -0.07
  • 00143 samples to -0.45
  • 00151 samples to -0.07
  • 00159 samples to 0
  • 00366 samples to start of next wav.

Could you attach a sample of the recorded file?
I can’t view the images.

There’s also a pwl version that works with time intervals rather than absolute times–ideal for your values given above.

Here is a 1 second of a recorded pemf pulse.

Attempt to duplicate the pemf machine waveform. However the magnet frequency can’t go as high due to the long lead in.

;nyquist plug-in
;version 4
;type generate
;name "PEMF v1"
;preview true
;action "Generating PEMF Pulse ..."
;author "Dean Montgomery"
;copyright "Released under terms of the GNU General Public License version 2"
;control magfreq "Magnet frequency" int "Hz" 120 1 22050
;control magduty "Magnet duty cycle" int "% (5)" 5 1 99
;control magamp "Magnet Amplitude" int "% (98)" 98 80 100
;control pulsefreq "Pulse frequency" int "Hz e.g. (12),4,8,20,2" 12 1 50
;control pulseduty "Pulse duty cycle" int "% (49)" 48 1 99
;control dur "Duration 5m,8m,10m,20m" int "seconds (60) = 1min" 60 1 3000
;;control dur "Duration" int "minutes (10)" 10 1 20

(print (type-of magduty))
(setf magduty (* magduty 0.01))
(print (type-of magduty))
(setf pulseduty (* pulseduty 0.01))
(setf magamp (* magamp 0.01))
;;(setf dur (* dur 60))
;;(setf x (/ magfreq 60))
(setf x magfreq)
(setq *mag-pulse-table* (list
  (congen (pwl (* 0.0001133787 x) -0.21 (* 0.0031746032 x) 0.13 (* 0.0032653061 x) 0.95 (* 0.0032879819 x) 0.94 (* 0.003446712
 x) 0.018 (* 0.0036281179 x) 0.00 (* 0.0037 x) 0 1.00 ) 0.003 0.003)
  (hz-to-step 1) t))
(setq *pulse-table* (list
  (pwl 0 1 pulseduty 1 pulseduty 0 1)
  (hz-to-step 1) t))

(seqrep ( i dur )
    (hzosc magfreq *mag-pulse-table*)
    (hzosc pulsefreq *pulse-table*)))

That is a strange shape waveform. Why that shape? Is that the optimum / ideal shape, or is it just the best that the manufacturers could do within constraints of their chosen methods, development time. profit and manufacturing considerations… In other words, what were the technical design goals that resulted in that waveform?

The visual appearance of waveforms can be misleading. For example, these two waveforms have identical spectra, but their waveforms look very different. If our design goal was to produce the spectrum of these waveforms, the first form (a simple on/off square wave) is much easier to replicate exactly than attempting to match the complicated curves of the second version. On the other hand, if the phase relationship of the frequency components in the second track is the most important design issue, then first track, though much easier to produce, would be far from optimal.

Looking at it another way, is the “sawtooth” part of the waveform required to produce the desired magnetic and physiological effects, or is it just an irrelevant side effect of the hardware design? The final part of the pulse looks much like a transform-limited pulse - is that perhaps the design goal?

Only reason why I posted it is because my pwl was generating a horrible pulse as you guys pointed out.

Good questions - I don’t have an answers to. Been reading through medical papers on Google Scholar some are specific about the waveform and frequency and others are just using a pre-build machine.

Right now I’d like to improve the PEMF wave-form generator so it creates good clean magnetic pulse and scales from low Hz to high without too much distortion. It is somewhat broken at higher frequencies.
So far I’ve learned:

  • When the duty cycle is too long then the DC pulse turns into an AC pulse.
  • When the duty cycle is too short the magnet looses power. With the exception of higher frequencies.
  • If the amplifier or audio line out on the computer are too loud the DC pulse morphs into an AC pulse.
  • If the slew-rate is too fast (square), Audacity’s Frequency Analysis tool shows a “mess” especially at higher frequencies. When the pulse has a (bell-shape) then the Frequency Analysis tool shows a somewhat linear frequency report with equally spaced peaks. It seems the bell-shaped pulse has more control over magnet.
  • Generally aiming for approx ~1ms pulse with ability to fine tune the slew-rates and duty cycle.

I really like the Audacity platform. Thanks again for the help and feedback.

Trying to figure and answer the same question. In terms of wave forms, it appears like each manufacturer has their own. Some patented wave forms are explained with more detail:


  • sawtooth(ish)
  • vary over time - not a constant pulse. i.e. change every few minutes.
  • magnet’s Hz is cycled on and off with a secondary very low Hz.
  • 2 of the machines indicate that it is DC pulse. Not AC.
  • Even though the machines use different wave forms and use different magnetic intensities, they all have positive results.

So far Audacity has been successful with creating waveforms that has greatly helped various ailments in the family: chronic back pain, calcified tendinitis, arthritis, eczema.

Then perhaps the pulse shape is not particularly important in terms of effectiveness ?

I presume that the intensity of the magnetic flux is important (otherwise they would run the device with lower power). So for your home-made equipment which has limited power, higher flux is better, right?

As Robert mentioned earlier, running an audio amp flat out with a square pulse risks frying components in the amp.
I’m also imagining your neighbours wondering why they keep getting “tick tick tick” on their TV / radio. Have you tested for RF interference produced by the equipment?

Regardless of whether your amp blows up, or whether you ruin your neighbour’s evening in watching TV, we know that we want to efficiently produce discrete pulse of high magnetic flux. So perhaps a good way to proceed would be to test different shaped pulses, keeping everything constant except for the pulse shape, and measure the flux produced. So the amp needs to be set the same for each test, the pulses to have the same peak amplitude (a limiting factor on how much voltage gain the amp can provide), and measurements made in the same way.

Some ideas:

Square and trapezoid pulses can be made easily with PWL (as you have been doing).

A raised cosine pulse can be easily produced using something like:

(setf dur 0.1)
  (mult 0.5
    (sum 1 (osc (hz-to-step (/ dur)) dur *sine-table*  -90))))

This gives a nice “Gaussian” bell-shaped pulse:

(defun pulse (y n)
"n is the number of samples returned"
  (setf y (float y))
  (setf arpulse (make-array n))
  (let* ((ln (1- (length arpulse))) ;arrays are zero indexed
         (step (/ 2.0 ln))
         (offset (/ y))
         (norm (/ (- 1 offset))))
    (do ((x -1.0 (+ x step))
         (index 0 (1+ index)))
        ((> index ln)(snd-from-array 0 44100 arpulse))
      (setf val (power y (- (* x x))))
      (setf (aref arpulse index) (* norm (- val offset))))))

(setf pulse (pulse 2000 451))
(setf hz 10)
(seqrep (i 100) (at-abs (/ i (float hz)) (cue pulse)))

#1 Patent application, (not granted) , #2 lapsed Patent , (non-payment of fees).
If the thing worked they’d have enough money to pay the fees, and reason to do so: to maintain monopoly control.

NB: Having been granted a patent is not proof the invention does work, or could work,
e.g. :smiley:

see …

Trebor, I completely agree with you. Our family jokingly calls these expensive PEMF machines: “the best snake oil ever tasted”! The Wikipedia page on Dr. Oz notes

“An investigation by the British Medical Journal found that 46% of his claims were misleading or incorrect”.

It is also illegal in my country to use testimonials for proof that something works. The testimonials that I posted could very well be a placebo effect due to an elaborate placebo machine. We are receiving pain relief, not because the electromagnetic pulse works but because we anticipate and believe that it works. I may just be Pavlov’s Dog - salivating over a “bell shaped” sinusoidal tone generated in Audacity to drive an electromagnet.

The placebo effect is know to be so persuasive that in order for medical research to be valid, it must be blind or double-blind. i.e.

  • The subjects are divided up and half receive no magnetic pulse ( a placebo ).
  • The doctor analyzing the physiological and biochemical changes of the subjects must also not know know if the subject received the magnetic pulse or not. This avoids medical bias.

The best way to investigate if PEMF is placebo or not would be to read the double-blind scientific peer reviewed articles. Try Google Scholar (not Dr Oz website):

I will stop posting testimonial info. This is the wrong forum to discuss, explain, prove or disprove PEMF therapy. Yes I’m building a PEMF device. I’m on the form to get assistance with Audacity and Nyquist plugins. So far the forum members have been a great in helping me generate wave-forms used to drive an electromagnet.

The field-strength with the commercial PEMF machines is enormous : enough to cause muscles to twitch,
and sparks if metal objects are nearby, (see this scam cancer-clinic in Mexico).
So difficult to come up with a double-blind experiment, as the those getting the “real” treatment will feel it.

It was in your interest (and your family) for me to mention that quack electro-therapy devices exist,
e.g. …

Thanks DMonty, very kind.

I found the echo while recording the magnetic pulse via mic can be fixed in Audacity by:
Unchecking: Edit=>Preferences=>Recording=>Software Playthrough

The magnetic pulses are much cleaner and now closely match the audio out wave form.