Adding white noise to a wav file??? URGENT!
18 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Bex G
am 5 Dez. 2014
Kommentiert: Bex G
am 5 Dez. 2014
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 Kommentare
Akzeptierte Antwort
Image Analyst
am 5 Dez. 2014
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
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Audio and Video Data finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!