Noise in Handel’s Messiah adding noises with random number generator
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
This is the assignment:
- Implement the following section of code to use a random number generator to add noise to the sample of Handel’s Messiah.
- Add noise in such a way that the music file is noise free after 7 seconds of music have passed
- Use subplot to plot the following in the same figure
- - the first 300 data points in the noise vector
- - the first 300 data points in sound_w_noise vector
But I genuinely have no idea where to start or where to go. I do not know how to do this assignment at all and the lecture notes were no help (also my professor doesn't like to email me back). This is what I have so far on the assignment....
%% Assignment 6 part 4
% Implement the following section of code to use a random number generator to add noise to the sample of Handel’s Messiah.
% Add noise in such a way that the music file is noise free after 7 seconds of music have passed
% Use subplot to plot the following in the same figure
% the first 300 data points in the noise vector
% the first 300 data points in sound_w_noisevector
%% Load Handel's Messiah
load handel
sound(y,Fs);
pause
multiplier=0.10;
noise=randm(length(y),1)*multiplier;
sound_w_noise=y+noise;
%% Subplots
0 Commenti
Risposte (1)
John D'Errico
il 12 Mar 2020
Well, you did make some effort, sadly an unusual thing from many students. So a start. ;-(
clear
load handel
whos
Name Size Bytes Class Attributes
Fs 1x1 8 double
y 73113x1 584904 double
What Fs? What does it mean? If you read the help for sound, it is the sample rate for the sound vector in y, in samples per second.
So how many seconds of time does the entire song fragment encompass?
length(y)/Fs
ans =
8.9249267578125
And how many samples will exactly 7 seconds require?
It is your homework. You need to do some thinking here, but this should get you started.
6 Commenti
Image Analyst
il 15 Mar 2020
Modificato: Image Analyst
il 15 Mar 2020
Well it didn't plot because you got a pause in there and is waiting for you to hit a key, and then you messed up the subplot so it's blowing away your first plot. Plus you got the y label wrong. Y is amplitude, not frequency. Here is the fix:
load handel
multiplier=0.10;
noise = randn(length(y),1)*multiplier;
% Subplots
t = 1:length(y);
noisy = y + noise;
% Plot noise-free signal.
subplot(3,1,1);
plot(t(1:300), y(1:300));
title('Noise-Free Sound');
xlabel('Element Number in Music Array');
ylabel('Amplitude');
grid on;
% Plot noise signal with no audio.
subplot(3,1,2);
plot(t(1:300), noise(1:300));
title('Noise Alone');
xlabel('Element Number in Music Array');
ylabel('Amplitude');
grid on;
subplot(3,1,3);
plot(t(1:300), noisy(1:300));
title('Noisy Sound');
xlabel('Element Number in Music Array');
ylabel('Amplitude');
grid on;
% Play both sounds one after the other.
sound(y,Fs);
uiwait(msgbox('When the music ends, click OK to hear the noisy audio'));
sound(noisy,Fs);
Vedere anche
Categorie
Scopri di più su Time-Frequency Analysis 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!