Can code generate a catchy pop tune? Im sure it can. Would I qualify it as music? Probably not.
Music can pull from sources that are EXTERNAL to the music: Heres a modern track that does just such a thing: https://www.youtube.com/watch?v=xvtNS6hbVy4
Music can have some very non traditional structure that most would qualify as "noise" https://www.youtube.com/watch?v=zYaWND9n9h0
Hell music can even be "silent" http://rosewhitemusic.com/piano/writings/silence-taught-john...
Ultimately, I think that it is possible for a machine to generate music, but were going to be talking about something that is more or less an AI at that point, after all music has a soul.