3 // C++ Implementation: Sonogram
8 // Author: Melchior FRANZ <mfranz@kde.org>, (C) 2004
10 // Copyright: See COPYING file that comes with this distribution
16 #include <QResizeEvent>
17 #include <QPaintEvent>
21 Sonogram::Sonogram(QWidget
*parent
) :
22 Analyzer::Base2D(parent
, 16, 9)
37 void Sonogram::resizeEvent(QResizeEvent
*e
)
42 #if !( __GNUC__ > 4 || ( __GNUC__ == 4 && __GNUC_MINOR__ >= 0 ) )
43 resizeForBands(height() < 128 ? 128 : height());
46 Analyzer::Base2D::resizeEvent( e
);
47 // p.drawPixmap( 0, 0, background() )
48 // bitBlt(this, 0, 0, background());
52 void Sonogram::analyze(const Scope
&s
)
55 // Analyzer::interpolate( s, m_scope );
60 Sonogram::paintEvent( QPaintEvent
* )
66 // bitBlt(canvas(), 0, 0, canvas(), 1, 0, x, height());
67 // p.drawPixmap( 0, 0, this, 1, 0, x, height() );
68 const Scope
&s
= m_scope
;
69 Scope::const_iterator it
= s
.begin(), end
= s
.end();
70 for (int y
= height() - 1; y
;) {
71 if (it
>= end
|| *it
< .005)
72 c
= p
.background().color();
74 c
.setHsv(95, 255, 255 - int(*it
* 4000.0));
76 c
.setHsv(95 - int(*it
* 90.0), 255, 255);
89 void Sonogram::transform(Scope
&scope
)
91 float *front
= static_cast<float*>(&scope
.front());
93 m_fht
->scale(front
, 1.0 / 256);
94 scope
.resize( m_fht
->size() / 2 );
100 analyze(Scope(m_fht
->size(), 0));