TheCherno / HazelAudio

Hazel Audio is an audio library designed for Hazel
Apache License 2.0
81 stars 24 forks source link

Float PCM #1

Open dlandahl opened 4 years ago

dlandahl commented 4 years ago

I would consider using float 32 PCM rather than integer PCM in modern game systems. The maths and code become much simpler when implementing filters / audio processes. Many systems that use integers will end up converting back and forth between floats, and even using floating-point values in the 16-bit int range (-32768 to 32767) to do more complex processing. What a mess. Float PCM also retains peaking information - clipping audio data can be recovered in a later gain stage. This means that sound designers working in-engine have more freedom in their workflow.

Maybe there are reasons people use integer PCM in game-dev that I don't know about, but to me it seems best to convert to float32s in [-1, 1] as early as possible and keep it in that format for as long as possible; it's how we do it with pro-audio software at least.

Tiwann commented 1 year ago

I would use 32 float pcm samples for signal processing, adding effects and such then convert it all into 16bit int samples for playback.