WatchUSeek Watch Forums banner
1 - 20 of 68 Posts

·
Registered
Joined
·
87 Posts
Discussion Starter · #1 ·

Hi guys,

I have a more or less usable version of my timing program that is ready
for initial testing, if anyone is interested.

First the goodies. Here are Windows binaries
http://ciovil.li/tg.zip
and here is the full source code
https://github.com/vacaboja/tg

Now some info on the program. This program is released under the GNU GPL
license, version 2 -- basically you can do what you want with it, free of
charge, no warranty, if you redistribute a (modified) version, you must
distribute also the source code. If you want to build from source, you
need gtk+ (I'm using v. 2.24), portaudio2, and fftw3, plus a C99 compiler
clearly. If you want to run the Windows version, just download the zip
archive, unzip, double click.

This program tries to pick up audio from the default audio input of your
computer, which should be the same that Audacity defaults to, so you can
test the audio setup with Audacity. It does not fiddle with the volume:
just check that it is set to a reasonable level. Of course the rate that
you get from this program, for any watch, is affected by the rate of the
clock of your sound card: the same holds for all timing programs and there
is no escape (except calibrating the card against a reliable time source).

The algorithm I decided to use is quite hungry of computing power, so I
made two versions: "tg" is the full version, "tg-lt" is a lighter version.
The light version sacrifices some accuracy and noise resilience for speed.

My intended audience is amateurs and tinkerers. This program has not been
written for professionals, neither do I want to compete with
professionally built hardware or software, nor with those that can write
better software on their own. In particular I have set to myself the
following three goals.

One. Try a less conventional algorithm to deal with bad audio, at the
expense of lots of number crunching (all other programs for which I did
find information online use possibly some band pass filter and a threshold
trigger, we do it differently). I can currently obtain satisfactory
results from the internal mic of my ThinkPad and a few other lower quality
mics. I don't know how it will perform with a good piezo, but I am
interested (probably, for clean audio, mine is not the best approach).
Your mileage may vary.

Two. To avoid complaints like this one
Review: TickoPrint Android App | Watch Guy
the entire operation of the algorithm is designed to be double-checkable.
In particular, the waveforms that the program associates to the tics and
tocs of the watch are shown in real time, so one can check that they are
properly recognized and properly aligned. The slope representing the
currently detected instantaneous rate is drawn (the blue lines) on the
timing-machine-like graph, etc. See also the discussion here for some
example of such double checking
https://www.watchuseek.com/f6/definition-beat-error-2394130.html

Three. Make it open source, so other people can tinker with the source
code (well, this one was the easy part).

Usage should be quite intuitive for those that know how an escapement
works. See also the thread referenced above for more info.

That's all for now. Any feedback is appreciated.
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #3 ·
I poked through the source a bit, and have grabbed the windows build. I can't wait to actually try it out, I'll need to dig up the old piezo mic I cobbled together years ago.
Thanks a lot!

Theoretically, you should not need a piezo. For instance, this
http://ciovil.li/tic4.wav
is one of the test cases that I have been using (it's a weak watch with lots of beat error and dogs, recorded with some regular microphone). If you can get audio of this quality, then the program -- wishful thinking -- should give you some reasonable output. Audio like this one, for instance, also works apparently well (I'm not the author of this video, I just used YouTube as another source of test cases)
This is the mother of all test cases (I'm not the author of this either)
the current version, here, does not lock on the 18000 bph. The 21600 is all over the place, and the amplitude is so bad that it's out of the scale, but that's a problem of the watch, not of the program.

I'm not a Windows user, so the Windows version has not been properly tested. If it gives absolutely no reaction, then just assume that something is wrong with my audio interface. In this case, I would be grateful if you let me know.
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #9 ·
Please correct me if I'm wrong. I guess the amplitude is given.
Testing another watch (that I cleaned about 1 1/2 year ago and just wound up) a difference is visible (marked in screenshot). In my opinion it'll give about 300° to the one side and about 280° to the other.
Is my speculation right that the hairspring is not exactly in the middle of the pins?

First of all, many thanks to you for your review, and also to the other
participants of this thread.

You are absolutely right that the amplitude is given, and also on the
method to read it. The decision not to show the amplitude in a numerical
format is actually deliberate. In fact, you pointed out quite clearly one
of the reasons that lead me to this decision: let me describe it more in
detail for the rest of the readers. The amplitude, as your figure
demonstrates quite clearly, is determined by the timing of the first pulse
of each tic or toc (relative to the third pulse, and also by the lift
angle, etc.). It happens quite often that this timing is not consistent
between the tics and the tocs, so the tics suggest an amplitude of, for
instance in your case, 300 deg, and the tocs of 280. Some difference is,
actually, almost always there. So what can we say about the amplitude in a
case like this? Honestly, the only correct statement, is that we estimate
the amplitude to be about 280-300 degrees. Any more precise figure, like
293 or something, would be a misrepresentation. This is not a deficiency
of the algorithm: you can check with Audacity, for instance, that the tics
and the tocs are actually different. The data is quite simply not there.

In conclusion, I elected to let the user, with his human brain and his
common sense, do the pattern matching and read the amplitude off the
graphs. That is in keeping with the principle of producing only
information that can be understood and checked, no magic numbers. In
conclusion, for me, it is a feature, not a deficiency.

On the other hand, I started this thread precisely to know your opinions
about this program, so I am very interested to know if you find that this
was a bad choice.

About the reason of the difference, you suggest that it is because the gap
between the pins is too large. I have completely no idea. Maybe sometimes
the actual (as opposed to nominal) lift angle of the tics and the tocs is
slightly different due to manufacturing tolerances, the banking pins being
a little out of symmetry, or some other form of the multifarious
phenomenon known as bad luck. I would love to read the opinion of a
watchmaker.
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #11 ·

Thanks a lot, Ocram, for testing on newer Windows systems, and also for
your "like" and your review. I have a penchant for doing idle blah blah on
this forum, so you will excuse me if I take your screenshot as an
opportunity to indulge.

You pointed out exactly the kind of use case that I had in mind! Cheap
consumer mic, and a diver case that, I believe, does not help. If we
imagine an absolute beginner, he will almost invariably be more or less in
such conditions. At least I was in these conditions (and I still am an
absolute beginner at best). The only option that one can trust and does
not involve some form of commitment is to use generic audio editing
programs like Audacity. This method is sure, but so slow and boring that
even I (despite being thorough _and_ slow) became discouraged.

Also one can see in your screenshot my other reason not to include a
numeric display for the amplitude. When the audio is bad, it might be
still possible to get the rate and the beat error, but the amplitude is
often lost because the first pulse is to weak to come through the noise.
The user can read the graphs and decide very easily, but, at least for me,
to design an algorithm that reliably does that is a nightmare (or perhaps
a dream). And also pointless, because the user can do it better than the
machine anyway.


 

·
Registered
Joined
·
87 Posts
Discussion Starter · #12 ·

Hi my friends!

Just a little update: I fixed a bug in the algorithm that prevented it
from locking in some situations, and I made a small change to the
interface. Download link, the same.
http://ciovil.li/tg.zip

I really appreciated the enthusiastic reviews of Klaus and Ocram (Marco?),
however I would like to find the remaining bugs and call it v.1.0. So
anyone who tries it and is dissatisfied will have my gratitude if he drops
a line, even by PM. Any critical opinion is welcome. (However please
update to the latest version.)

By the way, I am becoming addicted to test every random watch from
Youtube: it makes even a noob like me feel like I have the elusive BCB.
And you don't get this with any other program! For eye-candy, here you
have one with birds, I suppose, and severe positional variation.

Line Font Technology Slope Pattern

 

·
Registered
Joined
·
87 Posts
Discussion Starter · #15 ·
Hi Contrate_wheel,

Your program looks neat. It might have been a different thread, but I think you were suggesting compiling for OSX would be trivial.

Could you post instructions on how to do this? I am running OSX 10.10.4 if that is of interest.
I can not write instructions because I don't have a mac to experiment with, but, if you want, let's try it!

So, you need to be able to compile C99, if you have make and pkg-config things will be easier, and you need to link with gtk+2, portaudio2, and fftw3. There are multiple ways to achieve this, either installing the development tools and libraries sparately, or using some distribution that packages all of them. When I had a mac (centuries ago), I used FINK (Fink - Home), and they seem to be still alive.

In short, you need (1) being confortable with the command line, (2) a working development environment, as in "beeing able to compile hello-world", (3) it's better to have make and pkg-config, (4) gtk+2 -- version 3 might also work, (5) portaudio2 and fftw3.

To make progress I need to know at which step you are...
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #16 ·
as i said could you add the amplitude even the average one, that would mean a lot to the more serious hobbyst's .

br emso
Thanks, you made me reconsider my design a bit.

As Klaus demostrated, the amplitude is there, it's just not written as a number. For instance, in the screenshot above (pretending that the lift angle 52 is correct: I didn't look it up), the amplitude is about 155 deg.

I have three questions:
1 - Did you try the program on your setup?
2 - Was it hard to read the amplitude from the graph (if yes, screenshot or even better sound sample would be appreciated)?
3 - Why do you feel that the number is better than the picture?

The third is not a rethorical question. Users are king, so if users really prefer a number, then I will see what I can do to get it!
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #20 ·
@1 setup as shown in first picture
@2 let me say ... depending ... I tried to add some soundfiles to show you why, but have not been able to upload them o|
@3 to have an unreliable number is not as helpful as a reliable graph. I prefer to decide by myself if the amplitude can be read from the raw-data. An additional value in form of a number would be fine.
Thank you. I was actually asking these questions specifically to Emso, yet your answers are very welcome!

I agree with you. I will try to add a numerical value, without subtracting anything from the current design. As you see, one needs to devise an algorithm smart enough to decide whether the numerical amplitude is reliable (and then show it) or not. I have definitely to think and experiment, but it would be stupid not to try.

Your sound samples would definitely help me immensely. In particular the good ones. By the way, if anyone is interested in contributing to this project, real world samples are the thing that I need more.

I don't know how to upload them on the forum, if possible at all. As you can see I am a noob. You could put them in Dropbox, or somewhere else on the public internet, and post a link. Feel free to PM if you don't like posting it. I will also send you my e-mail by PM, so you can e-mail them to me, if you prefer. If you can, use an uncompressed format (zipped .wav is OK), and take at least 30 seconds.

Thanks again!
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #23 ·
@Baillive

Thanks a lot! The flag -fcx-limited-range enables an optimazation on complex division: it has completely no impact, not even on performance. So I removed it. Actually I don't even remember why it was there, probably left over from some previous version of the algorithm. It's great that you managed to compile on OS X! As soon as I'm satisfied with this testing phase, if you agree, I will ask your help to make a mac binary to distribute. Maybe you could not post links because that was your first post? Some sort of anti-spam countermeasure? It seems strange because I am sure that I posted links on my first post.

@Diveboy

Thanks. There are many schematics for microphones and ampifiers on the internet, and also on this very forum, I believe. However, my program has been designed to work with bad microphones, at least a little, and, in fact, it is the first program out there made specifically for this goal, as far as I know. The idea of using a clip-on guitar pickup suggested by Klaus in this thread sounds very very good to me. Unfortunately I didn't have time to experiment with that, but I most probably will. There is even the possibility that it might work without the amplifier: Klaus, did you try?

Now I am debugging (thanks to Ocram for a lot of support and some pretty good testing) and working to add an amplitude display. The import and export to file is definitely a good idea, actually I had this capability in place in a much older version of the program, but I removed it because it became messy to maintain. To analyze a sound file, if you want a workaround, you can just redirect digitally the sound output of your system to a virtual input device, set this as default input, and play the sound file with just any player. This is how I test the program on known samples. On linux/pulseaudio, this can be done in just a couple of clicks using pavucontrol. There must be a way to do it on Windows as well, but I don't know it.

A couple of pages of manual will definitely come as soon as we are at version 1.0. At least if there is enough interest.
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #29 · (Edited)
@consum3r
- Linux: yes, I developed on Debian Jessie. Should compile under any common distro. You need gtk+2, portaudio, and fftw3 (on Debian or Ubuntu you need to install the -dev version of these libraries, don't know other distros).

@Halda
- Yes, a statically linked OS X binary would be better. To make one, it might be enough to modity the Makefile adding -static to the LDFLAGS and also --static to the pkg-config command in there.
- Out of beat means that the beat error is (significantly) different from zero. An asymmetry in the tic's and the toc's waveforms is something different. How to interpret it, in a horological sense, was already asked by Klaus and by me. I am no watchmaker, so I don't know, and unfortunately no one answered.
- Watch-O-Scope is a very nice commercial program, it comes for free in restricted form for non commercial use, and its author is also a member of this forum. It's much superior to biburo, in my personal opinion, which is also for free proprietary software. Another very complete program is Watch Escapement Analyzer, unfortunately the interactive version comes at a fee. All of these programs take a similar approach (as far as I can tell) and the algorithm of tg is radically different. I had fun comparing them together and with tg.

I hope to find the time to put out a tentative amplitude display this weekend.
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #31 · (Edited)
it had trouble with a high beat movement, kept jumping between 18,000 and 36,000.
Thanks! You have hit a known bug, that was already fixed, hopefully. However, my fault, I forgot to make a new Windows binary. May I ask you to re-download (you will recognize the latest version by "tg 0.1.0" in the upper left corner), repeat the experiment once more, and tell me the result?

Clearly you understood that the beat error 3.6ms for your Elgin Grade 760 is spurious. I guess that tg actually displayed a value close to zero, the correct one, most of the time, and it jumped to 3.6 occasionally. This happens because, as you can see, the waveforms of the tic and the toc are very different from eachother, and this fact confuses tg quite a bit. It would help me a lot if you could send me a 30 seconds recording of your watch...

The Elgin Grade 69 looks great! Is the lift angle of this movement really 52?

Thanks again for your contribution!
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #33 ·
two feature requests

1. "Reset" button, I found when swapping watches I was just closing it and launching it again.
2. Version number in Title - will confirm what version is being ran.

The Elgin Grade 760 hasn't been serviced, so I expect it to be "random" and didn't read too much into it.

The Elgin grade 69 has been serviced by an expert and you can clearly see the results. I'll confirm the lift angle with said expert and redo the testing if it's different.

I'll download again and test in the next 48 hours.

Thanks again
Great, thanks to you!

Feature 1. Perhaps you are referring to the fact that the animation stops when a watch is not detected any more. This is just to allow close examination of the trace. As soon as a watch is detected again, tg should resume its normal function automatically. Can you confirm?
Feature 2. Just did :) Starting from the latest version it's on the top left of the window, before there was no version number at all...
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #35 ·
it does resume but I like a clean slate for a new test, IE if I change watch or change watch position, then by resetting the display, I know when it started testing, I don't have to remember at what point I changed something.
I see, basically a "clear trace" button. That's a good idea, and it's also very easy to add. I will certainly do it in the version with the amplitude!

Thanks again!
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #38 ·
Nuntio vobis gaudium magnum: habemus amplitudinem!

Well, just a little update to tell you that I have a tentative amplitude algorithm that should be more or less stable if the audio is good. The download link is the same
http://ciovil.li/tg.zip
and the source code is here
https://github.com/vacaboja/tg

Thanks to all those that contributed so far, and in particular to Baillive, Diveboy, Klaus, and Ocram.

Testing is dearly needed and comments of all sorts are deeply appreciated!

Here is the obbligatory screenshot of tg 0.2.0 running on a fine sample provided by Klaus.

Text Line Font Technology Oscilloscope
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #41 ·
Great !

I tried to compile on OSX, but the executable crash at launch because he's not able to find the font, even if they are in the same folder. The result was the same when I installed the font on the system.

I tried a few things, but I was not able to find a workaround. Maybe the solution is to use relative path ? Or maybe the system for selecting a font is fundamentally different on OSX.
Thanks, I am baffled. I added some error reporting, could you please update your source and tell me the error message?
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #44 ·
@Halda

Beautiful, thanks a lot!

I was about to ask you to try more or less the same experiment, in fact I just updated the code in such a way that it builds a path. I also replaced FT_New_Face() with FT_Open_Face(), that should follow the same code path under linux and OS X. It would great if you could try again, but I believe that the same result will follow (no text visible).

If it still does not work, I will just use a default font as fallback. The problem with using the default font is that, at least under Windows, not always the monospace one is really monospace. Yet it's better than nothing I guess...
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #47 ·
Yep, only the lines drawn before the first call to cairo_show_text(). So apparently the first misbehaving cairo_show_text() messes up the cairo context, and from that moment on nothing else is drawn. This also explains the zero height, because probably everything cairo-related is just garbage. Font file corrupted? The md5 of mine is 37d8aff129ecd7d3fc495b7239f834db.

As an experiment I tried to set cr_face to NULL and, on debian, cairo just reverts to the default. Apparently cairo_ft_font_face_create_for_ft_face() is not supposed to ever return NULL, but there is a function cairo_font_face_status(cairo_font_face *f) that should check whether an error has occurred with f. Except for this, these objects seem to be pretty opaque. There is a function cairo_font_extents() that is more or less like cairo_text_extents(), however it works on the cairo context, not on the font face itself.

Thanks a lot for this...
 

·
Registered
Joined
·
87 Posts
Discussion Starter · #51 ·
@Apollonaught

Thanks for your review.

The figures on page 3 of this manual
http://www.witschi.com/assets/files/sheets/Test and measuring technology mechanical watches.pdf
show how the noises produced by an escapement are supposed to look if recorded with a perfect mic. The amplitude is determined by the timing between the first and the third of the three events. The first watch of your screenshots is perfectly fine, however, as one can see from the graphs, the first pulse is too weak to stand out above the noise, so tg is unable to compute the amplitude. This happens only because you are using the internal mic of your computer, and, you might try, but I believe that no other publicly available program would perform better than tg in this situation. I would venture to say that here one can not extract the amplitude from the audio data, because this information has been completely destroyed by noise.

So, strictly speaking, it is not volume, rather it is signal-to-noise ratio. In your other watch, the first pulse is just about visible above the noise level, so tg can, and in fact does, pick it up.
 
1 - 20 of 68 Posts
Top