I am trying to write my own AFSK decoder with QT/C++.
cool!
(ITA2 LSB)
ITA2 turns 100 in two years, what a legend! Hope you're in for some specialities not owed to it being logical or easy the way it is done, but possible by devices which didn't even have the vacuum tubes and which predate even the fundamental theory behind communications over a noisy channel. This is not a complex mode, but it's one that's actually not well-suited for anything but the original device designs :) This just increases my respect towards this project.
I am unable to figure out how to synchronize the data stream.
That's actually a good sign – synchronization is the harder part in such systems, compared to simple demodulation!
So on decoding ... is there a preamble i.e. ? Note: This is my made-up preamble.
01010 10100 00110
<PRE> <H> <I>
The problem lies even deeper: your receiver doesn't even know when one 0 ends and another 0 starts, or more generally, what the symbol timing is.
You need timing recovery, as us communications engineers would say!
Now, how to do that really depends on how you're demodulating the AFSK. FSK is generally not the easiest system to synchronize, and you'd work with how the demodulator deals with changes in frequency. However, different demodulators deal with things differently!
But: of course, if you have a preamble that's long enough (so that the energy in preamble -to- energy in noise during preamble is high enough) you can just use a correlator that you just let run all the time on the raw input signal. As soon it sees a preamble, it can output a sample-accurate (sub-sample-accurate, even, if you know a bit about the FSK pulse shaping) estimate of the time at which the preamble happens – and from there, it's just counting forwards.
However, Baudot code ITA2 is 98 years old, so no, it doesn't have a proper preamble. You're picking an unnecessarily hard system! It only has a five-pulse "preamble", which isn't unique, has bad autocorrelation properties, and thus, is hard to detect.
No