I don't know if this fits your usecase exactly, but I'd recommend looking into a looper. It seems like Giada can do what you need it to without too much fuss. It's free and open source, too.
try this see if it works this should be able to record and loopback audio ideally on the fly but may not be as easy as you want that may require some hardware not sure where to start there but just look up loopback software.
The way media players handle files is different than applications designed to work with live music. If you aren't familiar with any, giada isn't a bad place to start. You can load your clip into a channel, set it to loop, and play it.
This sounds a lot like you're looking for a loop machine style interface. Patterns loop and you toggle them on and off to to build up your track. If that's the case, look into Giada.
I can't speak to how well it works or how intuitive it is, but I've been meaning to try it out for awhile now.
There is this https://www.giadamusic.com/ which I have not used, although I've heard a lot of people who use it.
It is partially a question of what you want to do with the loops once you record them. There are a ton of looping things out there, from Ableton Live which has it built in as part of its basic functionality, no doubt a ton of Reaktor ensembles that will do different kinds of looping. But essentially you want to be able to, ideally, have something that lets you assign one MIDI CC to "record" and another (or the same one) to "play", at which point the record will stop and play back what you have (often this button would double as your "stop"). It helps to have an additional function to delete what you just did. Again, it depends on what you want your workflow to be like (do you want to then have another loop that goes over the first one, and if so, do you want it to have the same length or loop independently, etc). It's a huge subject.