Here is a patch I just mashed up that sort of does a real-time beat detective-ish thing. It records 10 seconds of audio into a buffer, while bonk~ (you'll have to d/l it to use the patch) detects "events" in the incoming audio stream and stores their start times in a coll. You can then play specific segments back by selecting them from the coll.
I've only tested it by whistling into my laptop mic, and you'll have to do some tweaking of the parameters of bonk~ for it to pick up the start of every note (it sometimes misses them). This kind of method will never be 100% accurate either, but I'm sure you can tweak it to be useable.
It's just to demonstrate though, there are better ways of doing most parts of the patch really. Also there is no windowing of the playback, so it sounds quite glitchy.