当前位置:网站首页>[signal processing] digital signal processing matlab design with GUI interface and report

[signal processing] digital signal processing matlab design with GUI interface and report

2022-06-11 13:21:00 Matlab scientific research studio

1 brief introduction ​

Signal processing is the basic content of modern information processing , Digital signal processing is the most important . The main research content of digital signal processing is speech signal and image signal , The study of speech signal has a positive significance for modern speech communication . The study of speech signal can be divided into time domain and frequency domain .

(1) Time domain analysis and processing of speech signal : One is speech signal analysis , The other is to generate and transform various modulation signals , The dynamic range of the signal average accumulator is compressed and expanded , Using threshold method to suppress noise and so on . The former is the linear processing of the signal average accumulator in the time domain , Mainly through the addition and subtraction of signals 、 Time shift 、 multiplier 、 Convolution 、 Find the correlation function to realize . The latter category , It belongs to nonlinear transformation and processing .

(2) Spectrum analysis and processing of speech signal : The time-domain spectrum analysis of signals is usually carried out together .

In the digital design system , Any signal processing device can be regarded as a filter , Filter design is an important part of digital signal processing . The filter is based on the analysis of the signal , Design appropriate systems , Extract useful signals , Suppress noise signal interference . The filter design is usually carried out in the frequency domain .

This design uses MATLAB The simulation software designs a filter to filter the disturbed speech signal , And analyze the spectrum of each part .

1. Voice signal acquisition

Be familiar with and master MATLAB About sound in (wave) Recording 、 Play 、 Functions for storing and reading , stay MATLAB Environment , Use the sound correlation function to record 3 Seconds or so of your own voice .( Consider how to solve a practical problem : At the beginning of recording , There is often a phenomenon that the actual sound is half a beat behind the recorded action , How to exclude the sampling of these invalid points ?)

2. Spectrum analysis of speech signal

It is required to draw the time domain waveform of the speech signal first ; Then the speech signal is subjected to fast Fourier transform , Get the spectrum characteristics of the signal , So as to deepen the understanding of spectrum characteristics .

3. Design digital filter and draw its frequency response

The performance index of each filter is given :

(1) Low pass filter performance index :fb=1000 Hz,fc=1200 Hz,As=100dB,Ap=1dB.

(2) High pass filter performance index :fc=4800 Hz,fb=5000 Hz As=100dB,Ap=1dB.

(3) Performance index of bandpass filter :fp1=1200 Hz,fp2=3000 Hz,fsc1=1000 Hz,fsc2=3200Hz,As=100dB,Ap=1dB.

It is required to use window function method and bilinear transformation method to design the above requirements 3 A kind of filter . stay Matlab in , Using functions butter,cheby1 Equifunction design IIR filter ; utilize Matlab The function in freqz Draw the frequency response of each filter .

4. Filter the signal with a filter

It is required to filter the collected signals with various filters designed by ourselves , stay Matlab in ,FIR Filter utilization function fftfilt Filter the signal ,IIR Filter utilization function filter Filter the signal .

5. Compare the waveform and spectrum of speech signal before and after filtering

It is required to draw the waveform and spectrum before and after filtering in one window at the same time .

6. Playback voice signal

stay Matlab in , Use the relevant sound function to play back the sound . Identify the changes of sound before and after filtering .

7. Analysis of spectrum characteristics of male and female voice signals

Change someone who is different from your gender to record the same voice content , Analyze the characteristics between two speech signal spectrums with the same content .

8.  Background noise filtering

Record another period of background noise for the same length of time ( The spectrum energy is concentrated in a small range ) Superimposed on your voice signal , Analyze the change of signal spectrum before and after superposition , Design a suitable filter , The noise can be filtered out .

9. Design system interface ( use MATLAB in GUIDE Tools , Self study is required )

In order to make the program easy to operate , Students with ability are required , Design the user interface of the processing system . The filter type can be selected on the designed system interface , Input filter parameters , Display the frequency response of the filter , Select signal, etc .

2 Part of the code

<span style="color:#333333"><span style="background-color:rgba(0, 0, 0, 0.03)"><code><span style="color:#ca7d37">function</span> varargout = cover1(varargin)</code><code>% Begin initialization code - DO NOT EDIT</code><code>gui_Singleton = 1;</code><code>gui_State = struct(<span style="color:#dd1144">'gui_Name'</span>,       mfilename, ...</code><code>    <span style="color:#dd1144">'gui_Singleton'</span>,  gui_Singleton, ...</code><code>    <span style="color:#dd1144">'gui_OpeningFcn'</span>, @cover1_OpeningFcn, ...</code><code>    <span style="color:#dd1144">'gui_OutputFcn'</span>,  @cover1_OutputFcn, ...</code><code>    <span style="color:#dd1144">'gui_LayoutFcn'</span>,  [] , ...</code><code>    <span style="color:#dd1144">'gui_Callback'</span>,   []);</code><code><span style="color:#ca7d37">if</span> nargin && ischar(varargin{1})</code><code>    gui_State.gui_Callback = str2func(varargin{1});</code><code>end</code><code>​</code><code><span style="color:#ca7d37">if</span> nargout</code><code>    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});</code><code><span style="color:#ca7d37">else</span></code><code>    gui_mainfcn(gui_State, varargin{:});</code><code>end</code><code>% End initialization code - DO NOT EDIT</code><code><span style="color:#ca7d37">function</span> cover1_OpeningFcn(hObject, eventdata, handles, varargin)</code><code>handles.output = hObject;</code><code>​</code><code>ha=axes(<span style="color:#dd1144">'units'</span>,<span style="color:#dd1144">'normalized'</span>,<span style="color:#dd1144">'position'</span>,[0 0 1 1]);</code><code>uistack(ha,<span style="color:#dd1144">'down'</span>);</code><code>II=imread(<span style="color:#dd1144">'cover1.jpg'</span>);</code><code>image(II)</code><code>colormap gray</code><code><span style="color:#ca7d37">set</span>(ha,<span style="color:#dd1144">'handlevisibility'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>​</code><code>hb = axes(<span style="color:#dd1144">'unit'</span>,<span style="color:#dd1144">'normalized'</span>,<span style="color:#dd1144">'position'</span>,[0.38 0.95 0.365 0.051]);</code><code>strCell = {<span style="color:#dd1144">' Speech signal processing and filtering '</span>};%%  Show text column by column </code><code>text(<span style="color:#dd1144">'string'</span>,strCell,<span style="color:#dd1144">'FontSize'</span>, 18, <span style="color:#dd1144">'FontWeight'</span>, <span style="color:#dd1144">'bold'</span>);</code><code><span style="color:#ca7d37">set</span>(hb,<span style="color:#dd1144">'handlevisibility'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>​</code><code>hc = axes(<span style="color:#dd1144">'unit'</span>,<span style="color:#dd1144">'normalized'</span>,<span style="color:#dd1144">'position'</span>,[0.01 0.56 0.061 0.03]);</code><code>strCell = {<span style="color:#dd1144">' Sound selection :'</span>};%%  Show text column by column </code><code>text(<span style="color:#dd1144">'string'</span>,strCell,<span style="color:#dd1144">'FontSize'</span>, 14, <span style="color:#dd1144">'FontWeight'</span>, <span style="color:#dd1144">'bold'</span>);</code><code><span style="color:#ca7d37">set</span>(hc,<span style="color:#dd1144">'handlevisibility'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>​</code><code>​</code><code>hd = axes(<span style="color:#dd1144">'unit'</span>,<span style="color:#dd1144">'normalized'</span>,<span style="color:#dd1144">'position'</span>,[0.258 0.822 0.094 0.041]);</code><code>strCell = {<span style="color:#dd1144">' Filter settings :'</span>};%%  Show text column by column </code><code>text(<span style="color:#dd1144">'string'</span>,strCell,<span style="color:#dd1144">'FontSize'</span>, 14, <span style="color:#dd1144">'FontWeight'</span>, <span style="color:#dd1144">'bold'</span>);</code><code><span style="color:#ca7d37">set</span>(hd,<span style="color:#dd1144">'handlevisibility'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>​</code><code>​</code><code>he = axes(<span style="color:#dd1144">'unit'</span>,<span style="color:#dd1144">'normalized'</span>,<span style="color:#dd1144">'position'</span>,[0.258 0.738 0.074 0.037]);</code><code>strCell = {<span style="color:#dd1144">' Design method :'</span>};%%  Show text column by column </code><code>text(<span style="color:#dd1144">'string'</span>,strCell,<span style="color:#dd1144">'FontSize'</span>, 8);</code><code><span style="color:#ca7d37">set</span>(he,<span style="color:#dd1144">'handlevisibility'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>​</code><code>​</code><code>hf = axes(<span style="color:#dd1144">'unit'</span>,<span style="color:#dd1144">'normalized'</span>,<span style="color:#dd1144">'position'</span>,[0.258 0.57 0.105 0.03]);</code><code>strCell = {<span style="color:#dd1144">' Please enter filter parameters :'</span>};%%  Show text column by column </code><code>text(<span style="color:#dd1144">'string'</span>,strCell,<span style="color:#dd1144">'FontSize'</span>, 8);</code><code><span style="color:#ca7d37">set</span>(hf,<span style="color:#dd1144">'handlevisibility'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>                end</code><code>            end</code><code>        end</code><code>        </code><code>    end</code><code>end</code><code><span style="color:#ca7d37">function</span> filter_Callback(hObject, eventdata, handles)</code><code>global var</code><code>var = get(handles.filter,<span style="color:#dd1144">'value'</span>);</code><code>switch var</code><code>    <span style="color:#ca7d37">case</span> 1</code><code>        <span style="color:#ca7d37">set</span>(handles.lowpass,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.lowstop,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.lowpasstarget,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.lowstoptarget,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        </code><code>        <span style="color:#ca7d37">set</span>(handles.highpass,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.highstop,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.highpasstarget,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.highstoptarget,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        </code><code>        <span style="color:#ca7d37">set</span>(handles.bandfilterstop1,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.bandfilterpass1,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.bandfilterpass2,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.bandfilterstop2,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.bandfilterpasstarget,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.bandfilterstoptarget,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>        </code><code>        axes(handles.FPRes1);</code><code>        plot(0,0);</code><code>        axes(handles.FPRes2);</code><code>        plot(0,0);</code><code>    <span style="color:#ca7d37">case</span> 2</code><code>        <span style="color:#ca7d37">set</span>(handles.lowpass,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'on'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.lowstop,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'on'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.lowpasstarget,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'on'</span>);</code><code>        <span style="color:#ca7d37">set</span>(handles.lowstoptarget,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'on'</span>);</code><code>        </code><code>        <span style="color:#ca7d37">set</span>(handles.highpass,<span style="color:#dd1144">'visible'</span>,<span style="color:#dd1144">'off'</span>);</code><code>  Tips <span style="color:#dd1144">');</span></code><code>     l(get(handles.bandfilterstop2,'</code><code>                                bandfilterpasstarget = <span style="color:#ca7d37">eval</span>(get(handles.bandfilterpasstarget,<span style="color:#dd1144">'String'</span>));</code><code>                                bandfilterstoptarget = <span style="color:#ca7d37">eval</span>(get(handles.bandfilterstoptarget,<span style="color:#dd1144">'String'</span>));</code><code>                                wp1 = 2*pi*bandfilterpass1*1000*(1/8000);wp2 = 2*pi*bandfilterpass2*1000*(1/8000);</code><code>                                ws1 = 2*pi*bandfilterstop1*1000*(1/8000);ws2 = 2*pi*bandfilterstop2*1000*(1/8000);</code><code>                                Rp = bandfilterpasstarget;</code><code>                                As = bandfilterstoptarget;</code><code>                                Fs=8000;T=1/Fs;  % Convert to analog filter   Technical specifications of the wave device </code><code>                                Omgp1=(2/T)*tan(wp1/2);Omgp2=(2/T)*tan(wp2/2);</code><code>                                Omgp=[Omgp1,Omgp2]; Omgs1=(2/T)*tan(ws1/2);</code><code>                                Omgs2=(2/T)*tan(ws2/2); Omgs=[Omgs1,Omgs2];</code><code>                                bw=Omgp2-Omgp1;w0=sqrt(Omgp1*Omgp2);% Analog passband bandwidth and center frequency </code><code>                                [n,Omgn]=cheb1ord(Omgp,Omgs,Rp,As,<span style="color:#dd1144">'s'</span>); % Calculation order n And cutoff frequency </code><code>                                [z0,p0,k0]=cheb1ap(n,Rp);  %  Design a normalized analog filter prototype </code><code>                                ba1=k0*real(poly(z0)); % Find the prototype   Filter coefficients b</code><code>                                aa1=real(poly(p0));  % Find the prototype filter   The coefficient of the wave device a</code><code>                                [ba,aa]=lp2bp(ba1,aa1,w0,bw);% Transform to analog bandpass filter </code><code>                                [bd,ad]=bilinear(ba,aa,Fs);</code><code>                                voiceandbackground = wavread(<span style="color:#dd1144">'D:\Learning Practices\software program\Matlab Program\Course Design\voice file\voiceandbanckground.wav'</span>);</code><code>                                voiceandbackgroundfft = fft(voiceandbackgroundfft);</code><code>                                f = filter(bd,ad,voiceandbackground);</code><code>                                f1 = fft(f);</code><code>                                figure(11);</code><code>                                <span style="color:#ca7d37">set</span>(figure(11),<span style="color:#dd1144">'Menu'</span>,<span style="color:#dd1144">'none'</span>);</code><code>                                <span style="color:#ca7d37">set</span>(figure(11),<span style="color:#dd1144">'NumberTitle'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'Name'</span>,<span style="color:#dd1144">' The frequency spectrum of the filtered signal '</span>);</code><code>                                <span style="color:#ca7d37">set</span>(figure(11),<span style="color:#dd1144">'Color'</span>,<span style="color:#dd1144">'w'</span>);</code><code>                                subplot(2,2,1);plot(voiceandbackground);              % Draw the filtered time domain diagram </code><code>                                xlabel(<span style="color:#dd1144">' Time '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);</code><code>                                title(<span style="color:#dd1144">' Waveform before background noise filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,2);plot(20*log10(abs(voiceandbackgroundfft)));</code><code>                                xlabel(<span style="color:#dd1144">' frequency '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);     % Add X Axis description  % Add Y Axis description </code><code>                                title(<span style="color:#dd1144">' Relative amplitude spectrum of background noise before filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,3);plot(f1);              % Draw the filtered time domain diagram </code><code>                                xlabel(<span style="color:#dd1144">' Time '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);</code><code>                                title(<span style="color:#dd1144">' Waveform after background noise filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,4);plot(20*log10(abs(f1)));</code><code>                                xlabel(<span style="color:#dd1144">' frequency '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);     % Add X Axis description  % Add Y Axis description </code><code>                                title(<span style="color:#dd1144">' The relative amplitude spectrum of the filtered background noise '</span>);</code><code>                                grid;</code><code>                            end</code><code>                        end</code><code>                        <span style="color:#ca7d37">if</span>(var == 4)</code><code>                            <span style="color:#ca7d37">if</span>(isempty(str2num(get(handles.highpass,<span style="color:#dd1144">'String'</span>))) || isempty(str2num(get(handles.highstop,<span style="color:#dd1144">'String'</span>))) || ...</code><code>                                    isempty(str2num(get(handles.highpasstarget,<span style="color:#dd1144">'String'</span>))) || isempty(str2num(get(handles.highstoptarget,<span style="color:#dd1144">'String'</span>))))</code><code>                                errordlg(<span style="color:#dd1144">' Please input the parameters correctly '</span>,<span style="color:#dd1144">' Tips '</span>);</code><code>                            <span style="color:#ca7d37">else</span></code><code>                                highpass = <span style="color:#ca7d37">eval</span>(get(handles.highpass,<span style="color:#dd1144">'String'</span>));</code><code>                                highstop = <span style="color:#ca7d37">eval</span>(get(handles.highstop,<span style="color:#dd1144">'String'</span>));</code><code>                                highpasstarget = <span style="color:#ca7d37">eval</span>(get(handles.highpasstarget,<span style="color:#dd1144">'String'</span>));</code><code>                                highstoptarget = <span style="color:#ca7d37">eval</span>(get(handles.highstoptarget,<span style="color:#dd1144">'String'</span>));</code><code>                                wp = 2*pi*highpass*1000*(1/12000);</code><code>                                ws = 2*pi*highstop*1000*(1/12000);</code><code>                                Rp =  highpasstarget;</code><code>                                As =  highstoptarget;</code><code>                                </code><code>                                Fs=12000;T=1/Fs; %fs Is the sampling frequency , fp Is the center frequency </code><code>                                Omgp=(2/T)*tan(wp/2); % Prototype pass   Pre correction with frequency </code><code>                                Omgs=(2/T)*tan(ws/2); % Prototype resistance   Pre correction with frequency </code><code>                                [n,Omgc]=ellipord(Omgp,Omgs,Rp,As,<span style="color:#dd1144">'s'</span>); % Calculation order n And cutoff frequency </code><code>                                [z0,p0,k0]=ellipap(n,Rp,As); % Design a normalized elliptic analog filter prototype </code><code>                                ba=k0*real(poly(z0)); % Find the prototype   Filter coefficients  b</code><code>                                aa=real(poly(p0));  % Find the prototype filter   The coefficient of the wave device  a</code><code>                                [ba1,aa1]=lp2hp(ba,aa,Omgc); % Transform to analog high pass filter </code><code>                                [bd,ad]=bilinear(ba1,aa1,Fs);  % Find the frequency characteristic of digital system % Find the coefficient matrix of the numerator and denominator of the filter </code><code>                                </code><code>                                voiceandbackground = wavread(<span style="color:#dd1144">'D:\Learning Practices\software program\Matlab Program\Course Design\voice file\voiceandbanckground.wav'</span>);</code><code>                                voiceandbackgroundfft = fft(voiceandbackground);</code><code>                                f = filter(bd,ad,voiceandbackground);</code><code>                                f1 = fft(f);</code><code>                                figure(12);</code><code>                                <span style="color:#ca7d37">set</span>(figure(12),<span style="color:#dd1144">'Menu'</span>,<span style="color:#dd1144">'none'</span>);</code><code>                                <span style="color:#ca7d37">set</span>(figure(12),<span style="color:#dd1144">'NumberTitle'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'Name'</span>,<span style="color:#dd1144">' The frequency spectrum of the filtered signal '</span>);</code><code>                                <span style="color:#ca7d37">set</span>(figure(12),<span style="color:#dd1144">'Color'</span>,<span style="color:#dd1144">'w'</span>);</code><code>                                subplot(2,2,1);plot(voiceandbackground);              % Draw the filtered time domain diagram </code><code>                                xlabel(<span style="color:#dd1144">' Time '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);</code><code>                                title(<span style="color:#dd1144">' Waveform before background noise filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,2);plot(20*log10(abs(voiceandbackgroundfft)));</code><code>                                xlabel(<span style="color:#dd1144">' frequency '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);     % Add X Axis description  % Add Y Axis description </code><code>                                title(<span style="color:#dd1144">' Relative amplitude spectrum of background noise before filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,3);plot(f1);              % Draw the filtered time domain diagram </code><code>                                xlabel(<span style="color:#dd1144">' Time '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);</code><code>                                title(<span style="color:#dd1144">' Waveform after background noise filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,4);plot(20*log10(abs(f1)));</code><code>                                xlabel(<span style="color:#dd1144">' frequency '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);     % Add X Axis description  % Add Y Axis description </code><code>                                title(<span style="color:#dd1144">' The relative amplitude spectrum of the filtered background noise '</span>);</code><code>                                grid;</code><code>                            end</code><code>                        end</code><code>                        flagvoice =0;</code><code>                end</code><code>            end</code><code>        end</code><code>        <span style="color:#ca7d37">if</span>(Fvar == 3)</code><code>            <span style="color:#ca7d37">if</span>(var ~= 2 && var ~= 3 && var ~= 4)</code><code>                errordlg(<span style="color:#dd1144">' Please select the filter type '</span>,<span style="color:#dd1144">' Tips '</span>);</code><code>            <span style="color:#ca7d37">else</span></code><code>                switch flagvoice</code><code>                    <span style="color:#ca7d37">case</span> 1</code><code>                        <span style="color:#ca7d37">if</span>(var == 2)</code><code>                            <span style="color:#ca7d37">if</span>(isempty(str2num(get(handles.lowpass,<span style="color:#dd1144">'String'</span>))) || isempty(str2num(get(handles.lowstop,<span style="color:#dd1144">'String'</span>))) || ...</code><code>                                    isempty(str2num(get(handles.lowpasstarget,<span style="color:#dd1144">'String'</span>))) || isempty(str2num(get(handles.lowstoptarget,<span style="color:#dd1144">'String'</span>))))</code><code>                                errordlg(<span style="color:#dd1144">' Please input the parameters correctly '</span>,<span style="color:#dd1144">' Tips '</span>);</code><code>                            <span style="color:#ca7d37">else</span></code><code>                                lowpass = <span style="color:#ca7d37">eval</span>(get(handles.lowpass,<span style="color:#dd1144">'String'</span>));</code><code>                                lowstop = <span style="color:#ca7d37">eval</span>(get(handles.lowstop,<span style="color:#dd1144">'String'</span>));</code><code>                                lowpasstarget = <span style="color:#ca7d37">eval</span>(get(handles.lowpasstarget,<span style="color:#dd1144">'String'</span>));</code><code>                                lowstoptarget = <span style="color:#ca7d37">eval</span>(get(handles.lowstoptarget,<span style="color:#dd1144">'String'</span>));</code><code>                                wp = 2*pi*lowpass*1000*(1/3000);</code><code>                                ws = 2*pi*lowstop*1000*(1/3000);</code><code>                                Rp = lowpasstarget;</code><code>                                As = lowstoptarget;</code><code>                                deltaw=ws-wp;          % Calculate the width of transition zone </code><code>                                N0=ceil(6.6*pi/deltaw); % Calculate the filter length according to Hanning window N0</code><code>                                N=N0+mod(N0+1,2) ;       % In order to achieve FIR type I Even symmetric filters , Ensure that N It's odd </code><code>                                wc=(ws+wp)/2;           % Cut off frequency is the average of stopband frequency </code><code>                                [bd,ad]=fir1(N,wc/pi,hanning(N+1)); </code><code>                                boyvoice = wavread(<span style="color:#dd1144">'D:\Learning Practices\software program\Matlab Program\Course Design\voice file\voice source\czy_boy'</span>,[3000,18000]);</code><code>                                boyvoicefft = fft(boyvoice);</code><code>                                f = filter(bd,ad,boyvoice);</code><code>                                f1 = fft(f);</code><code>                                figure(1);</code><code>                                <span style="color:#ca7d37">set</span>(figure(1),<span style="color:#dd1144">'Menu'</span>,<span style="color:#dd1144">'none'</span>);</code><code>                                <span style="color:#ca7d37">set</span>(figure(1),<span style="color:#dd1144">'NumberTitle'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'Name'</span>,<span style="color:#dd1144">' The frequency spectrum of the filtered signal '</span>);</code><code>                                <span style="color:#ca7d37">set</span>(figure(1),<span style="color:#dd1144">'Color'</span>,<span style="color:#dd1144">'w'</span>);</code><code>                                subplot(2,2,1);plot(boyvoice);              % Draw the filtered time domain diagram </code><code>                                xlabel(<span style="color:#dd1144">' Time '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);</code><code>                                title(<span style="color:#dd1144">' The waveform before filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,2);plot(20*log10(abs(boyvoicefft)));</code><code>                                xlabel(<span style="color:#dd1144">' frequency '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);     % Add X Axis description  % Add Y Axis description </code><code>                                title(<span style="color:#dd1144">' Relative amplitude spectrum before filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,3);plot(f1);              % Draw the filtered time domain diagram </code><code>                                xlabel(<span style="color:#dd1144">' Time '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);</code><code>                                title(<span style="color:#dd1144">' The filtered waveform of boys '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,4);plot(20*log10(abs(f1)));</code><code>                                xlabel(<span style="color:#dd1144">' frequency '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);     % Add X Axis description  % Add Y Axis description </code><code>                                title(<span style="color:#dd1144">' The filtered relative amplitude spectrum of boys '</span>);</code><code>                                grid;</code><code>                            end</code><code>                        end</code><code>                        <span style="color:#ca7d37">if</span>(var == 3)</code><code>                            </code><code>                            <span style="color:#ca7d37">if</span>(isempty(str2num(get(handles.bandfilterstop1,<span style="color:#dd1144">'String'</span>))) || isempty(str2num(get(handles.bandfilterpass1,<span style="color:#dd1144">'String'</span>))) || ...</code><code>                                    isempty(str2num(get(handles.bandfilterpass2,<span style="color:#dd1144">'String'</span>))) || isempty(str2num(get(handles.bandfilterstop2,<span style="color:#dd1144">'String'</span>))) || ...</code><code>                                    isempty(str2num(get(handles.bandfilterpasstarget,<span style="color:#dd1144">'String'</span>))) || isempty(str2num(get(handles.bandfilterstoptarget,<span style="color:#dd1144">'String'</span>))))</code><code>                                errordlg(<span style="color:#dd1144">' Please input the parameters correctly '</span>,<span style="color:#dd1144">' Tips '</span>);</code><code>                            <span style="color:#ca7d37">else</span></code><code>                                bandfilterstop1 = <span style="color:#ca7d37">eval</span>(get(handles.bandfilterstop1,<span style="color:#dd1144">'String'</span>));</code><code>                                bandfilterpass1 = <span style="color:#ca7d37">eval</span>(get(handles.bandfilterpass1,<span style="color:#dd1144">'String'</span>));</code><code>                                bandfilterpass2 = <span style="color:#ca7d37">eval</span>(get(handles.bandfilterpass2,<span style="color:#dd1144">'String'</span>));</code><code>                                bandfilterstop2 = <span style="color:#ca7d37">eval</span>(get(handles.bandfilterstop2,<span style="color:#dd1144">'String'</span>));</code><code>                                bandfilterpasstarget = <span style="color:#ca7d37">eval</span>(get(handles.bandfilterpasstarget,<span style="color:#dd1144">'String'</span>));</code><code>                                bandfilterstoptarget = <span style="color:#ca7d37">eval</span>(get(handles.bandfilterstoptarget,<span style="color:#dd1144">'String'</span>));</code><code>                                wp1 = 2*pi*bandfilterpass1*1000*(1/8000);wp2 = 2*pi*bandfilterpass2*1000*(1/8000);</code><code>                                ws1 = 2*pi*bandfilterstop1*1000*(1/8000);ws2 = 2*pi*bandfilterstop2*1000*(1/8000); </code><code>                                Rp = bandfilterpasstarget;</code><code>                                As = bandfilterstoptarget;</code><code>                                deltaw = wp1-ws1;</code><code>                                N0 = ceil(11*pi/deltaw);</code><code>                                N = N0+mod(N0+1,2);</code><code>                                wc1 = (ws1+wp1)/2;wc2 = (ws2+wp2)/2;</code><code>                                wc = [wc1 wc2];</code><code>                                [bd,ad]=fir1(N,wc/pi,hanning(N+1));</code><code>                                boyvoice = wavread(<span style="color:#dd1144">'D:\Learning Practices\software program\Matlab Program\Course Design\voice file\voice source\czy_boy'</span>,[3000,18000]);</code><code>                                boyvoicefft = fft(boyvoice);</code><code>                                f = filter(bd,ad,boyvoice);</code><code>                                f1 = fft(f);</code><code>                                figure(2);</code><code>                                <span style="color:#ca7d37">set</span>(figure(2),<span style="color:#dd1144">'Menu'</span>,<span style="color:#dd1144">'none'</span>);</code><code>                                <span style="color:#ca7d37">set</span>(figure(2),<span style="color:#dd1144">'NumberTitle'</span>,<span style="color:#dd1144">'off'</span>,<span style="color:#dd1144">'Name'</span>,<span style="color:#dd1144">' The frequency spectrum of the filtered signal '</span>);</code><code>                                <span style="color:#ca7d37">set</span>(figure(2),<span style="color:#dd1144">'Color'</span>,<span style="color:#dd1144">'w'</span>);</code><code>                                subplot(2,2,1);plot(boyvoice);              % Draw the filtered time domain diagram </code><code>                                xlabel(<span style="color:#dd1144">' Time '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);</code><code>                                title(<span style="color:#dd1144">' The waveform before filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,2);plot(20*log10(abs(boyvoicefft)));</code><code>                                xlabel(<span style="color:#dd1144">' frequency '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);     % Add X Axis description  % Add Y Axis description </code><code>                                title(<span style="color:#dd1144">' Relative amplitude spectrum before filtering '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,3);plot(f1);              % Draw the filtered time domain diagram </code><code>                                xlabel(<span style="color:#dd1144">' Time '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);</code><code>                                title(<span style="color:#dd1144">' The filtered waveform of boys '</span>);</code><code>                                grid;</code><code>                                subplot(2,2,4);plot(20*log10(abs(f1)));</code><code>                                xlabel(<span style="color:#dd1144">' frequency '</span>); ylabel(<span style="color:#dd1144">' amplitude '</span>);     % Add X Axis description  % Add Y Axis description </code><code>                                title(<span style="color:#dd1144">' The filtered relative amplitude spectrum of boys '</span>);</code><code>                                grid;</code><code>                            end</code><code>                        end</code><code>                        <span style="color:#ca7d37">if</span>(var == 4)</code><code>                            <span style="color:#ca7d37">if</span>(isempty(str2num(get(handles.highpass,<span style="color:#dd1144">'String'</span>))) || isempty(str2num(get(handles.highstop,<span style="color:#dd1144">'String'</span>))) || ...</code><code>                                    isempty(str2num(get(handles.highpasstarget,<span style="color:#dd1144">'String'</span>))) || isempty(str2num(get(handles.hi</code></span></span>

3 Simulation results

4 reference ​

[1]  Wang Yishi , Digital signal processing , Beijing University of Technology Press .

[2]  Yujunfeng , Research on speech signal recognition and conversion , Dissertation , Chengdu University of technology .

[3]  Wang Zhenglin , Liu Ming . Master MATLAB 7[M]. Beijing : Electronic industry press ,2006.7

[4]  Liguoyong . Computer simulation technology and CAD— be based on MATLAB The control system of Electronic industry press

About bloggers : Good at intelligent optimization algorithms 、 Neural networks predict 、 signal processing 、 Cellular automata 、 The image processing 、 Path planning 、 UAV and other fields Matlab Simulation , relevant matlab Code problems can be exchanged by private letter .

Some theories cite network literature , If there is infringement, contact the blogger to delete .

原网站

版权声明
本文为[Matlab scientific research studio]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111253024028.html