Most chips will have some sort of PWM or advanced timer peripheral that can generate waveforms on a pin without direct CPU intervention. You write to registers to change the frequency, duty cycle, etc.
Many chips also include asynchronous DACs, but they're usually too low-resolution for high-fidelity audio.
Most microcontrollers also include some form of DMA, which can shuttle data between peripherals and memory without CPU intervention. You can also user timer peripherals to trigger DMA transfers, which lets you send buffered data to a DAC on a KHz schedule while the CPU does other things.
And of course, you can usually use timer peripherals to periodically interrupt the main thread when you don't want to wait in a busy-loop.
In DuinoTune [1] the song playback had a per song 'tick' timer interrupt at 12 per beat which handles note on/off, envelope, pitch/audio glides. And a per-sample timer interrupt which does a mixdown of the voices and updates the hardware PWM duty-cycle to generate the waveform.
If you've got multiple cores it's no problem: Just run the note-playing code on a different core. However, if you've only got one core you'll need some method to play those notes without disrupting the main loop.