






Estude fácil! Tem muito documento disponível na Docsity
Ganhe pontos ajudando outros esrudantes ou compre um plano Premium
Esta página não é visível na pré-visualização
Não perca as partes importantes!







INTRODUÇÃO Neste trabalho, foi implementado dois sistemas de filtragem. Sendo um para detecção de sinais DTMF e o outro a filtragem de áudios. Para o primeiro caso, foi utilizado o algoritmo de Goertzel para realização da FFT (Fast Fourier Transform) e também um conjunto de filtros do tipo FIR (Finite Impulse Response). No segundo sistema foi implementado para filtragem dos áudios filtros FIR e também filtros IIR (Infinite Impulse Response). Os detalhes de implementação serão apresentados a seguir. TAREFA 1: Detecção de tons DTMF a) Utilizando-se do algoritmo Goertzel, foi implementado uma lógica para detectar os tons DTMF através da análise das componentes de frequência. Uma vez que através do algoritmo de Goertzel é possível obter cada componente de frequência, bastou programar uma lógica para dado as componentes de frequência presente no sinal identificar qual é a tecla correspondente. Segue código-fonte MATLAB: clear all; clc; close all; %% DUAL-TONE MULTIFREQUENCY TONE DETECTION fs=8000; n=1:2048; % gera sequencia aleatoria seq = randi(10,1,8)-1; output = []; for i=1:length(seq) symbol=seq(i); if symbol== f1=697; f2=1209; tecla(697,1209)=1; end if symbol== f1=697; f2=1336; tecla(697,1336)=2; end if symbol== f1=697; f2=1477; tecla(697,1477)=3; end if symbol== f1=770; f2=1209; tecla(770,1209)=4; end if symbol== f1=770; f2=1336; tecla(770,1336)=5; end if symbol== f1=770; f2=1477; tecla(770,1477)=6; end if symbol== f1=852; f2=1209; tecla(852,1209)=7; end if symbol== f1=852; f2=1336; tecla(852,1336)=8; end
clear all; clc; close all; %% DUAL-TONE MULTIFREQUENCY TONE DETECTION fs=8000; Ts = 1/fs; ws = 2pifs; n=1:2048; % gera sequencia aleatoria seq = randi(10,1,8)- output = []; for i=1:length(seq) symbol=seq(i); if symbol== f1=697; f2=1209; tecla(697,1209)=1; end if symbol== f1=697; f2=1336; tecla(697,1336)=2; end if symbol== f1=697; f2=1477; tecla(697,1477)=3; end if symbol==
f1=770; f2=1209; tecla(770,1209)=4; end if symbol== f1=770; f2=1336; tecla(770,1336)=5; end if symbol== f1=770; f2=1477; tecla(770,1477)=6; end if symbol== f1=852; f2=1209; tecla(852,1209)=7; end if symbol== f1=852; f2=1336; tecla(852,1336)=8; end if symbol== f1=852; f2=1477; tecla(852,1477)=9; end if symbol== f1=941; f2=1336; tecla(941,1336)=0; end y=sin(2pif1n(1/fs))+sin(2pif2n(1/fs)); pause = zeros(1,length(n)); output = [output y pause]; end output = output + randn(1,length(output)); %% algoritmo N = 2048; %tamanho do sinal M = 51; %tamanho do filtro f = [697 770 852 941 1209 1336 1477]; %frequencias DTMF f_low = [697 770 852 941]; %frequencias baixas f_high = [1209 1336 1477]; %frequencias altas %define filtro FIR FPB e FPA corte = 1khz fc1 = 1e3; Wn1 = fc1/(fs/2); b_low = fir1((M-1),Wn1,'low'); b_high = fir1((M-1),Wn1,'high'); %% define filtros de saida %filtro 1 Wn = [0.97f(1)/(fs/2) 1.03f(1)/(fs/2)]; b1 = fir1((M-1),Wn,'stop'); %filtro 2 Wn = [0.97f(2)/(fs/2) 1.03f(2)/(fs/2)]; b2 = fir1((M-1),Wn,'stop'); %filtro 3 Wn = [0.97f(3)/(fs/2) 1.03f(3)/(fs/2)]; b3 = fir1((M-1),Wn,'stop'); %filtro 4 Wn = [0.97f(4)/(fs/2) 1.03f(4)/(fs/2)]; b4 = fir1((M-1),Wn,'stop'); %filtro 5 Wn = [0.97f(5)/(fs/2) 1.03f(5)/(fs/2)]; b5 = fir1((M-1),Wn,'stop'); %filtro 6 Wn = [0.97f(6)/(fs/2) 1.03f(6)/(fs/2)]; b6 = fir1((M-1),Wn,'stop'); %filtro 7 Wn = [0.97f(7)/(fs/2) 1.03f(7)/(fs/2)]; b7 = fir1((M-1),Wn,'stop');
close all; clear; clc; warning off init = 160000; % Inicio da musica size = 480000; k=1:size; M = 101; WN = [0.15 0.28]; %%%%%%%%%% % Musica % %%%%%%%%%% [x1,fs1,bits]=wavread('musica'); x1 = x1(:,1); %tira valor medio x1=x1-mean(x1); %amplifica x1=2*x1(init:init+size-1);
close all; clear; clc; warning off init = 160000; % Inicio da musica size = 480000; k=1:size; WN = [0.15 0.28]; %%%%%%%%%% % Musica % %%%%%%%%%% [x1,fs1,bits]=wavread('musica'); ws = 2pifs1; x1 = x1(:,1); %tira valor medio x1=x1-mean(x1); %amplifica x1=2*x1(init:init+size-1); spectrogram(x1)
figure wp = 0.1; wr = 0.15; Ap = 0.5; Ar = 20; [M wc]=cheb1ord(wp,wr,Ap,Ar,'s') [b1 a1]=cheby1(M,Ap,wc,'low'); freqz(b1,a1) figure %% %%%%%%%%%%% % Canário % %%%%%%%%%%% [x2,fs2,bits]=wavread('canary.wav'); while (length(x2) < size) x2 = [x2; x2]; end x2 = x2(1:length(k)); %tira valor medio x2=x2-mean(x2); %amplifica x2 = 2x2; wr1 = 0.14; wp1 = 0.16; wp2 = 0.27; wr2 = 0.29; Ap = 0.5; Ar = 20; [M wc]=cheb1ord([wp1 wp2],[wr1 wr2],Ap,Ar,'s') [b2 a2]=cheby1(M,Ap,[0.15 0.28],'bandpass'); spectrogram(x2) figure %% % Adicionando os sinais N=length(k); n=0:N-1; Ts=1/fs1; t=nTs; f=n/N*fs1; x=x1+x2; spectrogram(x) figure y1 = filter(b1,a1,x); y2 = filter(b2,a2,x); subplot(2,1,1) plot(t,x1,t,y1) title('Filtragem do audio 1 (musica)') legend('original','filtrado') xlabel('Tempo') ylabel('Amplitude') subplot(2,1,2) plot(t,x2,t,y2) title('Filtragem do audio 2 (canário)') legend('original','filtrado') xlabel('Tempo') ylabel('Amplitude') sound(x,fs1) pause(13) sound(y1,fs1) pause(13) sound(y2,fs1)