Combustion chamber/head design and direct injection come in to it a lot too. There was a noticeable reduction in quality of engine sounds as DI came out, it’s just that a turbocharging became popular at the same time.
There’s still some oddities about it too. The BMW N55 engine sounds good, an S55 takes work to sound…