ocmsp_freqz

 

Description

Frequency and phases response of filter:

 H(e^{j \omega}) = \frac{B(e^{j \omega})}{A(e^{j \omega})} = \frac{b(0)+b(1)e^{-j \omega}+...+b(m)e^{-j \omega}}{a(0)+a(1)e^{-j \omega}+...+a(n)e^{-j \omega}}

Syntax

int ocmsp_freqz( double * mag, double * pha, double * w, UINT n, const double * pb, UINT nb, const double * pa, UINT na, int flag = OMSP_MAG_DECIBEL|OMSP_PHA_UNWRAP )

Parameters

mag
[output] magnitude response, with size n
pha
[output] phase response, with size n
w
[output] frequencies(in radians/sample) on which the response values are calculated. size n
n
[input] points number, e.g. 512
pb
[input] filter numerator coefficients
nb
[input] size of numerator coefficients
pa
[input] filter denominator coefficients
na
[input] size of denominator coefficients
flag
[input] indicates the unit of returned magnitude and phase values, the range of frequency (0~pi or 0~2*pi), and if the phases are unwrapped. Can be one or more of OMSP_TWO_SIDE, OMSP_MAG_DECIBEL, OMSP_PHA_DEGREE, OMSP_PHA_UNWRAP.

Return

Return OE_NOERROR if succeed, otherwise, non-zero error code is returned (OE_NULL_POINTER, OE_INVALID_SIZE or OE_BAD_PARAM)

Examples

EX1

#include <ocmsp.h>
void ocmsp_freqz_ex1()
{
    vector b = {0.018886917952608, 0.169982261573470, 0.679929046293879,
                1.586501108019050, 2.379751662028575, 2.379751662028575,
                1.586501108019050, 0.679929046293879, 0.169982261573470,
                0.018886917952608};
    vector a = {1.000000000000000, 1.791581352788596, 2.531899880898121,
                2.118229420341933, 1.370756294393234, 0.609038913076474,
                0.199331556962956, 0.043104731015281, 0.005804261654309,
                0.000355580604258};

    Worksheet wks = Project.ActiveLayer();
    if(!wks)
        return;            
        
    int nRet = 0, n = 512, na = a.GetSize(), nb = b.GetSize();    
    vector& vw     = wks.Columns(0).GetDataObject();
    vector& vmag = wks.Columns(1).GetDataObject();
    vector& vpha = wks.Columns(2).GetDataObject();
    vw.SetSize(n);
    vmag.SetSize(n);
    vpha.SetSize(n);

    int type = OMSP_MAG_DECIBEL|OMSP_PHA_UNWRAP;
    if (0 != (nRet = ocmsp_freqz(vmag, vpha, vw, n, b, nb, a, na, type)))
    {
        printf("ocmsp_freqz failed, error code=%d\n", nRet);
        return;
    }
}

Remark

See Also

ocmsp_freqz_sos

header to Included

ocmsp.h

Reference