Is there an easier way to analyze periodic spikes?

Help for Audacity 2.x.x on GNU/Linux.

ImageThis forum is for Audacity 2.x.x on GNU/Linux and Unix-like operating systems.
Please state which version of Linux you are using, the exact three-section version number of Audacity from Help > About Audacity... and whether you installed your distribution's release or daily version of Audacity or compiled Audacity from source code.

Audacity 1.2.x and 1.3.x are obsolete and no longer supported. If you still have those versions, please upgrade at https://www.audacityteam.org/download/.
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.

Is there an easier way to analyze periodic spikes?

Permanent link to this post Posted by RandomTroll » Mon Feb 13, 2017 10:04 pm

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.
RandomTroll
 
Posts: 11
Joined: Tue Jan 12, 2010 5:53 am
Operating System: GNU/Linux other

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

Permanent link to this post Posted by kozikowski » Tue Feb 14, 2017 1:37 am

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
kozikowski
Forum Staff
 
Posts: 36958
Joined: Thu Aug 02, 2007 5:57 pm
Location: Los Angeles
Operating System: OS X 10.9 Mavericks

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

Permanent link to this post Posted by steve » Tue Feb 14, 2017 1:51 am

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: viewtopic.php?f=49&t=72887)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 43900
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

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

Permanent link to this post Posted by RandomTroll » Tue Feb 14, 2017 5:18 am

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
(187.78 KiB) Downloaded 12 times
RandomTroll
 
Posts: 11
Joined: Tue Jan 12, 2010 5:53 am
Operating System: GNU/Linux other

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

Permanent link to this post Posted by Trebor » Tue Feb 14, 2017 8:16 am

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
''20170211_Second_420'' = 36,5Hz.png (38.58 KiB) Viewed 201 times

The seventh harmonic is 292Hz , so the fundamental is 36.5Hz

Audacity spectrogram of ''20170211_Second_420'' = 36,5Hz.png
Audacity spectrogram of ''20170211_Second_420'' = 36,5Hz.png (36.31 KiB) Viewed 201 times
Trebor
 
Posts: 3638
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows Vista

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

Permanent link to this post Posted by steve » Tue Feb 14, 2017 2:45 pm

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)))))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 43900
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

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

Permanent link to this post Posted by steve » Tue Feb 14, 2017 2:56 pm

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
window001.png (54.04 KiB) Viewed 196 times
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 43900
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

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

Permanent link to this post Posted by RandomTroll » Tue Feb 14, 2017 3:15 pm

Thanks. I uploaded a different sample than I analyzed. I had already
converted the sample I described to mp3 and deleted the .wav. I see
this one as having peaks at 35, 73, 110, 146... consistent with a
fundamental of 36.5. Curiously the 2nd-highest peak is 1904, the 52nd
harmonic.
RandomTroll
 
Posts: 11
Joined: Tue Jan 12, 2010 5:53 am
Operating System: GNU/Linux other


Return to GNU/Linux and Unix-like



Who is online

Users browsing this forum: No registered users and 1 guest