Re: Looking through the wrong end of the telescope?
"[...] and generate some sort of melody."
IIRC that is the most difficult bit to create. After that inspiration - the approved rules of composition, the chosen instrument, and fashion tend to determine what you will get as the final piece. A composer's work is often identifiable by their borrowing melodies from their own previous compositions.
Many composers have borrowed their melody from another composer eg Vaughan Williams from Tallis; Procol Harum from J.S.Bach. Also from old folk tunes eg Dvořák; Mahler; Grainger.