Exemplo n.º 1
0
int QFilter::ProcessAndDecimate(CPX &in, CPX &out, int bsize) {

    Q_UNUSED(in)
    Q_UNUSED(bsize)

    //memset(tmp0, 0, sizeof(CPX) * m_size * 2);
    //memset(tmp1, 0, sizeof(CPX) * m_size * 2);
    //memcpy(tmp0, in, sizeof(CPX) * m_size);
	tmp0.resize(m_size * 2);
	tmp1.resize(m_size * 2);
	tmp0.resize(m_size);

    ovlpfft->DoFFTWForward((cufftComplex *) tmp0.data(), (cufftComplex *) tmp1.data(), m_size * 2);
    DoConvolutionCPX();
    ovlpfft->DoFFTWInverse((cufftComplex *) tmp0.data(), (cufftComplex *) tmp1.data(), m_size * 2);

    if (m_streamMode) {
		
		DoOverlapAddCPX();
        for (int i = 0, j = 0; i < m_size; i+=2, j++) {
			
			*(out.data()+j) = *(tmp0.data()+i);
        }
    }
	else {
		
		for (int i = 0, j = 0; i < m_size; i+=2, j++) {
			
			*(out.data()+j) = *(tmp1.data()+i);
        }
    }
    return m_size/2;
}
Exemplo n.º 2
0
void QFilter::ProcessFilter(CPX &in, CPX &out, int bsize) {

	Q_UNUSED (bsize)

	memcpy(tmp0.data(), in.data(), sizeof(cpx) * m_size);
    ovlpfft->DoFFTWForward((cufftComplex *) tmp0.data(), (cufftComplex *) tmp1.data(), m_size * 2);
    DoConvolutionCPX();
    ovlpfft->DoFFTWInverse((cufftComplex *) tmp0.data(), (cufftComplex *) tmp1.data(), m_size * 2);

    if (m_streamMode) {

    	//Normalize(tmp1, tmp2, m_size * 2);

    	// Overlap-Add
    	for (int i = 0; i < m_size; i++) {

    		out[i] = AddCPX(tmp1.at(i), ovlp.at(i));
    		ovlp[i] = tmp1.at(i + m_size);
    	}
		//DoOverlapAddCPX();
		//Normalize(tmp0, out, m_size * 2);
		//memcpy(out.data(), res.data(), sizeof(cpx) * m_size);
    }
    else {
		
		memcpy(out.data(), tmp1.data(), sizeof(cpx) * m_size);
    }
}
Exemplo n.º 3
0
void QFilter::ProcessForwardFilter(CPX &in, CPX &out, int bsize) {

	Q_UNUSED (bsize)

	//memcpy(tmp0, in, sizeof(CPX) * m_size);
	memcpy(tmp0.data(), in.data(), sizeof(cpx) * m_size);
    ovlpfft->DoFFTWForward((cufftComplex *) tmp0.data(), (cufftComplex *) tmp1.data(), m_size * 2);

    DoConvolutionCPX();
    //ovlpfft->DoFFTWInverse(tmp0, tmp1, m_size * 2);

    if (m_streamMode) {

        DoOverlapAddCPX();
        //memcpy(out, tmp0, sizeof(CPX) * m_size);
        memcpy(out.data(), tmp0.data(), sizeof(cpx) * m_size);
    }
    else {
		
		//memcpy(out, tmp1, sizeof(CPX) * m_size);
    	memcpy(out.data(), tmp1.data(), sizeof(cpx) * m_size);
    }
}
Exemplo n.º 4
0
void QFFT::DoFFTWMagnForward(CPX &in, int size, float baseline, float correction, float *fbr) {

    memcpy(cpxbuf, in.data(), sizeof(cpx) * size);

    fftwf_execute(plan_fwd);

    for (int i = 0, j = size-1; i < size; i++, j--) {

		*(buf.data()+j) = *(cpx *)(cpxbuf+i);
    }

    for (int i = 0, j = half_sz; i < half_sz; i++, j++) {

        *(fbr+i) = 10.0 * log10(MagCPX(*(buf.data()+j)) + baseline) + correction;
        *(fbr+j) = 10.0 * log10(MagCPX(*(buf.data()+i)) + baseline) + correction;
    }
}
Exemplo n.º 5
0
void QFilter::Decimate(CPX &in, CPX &out, int downrate) {

	int newsize = qRound((float) m_size/downrate);

	//memset(out, 0, newsize * sizeof(CPX));
	//memset(tmp, 0, m_size * sizeof(CPX));
	out.resize(newsize);
	tmp.resize(m_size);
	//memcpy(tmp, in, m_size * sizeof(CPX));
	memcpy(tmp.data(), in.data(), m_size * sizeof(cpx));

	for (int j = 0; j < newsize; j++) {
		for (int k = 0; k < downrate; k++) {
		//for (int k = 0; k < downrate - 1; k++) {

			if (j * downrate + k < m_size) {

				out[j].re += tmp.at(j * downrate + k).re;
				out[j].im += tmp.at(j * downrate + k).im;
			}
		}
	}
}
Exemplo n.º 6
0
void QFFT::DoFFTWInverse(CPX &in, CPX &out, int size)  {

    memcpy(cpxbuf, in.data(), sizeof(cpx) * size);
    fftwf_execute(plan_rev);
    memcpy(out.data(), cpxbuf, sizeof(cpx) * size);
}
Exemplo n.º 7
0
void QFFT::DoFFTWForward(CPX &in, CPX &out, int size) {
    memcpy(cpxbuf, in.data(), sizeof(cpx) * size);
    fftwf_execute(plan_fwd);
    memcpy(out.data(), cpxbuf, sizeof(cpx) * size);
}