class: mBitcrusher
crunch your sound by changing bitrate and samplerate
Description
A two-parameter bitcrusher. The sample-rate conversion is very rudimentary and should not be used for anything other than glitchy effects. The bit-rate changer operates in the opposite direction from most bitcrusher effects, allowing you to control how many bits are removed from a sound rather than how many are preserved.
Class Methods
Constructor
mBitcrusher(int sample_rate = 32768, int bits = 0)sample_rate: Sets the desired sample rate of the signal
bits: Sets the number of bits to reduce your signal by
void setBits(uint8_t bits)Remove bits of precision from your signal. The perceived change will differ depending on the bitrate of your input signal. If you have a high bit-rate signal (aka a loud signal) it will take more bits of removal to have an effect than on an already low bit-rate signal.
void setSampleRate(float sample_rate)Set the signal to approximate a desired sample_rate (1-32768). The sample-rate conversion is non-interpolating so it is particularly glitchy sounding.
int64_t next(int64_t in_sample)Send a sample to the bitcrusher and receive a crushed sample back.
Example
//global declaration
mBitcrusher my_bitcrusher(32768, 0);
//in updateAudio
out_sample = my_bitcrusher.next(oscillator_output); // where oscillator_output is the output of some previous sound-generating object