Blue bands and green pixels

As I keep getting asked what blue bands and green pixels stand for in my tape dumping firmware (DC2N3 and DC2N5-LC), client software (DC2N4-LC), and analysis software (e.g. Web-based tape analysis tool, TAP Studio), I thought to take a moment and explain it all.

Let’s first have a look at an example:

Screenshot from my Tape analysis tool by Luigi Di Fraia

Screenshot from my Tape analysis tool

Going by the definition of the TAP format: the duration of square waves is recorded using 8-bit samples, with a resolution of about 8.12 microseconds, or, if you prefer, using a counter rate of 123.156 kHz.

Back in the day, square waves were used to hold information on cassette tapes: different durations mean different information bits to be conveyed. The CBM Standard loader for the C64 uses three such durations, often referred to as short, medium and long. Obviously due to the tolerance of the electronics and moving parts involved in reading and writing tapes, when sampling CBM files we often observe a cluster of values around the three “ideal” durations as per CBM’s specification.

Using a 5 MB TAP file that contains exclusively CBM files, “Cassette 50 side 2” contributed by Peepo, I created a diagram of the occurrences of each sample in the TAP file, focusing on the range $22-$5B as there’s very little outside such range:

Occurrences of TAP values in "Cassette 50 side 2" by Luigi Di Fraia

Occurrences of TAP values in “Cassette 50 side 2”

Going by CBM’s specifications, we know that things make sense. Specifically, long pulses are less frequent as they are only involved in the definition of stop bits at a byte boundary, and short pulses occur way more often than medium pulses as pilot and trailer sequences use short pulses exclusively.

As we can appreciate from the above image, samples 0x2F, 0x41 and 0x55 are occurring the most here, with similar values clustering in their neighborhood. These clusters appear to be very well separated from each other and very much tight around mean values: this is an indication of the fact that the quality of the sampling is good, meaning that the negative effects of the tolerance of the electronics and of the inaccuracy of the alignment and operation of moving parts are negligible. This is extremely good news because further analysis and data extraction should be quite simple a task when the starting point is a good sampling.

Based on field learnings, gathered from the analysis of hundreds (probably thousands by now) of TAP files sampled over the years by different contributors, I would comfortably say that when samples do not deviate from the ideal values more than 3 units each way (in TAP resolution terms), then the sampling is very likely to be good. In other words, we shall say that given a tape with CBM files in it, if samples from such files satisfy the following criteria, then the sampling is good:

  1. short pulse samples are bounded in the range: $2C-$32 (2463 Hz – 2800 Hz)
  2. medium pulse samples are bounded in the range: $3E-$44 (1811 Hz – 1986 Hz)
  3. long pulse samples are bounded in the range: $52-$58 (1400 Hz – 1502 Hz)

Bear in mind that this is not equivalent to saying that CBM files for which the above criteria are not met are not good. In other words, the above condition is sufficient, but not necessary for a sampling to be good. The reason is going to be the topic for a more advanced discussion on this subject at a later time.

Back to ranges: blue bands are nothing else than the graphic representation of such ranges. Given a CBM file, if green pixels, i.e. TAP samples, consistently cluster inside such blue bands, then the sampling is good.
In other words, the position of green pixels relative to blue bands is a way to visually inspect samplings for quality, using references gathered from the analysis of a massive amount of CBM files.

For completeness, let’s now have a look at a tape sampling that is not as good as the one discussed earlier as the green pixels form larger clusters that also get worryingly close to each other at times:

Screenshot from my Tape analysis tool by Luigi Di Fraia

Screenshot from my Tape analysis tool

And now a couple from the category of samplings that are not good at all:

Screenshot from my Tape analysis tool by Luigi Di Fraia

Screenshot from my Tape analysis tool

Screenshot from my Tape analysis tool by Luigi Di Fraia

Screenshot from my Tape analysis tool

Believe it or not, these last two are actually completely faulty samplings of CBM files: the pilot part should be easily recognizable as it does, more or less, fall into its own reference band.

About Luigi Di Fraia

I am a Senior DevOps Engineer so I get to work with the latest technologies and open-source software. However, in my private time I enjoy retro-computing.
This entry was posted in Retrocomputing, Technical and tagged , , , , , . Bookmark the permalink.

1 Response to Blue bands and green pixels

  1. luigidifraia says:

    It should be noted that by calculating a weighted average using the most occurring values and the second most occurring ones, one comes up with the following approximations for CBM encoding frequencies:

    2641 Hz
    1884 Hz
    1441 Hz

    This is an indirect measurement, gathered from a sampling, so it describes the sampling itself. For actual standard values one should refer to CPU cycles of the host computer to measure durations or frequencies. However this opens a can of worms, as briefly discussed here: http://c64tapes.org/dokuwiki/doku.php?id=loaders:rom_loader

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s