Ejemplo n.º 1
0
Archivo: apt.cpp Proyecto: la1k/wxfetch
int getpixelv(buffer_t *sound_buffer, apt_t *apt, float *pvbuff, int nb)
{
    int n;

    for (n = 0; n < nb; n++) {
	double mult;
	int shift;

	if (apt->nam < BLKAMP) {
	    int res;
	    memmove(apt->ambuff, &(apt->ambuff[apt->idxam]), apt->nam * sizeof(float));
	    apt->idxam = 0;

	    float sound_buff[BLKAMP];
	    int num_samples = BLKAMP - apt->nam;
	    res = buffer_read(sound_buffer, num_samples, sound_buff);
	    getamp(&(apt->phaselock_state), &(apt->ambuff[apt->nam]), sound_buff, res);
	    apt->nam += res;
	    if (apt->nam < BLKAMP)
		return (n);
	}

	mult = (double) Fi * apt->phaselock_state.fr / Fc * apt->FreqLine;

	pvbuff[n] =
	    rsfir(&(apt->ambuff[apt->idxam]), rsfilter, RSFilterLen, offset,
		  mult) * mult * 2 * 256.0;

	shift = (int) ((RSMULT - offset + mult - 1) / mult);
	offset = shift * mult + offset - RSMULT;
	apt->idxam += shift;
	apt->nam -= shift;
    }
    return (nb);
}
Ejemplo n.º 2
0
Archivo: dsp.c Proyecto: bkerler/aptdec
int getpixelv(float *pvbuff, int nb)
{

   static double offset = 0.0;

#define BLKAMP 4096
    static double ambuff[BLKAMP];
    static int nam = 0;
    static int idxam = 0;

    int n,m;
    double mult;
    float v;
    static float ppv=0,pv=0;

    mult = (double) Fi/Fe*FreqLine;

    m=RSFilterLen/mult+1;

    for (n = 0; n < nb; n++) {
	int shift;

	if (nam < m) {
	    int res;
	    memmove(ambuff, &(ambuff[idxam]), nam * sizeof(double));
	    idxam = 0;
	    res = getamp(&(ambuff[nam]), BLKAMP - nam);
	    nam += res;
	    if (nam < m)
		return (n);
	}

	v = rsfir(&(ambuff[idxam]), rsfilter, RSFilterLen, offset, mult) * mult * 256.0;
	if(v<0.0) {
		v = 2.0*(pv-ppv);
		if (v<0.0) v=0.0;
		if (v>=256.0) v=255.0;
		pvbuff[n] = v;
		ppv=pv;
	} else {
		if (v>=256.0) v=255.0;
		pvbuff[n] = v;
		ppv=pv;pv=v;
	}

	shift = ((int) floor((RSMULT - offset) / mult))+1;
	offset = shift*mult+offset-RSMULT ;

	idxam += shift;
	nam -= shift;
    }
    return (nb);
}