Group Abstract Group Abstract

Message Boards Message Boards

Accurately calculate tick tock period of mechanical watches?

Posted 8 years ago

I'm looking to find the frequency of a relatively large dataset (or a relatively short audio file) of a repeating sound, like so:

sound Here are the original files, for those willing to play. :) eta2412 data1 Other examples: phenix140sc chaika1601

Blue is the original soundwave, and orange is a Highpass and Wiener filtered form at 44100Hz sample.

A finely zoomed in picture of each "tick" (unfiltered in an audio program) looks like so: enter image description here

It's extremely oscillatory, however, there is a clear and obvious local maximum (when zoomed in far enough anyways (the duration of a tick is 0.016s or so)

I'm not particularly interested per say in the amplitude, however what I'd like to do, is to be able to automate and count the freq. of the "beats/ticks". This is currently done 'by hand' for each individual file I have to deal with and when a person has MMA...well, you get the point

Accuracy is a must in this case, the possible periods of the beats are at 0.200 [s] and 0.166 [s] repeating (5hz, and 6hz respectfully). Any kind of drift more than +/-0.002 second isn't acceptable.

Through many readings of this link, this link,this (the last link does nearly what but alas it's bpm) and many others, I've managed to cobble together something...that doesn't seem to get me anywhere.

dir = NotebookDirectory[];
SetDirectory[dir];
file = "eta2412.m4a";
snd = Import[file];
sndhpf = HighpassFilter[snd, 20000];
sndwf = WienerFilter[HighpassFilter[snd, 20000], 25];
sndSampleRate = Import[file, "SampleRate"];
p1 = AudioPlot[snd,  PlotRange -> {{0, 5}, {-1*10^-2, 1*10^-2}}];
p2 = AudioPlot[sndwf, PlotRange -> {{0, 5}, {-1*10^-2, 1*10^-2}}, PlotStyle -> Purple];
p3 = AudioPlot[sndhpf, PlotRange -> {{0, 5}, {-1*10^-2, 1*10^-2}}, PlotStyle -> Green];
data = Flatten[AudioData[sndwf]];
data1 = Drop[data, {50000, Length[data]}];

I've attempted to do audio processing itself,

getting to

res = AudioLocalMeasurements[sndwf,"RMSAmplitude",PartitionGranularity ->{Quantity[0.1, "Milliseconds"],Quantity[0.1, "Milliseconds"]}];
ListLinePlot[res, PlotStyle -> Red, PlotRange -> {{0, 2}, {0, 0.005}}]

Show[AudioPlot[sndwf, PlotRange -> {{0, 5}, {0, 0.005}}],ListLinePlot[res, PlotStyle -> Red, PlotRange -> {{0, 5}, {0, 0.005}}], AspectRatio -> 3/6, ImageSize -> "Large"]

show

Now, I'm unfortunately at a complete loss on how to get each ticks local peak and calculate their global frequency, or rather, period.

How would one go about this? I've tried in Fourier as suggested in other posts..but the noise seems too extreme to give me anything I can understand or use to get further.

ListLinePlot[p = PeriodogramArray[data1], PlotRange -> All, ImageSize -> Large]

fourer

I have posted this over at stackexchange as well, incase this seems familiar to anyone. But I figured I'd try to hit two birds with two stones, should someone there post a solution I"ll gladly update it here. Thanks for the help! :)

POSTED BY: Mor Bo
16 Replies
Posted 7 years ago
POSTED BY: Mor Bo

@ Mor Bo (01/04/2019) : You provided "TickingClock.nb". Can you provide your "eta2412 data1" as another attachment available in this Mathematica Community post? Your internet link to this data file (and other data files above) are no longer working. Thank you! Gilmar Rodriguez-Pierluissi

Posted 8 years ago
POSTED BY: Mor Bo
Anonymous User
Anonymous User
Posted 8 years ago

I feel like you didn't read

i've read it again i see no mention that you already had a solution and were duplicating it for hobby

the OS i showed is obviously just one model - i did not say it was the least cost model needed

POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 8 years ago
POSTED BY: Anonymous User
Anonymous User
Anonymous User
Posted 8 years ago
POSTED BY: Anonymous User
POSTED BY: Neil Singer
POSTED BY: Neil Singer
Posted 8 years ago

I will write you an email today, as soon as I get a chance! Definitely looking forward to working with you on this problem :)!

POSTED BY: Mor Bo
Posted 8 years ago
POSTED BY: Mor Bo
POSTED BY: Neil Singer
Attachments:
POSTED BY: Neil Singer
Posted 8 years ago

Hi Daniel! Ahh here are some links for the audio files, with .mp3 extension....the m4a are typically Apple. I attempted to something similar with MaxPeak, however it seemingly failed with the line plot only returning 1s (likely my poor MMA skills at work here)...The only issue I could see with it however, is that there isn't any nice cutoff for maximum peaks, between different movements things can change wildly.

I'll look into trying clip, hope the mp3s are useful :) in the meantime.

phenix140sc chaika1600 eta2412

POSTED BY: Mor Bo

Apparently my Linux machine does not like that format, so I cannot experiment. From the pictures, I wonder if you might use Clip to set values above some threshold to 1, and below to 0. The main frequency might then be more easily obtained from Fourier or similar.

POSTED BY: Daniel Lichtblau
Posted 8 years ago

As additional information I

All the watches I deal with for work are 5hz or 6hz explicitly, to gauge their accuracy, or (where the research is) the degradation of them over time, I load up the recorded file, and measure the peaks by hand in sonic visualiser and average the peak period. Some movement info and examples can be found: eta2412 Phenix 140SC As measured yesterday:

Phenix 140SC has a period of 0.187, making it 96 seconds per day fast Eta2412 has a period of 0.16668, making it -0.112 seconds slow. Chaika1600 has a period of 0.1678, making it -9 second slow.

Thanks again for the help!

POSTED BY: Mor Bo
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard