⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 drum.m

📁 This is a program to extract the drum sounds (bass) from a music file. You can replace the "windycit
💻 M
字号:
clc;
clear all;

[y, fs, nbits]=wavread('windycity.wav');
figure(1)
plot(y);
title('Music Waveform');
%soundsc(y,fs);


% %-----------------------------------------------------------------------
% % Power Spectral Density of the signal
% h = spectrum.periodogram;
% hopts = psdopts(h); hopts.CenterDc=true; hopts.NormalizedFrequency=false;
% hpsdx = psd(h,y,hopts);
% plot(hpsdx);
% set(gcf, 'Color', [1 1 1])
% %-----------------------------------------------------------------------


% Designing a filter bank

TW = 0.02;                          % Transition width
Ast = 40;                           % 40 dB of attenuation in the stopband
d  = fdesign.halfband('Type','Lowpass','TW,Ast',TW,Ast);
f = design(d,'kaiserwin');       % Kaiser-window design


n = 99;
[h0,h1,g0,g1] = firpr2chfb(n,.45);
% fvtool(h0,1,h1,1,g0,1,g1,1);

% Analysis filters (decimators).
Hlp = mfilt.firdecim(2,h0);
Hhp = mfilt.firdecim(2,h1);

% Synthesis filters (interpolators).
Glp = mfilt.firinterp(2,g0);
Ghp = mfilt.firinterp(2,g1);

% Lowpass frequency band.
y0 = filter(Hlp,y);       % Analysis filter bank output
y0 = filter(Glp,y0);      % Synthesis filter bank output

% High frequency band.
y1 = filter(Hhp,y);       % Analysis filter bank output
y1 = filter(Ghp,y1);      % Synthesis filter bank output

% Lowpass frequency band.
y00 = filter(Hlp,y0);       % Analysis filter bank output
y00 = filter(Glp,y00);      % Synthesis filter bank output

% High frequency band.
y01 = filter(Hhp,y0);       % Analysis filter bank output
y01 = filter(Ghp,y01);      % Synthesis filter bank output

% Lowpass frequency band.
y000 = filter(Hlp,y00);       % Analysis filter bank output
y000 = filter(Glp,y000);      % Synthesis filter bank output

% High frequency band.
y001 = filter(Hhp,y00);       % Analysis filter bank output
y001 = filter(Ghp,y001);      % Synthesis filter bank output

% Lowpass frequency band.
y0000 = filter(Hlp,y000);       % Analysis filter bank output
y0000 = filter(Glp,y0000);      % Synthesis filter bank output

% High frequency band.
y0001 = filter(Hhp,y000);       % Analysis filter bank output
y0001 = filter(Ghp,y0001);      % Synthesis filter bank output

% Lowpass frequency band.
y00000 = filter(Hlp,y0000);       % Analysis filter bank output
y00000 = filter(Glp,y00000);      % Synthesis filter bank output

% High frequency band.
y00001 = filter(Hhp,y0000);       % Analysis filter bank output
y00001 = filter(Ghp,y00001);      % Synthesis filter bank output

% Lowpass frequency band.
y000000 = filter(Hlp,y00000);       % Analysis filter bank output
y000000 = filter(Glp,y000000);      % Synthesis filter bank output

% High frequency band.
y000001 = filter(Hhp,y00000);       % Analysis filter bank output
y000001 = filter(Ghp,y000001);      % Synthesis filter bank output

% Lowpass frequency band.
y0000000 = filter(Hlp,y000000);       % Analysis filter bank output
y0000000 = filter(Glp,y0000000);      % Synthesis filter bank output

% High frequency band.
y0000001 = filter(Hhp,y000000);       % Analysis filter bank output
y0000001 = filter(Ghp,y0000001);      % Synthesis filter bank output

% Lowpass frequency band.
y00000000 = filter(Hlp,y0000000);       % Analysis filter bank output
y00000000 = filter(Glp,y00000000);      % Synthesis filter bank output

% High frequency band.
y00000001 = filter(Hhp,y0000000);       % Analysis filter bank output
y00000001 = filter(Ghp,y00000001);      % Synthesis filter bank output

figure(2);
plot(y0000);

z0 = filter(f,y);

% % Power Spectral Density of the signal
% h = spectrum.periodogram;
% hopts = psdopts(h); hopts.CenterDc=true; hopts.NormalizedFrequency=false;
% hpsdx = psd(h,y0,hopts);
% plot(hpsdx);
% set(gcf, 'Color', [1 1 1])








% A = 10; % peak ripple in dB
% dev = 10^(-A./20);
% 
% r = 0.2; % roll-off factor
% l = 2;
% 
% b = firnyquist('minorder',l,r,dev);
% hfvt = fvtool(b,1);
% set(hfvt, 'Filters', dfilt.dffir(b));
% legend(hfvt,'FIRNYQUIST equiripple design');

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -