Skip to content

Instantly share code, notes, and snippets.

@Xenakios
Created July 22, 2020 14:31
Show Gist options
  • Save Xenakios/8c4962c321226945adcf9b536ed9668c to your computer and use it in GitHub Desktop.
Save Xenakios/8c4962c321226945adcf9b536ed9668c to your computer and use it in GitHub Desktop.
class MyCallback : public AudioIODeviceCallback
{
public:
void audioDeviceIOCallback(const float** inputChannelData, int numInputChannels,
float** outputChannelData, int numOutputChannels, int numSamples) override
{
for (int i = 0; i < numSamples; ++i)
{
float sample = jmap(rng.nextFloat(), 0.0f, 1.0f, -noiseGain, noiseGain);
for (int j = 0; j < numOutputChannels; ++j)
{
outputChannelData[j][i] = sample;
}
}
}
void audioDeviceAboutToStart(AudioIODevice* device) override
{
}
void audioDeviceStopped() override
{
}
float noiseGain = 0.05f;
private:
Random rng;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment