I have to say that it'll take a lot of effort to make an automatic music stage, so there's that to keep in mind before really attempting doing such thing.
Also, you'll want to use the mute sound, which is obtained by shaking the blue heart icon. For the music to completely turned off, you'll want to place that to Mario.
There's a guide in GameFAQs that covers pretty much everything you need to know on how to make a music level.