I'm working on a project for university and part of my project at the minute is adding noise to a .wav file. Originally my supervisor wanted me to generate noise by "specifying a given variance and adding it to the data of the .wav file". I took this to mean that the user would specify a variance of n and I would use Python's Random library in the stdlib to add variance in the range of -n..n. I've implemented this successfully and can load a file, add white noise and save it as a new file.

My supervisor has then decided we could expand on this by using signal to noise ratio. I'm just at the point where I can implement this so previously I haven't given it much thought. I've been doing some reading on it today and I don't really know how he would want it implemented.

My guess would be that I would be able to specify the power of the signal and the power of the noise. When I calculate the SNR from these values I would then use the result to generate noise and add it do the data of the wave file. Does this sound right? If it does, does anyone know how I might implement this?


1 Answer 1


Simply limit the range of negative and positive values being added to the existing value. If you have an existing signal, noise generally is additive to that signal (such as voltages induced in a wire).

You can generate random values within a given amplitude (the amount of noise) and sum them to your samples (signal). The higher the amplitude of the noise, the less signal there is per unit of noise.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.