This is my first foray into Digital Signal Processing (DSP). It was spurred from an interesting video on the early days of modems and email. My interest in this project is to simply understand basics of modulation and figure out what is encoded at the end of the aforementioned video’s audio stream.
So first things first; I downloaded the video’s audio file using http://www.youtube-mp3.org/, then opened it up in Reaper:
First thing to notice is what appears to be a tone on the right channel (bottom) that starts out consistent. I assume this is intended for calibration and does not contain data. For now, I am assuming the left channel is noise as it is very quiet, and when zoomed in, does not contain coherent wave forms. Possibly a side-effect of its Broadcast/Tape origins, journey to flash video and finally mp3 format.
Here is a closer look at the ‘calibration’ signal:
Then later on there are four distinct sections.
Here is a closer look in a small part of the first data section:
You can see where the frequency closely resembles the first example at the beginning and end of this sample. This pattern repeats.
Given the following observations from the above samples, a few suppositions can be made:
- The amplitude barely changes; however, in the distinct sections the frequency shifts between two . This is likely Frequency-shift Keying (FSK).
- The repeating pattern indicates either parity data, transmission codes, header data, or some other predictable construct. Therefore, after demodulating and once we start decoding there will be some indication on where each byte starts.
In FSK, there are two discrete frequencies (potentially more if you want to send multiple streams of data simultaneously) that define the on and off bits. In the data section sample we can observe two such frequencies (width of the waveform):
mark frequency (these come in pairs, two of them represents 1):
space frequency (represents 0):
An important note to make on FSK is that we have a constant sinusoidal carrier wave which is modulated by a square wave, our data stream. Here is an example from wikipedia:
It is important to note that two periods of the carrier wave correspond to 0, while one period of the half frequency corresponds to 1.
Armed with this knowledge, I hope to be able to load the audio file into a program and convert the audio stream into a string of bits that can be written to file.
My weapon of choice is C# utilizing Visual Studio 2015.
Also assisting in my endeavor will be some DSP functions/classes from GitHub.
Using a zero-crossing detection method, we can determine the frequency for a given period.
By determining that the zero-crossing starts on a rising wave and ends on a falling wave, we are guaranteed the positive section of a period.
The algorithm I use is as follows:
- Load file using Wave class defined in DSP4DotNET
- Loop through all the elements of the channel containing the data stream
- Increment a sample point counter
- Get direction of wave at current point (i.e. rising, falling, zero)
- At zero-crossing and rising wave, set sample point counter to one
- At zero-crossing and falling wave, append a data string with a ‘z’ on space frequency or a ‘1’ on mark frequency (determined by minimum sample point count)
- Since two periods of a space frequency represents a ‘0’, convert all paired ‘z’ characters to ‘0’
- Drop all unpaired ‘z’ characters (If there are any unpaired space characters, the threshold probably needs to be adjusted or there could be loss/noise in the signal)
- Find the beginning and end of each data segment (There are four data segments in our example, these are probably separate files)
- Convert each segment to a byte array and write out to a file.
Determining the encoding is somewhat open-ended at this point. I’m fairly certain it is ASCII UTF-8 as it appears that was still popular in the 80’s and most of the alternatives were from the 60′ and 70’s. In spite of that assumption, the only way to determine the file structure is by researching to devices shown in the referenced video.
I may revisit this in a future blog post, until then you are welcome to fork this project from my GitHub. The data files can be found in the DeModProj.zip.
A modem (modulator-demodulator) is a network hardware device that modulates one or more carrier wave signals to encode digital information for transmission and demodulates signals to decode the transmitted information.