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

📄 analytic_impulse.m

📁 我认为很不错的语音处理的matlab源代码
💻 M
字号:
function [y, t, n]=analytic_impulse(Fs, fc, td, tau, delay, A1, A2, rise_time)
% % analytic_impulse: Impulsive noise with known peak level, frequency, duration
% % 
% % Syntax:
% %
% % [y, t, n]=analytic_impulse(Fs, fc, td, tau, delay, A1, A2, rise_time);
% %
% % *********************************************************************
% % 
% % Description
% % 
% % This program produces an impulsive test signal 
% % 
% % The signal is an exponentially decaying sin wave with background 
% % gaussian noise.  
% % 
% % *********************************************************************
% % 
% % Input Variables
% % 
% % Fs=50000;           % Hz sampling rate of the impulsive noise
% %                     % default is Fs=50000;
% % 
% % fc=1000;            % Hz ringing frequency of sin wave
% %                     % default is fc=1000; 
% % 
% % td=1;               % seconds time duration of the test signal
% %                     % default is td=5; 
% % 
% % tau=0.1;            % seconds decay constant for modelling the 
% %                     % decay of the ringing noise.  
% %                     % default is tau=2;
% % 
% % delay=1;            % seconds time delay between impulsive noise 
% %                     % and test signal recording.
% %                     % default is delay=1; 
% % 
% % A1=1;               % Pa amplitude of the background gaussian noise
% %                     % default is A1=1;
% % 
% % A2=100;             % Pa initial ampitude of the of the sin wave
% %                     % default is A2=100;
% %   
% % rise_time=0.0005;   % seconds time to reach peak value from back ground
% %                     % noise level.
% %                     % default is rise_time=0.0005;  
% %   
% % *********************************************************************
%
%
% Example='';
%
%
% % Each of the inputs can be a constant or a one-dimensional array.
% 
% tau=0.01;         % seconds decay constant for modelling the ringing
% td=1;             % seconds time duration of the test signal
% A2=20;            % Pa initial ampitude of the of the sin wave
% A1=1;             % Pa amplitude of the background gaussian noise
% Fs=100000;        % Hz sampling rate of the impulsive noise
% fc=1000;          % Hz ringing frequency of sin wave
% delay=0.1;        % seconds time delay between impulsive noise 
%                   % and test signal recording
% rise_time=0.0005; % seconds time to reach peak value from back ground
%                   % noise level
% 
% [y, t]=analytic_impulse(Fs, fc, td, tau, delay, A1, A2, rise_time);
% 
% 
% % *********************************************************************
% % 
% % Output variables
% % 
% % y the time record in Pa
% % 
% % t the time array in seconds
% % 
% % n is the number of data points in the rise time.  
% % 
% % *********************************************************************
% % 
% % Program Written by Edward L. Zechmann
% %    
% %     Date  17 December  2007
% % 
% % modified  18 December   2007    Added Comments
% % 
% % modified  21 August     2008    Updated Comments
% % 
% % modified  15 September	2008    Updated Comments
% % 
% % modified   3 December   2008    Updated Comments
% % 
% % *********************************************************************
% % 
% % Please Feel Free to Modify This Program
% %    
% % See Also: freidlander, Impulsive_Noise_Meter   
% %    

if nargin < 1
    Fs=50000;
end

if nargin < 2
    fc=1000;
end

if nargin < 3
    td=5; 
end

if nargin < 4
    tau=2;
end

if nargin < 5
    delay=1;
end

if nargin < 6
    A1=1;
end

if nargin < 7
    A2=100;
end

if nargin < 8
    rise_time=0.0005;
end



Fs=Fs(1);
fc=fc(1);
td=td(1);
tau=tau(1);
delay=delay(1);
A1=A1(1);
A2=A2(1);

N0=ceil(Fs*delay);

t0=1./Fs.*(-(N0-1):0);

y0=A1.*randn(1, N0);

n=ceil(Fs*rise_time);
if n >  N0   
    n=1;
end

bb=hann(2*n)';
rise=bb(1:n);

N=ceil(td*Fs);
t=1./Fs.*(1:(N));

bbb=A1.*randn(1, N)+A2.*exp(-1./(tau).*t).*sin(2*pi*fc.*t);

rise=rise.*bbb(1:n);
after_rise=bbb((n+1):end);

y=[y0 rise after_rise ];

t=[t0 t];

⌨️ 快捷键说明

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