Prev: Find angle between two lines
Next: Indexing Error
From: Soukaina BENAMAR on 8 Jul 2010 11:23 Bonjour, Pourriez vous m'expliquer ce Programme ( sur tous les commandes) Merci d'avance %% Vuvuzela Denoising using Parametric Equalizers % % Author: Charulatha Kalluri % % Copyright 2010 The MathWorks, Inc. % %% Introduction % % This example demonstrates how you can design parametric equalizer filters % in MATLAB and use them to filter out vuvuzela sounds from an audio % stream. This demo uses Signal Processing Toolbox, Filter Design Toolbox % and Signal Processing Blockset. %% Set up input data streams % First, let us look at how we can create streaming inputs in MATLAB % Create a System object to read from the audio file % We need an input audio stream that can read data from a WAV file. To do % this, we can use the MultimediaFileReader System object hSound = signalblks.MultimediaFileReader('Vuvuzela.wav',... 'SamplesPerAudioFrame', 1024, ... 'AudioOutputDataType', 'double'); %Get the input sampling frequency hInfo = info(hSound); Fs = hInfo.AudioSampleRate; %% Create a System object to play back audio to the sound card hPlayer = signalblks.AudioPlayer('SampleRate', Fs); %% Create a System object to write to an audio file hOutputFile = signalblks.MultimediaFileWriter('with_then_without_vuvuzela.wav',... 'SampleRate', Fs); %% Create System objects for logging pure noise and filtered output signals hLogNoise = signalblks.SignalLogger; hLogOutput = signalblks.SignalLogger; %% Advance input audio by 5 seconds % The first 5 seconds of the input do not contain any significant data,i.e, % not even noise, so let’s advance the input by 5 seconds, i.e., about 100 % frames. (@Fs =22050Hz, 1024 samples per frame) for frame_index=1:100 step(hSound); end %% Extract the noise spectrum %To obtain our “pure noise” signal, we use a 1-second portion of the %signal, from 00:05 to 00:06 seconds, that has only the vuvuzela sound, but %no speech. 1 second -> ~20 frames (@Fs=22050Hz, 1024 samples per frame) for noise_frames = 1:20 noise = step(hSound); step(hLogNoise, noise); end %% Plot noise spectrum and identify vuvuzela frequencies pwelch(hLogNoise.Buffer, [], [], 8192, Fs); set(gcf,'Color','white'); %% Identify noise peaks % Zoom into the plot above to identify the vuvuzela frequencies openfig('noise_peaks.fig'); % Noise peaks are observed at the following frequencies: % 235Hz, 476Hz, 735Hz, 940Hz, 1180Hz %% Designing the parametric equalizers % Our next task is to design notch parametric equalizers that will % selectively filter out these frequencies. Since the notch filters will % also remove components of the speech signal at the above frequencies, we % will apply a peak filter to boost the speech signal at the output of the % notch filters. % % To design parametric equalizers, we need to specify filter order, center % frequency, and the bandwidth or Q-factor of the filter. To determine the % bandwidth or Q-factor of the filter, let’s take a closer look at the % noise spectrum. At the lower frequeuncies (235Hz, 465Hz), we see that the % peaks are sharp. At the higher frequencies, the noise peaks are spread % across a wider band. So, for the notch filters at the lower frequencies, % we specify a narrow stopband, i.e., a high Q, and for higher frequencies, % we specify a wider stopband, i.e., a low Q. %% Specifications for notch parametric equalizers F01 = 235; F02 = 476; F03 = 735; F04 = 940; F05 = 1180; N = 2; %Filter order Gref = 0; %Reference gain G0 = -20; %Attenuate by 20dB Qa = 10; %Higher Q-factor for fundamental and 1st harmonic Qb = 5; %Lower Q-factor for higher harmonics f1 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F01,Qa,Gref,G0,Fs); f2 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F02,Qa,Gref,G0,Fs); f3 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F03,Qb,Gref,G0,Fs); f4 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F04,Qb,Gref,G0,Fs); f5 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F05,Qb,Gref,G0,Fs); %% Specifications for peak parametric equalizer N_peak = 8; %Use higher filter order for peak filter F06 = 480; %Center frequency to boost Qc = 0.5; %Use very low Q-factor for boost equalizer filter G1 = 9; %Boost gain by 9dB f6 = fdesign.parameq('N,F0,Qa,Gref,G0',N_peak,F06,Qc,Gref,G1,Fs); %% Design filters and visualize responses Hp1 = design(f1, 'butter'); Hp2 = design(f2, 'butter'); Hp3 = design(f3, 'butter'); Hp4 = design(f4, 'butter'); Hp5 = design(f5, 'butter'); Hp6 = design(f6, 'butter'); hFV = fvtool([Hp1 Hp2 Hp3 Hp4 Hp5 Hp6], 'Color', 'white'); legend(hFV,'NotchEQ #1', 'NotchEQ #2', 'NotchEQ #3', 'NotchEQ #4','NotchEQ #5','Peak EQ'); %% Implement filters using second-order sections hEQ1 = signalblks.BiquadFilter('SOSMatrix',Hp1.sosMatrix,'ScaleValues',Hp1.ScaleValues); hEQ2 = signalblks.BiquadFilter('SOSMatrix',Hp2.sosMatrix,'ScaleValues',Hp2.ScaleValues); hEQ3 = signalblks.BiquadFilter('SOSMatrix',Hp3.sosMatrix,'ScaleValues',Hp3.ScaleValues); hEQ4 = signalblks.BiquadFilter('SOSMatrix',Hp4.sosMatrix,'ScaleValues',Hp4.ScaleValues); hEQ5 = signalblks.BiquadFilter('SOSMatrix',Hp5.sosMatrix,'ScaleValues',Hp5.ScaleValues); hEQ6 = signalblks.BiquadFilter('SOSMatrix',Hp6.sosMatrix,'ScaleValues',Hp6.ScaleValues); %% Stream processing loop to filter out vuvuzela noise %Note: To process the entire data,use a while loop instead of a for loop %while (~isDone(hSound)) %Filter 400 frames of input data for frames = 1:400 %Step through input WAV file one frame at a time input = step(hSound); %Apply notch EQ filters first, then peak EQ filter out1 = step(hEQ1, input); out2 = step(hEQ2, out1); out3 = step(hEQ3, out2); out4 = step(hEQ4, out3); out5 = step(hEQ5, out4); denoised_sig = step(hEQ6, out5); %Play 200 frames of input signal, then 200 frames of filtered output %to compare original and filtered signals %Log the audio output to a WAV file if frames < 200 step(hPlayer, input); step(hOutputFile, input); else step(hPlayer, denoised_sig); step(hOutputFile, denoised_sig); end %Log filtered output to buffer step(hLogOutput, denoised_sig); end %% Plot filtered signal spectrum % Here’s the power spectrum of the filtered signal. If you zoom into the % plot, you can see that the vuvuzela frequencies have been attenuated by % our notch equalizer filters: figure; pwelch(hLogOutput.Buffer, [], [], 8192, Fs); set(gcf,'Color','white'); %% Cleanup %Close input and output stream System objects close(hSound); close(hPlayer); close(hOutputFile);
From: Charulatha Kalluri on 8 Jul 2010 13:21 Hello Soukaina, It sounds like you're looking for more detailed information on how System objects work. I recommend that you watch the following webinar recording, which introduces System objects, and uses these objects to develop an audio filtering example. The concepts are the same as the vuvuzela demo, it's just that the filtering methods are different. http://www.mathworks.com/company/events/webinars/wbnr43430.html?id=43430&p1=723906872&p2=723906890 For details on each System objects and its parameters, please refer to the documentation pages: http://www.mathworks.com/access/helpdesk/help/toolbox/dspblks/ref/bsf2cw2.html Let me know if you have any other questions, and I will be happy to help you out. Thanks! Charu "Soukaina BENAMAR" <soukainabenamar5(a)hotmail.com> wrote in message <i14qgr$dju$1(a)fred.mathworks.com>... > Bonjour, > Pourriez vous m'expliquer ce Programme ( sur tous les commandes) > Merci d'avance > %% Vuvuzela Denoising using Parametric Equalizers > % > % Author: Charulatha Kalluri > % > % Copyright 2010 The MathWorks, Inc. > % > > %% Introduction > % > % This example demonstrates how you can design parametric equalizer filters > % in MATLAB and use them to filter out vuvuzela sounds from an audio > % stream. This demo uses Signal Processing Toolbox, Filter Design Toolbox > % and Signal Processing Blockset. > > %% Set up input data streams > % First, let us look at how we can create streaming inputs in MATLAB > > % Create a System object to read from the audio file > > % We need an input audio stream that can read data from a WAV file. To do > % this, we can use the MultimediaFileReader System object > > hSound = signalblks.MultimediaFileReader('Vuvuzela.wav',... > 'SamplesPerAudioFrame', 1024, ... > 'AudioOutputDataType', 'double'); > > > %Get the input sampling frequency > hInfo = info(hSound); > Fs = hInfo.AudioSampleRate; > > %% Create a System object to play back audio to the sound card > hPlayer = signalblks.AudioPlayer('SampleRate', Fs); > > %% Create a System object to write to an audio file > hOutputFile = signalblks.MultimediaFileWriter('with_then_without_vuvuzela.wav',... > 'SampleRate', Fs); > > %% Create System objects for logging pure noise and filtered output signals > > hLogNoise = signalblks.SignalLogger; > hLogOutput = signalblks.SignalLogger; > > %% Advance input audio by 5 seconds > % The first 5 seconds of the input do not contain any significant data,i.e, > % not even noise, so let’s advance the input by 5 seconds, i.e., about 100 > % frames. (@Fs =22050Hz, 1024 samples per frame) > > for frame_index=1:100 > step(hSound); > end > > %% Extract the noise spectrum > %To obtain our “pure noise” signal, we use a 1-second portion of the > %signal, from 00:05 to 00:06 seconds, that has only the vuvuzela sound, but > %no speech. 1 second -> ~20 frames (@Fs=22050Hz, 1024 samples per frame) > > for noise_frames = 1:20 > noise = step(hSound); > step(hLogNoise, noise); > end > > %% Plot noise spectrum and identify vuvuzela frequencies > > pwelch(hLogNoise.Buffer, [], [], 8192, Fs); > set(gcf,'Color','white'); > > %% Identify noise peaks > > % Zoom into the plot above to identify the vuvuzela frequencies > openfig('noise_peaks.fig'); > > % Noise peaks are observed at the following frequencies: > % 235Hz, 476Hz, 735Hz, 940Hz, 1180Hz > > %% Designing the parametric equalizers > % Our next task is to design notch parametric equalizers that will > % selectively filter out these frequencies. Since the notch filters will > % also remove components of the speech signal at the above frequencies, we > % will apply a peak filter to boost the speech signal at the output of the > % notch filters. > % > % To design parametric equalizers, we need to specify filter order, center > % frequency, and the bandwidth or Q-factor of the filter. To determine the > % bandwidth or Q-factor of the filter, let’s take a closer look at the > % noise spectrum. At the lower frequeuncies (235Hz, 465Hz), we see that the > % peaks are sharp. At the higher frequencies, the noise peaks are spread > % across a wider band. So, for the notch filters at the lower frequencies, > % we specify a narrow stopband, i.e., a high Q, and for higher frequencies, > % we specify a wider stopband, i.e., a low Q. > > %% Specifications for notch parametric equalizers > > F01 = 235; F02 = 476; F03 = 735; F04 = 940; F05 = 1180; > > N = 2; %Filter order > Gref = 0; %Reference gain > G0 = -20; %Attenuate by 20dB > Qa = 10; %Higher Q-factor for fundamental and 1st harmonic > Qb = 5; %Lower Q-factor for higher harmonics > > f1 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F01,Qa,Gref,G0,Fs); > f2 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F02,Qa,Gref,G0,Fs); > f3 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F03,Qb,Gref,G0,Fs); > f4 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F04,Qb,Gref,G0,Fs); > f5 = fdesign.parameq('N,F0,Qa,Gref,G0',N,F05,Qb,Gref,G0,Fs); > > %% Specifications for peak parametric equalizer > > N_peak = 8; %Use higher filter order for peak filter > F06 = 480; %Center frequency to boost > Qc = 0.5; %Use very low Q-factor for boost equalizer filter > G1 = 9; %Boost gain by 9dB > > f6 = fdesign.parameq('N,F0,Qa,Gref,G0',N_peak,F06,Qc,Gref,G1,Fs); > > %% Design filters and visualize responses > > Hp1 = design(f1, 'butter'); > Hp2 = design(f2, 'butter'); > Hp3 = design(f3, 'butter'); > Hp4 = design(f4, 'butter'); > Hp5 = design(f5, 'butter'); > Hp6 = design(f6, 'butter'); > > hFV = fvtool([Hp1 Hp2 Hp3 Hp4 Hp5 Hp6], 'Color', 'white'); > legend(hFV,'NotchEQ #1', 'NotchEQ #2', 'NotchEQ #3', 'NotchEQ #4','NotchEQ #5','Peak EQ'); > > %% Implement filters using second-order sections > > hEQ1 = signalblks.BiquadFilter('SOSMatrix',Hp1.sosMatrix,'ScaleValues',Hp1.ScaleValues); > hEQ2 = signalblks.BiquadFilter('SOSMatrix',Hp2.sosMatrix,'ScaleValues',Hp2.ScaleValues); > hEQ3 = signalblks.BiquadFilter('SOSMatrix',Hp3.sosMatrix,'ScaleValues',Hp3.ScaleValues); > hEQ4 = signalblks.BiquadFilter('SOSMatrix',Hp4.sosMatrix,'ScaleValues',Hp4.ScaleValues); > hEQ5 = signalblks.BiquadFilter('SOSMatrix',Hp5.sosMatrix,'ScaleValues',Hp5.ScaleValues); > hEQ6 = signalblks.BiquadFilter('SOSMatrix',Hp6.sosMatrix,'ScaleValues',Hp6.ScaleValues); > > %% Stream processing loop to filter out vuvuzela noise > > %Note: To process the entire data,use a while loop instead of a for loop > %while (~isDone(hSound)) > > %Filter 400 frames of input data > for frames = 1:400 > %Step through input WAV file one frame at a time > input = step(hSound); > > %Apply notch EQ filters first, then peak EQ filter > out1 = step(hEQ1, input); > out2 = step(hEQ2, out1); > out3 = step(hEQ3, out2); > out4 = step(hEQ4, out3); > out5 = step(hEQ5, out4); > denoised_sig = step(hEQ6, out5); > > %Play 200 frames of input signal, then 200 frames of filtered output > %to compare original and filtered signals > %Log the audio output to a WAV file > if frames < 200 > step(hPlayer, input); > step(hOutputFile, input); > else > step(hPlayer, denoised_sig); > step(hOutputFile, denoised_sig); > end > > %Log filtered output to buffer > step(hLogOutput, denoised_sig); > end > > %% Plot filtered signal spectrum > > % Here’s the power spectrum of the filtered signal. If you zoom into the > % plot, you can see that the vuvuzela frequencies have been attenuated by > % our notch equalizer filters: > figure; pwelch(hLogOutput.Buffer, [], [], 8192, Fs); > set(gcf,'Color','white'); > > %% Cleanup > > %Close input and output stream System objects > > close(hSound); > close(hPlayer); > close(hOutputFile);
From: Steven Lord on 8 Jul 2010 14:11 "Soukaina BENAMAR" <soukainabenamar5(a)hotmail.com> wrote in message news:i14qgr$dju$1(a)fred.mathworks.com... > Bonjour, Pourriez vous m'expliquer ce Programme ( sur tous les commandes) > Merci d'avance *snip* First, please do not copy a file from the File Exchange into your posting. Just include a link to the file. http://www.mathworks.com/matlabcentral/fileexchange/28068-vuvuzela-filtering-with-parametric-equalizers-using-system-objects or perhaps: http://www.mathworks.com/matlabcentral/fileexchange/27912-vuvuzela-sound-denoising-algorithm Second, the comments in the code explain in general what each section of the code does; if you still need further help understanding a specific section, take a look at the help text and/or documentation for the function or functions you don't understand. For example, to learn what the SIN function does, you would execute one or both of the following commands at the MATLAB prompt: help sin doc sin After reading through the comments in the code, the help text, and the documentation if you have a SPECIFIC question about what the code is doing, then go ahead and ask that SPECIFIC question here. -- Steve Lord slord(a)mathworks.com comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ To contact Technical Support use the Contact Us link on http://www.mathworks.com
From: Soukaina BENAMAR on 8 Jul 2010 14:20 Hello charulatha, thank you for your answer . i will see now the websites ^_^ Thank you a lot
From: Soukaina BENAMAR on 8 Jul 2010 14:30
hello I don't understand the role of functions such as : fdesign.parameq, also signalblks.MultimediaFileReade!!! "Steven Lord" <slord(a)mathworks.com> wrote in message <i154d7$rd$1(a)fred.mathworks.com>... > > "Soukaina BENAMAR" <soukainabenamar5(a)hotmail.com> wrote in message > news:i14qgr$dju$1(a)fred.mathworks.com... > > Bonjour, Pourriez vous m'expliquer ce Programme ( sur tous les commandes) > > Merci d'avance > > *snip* > > First, please do not copy a file from the File Exchange into your posting. > Just include a link to the file. > > http://www.mathworks.com/matlabcentral/fileexchange/28068-vuvuzela-filtering-with-parametric-equalizers-using-system-objects > > or perhaps: > > http://www.mathworks.com/matlabcentral/fileexchange/27912-vuvuzela-sound-denoising-algorithm > > Second, the comments in the code explain in general what each section of the > code does; if you still need further help understanding a specific section, > take a look at the help text and/or documentation for the function or > functions you don't understand. For example, to learn what the SIN function > does, you would execute one or both of the following commands at the MATLAB > prompt: > > help sin > > doc sin > > After reading through the comments in the code, the help text, and the > documentation if you have a SPECIFIC question about what the code is doing, > then go ahead and ask that SPECIFIC question here. > > -- > Steve Lord > slord(a)mathworks.com > comp.soft-sys.matlab (CSSM) FAQ: http://matlabwiki.mathworks.com/MATLAB_FAQ > To contact Technical Support use the Contact Us link on > http://www.mathworks.com > |