So through some experimenting it appears that you can't really control the length of music, but you can control an area it plays in. Essentially, if Mario hits a tile which plays music, then that music will continue to play so long as he continues to touch tiles with that music block in it. The music will eventually stop playing once Mario has stopped touching a tile containing that music block.
So if you wanted to have a room that played music for the duration of Marios stay you would need to put a Music block in every tile of the room. Aside from being annoying, this does have the flaw that there is a limit the number of music tiles you can have in a level, and it's not very large.
Something else I've discovered,and which the internet confirms, is that putting a music tile on Mario will make a song play for the duration of the level.