# Adding White Gaussian noise to a voice signal

I'm trying to add White Gaussian Noise to an audio file. However; the energy of the noise should be 1/10th of that of the signal. My first attempt is as following:

[y,Fs] = audioread('drum.wav');
%sound(y,Fs);
sound(noisy_sig,Fs);

function noisy_sig = addnoise( sig , SNRdb )
sig_power = norm(sig,2) / length(sig);
% noise power is equal to sigma^2
sigma2 = sig_power / 10^(SNRdb/10) ;
noisy_sig = sig + sqrt(sigma2)*randn(size(sig));
end


When I listen the resulting wav, there is no difference between the original and noisy ones. Am I doing something wrong? Any help would be appreciated.

• So, Is it correct to say x = y + 0.1*randn(length(y),1) ? The energy of the noise signal should be 1/10th of the original signal. Commented Dec 18, 2019 at 15:31

Your problem is how you calculate the signal power. You are calling norm which calculates $$\sqrt{\sum_i |x_i|^2}$$ but you want to calculate the sum of the squared values and then divide by the length as you do in your code. Try this instead: sig_power = norm(sig)^2 / length(sig);. This line will calculate $$\frac{1}{N}\sum_{i=1}^N |x_i|^2$$.
• That adds noise with variance $0.1$. But from your comment you don't mention anything about y's power. SNR is signal-to-noise ratio so it is the signal and noise power relative to each other. Commented Dec 18, 2019 at 17:07