Thomas Mann, _Dr Faustus_. Wicked composer sells his soul for the devil's help in escaping the decadence of music.
Not quite sure I read the plot the same way, but anyway - the composer is biographically Nietzsche and musically Schoenberg. The big palindromic piece is based on Schoenberg's Die Jakobsleiter.