Adding white noise to a wav file??? URGENT!

조회 수: 3 (최근 30일)
Bex G
Bex G 2014년 12월 5일
댓글: Bex G 2014년 12월 5일
Hi,
I need to add white gaussian noise to a wav file. I've managed to do this by adding the two together
freq = 9000;
duration = 0.4;
S2 = rand(1,(freq * duration));
S1 = audioread('drum.wav');
S = S1;
S(1:length(S2), 2) = S2;
soundsc(S)
but the sound signal in the wav.file when they are both played together turns into a really low distorted pitch. I understand now that if i was [y,fs] = audioread('drum.wav') then it will play normally but im not sure how to add white noise to this??? I have tried several ways but nothing seems to work apart from the above which distorts it!!
please help!!! URGENT!!
* I preferably want someone using the program to change the white noise using some kind of Standard Deviation so i dont want to just use awgn*

채택된 답변

Image Analyst
Image Analyst 2014년 12월 5일
You didn't use randn and you didn't pass in the frequency. Try this:
% Open standard demo sound that ships with MATLAB.
[perfectSound, freq] = audioread('guitartune.wav');
% Add noise to it.
noisySound = perfectSound + 0.01 * randn(length(perfectSound), 1);
% Find out which sound they want to play:
promptMessage = sprintf('Which sound do you want to hear?');
titleBarCaption = 'Specify Sound';
button = questdlg(promptMessage, titleBarCaption, 'Perfect', 'Noisy', 'Perfect');
if strcmpi(button, 'Perfect')
% Play the perfect sound.
soundsc(perfectSound, freq);
else
% Play the noisy sound.
soundsc(noisySound, freq);
end
  댓글 수: 1
Bex G
Bex G 2014년 12월 5일
Thankyou so much :D it works, great help!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Audio and Video Data에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by