Added reset & smooth buttons, graphics, fixed graph smoothing behaviour

This commit is contained in:
Vesa
2014-02-12 16:21:46 +02:00
parent 201fa1d89a
commit 4b125abc0e
11 changed files with 49 additions and 29 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 11 KiB

After

Width:  |  Height:  |  Size: 60 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 42 KiB

After

Width:  |  Height:  |  Size: 44 KiB

View File

@@ -30,7 +30,8 @@
#include "waveshaper_controls.h"
#include "embed.h"
#include "graph.h"
#include "pixmap_button.h"
#include "tooltip.h"
waveShaperControlDialog::waveShaperControlDialog(
@@ -42,48 +43,47 @@ waveShaperControlDialog::waveShaperControlDialog(
pal.setBrush( backgroundRole(),
PLUGIN_NAME::getIconPixmap( "artwork" ) );
setPalette( pal );
setFixedSize( 222, 300 );
QVBoxLayout * tl = new QVBoxLayout( this );
tl->addSpacing( 30 );
tl->addStrut( 204 );
setFixedSize( 224, 300 );
graph * waveGraph = new graph( this, graph::NearestStyle, 204, 204 );
waveGraph -> move( 10, 32 );
waveGraph -> setModel( &_controls -> m_wavegraphModel );
waveGraph -> setAutoFillBackground( true );
pal = QPalette();
pal.setBrush( backgroundRole(),
PLUGIN_NAME::getIconPixmap("wavegraph") );
waveGraph->setPalette( pal );
waveGraph->setGraphColor( QColor( 170, 255, 255 ) );
// waveGraph -> setMinimumSize( 204, 204);
// waveGraph -> resize( 204, 204);
waveGraph -> setMaximumSize( 204, 204 );
tl -> setSizeConstraint( QLayout::SetNoConstraint );
tl -> addWidget( waveGraph );
QHBoxLayout * l = new QHBoxLayout;
knob * inputKnob = new knob( knobBright_26, this);
inputKnob -> move( 10, 251 );
inputKnob->setModel( &_controls->m_inputModel );
inputKnob->setLabel( tr( "INPUT" ) );
inputKnob->setHintText( tr( "Input gain:" ) + " ", "" );
knob * outputKnob = new knob( knobBright_26, this );
outputKnob -> move( 50, 251 );
outputKnob->setModel( &_controls->m_outputModel );
outputKnob->setLabel( tr( "OUTPUT" ) );
outputKnob->setHintText( tr( "Output gain:" ) + " ", "" );
l->addWidget( inputKnob );
l->addWidget( outputKnob );
tl->addLayout( l );
setLayout( tl );
pixmapButton * resetButton = new pixmapButton( this, tr("Reset waveform") );
resetButton -> move( 164, 251 );
resetButton -> resize( 12, 48 );
resetButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "reset_active" ) );
resetButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "reset_inactive" ) );
toolTip::add( resetButton, tr( "Click here to reset the wavegraph back to default" ) );
pixmapButton * smoothButton = new pixmapButton( this, tr("Smooth waveform") );
smoothButton -> move( 164, 267 );
smoothButton -> resize( 12, 48 );
smoothButton -> setActiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_active" ) );
smoothButton -> setInactiveGraphic( PLUGIN_NAME::getIconPixmap( "smooth_inactive" ) );
toolTip::add( smoothButton, tr( "Click here to apply smooth to wavegraph" ) );
connect( resetButton, SIGNAL (clicked () ),
_controls, SLOT ( resetClicked() ) );
connect( smoothButton, SIGNAL (clicked () ),
_controls, SLOT ( smoothClicked() ) );
}

View File

@@ -40,6 +40,7 @@ public:
{
}
private:
} ;

View File

@@ -29,7 +29,8 @@
#include "waveshaper_controls.h"
#include "waveshaper.h"
#include "graph.h"
#include "engine.h"
#include "song.h"
waveShaperControls::waveShaperControls( waveShaperEffect * _eff ) :
@@ -125,5 +126,19 @@ void waveShaperControls::setDefaultShape()
m_wavegraphModel.setSamples( (float*)&shp );
}
void waveShaperControls::resetClicked()
{
setDefaultShape();
engine::getSong()->setModified();
}
void waveShaperControls::smoothClicked()
{
m_wavegraphModel.smooth();
engine::getSong()->setModified();
}
#include "moc_waveshaper_controls.cxx"

View File

@@ -67,6 +67,9 @@ private slots:
void changeInput();
void changeOutput();
void samplesChanged( int, int );
void resetClicked();
void smoothClicked();
private:
waveShaperEffect * m_effect;

View File

@@ -558,11 +558,12 @@ void graphModel::smooth()
QVector<float> temp = m_samples;
// Smoothing
m_samples[0] = ( temp[0] + temp[length()-1] ) * 0.5f;
for ( int i=1; i < length(); i++ )
m_samples[0] = ( temp[length()-1] + ( temp[0] * 2 ) + temp[1] ) * 0.25f;
for ( int i=1; i < ( length()-1 ); i++ )
{
m_samples[i] = ( temp[i-1] + temp[i] ) * 0.5f;
m_samples[i] = ( temp[i-1] + ( temp[i] * 2 ) + temp[i+1] ) * 0.25f;
}
m_samples[length()-1] = ( temp[length()-2] + ( temp[length()-1] * 2 ) + temp[0] ) * 0.25f;
emit samplesChanged(0, length()-1);
}