I have a wav file and I want to play it....how?
    18 visualizzazioni (ultimi 30 giorni)
  
       Mostra commenti meno recenti
    
    Anthony Donnay-Wood
 il 23 Nov 2016
  
    
    
    
    
    Commentato: Image Analyst
      
      
 il 28 Nov 2021
            I have a project due tuesday and I am having trouble with this last part. I have to play a wav file, put noise to it and filter it out. How do I do this. Everytime I try to play the wav file it either will not work or plays ridiculously slow. Please help, I really need it.
0 Commenti
Risposta accettata
  Image Analyst
      
      
 il 24 Nov 2016
        
      Modificato: Image Analyst
      
      
 il 28 Nov 2021
  
      Try soundsc(). Here's one way to add white noise:
% Read in the standard demo wave file that ships with MATLAB.
[y, fs] = audioread('guitartune.wav');
soundsc(y, fs);  % Here is where we actually play the music from the speakers.
% Plot the original waveform.
subplot(2, 1, 1);
plot(y, 'b-');
grid on;
drawnow;
% Give it time for it to finish playing the original tune
% while asking user if they want to play the noisy one.
message = sprintf('Do you want to play the noisy one?');
reply = questdlg(message, 'Play tune?', 'Yes', 'No', 'Yes');
if strcmpi(reply, 'No')
  % User said No, so exit.
  return;
end
% Define the noise amplitude.  Change this to increate or decrease the noise.
noiseAmplitude = 0.1;
% Add noise to every element of the sound waveform.
yNoisy = y + noiseAmplitude * rand(length(y), 1) - noiseAmplitude/2;
% Plot the noisy waveform below the original one.
subplot(2, 1, 2);
plot(yNoisy, 'b-');
grid on;
drawnow;
% Here is where we actually play the music from the speakers.
soundsc(yNoisy, fs);
4 Commenti
  Razan Al Hakim
 il 28 Nov 2021
				Why the argument of plotting the noisy sound is “y” and not “ynoisy” ? yNoisy = y + noiseAmplitude * rand(length(y), 1) - noiseAmplitude/2; % Plot the noisy waveform below the original one. subplot(2, 1, 2); plot(***y***, 'b-');
  Image Analyst
      
      
 il 28 Nov 2021
				@Razan Al Hakim, just an oversight.  Thanks for catching it.  I've fixed it.
Più risposte (0)
Vedere anche
Categorie
				Scopri di più su Audio Processing Algorithm Design in Help Center e File Exchange
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



