Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- samplingRate = 48000;
- width = 550;
- cutoff = 1500;
- ripple = -80;
- A = -ripple;
- transitionWidthNorm = 2 * pi * width / samplingRate;
- cutoffNorm = cutoff / samplingRate;
- nTemp = (A - 7.95) / (2.285 * transitionWidthNorm);
- N = ceil(nTemp);
- if(mod(N, 2) == 0)
- N = N + 1;
- end
- beta = 0.1102 * (A - 8.7);
- %Working out window starts here.
- hN = (N - 1) / 2;
- n= -hN : hN;
- window = kaiser(N, beta)';
- response = 2 * cutoffNorm * sin(2 * pi * cutoffNorm * n)./(n * 2 * pi * cutoffNorm);
- response(hN+1) = 2 * cutoffNorm;
- windowedResponse = response.*window;
- %Working out window ends here.
- lpAddress = (2^ceil(log2(N)));
- lowpassFile = fopen('D:\Windows Folders\Desktop\LowPassCoef.asm', 'w');
- fprintf(lowpassFile, '\torg\tx:%d\n\n', lpAddress);
- fprintf(lowpassFile, 'NTAPS\tEQU\t%d\n\n', N);
- for c = 1 : N
- fprintf(lowpassFile, 'lpcoef_%d\tdc\t%1.12f\n', c, windowedResponse(c));
- end
- fclose(lowpassFile);
- %Start working out high pass filter here.
- transitionWidthNorm = 2 * pi * width / samplingRate;
- cutoffNorm = cutoff / samplingRate;
- nTemp = (A - 7.95) / (2.285 * transitionWidthNorm);
- N = ceil(nTemp);
- if(mod(N, 2) == 0)
- N = N + 1;
- end
- beta = 0.1102 * (A - 8.7);
- %Working out window starts here.
- hN = (N - 1) / 2;
- n= -hN : hN;
- window = kaiser(N, beta)';
- response = -2 * cutoffNorm * sin(2 * pi * cutoffNorm * n)./(n * 2 * pi * cutoffNorm);
- response(hN+1) = 1 - (2 * cutoffNorm);
- windowedResponse = response.*window;
- %Working out window ends here.
- %Plot graphs of high pass filter.
- figure(1)
- subplot(3, 1, 1), plot(n, response);
- subplot(3, 1, 2), plot(n, window);
- subplot(3, 1, 3), plot(n, windowedResponse);
- [h1,w] = freqz(response,1,4096,samplingRate);
- [h2,w] = freqz(windowedResponse,1,4096,samplingRate);
- figure(2)
- subplot(2,1,1)
- plot(w,20*log10(abs(h1)),w,20*log10(abs(h2)))
- subplot(2,1,2)
- plot(w,unwrap(angle(h1)),w,unwrap(angle(h2)))
- hpAddress = (2^ceil(log2(N))) * 2;
- highpassFile = fopen('D:\Windows Folders\Desktop\HighPassCoef.asm', 'w');
- fprintf(highpassFile, '\torg\tx:%d\n\n', hpAddress);
- for c = 1 : N
- fprintf(highpassFile, 'hpcoef_%d\tdc\t%1.12f\n', c, windowedResponse(c));
- end
- fclose(highpassFile);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement