electro-smith / DaisySP

A Powerful DSP Library in C++
https://www.electro-smith.com/daisy
Other
839 stars 132 forks source link

Bitcrush does not work properly #134

Open jerry20091103 opened 3 years ago

jerry20091103 commented 3 years ago

The bitcrush module is outputing a huge DC offset in my testing, it seems that there's a bug in the code. In line 27 of bitcrush.cpp: out *= (65536.0f / bits) - 32768; I believe it should be out *= (65536.0f / bits); out -= 32768; or something equivalent instead.

stephenhensley commented 3 years ago

Thanks for pointing this out.

I was just discussing with someone this morning how we have multiple modules that accomplish similar goals, and we may remove a few to consolidate all downsampling/bitcrushing to a single module.

For now, you can try the Decimator module as an alternative.

PaulBatchelor commented 3 years ago

Another issue with BitCrush is that the internal fold transformation will eventually suffer from numerical overflow (both integer AND floating point), which is UB. Reason for this is that fold uses two indefinitely incrementing counters to keep track of absolute time. It's also been a longstanding bug in Soundpipe all this time. Oops.