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

8 ビュー (過去 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 Center および File ExchangeAudio and Video Data についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by