A barrel organ (or roller organ) is a mechanical musical instrument consisting of bellows and one or more ranks of pipes housed in a case, usually of wood, and often highly decorated. The basic principle is the same as a traditional pipe organ, but rather than being played by an organist, the barrel organ is activated either by a person turninga crank, or by clockwork driven by weights or springs. The pieces of music are encoded onto wooden barrels (or cylinders), which in a sense, replace the keyboard of the traditional pipe organ.
The pieces of music (or tunes) are encoded onto the barrel using metal pins and staples. Pins are used for short notes, and staples of varying lengths for longer notes. Each barrel usually carried several different tunes. Pinning such barrels was something of an art form, and the quality of the music produced by a barrel organ is largely a function of the quality of its pinning. This complex encoding of music was an early form of programming.
Since the music is hard-coded onto the barrel, the only way for a barrel organ to play a different set of tunes is to replace its barrel with a different one.