2D Spectrogram with FFTW and QT.



  • I am developing an application for audio processing in real time.

    I used the FFTW library to build a NxM matrix representing the spectrogram of the recorded signal.

    My idea now is to represent graphically the spectrogram . At first I tried it with QWT but is too slow and I need to make the process faster as it is in real time.

    Another solution has been to use a QImage object.

    @ imageToShow(width, high, QImage::Format_Indexed8)@

    I implemented a method :

    @int MatrixPlotter::DefineDataToPlot(int width, int high,std::vector< std::vector<unsigned int> > data){
    if(this->width!=width || this->high!=high){
    return ERROR;
    }else{
    for(int i=0;i<this->width;i++){
    for(int j=0;j<this->high;j++){
    this->imageToShow.setPixel(i,j,data[i][j]);
    }
    }
    return READY;
    }
    }@

    For each pixel of the image I assign a value of NxM matrix. To do this previously , I make a change to the " double" values ​​NxM matrix on a scale from 0-255 (unsigned int) .

    The system works well but I have a problem and it is relatively slow. If the FFT size is very large tends to introduce delays .

    I thought implement it using the OpenGL library. I need help to learn how to do it.

    Does anyone could advise a more efficient method? Are there any alternatives for implementation?

    My level of English is limited. I hope I have expressed myself correctly. Thank you very much.



  • When going with Qwt image composition from data on my box ( i5 qudcore ) takes about ~50ms ( ~ 1800x1000 pixels ).
    But iterating about a widget of 1000x1000 pixels is always something that takes some time.

    Concerning your loop: using setPixel() is slow as you recalculate the position in the buffer for each pixel ( a million times ). Better use a ptr iterating over each scan line ( or use Qwt that does this all + multithreaded for you ).



  • [quote author="uwer" date="1422975543"]When going with Qwt image composition from data on my box ( i5 qudcore ) takes about ~50ms ( ~ 1800x1000 pixels ).
    But iterating about a widget of 1000x1000 pixels is always something that takes some time.

    Concerning your loop: using setPixel() is slow as you recalculate the position in the buffer for each pixel ( a million times ). Better use a ptr iterating over each scan line ( or use Qwt that does this all + multithreaded for you ).

    [/quote]

    I work with images of a 500x80 or 500x200 size , a very small size. When implemented in QWT takes about 3 s . I guess I have not implemented correctly .

    How did you implemented ? Could you share the code ?

    Thank you very much for responding.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.