How is sound and microphone sampling supposed to work?

17 Views Asked by At

I've started using miniaudio sound library written in C, which is an impressive single-header roughly 100k lines of code library for playing audio and reading microphone in a cross_platform way. I'm wondering, what it seems to do is launch a worker thread, and loop, and calls your callback (I'm not exactly sure what it does), but this means that a single thread is using all of the CPU core on which it runs, because that's what endless loops do, it doesn't sleep or anything like that. Smooth playback/reading is said to be around 44khz, whereas looping is running at max speed of the CPU. How is sampling supposed to be done generally speaking? How is it done in for example a game engine? What's the proper way to do this?

0

There are 0 best solutions below