Kenny Wheeler described his compositional process in a masterclass at NEC in 2002:
The process I go through to write or compose a new melody is this--I get up about 7:00 and don't wash or shave or anything, but put on a bathrobe or dressing gown and take a couple of biscuits, a tea, and sit at the piano which is an old slightly out of tune upright. Then I play through some 4-part Bach Chorales. After that I try, with my limited technique to play through some Bach 2- or-3 part Inventions or maybe Preludes. Then I fumble through some more modern music such as Ravel, Debussy, Hindemith, Bartok or maybe the English Peter Warlock.
And then begins the serious business of trying to compose something. This consists of improvising at the piano for anywhere from 1/2 hour to 3 or 4 hours or even more. What I think I'm looking for during this time is something I'm not looking for. That is, I'm trying to arrive at some semi-trance-like state where the improvising I'm doing at the piano is kind of just flowing through me or flowing past me. I don't mean at all that this is any kind of a religious state but more of a dream-like state. And then, if I do manage to arrive at this state, then I might play something that catches the nondream-like part of me by surprise. It may only be 3 or 4 notes. But it's like the dream-like part of me managed to escape for a second or two from the awake part of me and decided to play something of its own choice. But the awake part of me hears that little phrase and says "What was that? That's something I didn't expect to hear, and I like it." And that could be the beginning of your new melody.
But there is no guarantee that you will reach this semi-dream-like state. After many hours you may not get there. But you might take a break, or you might have a little argument with your wife, and go back to the piano a little bit angry and bang out a phrase in anger which makes you say "Wait a minute! What was that?" There doesn't seem to be any sure way of reaching this state of mind where you play something that surprises yourself. I just know that I can't start the day all fresh at the piano at 7:00 and say to myself "And now I will compose a melody." It seems I have to go through this process which I described.
R.I.P., Kenny Wheeler, 1930-2014.