I, personnaly, sit at the piano and improvise a lot! I record, cut, keep, throw. And when an idea that I improvised begin to become a real track, I tried to rattach it lorewise. When I began to have the first track, I listened to all the little pieces I had improvised and some inspired me the next track.
Also, for my melodies and rhythm, I find it really important to sing and mimic the instrument I write for! It permits to humanize and add respirations in my tracks!