Risky music on an old IBM mainframe line printer

We at our Museum of Computer History recently purchased a set of punch cards for a 50-year-old computer music program. Most computers did not have sound cards then, but creative programmers found ways to deliver music using linear printers. We were a little worried that this program could damage the printer, but still we risked running it on the ancient IBM 1401 mainframe . As you might expect, the music played by the linear printer sounds awful - but the melody can be sorted out and the printer wasn’t hurt.





The IBM 1401 business computer was introduced in 1959, and it became the best-selling computer in the mid-1960s — more than 10,000 such systems were delivered. The key competitive advantage of the IBM 1401 was the IBM 1403 high-speed line printer. The fast-spinning character chain allowed the printer to print 10 lines per second with excellent quality — it was thought to be the best quality before laser printers appeared in the 1970s.





The printed circuit of the printer is 1401. It has 48 different characters, which are repeated 5 times.



Line printers were very noisy, but programmers soon found out that when printing certain lines of characters from noise, certain frequencies could be extracted. It was possible to play a note by printing the necessary lines. In the region of 1970, computer science specialist Ron Mack coded several songs on punch cards using the existing music program. He recently came across his old programs and gave us the opportunity to try them out.



How a linear printer works



To print characters, the printer uses a chain of links with characters that rotates at a high speed opposite the paper, and there is an ink ribbon between the paper and the chain. The printer produces lines of 132 columns - that is, each column has its own hammer and electromagnet. At the right moment, when the desired symbol moves past the hammer, the electromagnet presses the hammer against the paper, and the paper along with the tape hit the link, printing the symbol.





IBM 1401 linear printer print engine (from instructions)



For this process to work, the printer needs to carefully calculate the time of operations. The chain rotates at a speed of 2.3 m / s, and every 11.1 μs the next link is opposite the malleus. The control circuit barely has enough time to read the location of this symbol from the main memory, compare it with the symbol located under the hammer, and hit the hammer in case of coincidence. For 132 time intervals, each malleus has the ability to print one character; this is called a "scan." Since there are 48 characters in the set (without capital letters), to print all the characters in any column, you need to repeat this process 48 times. For each scan, the chain is shifted by only one character width.





The hammer set of the IBM 1403 printer. Below are the impact points of 132 hammers (one per column). At the top are the coils and wires of 33 of 132 hammers.



At the bottom of the photo one hammer is shown. Above left is an electromagnetic coil and wires. We had to replace this hammer after the coil was overheated and smoked - the photo shows its blackened area (this happened a long time ago and is not related to music).







Music generation



Having understood how the printer works, the hammer of which has the ability to operate every 11.1 μs, it will be easier to understand the strategy for obtaining music. By printing carefully selected text, you can control the response time of the hammers. If the hammers are triggered at certain intervals, it will be possible to create the necessary frequencies. For example, a note la (440 Hz) can be obtained by printing a line of text so that the mallets work every 1/440 of a second. This can be achieved by typing 1 in the 1st column (first hammer), then # in the 14th column on the next scan, a comma in the 30th column, and so on. The following is the entire line that needs to be printed to create a note. You may be surprised that with only 48 positions, the character set includes such strange occurrences as ⌑ and ‡.



1 ⌑YC# 0 Q 3, ‡FRT 4 - , IU $7 MV . * 9N ⌑ ZE @ P3
      
      





The diagram below shows the temporal distribution of the hammers, a uniform frequency of 440 Hz, given by the given line of characters. The x-axis represents time; each printed character is marked with red bars. The red stripes are distributed evenly, at a distance of 1/440 second, which gives a note at 440 Hz. Each bar is marked with an associated symbol and a column on the page. Note that characters are not printed in the order in which they appear on the line. There is no simple relationship between the arrangement of characters in a string and their time sequence. A few gray lines are shown where the hammer should have worked, but the symbol is missing. At this point, the network is synchronizing, so it cannot print.





Time distribution diagram for note la.



By typing another line, you can generate another note. Below is a si note, 987 Hz (more than an octave higher). As expected, more notes require more characters:



 1 @EQ4S J 8. ND ‡ SH 7 AM Y#2 G- KV . 0 DQSJ 7& ND ‡/4 H AMX0 2 QGJ W. 0 DP‡ S 7&AM ‡/4G * MX0 D 3
      
      







Time distribution diagram for note s.



The following is a line for a sharp note (138 Hz). At first, it was not clear to me why this note requires printing a string where all the characters are gathered in a heap and not scattered, like other notes. It turns out that 138 Hz coincides with the hammers in a row. And although the characters are next to each other, they are evenly distributed over time.



 16#UZKP*E&38
      
      







Temporal distribution diagram for a sharp note.



What is the risk of chain music



We were worried that this music program could damage our printer. There are many stories about how people broke printers by printing a line that makes all the mallets work at the same time. I think that these are mainly urban legends (1403 mallets fire in turn). However, we were worried that chain music might overload the printer chain and it would break. The photo below shows a chain broken during normal use; torn wires and individual links are visible.







A chain for the printer was made by braiding a thin wire into a ribbon and attaching blocks with letters to it. Until recently, these chains were rare and could not be replaced; if the wire was torn, it was impossible to fix it. However, the Techworks Museum! from Binghamton have recently come up with a way to restore printed circuits. Therefore, our King at IBM 1401, Frank King, reluctantly approved the use of the restored circuit to play music. Fortunately, the chain survived the music generation perfectly. Having studied the music program, I came to the conclusion that it strains the circuit much less than regular printing, unless, of course, a particularly unfortunate resonance arises in it.





Printed circuit (upside down) at close range



Program







The source code for the program has long sunk into oblivion, so I disassembled the machine codes from the cards to understand how it works (I list it separately). First, it reads the “frequency cards” that determine which line to print for which note. It creates in memory an array of lines for printing, together with a table with the names of notes and the addresses of lines for printing. Then the program reads the notes of the songs, one note per card (the photo shows that for some songs you have to use a lot of cards). For each note, the program searches for the corresponding line to print in the table. It prints a line as many times as needed, depending on the length of the note. Further fulfills a cycle of silence, from 200 to 2000 times.





Punched cards with the machine code of the music program. For some reason, the contents of each card are printed on it twice.



Machine code 1401 is very different from modern computers. One of the differences is that previously self-modifying code was used frequently, but today such practices are condemned. For example, a table of lines for printing is created by changing the load instructions, where the address field changes. Even returns from routines use self-modifying code by placing the return address in the jmp statement at the end of the routine. To process a note, the program on the fly generates a sequence of three instructions to load a line, go to the print code, and then go back to the main loop. Self-modifying code made it difficult for me to understand the program, because the disassembled code does not match the one that actually ran.



Behind the cards with the program are frequency cards that define the lines for each note. The code supports up to 20 different notes, so the frequency cards were selected for each song separately. Each line of 132 characters is divided into two cards, the first of which determines the right side of the line. The name of the note and frequency are printed on each card in the right corner.





Frequency cards



The final set of cards creates a melody, and each note (or gap) has its own card. Each card has a note and duration printed on it. A long melody can involve hundreds of cards. It’s easy to save a new melody on the cards - you just need to punch notes on the cards. Notes are indicated in the American notation system , where the name of the note is followed by an octave number. For example, C4 is the average to. Since only some printed circuits have the symbol #, sharps are denoted by the letter S, that is, CS instead of C #.





A photo of a card with the melody "Silver Bells" close-up.



Conclusion



We successfully played music on an IBM 1403 printer by running programs that no one had been running for almost 50 years. Although the quality of music was not particularly high, we were glad that the printer did not self-destruct. The last time Ron Mack launched these programs in 1970; by the link you will find some tunes. The video below shows an excerpt from the Marseillaise; In this video you can watch the printing of each line.





The Mountain View Museum of Computer History shows off IBM 1401 on Wednesdays and Saturdays , so if you are nearby, I recommend you visit our exhibit.



All Articles