Ghost notes from midi controller

Is there a way to play ghost notes with an external midi controller?

I have a following use case in mind:

  1. Define phrase with rythm/arpeggio sequence using a single note (e.g. C in different octaves)
  2. Improvise a melody by shifting the running phrase with a midi keyboard
  3. Record improvisation in a pattern

Ghost notes are important in this case as we want not to screw up the rhythm by retriggering the phase on every note.