improved appearence of Spectrum Analzyer
git-svn-id: https://lmms.svn.sf.net/svnroot/lmms/trunk/lmms@1127 0778d3d1-df1d-0410-868b-ea421aaaa00d
This commit is contained in:
@@ -1,5 +1,12 @@
|
||||
2008-06-14 Tobias Doerffel <tobydox/at/users/dot/sourceforge/dot/net>
|
||||
|
||||
* plugins/spectrum_analyzer/background.png:
|
||||
* plugins/spectrum_analyzer/spectrum_background.png:
|
||||
* plugins/spectrum_analyzer/spectrum_background_plain.png:
|
||||
* plugins/spectrum_analyzer/spectrumanalyzer_control_dialog.cpp:
|
||||
* plugins/spectrum_analyzer/spectrum_analyzer.h:
|
||||
improved appearence of Spectrum Analzyer
|
||||
|
||||
* configure.in:
|
||||
* plugins/Makefile.am:
|
||||
* plugins/spectrum_analyzer/Makefile.am:
|
||||
|
||||
BIN
plugins/spectrum_analyzer/background.png
Normal file
BIN
plugins/spectrum_analyzer/background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 25 KiB |
@@ -32,7 +32,7 @@
|
||||
#include "spectrumanalyzer_controls.h"
|
||||
|
||||
|
||||
const int MAX_BANDS = 400;
|
||||
const int MAX_BANDS = 249;
|
||||
const int BUFFER_SIZE = 2048;
|
||||
|
||||
|
||||
|
||||
BIN
plugins/spectrum_analyzer/spectrum_background.png
Normal file
BIN
plugins/spectrum_analyzer/spectrum_background.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 13 KiB |
BIN
plugins/spectrum_analyzer/spectrum_background_plain.png
Normal file
BIN
plugins/spectrum_analyzer/spectrum_background_plain.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.5 KiB |
@@ -29,6 +29,26 @@
|
||||
#include "spectrum_analyzer.h"
|
||||
#include "song_editor.h"
|
||||
#include "led_checkbox.h"
|
||||
#include "embed.h"
|
||||
|
||||
|
||||
inline void darken( QImage & _i, int _x, int _y, int _w, int _h )
|
||||
{
|
||||
uchar * d = _i.scanLine( _y ) + _x * sizeof( QRgb );
|
||||
const int add = ( _i.width() - _w ) * sizeof( QRgb );
|
||||
for( int y = 0; y < _h; ++y )
|
||||
{
|
||||
for( int x = 0; x < _w; ++x )
|
||||
{
|
||||
*d = *d >> 1; ++d;
|
||||
*d = *d >> 1; ++d;
|
||||
*d = *d >> 1; ++d;
|
||||
++d;
|
||||
}
|
||||
d += add;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
class spectrumView : public QWidget
|
||||
@@ -36,11 +56,14 @@ class spectrumView : public QWidget
|
||||
public:
|
||||
spectrumView( spectrumAnalyzer * _s, QWidget * _parent ) :
|
||||
QWidget( _parent ),
|
||||
m_sa( _s )
|
||||
m_sa( _s ),
|
||||
m_backgroundPlain( PLUGIN_NAME::getIconPixmap( "spectrum_background_plain" ).toImage() ),
|
||||
m_background( PLUGIN_NAME::getIconPixmap( "spectrum_background" ).toImage() )
|
||||
{
|
||||
setFixedSize( 400, 200 );
|
||||
setFixedSize( 249, 151 );
|
||||
connect( engine::getSongEditor(), SIGNAL( periodicUpdate() ),
|
||||
this, SLOT( update() ) );
|
||||
setAttribute( Qt::WA_OpaquePaintEvent, TRUE );
|
||||
}
|
||||
|
||||
virtual ~spectrumView()
|
||||
@@ -50,10 +73,13 @@ public:
|
||||
virtual void paintEvent( QPaintEvent * _pe )
|
||||
{
|
||||
QPainter p( this );
|
||||
p.fillRect( rect(), Qt::black );
|
||||
QImage i = m_sa->m_saControls.m_linearSpec.value() ?
|
||||
m_backgroundPlain : m_background;
|
||||
const double e = m_sa->m_energy;
|
||||
if( e <= 0 )
|
||||
{
|
||||
darken( i, 0, 0, i.width(), i.height() );
|
||||
p.drawImage( 0, 0, i );
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -63,7 +89,6 @@ public:
|
||||
int h;
|
||||
if( m_sa->m_saControls.m_linearSpec.value() )
|
||||
{
|
||||
p.setPen( QColor( 0, 255, 0 ) );
|
||||
for( int x = 0; x < MAX_BANDS; ++x, ++b )
|
||||
{
|
||||
if( lin_y )
|
||||
@@ -74,7 +99,15 @@ public:
|
||||
{
|
||||
h = (int)( height() * (20*(log10( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) );
|
||||
}
|
||||
p.drawLine( x, height(), x, height()-h );
|
||||
if( h < 0 )
|
||||
{
|
||||
h = 0;
|
||||
}
|
||||
else if( h > height() )
|
||||
{
|
||||
h = height();
|
||||
}
|
||||
darken( i, x, 0, 1, height()-h );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -89,13 +122,29 @@ public:
|
||||
{
|
||||
h = (int)( height() * (20*(log10( *b / e ) ) - LOWER_Y ) / (-LOWER_Y ) );
|
||||
}
|
||||
p.fillRect( x*13, height()-h, 11, h, QColor( 0, 255, 0 ) );
|
||||
if( h < 0 )
|
||||
{
|
||||
h = 0;
|
||||
}
|
||||
else if( h > height() )
|
||||
{
|
||||
h = height();
|
||||
}
|
||||
else
|
||||
{
|
||||
h = ( h / 3 ) * 3;
|
||||
}
|
||||
darken( i, x*8, 0, 8, height()-h );
|
||||
}
|
||||
darken( i, 31*8, 0, 1, height() );
|
||||
}
|
||||
p.drawImage( 0, 0, i );
|
||||
}
|
||||
|
||||
private:
|
||||
spectrumAnalyzer * m_sa;
|
||||
QImage m_backgroundPlain;
|
||||
QImage m_background;
|
||||
|
||||
} ;
|
||||
|
||||
@@ -104,16 +153,26 @@ spectrumAnalyzerControlDialog::spectrumAnalyzerControlDialog(
|
||||
spectrumAnalyzerControls * _controls ) :
|
||||
effectControlDialog( _controls )
|
||||
{
|
||||
QVBoxLayout * l = new QVBoxLayout( this );
|
||||
setAutoFillBackground( TRUE );
|
||||
QPalette pal;
|
||||
pal.setBrush( backgroundRole(),
|
||||
PLUGIN_NAME::getIconPixmap( "background" ) );
|
||||
setFixedSize( 280, 243 );
|
||||
setPalette( pal );
|
||||
/* QVBoxLayout * l = new QVBoxLayout( this );*/
|
||||
spectrumView * v = new spectrumView( _controls->m_effect, this );
|
||||
v->move( 24, 30 );
|
||||
|
||||
ledCheckBox * lin_spec = new ledCheckBox( tr( "Linear spectrum" ), this );
|
||||
ledCheckBox * lin_y = new ledCheckBox( tr( "Linear Y axis" ), this );
|
||||
lin_spec->move( 24, 204 );
|
||||
lin_spec->setModel( &_controls->m_linearSpec );
|
||||
|
||||
ledCheckBox * lin_y = new ledCheckBox( tr( "Linear Y axis" ), this );
|
||||
lin_y->move( 24, 220 );
|
||||
lin_y->setModel( &_controls->m_linearYAxis );
|
||||
l->addWidget( v );
|
||||
/* l->addWidget( v );
|
||||
l->addWidget( lin_spec );
|
||||
l->addWidget( lin_y );
|
||||
l->addWidget( lin_y );*/
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user