I have been writing music since the early ninetees. I can write music in tracker software and midi software. Back in the early ninetees I even got a letter from dr awesome(bjorn lynne) asking me if I could write music for his disk magazine. I can write music pretty well. But I never got good enough(still working on that)
What I have learned in writing music is that you should memorize parts of populair music and use those parts to make your own music. You can hear this in the movie amadeus where mozart plays a song that someone else wrote. He used parts of his own populair music in it to make it sound better.
I spend a lot of time softly whisteling populair parts of music and changing and mixing that.
In better music from the top 40's you can clearly hear parts of other music in it.