[p1,fs]=audioread('40kph_RN.wav');
[p2,fs]=audioread('2000rpm_Knock.wav');
fs=44100;
L=8;N=448505;
g=randp(N);
y=filter(Num,1,g)
p2(448512,[1 2]) = [0,0];
Lch_p1=p1(:,1);
Rch_p1=p1(:,2);
Lch_p2=p2(:,1);
Rch_p2=p2(:,2);
smix_Lch=6*Lch_p1+Lch_p2/10+y/10;
filename='mix_Lch.wav';
audiowrite(filename,smix_Lch,fs);
smix_Rch=6*Rch_p1+Rch_p2/10+y/10;
filename='mix_Rch.wav';
audiowrite(filename,smix_Rch,fs);
fft_white=fft(y/10);
dB_white=mag2db(abs(fft_white));
fft_p1L=fft(6*Lch_p1);
dB_p1L=mag2db(abs(fft_p1L));
fft_p1R=fft(6*Rch_p1);
dB_p1R=mag2db(abs(fft_p1R));
fft_p2L=fft(Lch_p2/10);
dB_p2L=mag2db(abs(fft_p2L));
fft_p2R=fft(Rch_p2/10);
dB_p2R=mag2db(abs(fft_p2R));
f = (0:length(fft_p1L)-1)*fs/length(fft_p1L);
figure(1)
semilogx(f,dB_p2L)
xlim([0 fs/2])
ylim([-100,100])
xlabel('frequency[Hz]')
ylabel('Magnitude[dB]')
hold on
semilogx(f,dB_p1L)
grid on, hold off
hold on
semilogx(f,dB_white)
grid on, hold off
legend('2000rpm.knock','roadnoise','whitenoise');
figure(2)
semilogx(f,dB_p2R)
xlim([0 fs/2])
ylim([-100,100])
xlabel('frequency[Hz]')
ylabel('Magnitude[dB]')
hold on
semilogx(f,dB_p1R)
grid on, hold off
hold on
semilogx(f,dB_white)
grid on, hold off
legend('2000rpm.knock','roadnoise','whitenoise');