Mozart’s Credit Card is a Verifone Tranz 330 card processing terminal, reprogrammed to play music that’s generated from the data stored on the card’s magnetic stripe.
While browsing at an electronics surplus store one day, I picked up an old point-of-sale terminal. After discovering a cool little Z-80 based computer inside, and reverse-engineering the hardware, I decided to reprogram it to unlock the music hidden inside magnetic stripe cards. I call this wonder Mozart’s Credit Card.
The hardware is a Tranz 330 POS terminal from VeriFone, dating from the 1980′s. The 330 and its cousins are great for electronics tinkerers. They’re self-contained 8-bit computers with lots of intersting I/O interfaces, and retro-style vacuum-fluorescent displays. They use the same microprocessor as the TRS-80 and ZX Spectrum, so handy software routines from those computers can be reused. The terminals are commonly available from surplus stores or eBay for around $10.
Documentation for the 330 is readily available online, but it only addresses how to use the POS features, with very little hardware information. The Z-80, its support chips, and the other components like the display driver and real-time clock are all well-documented, but to use them, it was necessary to reverse-engineer the terminal’s hardware design. I needed to know how the I/O interfaces were mapped into the address space, which chips were connected to which port pins, and what timing and communication protocol requirements existed. Through a combination of tracking the signal traces by “beeping out” the board, and examining the disassembly of the POS software in the terminal’s ROM, I was able to learn what I needed.
After due consideration (and a couple of beers), I decided to make a demo that reads data from magnetic stripe cards, and uses it to play music. What song does your Visa play? How about your driver’s license? Ooh, that library card’s got a nice rhythm. Check the video to see Mozart’s Credit Card in action:
Mozart’s Credit Card is a custom program written in Z-80 assembly language. I burned the program to a Flash ROM, and swapped the new ROM for the terminal’s original ROM. Fortunately the 330′s ROM is in a socket, making replacement easy. When a card is swiped, the card reader returns the ISO 7813 Track 2 data, which is up to 40 BCD characters, with 4 data bits and 1 parity bit per character. The raw data uses F2F encoding, in which all bit intervals are the same duration, but a logical 1 has a low-to-high or high-to-low transition during the bit interval, and a logical 0 has the same polarity during the whole bit interval. This F2F signal must be converted into binary data in software.
Once the card data has been read, a rule-based system is used to turn it into semi-acceptable music. Converting the card digits directly to notes only generates random beeping, so a more complex system based on the ideas from the Melisma Stochastic Melody Generator was used. The Mozart music engine generates random melodies with a given key, mode, length, tempo, interval size range, and other parameters from music theory. The parameters are used to construct a set of probability tables, which are then multiplied to construct the final table used to randomly select the next note.
The choice of major or minor mode is determined by the card’s year of expiration. If the card expires soon, it plays a minor melody – spooky! The key – F, B-flat, whatever – is determined by the month of expiration. There are twelve months in a year, and twelve semi-tones in an octave, so it was a perfect fit. The number of data bytes on the card determines how many measures of music are played. A credit card will play a longer melody than a grocery club card. The tempo, rhythm, interval sizes, and actual notes come from a random number generator, whose seed is the card’s account number.