Carillons (http://en.m.wikipedia.org/wiki/Carillon) had control drums ('speeltrommel' is the better search term) in the sixteenth century (oldest one I could find is from 'before 1542') that allowed one to program in a melody to play. Example of programming at http://youtu.be/kHuvTKxZwr0