i'm thinking about how you'd do this,
and the picture in my mind is of a single 2 second long clarinet note with a hihat being hit after about 1 second.
so, if you were going to stretch or compress that, you'd want to preserve the parts with the most 'colour' ...which i would guess would be the attack of the clarinet and then especially the attack of the hihat.
[bonk~] will find those bits for you quite easily. so you can just mark the sections bonk~ finds and set them as 'do not touch'
but the hard part is stretching the remaining sections. i think ableton and melodyne have good approaches for this, and from what i can gather it's a good granular approach with the grain length being constantly adjusted so that the playback doesn't introduce too much AM effect.
i have a feeling they also do a pitch analysis, so that the playback grain length can be adjusted longer for lower overall pitch and shorter for higher pitched sections.
i could be completely wrong of course. wouldn't be the first time. :)