Is there an easier way to analyze periodic spikes?

Help for Audacity 2.x.x on GNU/Linux.
Forum rules
This forum is for Audacity 2.x.x on GNU/Linux.
• which version of Linux you are using,
• the exact three-section version number of Audacity from Help menu > About Audacity,
• whether you installed your distribution's release, PPA version, or compiled Audacity from source code.

The old forums for those versions are now closed, but you can still read the archives of the 1.2.x and 1.3.x forums.
RandomTroll
Posts: 15
Joined: Tue Jan 12, 2010 5:53 am
Operating System: GNU/Linux other

Is there an easier way to analyze periodic spikes?

I want to measure the speed of my pickup truck's engine. I made an inductive pickup that I wrapped around the ignition coil's wire and recorded a few minutes of it idling. That gives me a spike twice every time my engine rotates. I had hoped to get Audacity to count the spikes for me, but I can't find a technique in 'plot spectrum' or elsewhere that does that. It doesn't even detect the frequency of the pulses as a frequency, just the frequency content of the spikes themselves. So I have to squint and count by hand. This is not a big deal, but I hoped for something more convenient and accurate.

Audacity 2.1.2, built from source 2017 February 10, Slackware, Kernel 4.9.9, wxWidgets 3.0.2, other packages updated daily.

kozikowski
Forum Staff
Posts: 40428
Joined: Thu Aug 02, 2007 5:57 pm
Operating System: OS X 10.9 Mavericks
Location: Los Angeles

Re: Is there an easier way to analyze periodic spikes?

That gives me a spike twice every time my engine rotates.
You have a two cylinder pickup? I guess you could have six coils.

You can get there from time. Measure the time between two spikes and divide that into 1.

.001 seconds into 1 is a thousand cycles, 1KHz. Pick the time between the first and fifth spike and divide by 5 to get better time accuracy.

Koz

steve
Posts: 47281
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Is there an easier way to analyze periodic spikes?

If you post a short sample in WAV format, we may be able to offer better suggestions (see here for how to post an audio sample: http://forum.audacityteam.org/viewtopic ... 49&t=72887)

RandomTroll
Posts: 15
Joined: Tue Jan 12, 2010 5:53 am
Operating System: GNU/Linux other

Re: Is there an easier way to analyze periodic spikes?

I have a 4-cylinder engine with 1 ignition coil that fires every half-rotation.

I asked in this forum so that I wouldn't have to count by inspection.

I read the FAQs first; I always do.

I eventually figured it out by excerpting a single second and raising 'Size' in 'Spectrum Analysis' to 4096. This revealed 43 Hz as the most-common frequency, followed
by its harmonics; I counted 43 spikes in the 1-second sample. 1290 rpm sounds about right.

I take it 'Size' is a divisor; when I tried 65536 Audacity complained of too little data.
Attachments
20170211_Second_420.wav

Trebor
Posts: 4506
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows Vista

Re: Is there an easier way to analyze periodic spikes?

RandomTroll wrote:I eventually figured it out by excerpting a single second and raising 'Size' in 'Spectrum Analysis' to 4096. This revealed 43 Hz as the most-common frequency ...
ATTACHMENTS
20170211_Second_420.wav (187.78 KiB)
On that recording the fundamental frequency is ~37Hz ...
''20170211_Second_420'' = 36,5Hz.png (38.58 KiB) Viewed 531 times
The seventh harmonic is 292Hz , so the fundamental is 36.5Hz
Audacity spectrogram of ''20170211_Second_420'' = 36,5Hz.png (36.31 KiB) Viewed 531 times

steve
Posts: 47281
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Is there an easier way to analyze periodic spikes?

Trebor wrote:On that recording the fundamental frequency is ~37Hz ...
Counting the peaks with Nyquist gives the same answer:

Code: Select all

``````;version 4

(setf threshold 0.8)  ;count click each time we cross this level
(setf step 180)       ;follow waveform in steps of this number of samples

;; Use only the left channel of stereo tracks
(if (arrayp *track*)
(setf *track* (aref *track* 0)))

(let ((sig (snd-avg *track* step step op-peak))
(dur (get-duration 1))
(count 0))
(do ((val (snd-fetch sig)(snd-fetch sig))
(low t))
((not val) (/ count dur))
(cond
((and low (> val threshold))
(setf low nil)
(setf count (1+ count)))
((< val threshold)
(setf low t)))))
``````

steve
Posts: 47281
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu
Contact:

Re: Is there an easier way to analyze periodic spikes?

steve wrote:Counting the peaks with Nyquist gives the same answer:
With this solution, the "step" setting is important.
Zooming in on the track we can see that there are gaps of around 400 samples length between spikes, but the spikes themselves have "gaps" of around 70 samples duration. To count the spikes accurately we need to smooth the waveform so that the "gaps" are ignored, but the spaces between spikes remain. To do this I chose to smooth the track in steps of 180 samples, but anything between about 100 and 300 should work.
window001.png (54.04 KiB) Viewed 526 times