Long before sound was first recorded, music was recorded—first by written music notation, then also by mechanical devices (e.g., wind-up music boxes, in which a mechanism turns a spindle, which plucks metal tines, thus reproducing a melody). Automatic music reproduction traces back as far as the 9th century, when the Banū Mūsā brothers invented the earliest known mechanical musical instrument, in this case, a hydropowered (water-powered) organ that played interchangeable cylinders. According to Charles B. Fowler, this "...cylinder with raised pins on the surface remained the basic device to produce and reproduce music mechanically until the second half of the nineteenth century." The Banū Mūsā brothers also invented an automatic flute player, which appears to have been the first programmable machine.
In the 14th century, a mechanical bell-ringer controlled by a rotating cylinder was introduced in Flanders. Similar designs appeared in barrel organs (15th century), musical clocks (1598), barrel pianos (1805), and music boxes (ca. 1800). A music box is an automatic musical instrument that produces sounds by the use of a set of pins placed on a revolving cylinder or disc so as to pluck the tuned teeth (or lamellae) of a steel comb.
The fairground organ, developed in 1892, used a system of accordion-folded punched cardboard books. The player piano, first demonstrated in 1876, used a punched paper scroll that could store a long piece of music. The most sophisticated of the piano rolls were hand-played, meaning that the roll represented the actual performance of an individual, not just a transcription of the sheet music. This technology to record a live performance onto a piano roll was not developed until 1904. Piano rolls were in continuous mass production from 1896 to 2008. A 1908 U.S. Supreme Court copyright case noted that, in 1902 alone, there were between 70,000 and 75,000 player pianos manufactured, and between 1,000,000 and 1,500,000 piano rolls produced.