Example #1
0
static void
hybwin(int lpsize, int framesize, int nrsize, real old_input[], 
       real new_input[], real output[],real WIN_MEM window[],
		    real rec[],		/* Recursive Part */
		    real decay)
{
    int N1 = lpsize + framesize; /* M+L */
    int N2 = lpsize + nrsize;	/* M+N */
    int N3 = lpsize + framesize + nrsize;
    int i;
    real ws[N3];
    real tmp1[lpsize+1], tmp2[lpsize+1];


    /* shift in INPUT into OLD_INPUT and window it*/
    
    for(i=0; i<N2; i++)
	old_input[i] = old_input[i+framesize];
    for(i=0; i<framesize; i++)
	old_input[N2+i] = new_input[i];

    VPROD(old_input,window,ws,N3);
    
    AUTOCORR(ws, tmp1, lpsize, lpsize, N1);
    
    for(i=0; i<=lpsize; i++)
	rec[i] = decay * rec[i] + tmp1[i];
    
    AUTOCORR(ws, tmp2, lpsize,  N1, N3);
    
    for(i=0; i<=lpsize; i++)
	output[i] = rec[i] + tmp2[i];

    output[0] *= WNCF;
}
Example #2
0
// create auto-correlator object                            
//  _window_size    : size of the correlator window         
//  _delay          : correlator delay [samples]            
AUTOCORR() AUTOCORR(_create)(unsigned int _window_size,
                             unsigned int _delay)
{
    // create main object
    AUTOCORR() q = (AUTOCORR()) malloc(sizeof(struct AUTOCORR(_s)));

    // set user-based parameters
    q->window_size = _window_size;
    q->delay       = _delay;

    // create window objects
    q->w      = WINDOW(_create)(q->window_size);
    q->wdelay = WINDOW(_create)(q->window_size + q->delay);

    // allocate array for squared energy buffer
    q->we2 = (float*) malloc( (q->window_size)*sizeof(float) );

    // clear object
    AUTOCORR(_reset)(q);

    // return main object
    return q;
}
Example #3
0
    // create window objects
    q->w      = WINDOW(_create)(q->window_size);
    q->wdelay = WINDOW(_create)(q->window_size + q->delay);

    // allocate array for squared energy buffer
    q->we2 = (float*) malloc( (q->window_size)*sizeof(float) );

    // clear object
    AUTOCORR(_reset)(q);

    // return main object
    return q;
}

// destroy auto-correlator object, freeing internal memory
void AUTOCORR(_destroy)(AUTOCORR() _q)
{
    // destroy internal window objects
    WINDOW(_destroy)(_q->w);
    WINDOW(_destroy)(_q->wdelay);

    // free array for squared energy buffer
    free(_q->we2);

    // free main object memory
    free(_q);
}

// reset auto-correlator object's internals
void AUTOCORR(_reset)(AUTOCORR() _q)
{