WatchUSeek Watch Forums banner

Open source timing software.

318K views 673 replies 145 participants last post by  aimhigh9685 
#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.
 
See less See more
#2 ·
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 for doing this, especially as FOSS. I started a half-hearted attempt a few years back but became too bored with learning about FFTs to see it through. I'm glad there was someone else out there willing to stick to it.
 
#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.
 
#5 ·
Kudos to you contrate_wheel !!!

Both versions are running perfectly (Win10) I've just finished "playing" with your software for a while with simple and inexpensive hobbyist equipment (small amplifier ~10€ + battery ~75ct + guitar pick-up-clip ~2€ + some cables from my junk box + some soldering)

The algorythm for filtering noise and calculating timesignal IMHO seems to be crazy good.
I recently adjusted one of my watches using biburo and today checked it using your new programm. My conclusion: 100% plug-and-play :) 100% working :) 100% fun :)

I try to add some pictures (upload-newbie ... sorry if it fails)

Wire Electronics Technology Electronic device Gadget

Text Line Font Technology Pattern
3H
Text Line Font Technology Oscilloscope
6H
Text Line Font Technology Diagram
9H
Text Line Font Technology Design
12H
Text Font Line Design Technology
CH
Text Font Line Technology Oscilloscope
FH
 
#6 ·
good working but i cant see the amplitude values here, are they available because its an must information of how good the watch is repaired/condition
 
#8 ·
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?

Text Line Font Technology Oscilloscope
 
#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.
 
#27 ·
#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.


 
#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

 
#14 ·

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.


View attachment 5972098
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
 
#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...
 
#21 ·
Ok, so I can't post links... I will give the title of the relevant articles to search on google.

Thank you very much for this wonderful programm, contrate_wheel, this is how I got it working on OSX:

  • Install xcode command line tools (this is the compiler, you can find the instructions ont this article : How to Install Command Line Tools in OS X Mavericks & Yosemite (Without Xcode) (OSX daily)
  • Install Homebrew (this is the modern equivalent of fink) : brew(dot)sh
  • Type in your terminal : brew install gtk+ portaudio fftw
  • Time to compile tg, and here things get a little complicated :
    • You can download the version I compiled using the following link (dropbox(dot)com/s/bqefi53fyxhl6bz/tg-master.zip?dl=0). You can use it by clicking on the tg executable. Your mac will probably complain that the executable come from an unknown source (the solution is here : OS X Mavericks: Open an app from an unidentified developer (apple)).
    • Alternatively, you can download the latest source version and compile it. But this will result in an error and contrat_wheel help is needed : the OSX compiler treat any flag he doesn't know as error and abord the make process. Turn out he doesn't know the flag "-fcx-limited-range" and I was only able to compile the programm after removing this flag for the makefile. I don't know what this flag mean, but the programm seems to run fine without it. Can you remove it, or deactivate it somehow when compiling on OSX ?

For a primer on how to use the Terminal :
Introduction to the Mac OS X Command Line (teamthreehouse)
 
#22 ·
looking good. just need to have the microphone/amplifer opensourced and we are all gonna be happy.

If your looking for ideas, heres some suggestions

1. export/import to file so you can share it with someone
2. export to report file (pdf/jpg) so you can store it with the watch in your records
3. as someone has said, needs instructions or a what is this saying section for noobs like myself

Thanks so much for your time on this already
 
#25 ·
looking good. just need to have the microphone/amplifer opensourced and we are all gonna be happy.
A contact mic is not too hard to make, just scavenged one together out of junk yesterday with a piezo disc and an old pair of headphones, but the preamp is a bit trickier. I've ordered some components last night to try and make one, and if I get it working I'll see if I can put together some pictures and instructions etc. to post here for everyone else.
 
#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.
 
#68 ·
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?
Well, I did try but failed getting a poor signal. The reason might be that the piezo is sensitive predominantly for solid-borne sound which is very low.

If anybody else is going to try the pickup the following might be usefull. I removed the foam rubber for better contact and covered the hole with an adhesive tape to reduce sound-pressure of ambient noise. No big effect for the tape, just as a matter of conscience.

Dynamic microphones didn't satisfy my needs completely but the sound processing of timegrapher is such good that the built-in microphone of a laptop will be enough for a rough shot.

...but I can't get the application to run at all. I'm using Windows 7 Pro 64-bit and when I extract the files from the .ZIP, install the font, and attempt to run the program, nothing happens. I don't see any errors in the Windows error logs. I get a second or two of Windows "spinning wheel" but the program never launches. Could I be doing something wrong?
I'm experiencing as well the issue with version 0.2.0 and 0.2.2 not starting anymore and "the spinning wheel" causing the explorer to stick. Maybe caused by some windows 10 or antivirus updates? The old version 1.0.0 (nov 5th) is still running perfectly.Restore Auto-Saved Content
 
#24 ·
This looks great! Looking forward to future development.

I'm also on OS X, and can confirm it working on OS X 10.11 El Capitan.

The instructions posted above by Baillive does work, but note that you have to first install the required libraries via Brew before you can run the pre-compiled app. If we want a full stand-alone OS X app, it needs packaging together with GTK+ etc.

Some feedback on the amplitude discussion: I think it should be displayed like most other Timegraphers do. Check the Witschi technical paper. Their description of the amplitude makes it seem that they only measure the tic OR the toc pulses. I.e. the 1st and 3rd pulse OR 2nd and 4th. It's not entirely clear if the value they display is the average, but it does look like that. They also display the standard deviation, which is a nice extra.

BTW: If the amplitude measurements are different between tics/tocs that would mean the watch is out of beat, right?
 
#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.
 
#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!
 
#32 · (Edited)
Feature requests

1. "Reset" button, I found when swapping watches I was just closing it and launching it again.


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
 
#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...
 
#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
 
#39 ·
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.
 
#40 ·
I was going to do a small UI suggestion and ask for the data fields in the same order as real machines, but when checking I realized they are not all the same.

The original red Witschi Watch Expert had the fields as: RATE - BEAT ERROR - AMPLITUDE (and bph & lift angle at the bottom)

Witschi Watch Expert III has: RATE - AMPLITUDE - BEAT ERROR (and at the bottom CALIBER PARAMETERS, with bph & lift angle)

The Chinese Timegraphers are: RATE - AMPLITUDE - BEAT ERROR - PARAMETERS (bph / lift angle)

I guess the common order is to have the amplitude before the beat error, so maybe those could be switched around. Perhaps the bph reading could be moved out to after the bph setting above, since it's not something that will change.
 
#43 · (Edited)
I tried to compile the latest update on my Mac (OS X 10.11.1) and it fails at "#include <cairo/cairo-ft.h>"
If I change it to "#include <cairo-ft.h>" it works. Any ideas why?

Anyways, I'm getting the same error as Baillive does for what it's worth.

Edit: I did some further debugging this morning and found that using the full path to the font file in FT_New_Face will make the error go away, so it must be a problem with locating the file.

I'm not sure where Freetype is looking for relative file names, but changing #define INTERFACE_FONT "VeraMono.ttf" to "./VeraMono.ttf" will fix the problem on Mac (assuming the font is located next to the executable).

However, no text will show up in the interface. The FreeType font does seem to load properly because it reports a valid number of glyphs available etc.

I did manage to get text showing up by replacing cairo_set_font_face(c,cr_face) in cairo_init with something that didn't use that specific font:

cairo_select_font_face (c, "sans-serif", CAIRO_FONT_SLANT_NORMAL, CAIRO_FONT_WEIGHT_NORMAL);

Text Font Technology Parallel Electronic device
 
#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...
 
#45 ·
It would great if you could try again, but I believe that the same result will follow (no text visible).
The updated code compiles fine now, and it does load the font file. |> You're right that the result is the same though, no visible text showing...

I haven't worked with any of these libraries before, but my guess would be that Cairo is to blame. Maybe the conversion from Freetype doesn't work or it needs more initialisation? Is there a way to probe the cr_face object for details? I checked the cairo_text_extents during the text rendering and it reported a height of 0, which might be a clue?
 
Top