PDA

View Full Version : help needed to write a render class



franco.amato
1st June 2010, 17:31
Hi to all,
unfortunately I'm having some problems in writing a Qt class to render an audio wave, so I decide to pay some expert ( that I'm not ) to help me.

I hope to get some feedback.
Regards,
Franco

tbscope
1st June 2010, 17:34
What is your question please?

franco.amato
1st June 2010, 17:37
What is your question please?

My question is: can someone help me in writing such class?
I'll pay something for that help.

tbscope
1st June 2010, 18:07
Check out these programs:
http://qt-apps.org/index.php?xcontentmode=4220

I'm sure there's something there that displays a waveform.
Try to take a look at the source code on how they did it.

franco.amato
1st June 2010, 18:13
Check out these programs:
http://qt-apps.org/index.php?xcontentmode=4220

I'm sure there's something there that displays a waveform.
Try to take a look at the source code on how they did it.


Dear tbscope,
I already draw a waveform ( is not so hard ).
The help I need is to:

convert my wave widget from QWidget to QAbstractScrollArea ( from wysota )
improve the render algorithm to speed up the render time


From Johan thelin: draw the whole waveform in sub pixmap and render only one at time ( using a separate thread I think ), but I have no idea on how to do it and unfortunately now I'm on another project.

So I hope to get some help here.

tbscope
1st June 2010, 18:39
You should have mentioned that at the beginning.

Anyway, post your code so others can give their opinion.

franco.amato
1st June 2010, 18:48
You should have mentioned that at the beginning.
Sorry if I I have not been clear.


Anyway, post your code so others can give their opinion.
Which code must I post? It's large and I'm not sure wysota will be happy ;-)
Meanwhile now my render class inherits from QWidget. I have to change the parent to QAbstractScrollArea as now It doesn't work well.

I can post the render routine.

I have to cut the code and post only the relevant part.

tbscope
1st June 2010, 18:51
Post the relevant parts, like the widget that displays the waveform.
You can attach them.

franco.amato
1st June 2010, 19:49
Post the relevant parts, like the widget that displays the waveform.
You can attach them.

Ok I'm attaching wavedisplay.h and wavedisplay.cpp.
You can see that it inherits from QWidget that's not the correct way ( thanx wysota ), I have to change it to QAbstractScrollArea because in the render I would keep some text at a fixed position whyle the whole wave is scrolled when playing. And I also would move the whole wave moving the scrollbar position without repainting every time.

The relevant routines are:
WaveDisplay::setWave( SoundData* w )
WaveDisplay::paintEvent( QPaintEvent* pe )
WaveDisplay::updateWave()
WaveDisplay::resizeEvent( QResizeEvent * re )
WaveDisplay::drawStandardPCM16( QPainter& painter, int numSamples )

When I calculate the wave ( see drawStandardPCM16 ) I put the result in a QPixmap that I use as cache ( see updateWave ) then in the paintEvent basically I draw the cache context.
I call updateWave only when the wave changes ( for example in the resizeEvent or when zooming ), if not I draw the cache content.
The problem is that my sounds are very large ( 1 hour of sound 16 bits mono ) and it take loooong time to update/render the wave.
So I would write some smart algorithm to draw the huge wave in parts, maybe depending of the scrollbar position ( I think in a separate thread).

This is the help I have.
I hope to get some answer, If more informations are needed I can share the code.

Regards,
Franco

franco.amato
1st June 2010, 22:07
There is another issue in dividing the pixmap in parts and rendering only one at time.
When I play the sound the wave should be shifted from right to left ( simulating the time that spends ).
Doing so I should have infinite ( or many ) pixmaps to have a continuous effect and not a "discrete" effect.
So my idea is to fill the full image in a thread and render fragment of it.
So how can I do it?

Bye