hilbert

Capsim Block Documentation

Short Description

Discrete Hilbert Transform

Top
Input Connections
Port Type Name
0 float x
Top
Output Connections
Port Type Name
0 float y
Top
Parameters
Num Description Type Name Default Value
0 length of Hilbert transform impulse response int impl 17
1 bandwidth (0 < BW <= 0.5) float fbw 0.5
2 log2(fft length) int fftexp 8
Top
States
Num Type Name Initial Value Description
0 cap_fft_scalar* temp
1 cap_fft_scalar* temp2
2 cap_fft_cpx* iresp
3 cap_fft_cpx* freqBuffCx
4 cap_fft_scalar* save
5 int pcount
6 int fftl 1 << fftexp
7 cap_fftr_cfg preverse
8 cap_fftr_cfg pforward
9 double norm
Top

Declarations


 

	int i,k;
	float	anarg,imp_del,tmp,argval,window;
	int no_samples;
	char impResponseFile[200];
	int	impFlag;
	FILE* fp;



Top

Initialization Code



 

pcount = impl;
/*
 * allocate necessary storage
 */
if( (temp = (cap_fft_scalar*)calloc(fftl,sizeof(cap_fft_scalar))) == NULL
	 || (temp2 = (cap_fft_scalar*)calloc(fftl,sizeof(cap_fft_scalar))) == NULL
	 || (iresp = (cap_fft_cpx*)calloc(fftl,sizeof(cap_fft_cpx))) == NULL
	 || (freqBuffCx = (cap_fft_cpx*)calloc(fftl,sizeof(cap_fft_cpx))) == NULL
	 || (save = (cap_fft_scalar*)calloc(impl,sizeof(cap_fft_scalar))) == NULL  ) {
	fprintf(stderr,"hilbert: can't allocate work space\n"); 
	return(2);
}
imp_del=(float)impl/2.0-0.5;
for( i=0; i< impl; i++) {
	anarg=(float)i-imp_del;
	if(anarg != 0.0)
	{
		tmp = sin( fbw * PI * anarg);
		argval = 2*PI*(float)i/(float)(impl-1);
		/*
		 * Blackman window
		 */
		window= 0.42 -0.5*cos(argval) + 0.08*cos(2*argval);
		temp[i] = TWO_OVER_PI*tmp*tmp/anarg*window; 
	}
	else
		temp[i] = 0.0;
}

	preverse = cap_fftr_alloc(fftl, INVERSE_FFT, NULL,NULL);
	pforward = cap_fftr_alloc(fftl, FORWARD_FFT, NULL,NULL);
	
	
	
	cap_fftr(pforward, temp,iresp);
        norm=1.0/(float)fftl;
	
	
	
	

    // rfft(iresp, fftl);




Top

Main Code



 

	for(no_samples=MIN_AVAIL();no_samples >0; --no_samples) {
		IT_IN(0);
		temp[pcount++] = x(0);
		if(pcount == fftl) {
			for(i=0; i
    
Top

Wrapup Code



 

	free(temp); free(iresp); free(save); free(temp2); free(freqBuffCx);
	free(preverse);
        free(pforward);





Top

License



/*  Capsim (r) Text Mode Kernel (TMK) Star Library (Blocks)
    Copyright (C) 1989-2017  Silicon DSP Corporation

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Lesser General Public
    License as published by the Free Software Foundation; either
    version 2.1 of the License, or (at your option) any later version.

    This library is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with this library; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

    http://www.silicondsp.com
    Silicon DSP  Corporation
    Las Vegas, Nevada
*/


Top

Description



 

/* hilbert.s */
/***********************************************************************
                             hilbert()
************************************************************************
"Discrete Hilbert Transform":
Reference:
A.V. Oppenheim amd R. W. Schafer,"Digital Signal
Processing",pp 360-363,Prentice-Hall,1974 
A Blackman window is used in the design.
It then uses the overlap save method for fast convolution to model the
hilbert transform impulse response.
The parameters are as follows:
Param.	1 - (int) implexp: log2 [ length of impulse response in samples].
Note: The larger the length, the better the approximation. However, the
simulation efficiency suffers considerably.
Convolution is performed by the fft overlap-save method (described in
Oppenheim & Schafer, Digital Signal Processing, pp. 113).
The FFT length must be greater than the impulse response length.
For efficiency, it should probably be more than twice as long.

hilbert


"Discrete Hilbert Transform":
Reference:
A.V. Oppenheim amd R. W. Schafer,"Digital Signal
Processing",pp 360-363,Prentice-Hall,1974 
A Blackman window is used in the design.
It then uses the overlap save method for fast convolution to model the
hilbert transform impulse response.
The parameters are as follows:
Param.	1 - (int) implexp: log2 [ length of impulse response in samples].
Note: The larger the length, the better the approximation. However, the
simulation efficiency suffers considerably.
Convolution is performed by the fft overlap-save method (described in
Oppenheim & Schafer, Digital Signal Processing, pp. 113).
The FFT length must be greater than the impulse response length.
For efficiency, it should probably be more than twice as long.


Programmer: Sasan H. Ardalan, Overlap-save method by M. R. Civanlar
Date: July 26, 1990

*/