i usually just play along until i get it down. it can vary how long it takes me, and i don't always get it spot on before i play or improvise on it.
And the more you do it - the less time it takes. :D
together we stand, divided we fall..........