Adding white noise to a wav file??? URGENT!
조회 수: 3 (최근 30일)
이전 댓글 표시
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*
댓글 수: 0
채택된 답변
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
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Audio and Video Data에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!