Issues with BitCrush audio class

Hi All,

I am very new to audio processing (current setup is PlatformIO, Arduino framework).

I am currently trying to add a bitcrush effect to my input signal. I have run the bitcrush example and hear the crushed signal on the oscillator but am having trouble converting that to crush my input signal instead of the osc.

With the code below I am not getting any sound on the output line.

Any help would be greatly appreciated! Thank you!

bitcrush is a private member of the class

void BitCrush::Setup(size_t pNumChannels)
    numChannels = pNumChannels;

    depth = 1;
    float sampleRate = DAISY.get_samplerate();

    //set parameters for bitcrusher

audioInChannel and audioOutChannel are constants in the class, I have verified that I can bypass the input signal to the output signal with these channels. The error comes when I add the bitcrush.Process()

void BitCrush::AudioCallback(float **in, float **out, size_t size)
    float sig;
    for (size_t i = 0; i < size; i++)
        sig = in[audioInChannel][i];
        sig = bitcrush.Process(sig);
        out[audioOutChannel][i] = sig;

My entire codebase is a little complex because I’m using an interface to allow me to swap between multiple effects ( Everything in main.cpp is working as expected (I’ve used it successfully in a different repo to create a delay effect). This code lives in lib/BitCrush/

It’s probably better to upload full text instead if you want program to get a review. The part that you’ve posted looks OK, but it doesn’t show where all variables come from, i.e. audioInChannel/audioOutChannel. Also, Daisy has a yet unresolved bug that causes channels to swap sometimes, so maybe you’re getting audio not on the output that you expect.

@antisvin thanks for the recommendation!

I have updated my original post to include as much code as I could, and also a link to the entire repository for further context.

As a note, I have also tried making these exact same changes in the Arduino example and had no success.

I’m not super familiar with the BitCrush module, and it looks like you removed this specific code from your project, but I can take a look at the DaisySP module a bit later and see if there’s anything that stands out as wrong.

Maybe try using the Decimator module for the time being if you don’t find a solution on your end. I just used that one the other day, and it was working as expected.

Thanks @shensley I will try the Decimator module later this week and see if that works.

1 Like

@shensley you were right, I used the Decimator module and it is working perfectly, thank you!

1 Like