Showing posts with label retro. Show all posts
Showing posts with label retro. Show all posts

Gramophone audio from photograph, revisited

"I am the atomic powered robot. Please give my best wishes to everybody!"

Those are the words uttered by Tommy, a childhood toy robot of mine. I've taken a look at his miniature vinyl record sound mechanism a few times before (#1, #2), in an attempt to recover the analog audio signal using only a digital camera. Results were noisy at best. The blog posts resurfaced in a recent IRC discussion which inspired me to try my luck with a slightly improved method.

Source photo

I will be using an old photo of Tommy's internal miniature record I already had from previous adventures in 2012. I don't want to perform another invasive operation on Tommy to take a new photograph, as I already broke a plastic tab last time I opened him. But it also means I don't have control over the photographing environment. It's part of the challenge.

The picture was taken with a DSLR and it's an uncompressed 8-bit color photo measuring 3000 by 3000 pixels. There's a fair amount of focus blur, chromatic aberration and similar distortions. But at this resolution, a clear pattern can be seen when zooming into the grooves.

[Image: Close-up shot of a miniature vinyl record, with a detail view of the grooves.]

This pattern superficially resembles a variable-area optical audio track seen in old film prints, and that's why I previously tried to decode it as such. But it didn't produce satisfactory results, and there is no physical reason it even should. In fact, I'm not even sure as to which physical parameter the audio is encoded in – does the needle move vertically or horizontally? How would this feature manifest itself in the photograph? Do the bright blobs represent crests in the groove, or just areas that happen to be oriented the right way in this particular lighting?

Unwrapping

To make the grooves a little easier to follow I first unwrapped the circular record into a linear image. I did this by remapping the image space from polar to 9000-wide Cartesian coordinates and then resampling it with a windowed sinc kernel:

[Image: The photo of the circular record unwrapped into a long linear strip.]

Mapping the groove path

It's not easy to automatically follow the groove. As one would imagine, it's not a mathematically perfect spiral. Sometimes the groove disappears into darkness, or blurs into the adjacent track. But it wasn't overly tedious to draw a guiding path manually. Most of the work was just copy-pasting from a previous groove and making small adjustments.

I opened the unwrapped image in Inkscape and drew a colored polyline over all obvious grooves. I tried to make sure a polyline at the left image border would neatly continue where the previous one ended on the right side.

The grooves were alternatively labeled as 'a' and 'b', since I knew this record had two different sound effects on interleaved tracks.

[Image: A zoomed-in view of the unwrapped grooves labeled and highlighted with colored lines.]

This polyline was then exported from Inkscape and loaded by a script that extracted a 3-7 pixel high column from the unwrapped original, centered around the groove, for further processing.

Pixels to audio

I had noticed another information-carrying feature besides just the transverse area of the groove: its displacement from center. The white blobs sometimes appear below or above the imaginary center line.

[Image: Parts of a few grooves shown greatly magnified. They appear either as horizontal stripes, or horizontally organized groups of distinct blobs.]

I had my script calculate the brightness mass center (weighted y average) relative to the track polyline at all x positions along the groove. This position was then directly used as a PCM sample value, and the whole groove was written to a WAV file. A noise reduction algorithm was also applied, based on sample noise from the silent end of the groove.

The results are much better than what I previously obtained (see video below, or mp3 here):

Future ideas

Several factors limit the fidelity and dynamic range obtained by this method. For one, the relationship between the white blobs and needle movement is not known. The results could possibly still benefit from more pixel resolution and color bit depth. The blob central displacement (insofar as it is the most useful feature) could also be more accurately obtained using a Gaussian fit or similar algorithm.

The groove guide could be drawn more carefully, as some track slips can be heard in the recovered audio.

Opening up the robot for another photograph would be risky, since I already broke a plastic tab before. But other ways to optically capture the signal would be using a USB microscope or a flatbed scanner. These methods would still be only slightly more complicated that just using a microphone! The linear light source of the scanner would possibly cause problems with the circular groove. I would imagine the problem of the disappearing grooves would still be there, unless some sort of carefully controlled lighting was used.

Tomy Electronic PUCKMAN

Today it was time for some flea market shopping again. I found a pleated denim skirt for €4.50 that's a perfect fit, but that's not really the subject matter of this blog. I also found a Tomy Electronic PUCKMAN for €2.00, which will be further examined below.

[Image: A circularly shaped, brightly colored toy with 6 buttons, a small display and the text 'TOMY ELECTRONIC PUCKMAN'.]

It's an electronic game that obviously has a lot to do with Pac-Man. As sources have it, Puckman was the original name of the famous game. It has a display, a D-pad sort of controller, on-off switch, and a difficulty switch that lets the player choose between AMA and PRO.

[Image: Close-up photo of the unlit display, revealing that it is a 8x5 grid of small pictures of the game characters and the scene, and a 7-segment, 4-character number display.]

The display is a bright vacuum fluorescent display, or VFD, that has all the possible positions of the sprites pre-printed onto it. There's also a score counter of some sort.

[Image: Close-up photo of a microchip on a PCB, with the etchings 'NEC JAPAN, D553C, 8228EK, 160'.]

The main processor (or what appears to be one) is marked D553C-160. I couldn't find any info about it online, just googlespam by companies that claim to sell similar chips and lie about having the datasheet (shame on them!).

The device takes four C-sized batteries, totalling 6 volts, or an AC adapter. I happened to have a 6-volt DC adapter so I hooked it up to the battery terminals, and yay:

[Image: The display with parts of it glowing brightly, namely the walls of the scene, the main character in one corner, power-up pills everywhere and three ghosts near the middle. The score counter is showing zero.]

The sound it makes is very loud and nasty. But it is indeed the actual Pac-Man theme. Video below.

Portable TV, Raspberry-Pified

Recently I entered the era of video-capable portable music players. About time, too. My device of choice is this Action-branded Taiwanese gem from 1988 with a 5-inch CRT display (B/W), AM/FM radio, television receiver, and cassette player (mono, no rewind). It takes 9 D-sized batteries.

[Image: A person holding a portable television-cassette player measuring roughly 30 by 30 by 20 cm. The tape compartment is open and a yellow cassette is in. The device is labeled 'BLACK/WHITE TELEVISION-RADIO-CASSETTE PLAYER' with the brand name 'ACTION'. There's a cathode-ray type display roughly 20cm across; band selector for VHF low, VHF high, UHF, FM, and AM; A tuning wheel; a volume wheel; cassette control buttons on top; and a carrying handle. In the background, there's a bigger cassette deck, and a coffee cup with drawings of sheep.]

The batteries inside were leaking quite a bit so I removed them in favor of a DC adapter. They actually occupied roughly half of the casing. After removing them the device looked very empty and was unbalanced because of the heavy CRT. So I had to come up with something to fill the space with.

Then it struck me: it's a perfect video terminal and tape drive for the Raspberry Pi!

The screen

The Action has a 5" black-and-white CRT display and a television tuner. The receiver is on an AN5151N integrated circuit. Now, the Raspberry Pi outputs composite video. Someone else has tried injecting composite video onto the AN5151N before, with results that didn't look very successful to me at first sight, so I just ended up buying a cheap RF modulator. It modulates a TV-frequency carrier with the composite signal, and that can be fed into the aerial input of the TV to be demodulated again.

[Image: The cathode ray display showing the Linux console running the 'top' command. On top of it, a Raspberry Pi with two small devices connected into its USB ports and an RCA cable connected into its analog video output.]

Aerial input to the TV is via a miniplug, so I had to improvise an adapter for coax. It works almost perfectly, except that the CRT crops out the extremes of the display.

The battery compartment before and after refurbishing:

[Image: Two photos showing a big battery compartment, empty in the first picture and filled with electronics in the second one, with several wires coming out.]

The tape

The cassette player of this device is pretty simple. It does not have stereo, rewind, auto-stop, or any of the other hi-tech functions that many modern-day Walkmen have. It doesn't even stop automatically when Eject is pressed. But it works.

[Image: The cassette player opened, showing the tape drive mechanism with several wheels connected to each other via rubber strings, and the control buttons connected to them via springs and levers.]

I've written a little Perl program that can write data onto cassettes and read it back using a sound card. For this project I removed the sound card step. The way I've written the data onto the tape is such that when amplified with the tape player's U821B chip, the voltage can directly be used as a binary 3v3 GPIO logic level. I wouldn't recommend this though, unless you know what you're doing, because the GPIO port is essentially a direct connection to the CPU and there's no overvoltage protecti... blast, I've just fried my RasPi!

A moment of silence. And a screenshot honouring the memory of its last words over ssh. Here, a logic "1" is low voltage, and "0" is high. A wee bit too high.

111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111111111111111111111111111111111111111111111111111111111111111111111
111111111111111111110110011Write failed: Broken pipe
$ █

Anyway, I also modified the TV's power circuitry to supply power to both the CRT and tape player at the same time, and installed a switch to silence the speaker when reading data. If it weren't for the aforementioned overvolt accident, this would now be complete. Cassettes could be used to store e.g. Vectrex games; also reading C64 cassettes will be supported.

Moral of the story: The GPIO port is not 5V tolerant! Assuming there will a second attempt some day, I'll just use a transistor to pull the GPIO pin high when there's a high on the tape. Or use a sound card.

The Atomic-Powered Robot

[Image: A black toy robot standing next to a My Little Pony. The robot has golden ears and arms, a speaker on its chest, and a big round button on top of its head. On its belly, it has a symbol referring to nuclear power. Text around the robot says OMNI, 024-2931:1524, and 2 MODEL-B.]

This is my mechanical baby, Tommy. He's an atomic-powered [sic] robot that can talk and walk around the room. Born in 1984, he's been with me since the early 1990s, but for the last ten years he's been quite ill and not able to talk.

Today I finally fixed him. While doing that, I decided to do a full autopsy for the sake of science, as I've found his vocal cords especially intriguing. So please observe: Tommy's internals. (As with all medical imagery, it's not for the faint of heart.)

Tommy's belly is dominated by a pink-colored contraption that looks like it has a speaker on the front. The pink device gives Tommy his ability to utter the words "I am the atomic powered robot. Please give my best wishes to everybody!" and also make the sound of a laser gun. Below the sound player is the walking motor, which is quite simple and I'm not going to concentrate on it.

[Image: The robot opened up. A bunch of wires go from inside its head down to where its feet are, where some gears can also be seen. In the middle, a big pink box with a speaker in the front.]

Removing the cover of the pink device, we see a large funnel-shaped object that looks a bit like a speaker. It has a tense plastic membrane, like a drumhead.

[Image: Inside the pink box, a peculiar speaker with a translucent membrane.]

Now it gets really interesting. The speaker is resting on a tiny gramophone arm, which is playing a little vinyl record! There's even a simple electro-mechanical end-of-disc detection and arm-return mechanism. The vibrations of the needle are mechanically transferred to the speaker membrane; there's no electric amplification of any kind.

[Image: Still inside the speaker box, a slit reveals a little vinyl record underneath. A gramophone arm and needle are resting on it. Towards the end of the disc, there's a switch that seems to close an electronic circuit when the arm moves far enough.]

Could a gramophone record get any cuter?

[Image: Close-up of the disc being held in the author's hand, removed from the box. The disc is small enough to fit on the palm.]

And here's Tommy sending you his best wishes.

UPDATE: Okay, yeah, he's cute and all. But take another look at the above photo of the record. Don't you think it contains a lot of information about the recording? Perhaps you could even extract the audio from a good enough photograph. Just a silly thought.

Well, let's get to it.

First I'll need a good quality picture of the record's surface. My roommate lended me her expensive camera for this purpose. To get the rough surface evenly exposed, I used an exposure time of 10 seconds with an aperture of f/32. I circled a lamp around the record for 10 seconds and got this cool image.

[Image: A high-resolution photograph taken tangentially towards the record. Grooves are clearly visible as darker lines, and even the recorded signal can be seen as oscillations in the grooves. The end of the record seems to be silent.]

I'll hint the positions of the groove at every turn and then let Perl interpolate a smooth spiral:

[Image: Screenshot of Inkscape with the above image loaded and markers drawn on the spiral groove wherever it crosses the pi radians mark. Next to it, a computer-generated spiral with similar spacings.]

I'm going to read the record along the spiral at 360 RPM and just convert the pixel brightness at every point of the groove into PCM amplitude. This will probably result in something audible, although quite noisy. There appears to be two interleaved grooves: one for the speech, one for the laser sound. The groove gets randomly selected when the robot's head button is pressed, depending on where the needle happens to land. So I made a stereo sound file.

It's very noisy indeed and there's a lot of crosstalk, but something can be heard in the background. After edge detection on the image and some noise removal on the audio:

Update: Further studying of the record and better sound samples in "The laser-equipped Lego train".

The sound of the dialup, pictured

If you ever connected to the Internet before the 2000s, you probably remember that it made a peculiar sound. But despite becoming so familiar, it remained a mystery for most of us. What do these sounds mean?

(The audio was recorded by William Termini on his iMac G3.)

As many already know, what you're hearing is often called a handshake, the start of a telephone conversation between two modems. The modems are trying to find a common language and determine the weaknesses of the telephone channel originally meant for human speech.

Below is a spectrogram of the handshake audio. I've labeled some signals according to which party transmitted them, and also put a concise explanation below.

[Image: A large infographic detailing the phases of the dialup handshake, centered on a time-frequency-power representation (spectrogram).]

(You can order this poster as a high-res print via Redbubble!)

Hello, is this a modem?

The first thing we hear in this example is a dial tone, the same tone you would hear when picking up your landline phone. The modem now knows it's connected to a phone line and can dial a number. The number is signaled to the network using Dual-Tone Multi-Frequency signaling, or DTMF, the same sounds a telephone makes when dialing a number.

The remote modem answers with a distinct tone that our calling modem can recognize. They then exchange short bursts of binary data to assess what kind of protocol is appropriate. This is called a V.8 bis transaction.[2]

Suppressing echoes

Now the modems must address the problem of echo suppression. When humans talk, only one of them is usually talking while the other one listens. The telephone network exploits this fact and temporarily silences the return channel to suppress any confusing echoes of the talker's own voice.

Modems don't like this at all, as they can very well talk at the same time (it's called full-duplex). The answering modem now puts on a special answer tone that will disable any echo suppression circuits on the line. The tone also has periodic "snaps" (180° phase transitions) that aim to disable yet another type of circuit called echo canceller.[1]

Finding a suitable modulation

Now the modems will list their supported modulation modes and try to find one that both know.[1] They also probe the line with test tones to see how it responds to tones of different frequencies, and how much it attenuates the signal. They exchange their test results and decide a speed that is suitable for the line.[4]

Enough small talk!

After this, the modems will go to scrambled data. They add pseudorandom numbers to the data[3] before transmission to make its power distribution more even and to make sure there are no patterns that are suboptimal for transfer[5]. They listen to each other sending a series of binary 1's and adjust their equalizers to optimally shape the incoming signal.

Soon after this, the modem speaker will go silent and data can be put through the connection.

But why?

Why was it audible? Why not, one could ask. But my speculation is as follows. Back in the days, telephone lines were used for audio. The first modems even used the telephone receiver like humans do, by talking into the mouthpiece, until newer modems were developed that could directly connect into the phone line. Even then, the idea of not hearing what's happening on a phone line you're calling on was quite new, and modems would default to exposing the user to the handshake audio. And in case you accidentally called a human, you would still have time to pick up the telephone and explain the situation.

All you had to do to silence the handshake was to send the command ATM0 down the serial line before dialing.[6]

Poster

Update 02/2013: Due to numerous requests, I made this into a 42-megapixel poster that Redbubble is selling. A few dollars per poster is directed to the nerd who made this.

References

  1. RFC 4734: Definition of Events for Modem, Fax, and Text Telephony Signals (2006), section 2.3: V.8 events.
  2. ITU-T Recommendation V.8 bis (1996).
  3. ITU-T Recommendation V.33 (1988). Annex A: Scrambling.
  4. ITU-T Recommendation V.34 (1996). Chapter 10: Start-up signals and sequences.
  5. Advantages of Scrambling (2012). RF Wireless World.
  6. Turner, Glen (2003): Remote Serial Console HOWTO.

Vintage bits on cassettes

I had contemplated using Compact Cassettes as a cheap, fun and hipstery media for small yet valuable backups. Perhaps it would even be possible using only an ordinary tape recorder. So finally I thought: How hard could it be? Let's give it a try!

Searching led me to a Wikipedia article about the Commodore Datassette. It was a tape format used by the Commodore personal computer. It used two different frequencies to encode ones and zeros, and they were read back by simply detecting zero-crossings. I exploited this invention and modified it a bit by adding start and stop bits and a 50-byte lead-in tone:

Compact Cassettes sell for 20 cents at flea markets. They come in many colors and capacities. Using the data rate I chose about 1.2 MB fits on a single cassette.

Video proof below!

By the way, I only used text for demonstrational effect. All kinds of data can be saved onto the cassette. A nice way to do this is to use .tar files (which, incindentally, stands for "Tape Archive"!).

Edit: Here's some PNG data: