#ifndef NOISE_H_INCLUDED #define NOISE_H_INCLUDED #if defined(__cplusplus) extern "C" { #endif /** * \fn float AddNoise(float x, float amplitude, float ratio, unsigned nsamples); * * \brief Augments a given signal by adding some random noise and a sinusoidal waveform (e.g. 50Hz from power-line). * * \param x The input signal. * \param amplitude The amplitude of the noise/waveform. * \param ratio The ratio between random noise and sinusoidal waveform [0,1]. * \param nsamples The number of samples per period. Higher values will lower the sinusoidal frequency. * * \return The adjusted input signal */ float AddNoise(float x, float amplitude, float ratio, unsigned nsamples); /* Resets the sinusoidal phase and the LCG */ void ResetNoise(); /* Utility functions */ /* Initializes the LCG */ void slcg(unsigned seed); /* [0,32767] Linear congruential generator (PRNG) */ unsigned lcg(); /* [0,1] LCG */ float flcg(); /* [-1,1] LCG */ float sflcg(); /* Bhaskara sine approximation (in deg) */ float fsindeg(float x); /* Bhaskara cosine approximation (in deg) */ float fcosdeg(float x); #if defined(__cplusplus) }; #endif #endif /* NOISE_H_INCLUDED */