Code to encode and decode Kansas City standard

As part of my Retrochallenge 2012WW project, I’m writing a pair of C programs to encode and decode Kansas City standard and Processor Technology CUTS audio cassette formats, as these are the formats supported on the Processor Technology Sol-20.  These use FSK modulation, so it’s not too difficult.

In fact, FSK modulation is almost trivial, so I had the encoder written in less than an hour.

For decode, I decided to use the Goertzel algorithm, which is a simplified DFT that only looks for a single frequency.  I’ve used the Goertzel algorithm before on fixed-point DSP processors. There are app notes on using it for DTMF detection.  For FSK demodulation, I just use two Goertzels, one for the space frequency and one for the mark frequency.  The audio samples are dealt with in windows that are a fraction of a bit time, and the levels indicated by the two Goertzels are compared to decide which frequency predominates in that window.

Implementing the decoder program took a few hours last night and a few hours today.  It’s now basically working, at least for the perfectly sinusoidal waveforms generated by my encoder.  I still need to test it on some real tapes.

I’m currently using an 8 kHz sample rate for my audio files, although the encoder can be told to use a higher sample rate if desired, and the decoder will work with whatever sample rate the audio file uses.  Since the FSK frequencies are 1200 Hz and 2400 Hz, there should be no advantage to using a sample rate higher than 8 kHz.

I’m currently using libsndfile to read and write audio files.  I’d like to also use PortAudio to support direct access to the audio hardware, but I haven’t yet tried that.  While I’m doing the development on Linux, in principle the programs should work if compiled on Windows or MacOS.

I’ll release the programs under the GPLv3 license when I’ve verified that they work reasonably well.

This entry was posted in RetroChallenge, Software. Bookmark the permalink.

5 Responses to Code to encode and decode Kansas City standard

  1. Nathan B. says:

    How would you go about encoding the files in C? I have searched high and low and have not found anything currently.

  2. knut nygård says:

    I’m planning to use softwarebased communication (one way only) to transmit data from weather balloon using inexpensive “walkie-talkie”-set . (5 mile range)

    OOK or FSK will be OK. The decoding will be the challange!

    Knut

  3. fridelain says:

    Could you release the encoder now, please?

  4. Shaun says:

    I would like it too please, I am trying to write one in Game Maker but it is not quite working.

  5. Alex says:

    It’s July 27′th 2012. Where is the encoder and decoder source release?

Leave a Reply