A Flute That Plays Itself, From 9th-Century Baghdad

It was invented by three scholarly brothers named Banū Mūsā, and it has been reconstructed according to their treatise by a museum in Germany. (The brothers also invented an automatic hydraulic organ that could play with punch cards similar to player piano rolls.)