Results 1 to 20 of 24

Thread: Creating a waterfall plot with the spectrogram

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Join Date
    Jul 2010
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Creating a waterfall plot with the spectrogram

    xilcoy,

    Thank you again for your replies. I'm trying to get just a particuliar point in time done to start as you and Uwe suggest, but it seems no matter what I do with or without using a bounding rect I get the entire plot filled with bars spanning the spectrum of my colormap, instead of just the one horizontal 'bar' filling the coordinates of the bounding rect I am trying to fill in. The value function I am using is from one of the examples here on this forum (I think one of Uwe's) and uses uses a simple rounding for the re-sampling. The data fills the entire plot....seems to ignore the bounding rect I define. Maybe I'm defining it too late in the code after the raster area is already created...I'm not sure...

    tim

  2. #2
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    The spectrogram item requests the bounding rectangle from the raster data object each time it is repainted. Did you forget to copy the assigned bounding rectangle in your implementation of YourRasterData::copy() ?

    Uwe

    PS: All these nasty copy/clone methods are already removed in the development branch.

  3. #3
    Join Date
    Jul 2010
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Creating a waterfall plot with the spectrogram

    Hi Uwe,Xilcoy,

    I managed to get just a solid horizontal bar displayed on the spectrogram and have control over where it is drawn in the vertical direction (for step 1), but I still don't think I understand how the raster/ spectrogram plot works, and the way I'm drawing the bar is extremely slow....it takes in the order of 23 seconds to draw a screen with only one bar drawn (no animation even attempted yet).

    I am not doing anything with the copy method...should I be? Right now it is left as it was in the example I started with and just returns a pointer to the Spectrogram data object. I'm setting the bounding rect in the QwtRasterData method. To draw the horizontal line I have just been working with how the points are written to the value method. Admittedly this spectrogram plotting has me confused....Uwe, have you ever considered writing a tutorial book on Qwt? I'd buy it.

    tim

  4. #4
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    I managed to get just a solid horizontal bar displayed on the spectrogram and have control over where it is drawn in the vertical direction (for step 1), but I still don't think I understand how the raster/ spectrogram plot works, and the way I'm drawing the bar is extremely slow....it takes in the order of 23 seconds to draw a screen with only one bar drawn (no animation even attempted yet).
    Well, when the spectrogram item is requested ( by the plot widget ) to draw itself, it iterates over all pixels of the target device ( the widget ). For each pixel it calculates the corresponding scale coordinates (x/y) and requests a value ( QwtRasterData::value() ) for this position. Then it maps the value into a color ( using a QwtColorMap ) and puts it to a QImage. When all pixels are collected the image is painted to the target device.

    So your implementation of YourRasterData::value() needs to be pretty fast as it is called often ( width * height ! ). If you needs 23 seconds you are doing something very, very expensive in YourRasterData::value() ( or in your color map, when you have implemented your own ).

    Uwe, have you ever considered writing a tutorial book on Qwt? I'd buy it.
    Writing a tutorial is one of my priorities, when Qwt 6.0.0 has been done.

    Uwe

  5. #5
    Join Date
    Jan 2010
    Location
    Poland Warsaw
    Posts
    25
    Thanks
    1
    Qt products
    Qt4
    Platforms
    Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    Hello!

    I have wrote simple program which captures sound samples from sound card in one thread and writes them to circular buffer. Another thread takes samples from buffer and process them (calculate FFT). The output (double*) is added in beggining of QList<double* > (last item is removed) and than signal is emmited to main thread that new data is ready to display.
    In main thread i have two plots: simple qwtplot which plots current spectrum and second qwtspectrogram which plots spectrogram from QList.
    The problem is that it works very slow - about 2 FPS. When I remove spectrogram from GUI and leave only qwtplot I have about 22 FPS.
    So my question is: how to speed up generating/drawing spectrogram ?

    Misza

  6. #6
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    Quote Originally Posted by m15ch4 View Post
    So my question is: how to speed up generating/drawing spectrogram ?
    Implement YourRasterData::rasterHint().

    Uwe

  7. #7
    Join Date
    Jul 2010
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Creating a waterfall plot with the spectrogram

    I have gotten a waterfall plot working using the spectrogram widget thanks to a lot of help from Uwe and Xicoy above.... However, until now I have been using all positive values.....fe...x axis: 0-4096 samples, y axis: 0-250 ms, sample values between 0-40, colorbar scale 0-40. Now I need to modify it so that the x axis has +/- values (-2048 to 2048 for example), and data values from -200 to 200. Can that be done with this spectrogram widget? My attempts have yielded a colorbar which is still fine for positive values, but all negative values just remain at the color used for 0. And any negative data values default to the color for zero on the colorbar. Also values only plot on the positive side of the x axis, negative data values seem to be ignored and not plotted at all. I've tried adjusting range and axis values etc...but so far have had no success. Any thoughts or advice would be appreciated.
    I am using qwt 6.0.

    Thank you,
    tim

  8. #8
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    There is no limitation for ranges - the problem is on your side. Maybe the bounding rectangle of your data is wrong.

    Uwe

  9. The following user says thank you to Uwe for this useful post:

    twells5 (17th December 2010)

  10. #9
    Join Date
    Jul 2010
    Posts
    15
    Thanks
    2
    Qt products
    Qt4
    Platforms
    MacOS X Unix/X11

    Default Re: Creating a waterfall plot with the spectrogram

    Can the labels on the x-axis scale major ticks be changed to a different string other than the bounding rect interval values it defaults to? My data is displayed fine now thanks to your tip above, but I would like the major tick labels to show something like ...50Mhz 100Mhz 150Mhz....? I don't want to change anything about how the spectrogram data is plotted, just the label strings displayed.

    tim

  11. #10
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    Can the labels on the x-axis scale major ticks be changed to a different string other than the bounding rect interval values it defaults to?
    Derive from QwtScaleDraw and implement "QwtText YourScaleDraw::label((double) const".
    F.e. see the cpuplot example.

    Uwe

  12. The following user says thank you to Uwe for this useful post:

    twells5 (20th December 2010)

  13. #11
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    77
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    Quote Originally Posted by Uwe View Post
    Writing a tutorial is one of my priorities, when Qwt 6.0.0 has been done.Uwe
    Uwe v6.0.2 is out - if this tutorial exists, please post the location. It is sorely needed by Qwt newbies - as are working practical examples.

  14. #12
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    Qwt 6.1-rc1 is out too and all I have done so far is buying a book about DocBook.
    Concerning the examples: what topics would you like to see that are not covered by the existing ( 6.1 ) examples already ?

    Uwe

  15. #13
    Join Date
    Jun 2007
    Location
    Louisiana
    Posts
    77
    Thanks
    1
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    Reviewing v6.1 examples now.

    In general generic examples that do nothing are not useful in practice for newbies to Qwt. On topic, an example of using Qwt to make a waterfall widget that displays sound captured (from say a jack audio input client) would be an outstandingly practical example for anyone as long as it works.

  16. #14
    Join Date
    Feb 2006
    Location
    Munich, Germany
    Posts
    3,312
    Thanked 879 Times in 827 Posts
    Qt products
    Qt3 Qt4 Qt/Embedded
    Platforms
    MacOS X Unix/X11 Windows

    Default Re: Creating a waterfall plot with the spectrogram

    In general generic examples that do nothing are not useful in practice for newbies to Qwt.
    I completely disagree, examples like simpleplot are exactly what a newbie needs. The complete example has 42 lines of code and shows how easy it is to set up an application with a curve chart. This is the relevant information a user needs to know to get a project started.

    On topic, an example of using Qwt to make a waterfall widget that displays sound captured (from say a jack audio input client) would be an outstandingly practical example for anyone as long as it works.
    Nothing could be more off topic than this. A waterfall plot qualifies as a demo like the oscilloscope - a cool application showing the power of Qwt, but leaving a newbie completely clueless, when reading the code.

    But don't get me wrong: I would like to have a demo for a waterfall plot too, but the problem is the generation of the data:


    • examples have to run on all target platforms without external dependencies - nobody installs and runs jack only to see how Qwt works.
    • you can't blow up the size of a Qwt tarball with recorded data ( like the cpuplot example does for systems without a proc file system )


    That's why in the end examples often end with synthetic data.

    So if you have a specification for a waterfall plot and an idea how to generate the data I would be willing to implement such a demo. Also I could imagine to offer a more high level set of widgets - if I would have reasonable specifications - like:


    • QwtOscilloscope
    • QwtWaterfallPlot
    • ...


    This is not the first thread about a waterfall example, but unfortunately ideas like this usually die as soon as I'm asking for any type of contribution ...

    Uwe

Similar Threads

  1. Replies: 0
    Last Post: 2nd May 2010, 02:55
  2. Replies: 2
    Last Post: 12th October 2009, 21:17
  3. x-axis for waterfall plot
    By janK in forum Qwt
    Replies: 8
    Last Post: 29th July 2009, 15:00
  4. Spectrogram Plot Hints
    By shargath in forum Qwt
    Replies: 2
    Last Post: 25th February 2009, 11:11
  5. waterfall display
    By jmsbc in forum Qt Programming
    Replies: 7
    Last Post: 15th November 2008, 08:29

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.