There has been much interest, in recent years, in the possibility of representing our musical faculties in computational terms. A necessary first step is to develop a formally precise theory of musical structure, and to this end, useful analogies may be drawn between music and natural language. Metrical rhythms resemble syntactic structures in being generated by phrase-structure grammars; as for the pitch relations between notes, the tonal intervals of Western music form a mathematical group generated by the octave, the fifth and the third. On this theoretical foundation one can construct AI programs for the transcription, editing and performance of classical keyboard music. A high degree of complexity and precision is required for the faithful representation of a sophisticated pianoforte composition, and to achieve a satisfactory level of performance it is essential to respect the minute variations of loudness and timing by which human performers reveal its hierarchical structure.