diff --git a/include/graph.h b/include/graph.h index 3e9a2d2d3..808baf2e3 100644 --- a/include/graph.h +++ b/include/graph.h @@ -160,6 +160,7 @@ public slots: QString setWaveToUser( ); void smooth(); + void smoothNonCyclic(); void normalize(); signals: diff --git a/plugins/waveshaper/artwork.png b/plugins/waveshaper/artwork.png index 876bac563..768e52e4a 100644 Binary files a/plugins/waveshaper/artwork.png and b/plugins/waveshaper/artwork.png differ diff --git a/plugins/waveshaper/waveshaper_control_dialog.cpp b/plugins/waveshaper/waveshaper_control_dialog.cpp index 9a3454b9d..ca47c52e8 100644 --- a/plugins/waveshaper/waveshaper_control_dialog.cpp +++ b/plugins/waveshaper/waveshaper_control_dialog.cpp @@ -57,13 +57,13 @@ waveShaperControlDialog::waveShaperControlDialog( waveGraph -> setMaximumSize( 204, 204 ); knob * inputKnob = new knob( knobBright_26, this); - inputKnob -> move( 10, 251 ); + inputKnob -> move( 14, 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 -> move( 54, 251 ); outputKnob->setModel( &_controls->m_outputModel ); outputKnob->setLabel( tr( "OUTPUT" ) ); outputKnob->setHintText( tr( "Output gain:" ) + " ", "" ); diff --git a/plugins/waveshaper/waveshaper_controls.cpp b/plugins/waveshaper/waveshaper_controls.cpp index 0a027b93a..244fc140d 100644 --- a/plugins/waveshaper/waveshaper_controls.cpp +++ b/plugins/waveshaper/waveshaper_controls.cpp @@ -134,7 +134,7 @@ void waveShaperControls::resetClicked() void waveShaperControls::smoothClicked() { - m_wavegraphModel.smooth(); + m_wavegraphModel.smoothNonCyclic(); engine::getSong()->setModified(); } diff --git a/src/gui/widgets/graph.cpp b/src/gui/widgets/graph.cpp index d426e3a6b..7f24a91df 100644 --- a/src/gui/widgets/graph.cpp +++ b/src/gui/widgets/graph.cpp @@ -108,33 +108,37 @@ void graph::mouseMoveEvent ( QMouseEvent * _me ) int x = _me->x(); int y = _me->y(); - static bool skip = false; +/* static bool skip = false; if( skip ) { skip = false; return; } - +*/ // avoid mouse leaps int diff = x - m_lastCursorX; if( diff >= 1 ) { - x = qMin( width() - 2, m_lastCursorX + 1); + x = qMin( width() - 3, m_lastCursorX + 1 ); } - else if( diff <= 1 ) + else if( diff <= -1 ) { x = qMax( 2, m_lastCursorX - 1 ); } - else - { - x = m_lastCursorX; - } - + y = qMax( 2, qMin( y, height()-3 ) ); - changeSampleAt( x, y ); +/* if( qAbs( diff ) > 1 ) + { + drawLineAt( x, y, m_lastCursorX ); + + } + else + {*/ + changeSampleAt( x, y ); +// } // update mouse if( diff != 0 ) @@ -146,7 +150,7 @@ void graph::mouseMoveEvent ( QMouseEvent * _me ) QCursor::setPos( pt.x(), pt.y() ); } - skip = true; +// skip = true; } @@ -157,9 +161,6 @@ void graph::mousePressEvent( QMouseEvent * _me ) { if ( !( _me->modifiers() & Qt::ShiftModifier ) ) { - // toggle mouse state - m_mouseDown = true; - // get position int x = _me->x(); int y = _me->y(); @@ -180,6 +181,7 @@ void graph::mousePressEvent( QMouseEvent * _me ) drawLineAt( x, y, m_lastCursorX ); + m_mouseDown = true; setCursor( Qt::BlankCursor ); m_lastCursorX = x; } @@ -568,7 +570,21 @@ void graphModel::smooth() emit samplesChanged(0, length()-1); } +void graphModel::smoothNonCyclic() +{ + // store values in temporary array + QVector temp = m_samples; + // Smoothing + m_samples[0] = ( ( temp[0] * 2 ) + temp[1] ) / 3.0f; + for ( int i=1; i < ( length()-1 ); i++ ) + { + 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 ) ) / 3.0f; + + emit samplesChanged(0, length()-1); +} void graphModel::normalize() {