diff --git a/data/themes/default/random_wave_active.png b/data/themes/default/random_wave_active.png new file mode 100644 index 000000000..38b089c63 Binary files /dev/null and b/data/themes/default/random_wave_active.png differ diff --git a/data/themes/default/random_wave_inactive.png b/data/themes/default/random_wave_inactive.png new file mode 100644 index 000000000..9a35c9d16 Binary files /dev/null and b/data/themes/default/random_wave_inactive.png differ diff --git a/include/EnvelopeAndLfoParameters.h b/include/EnvelopeAndLfoParameters.h index 1d795bd9e..42641c791 100644 --- a/include/EnvelopeAndLfoParameters.h +++ b/include/EnvelopeAndLfoParameters.h @@ -157,6 +157,7 @@ private: float m_lfoAmount; bool m_lfoAmountIsZero; sample_t * m_lfoShapeData; + sample_t m_random; bool m_bad_lfoShapeData; SampleBuffer m_userWave; @@ -167,6 +168,7 @@ private: SawWave, SquareWave, UserDefinedWave, + RandomWave, NumLfoShapes } ; @@ -174,7 +176,6 @@ private: void updateLfoShapeData(); - friend class EnvelopeAndLfoView; friend class FlpImport; diff --git a/include/EnvelopeAndLfoView.h b/include/EnvelopeAndLfoView.h index 8df71b0ed..1ad292456 100644 --- a/include/EnvelopeAndLfoView.h +++ b/include/EnvelopeAndLfoView.h @@ -90,7 +90,8 @@ private: ledCheckBox * m_x100Cb; ledCheckBox * m_controlEnvAmountCb; - + + float m_randomGraph; } ; #endif diff --git a/src/core/EnvelopeAndLfoParameters.cpp b/src/core/EnvelopeAndLfoParameters.cpp index 668fb9d18..066c9132a 100644 --- a/src/core/EnvelopeAndLfoParameters.cpp +++ b/src/core/EnvelopeAndLfoParameters.cpp @@ -68,6 +68,7 @@ void EnvelopeAndLfoParameters::LfoInstances::reset() + void EnvelopeAndLfoParameters::LfoInstances::add( EnvelopeAndLfoParameters * lfo ) { QMutexLocker m( &m_lfoListMutex ); @@ -86,7 +87,6 @@ void EnvelopeAndLfoParameters::LfoInstances::remove( EnvelopeAndLfoParameters * - EnvelopeAndLfoParameters::EnvelopeAndLfoParameters( float _value_for_zero_amount, Model * _parent ) : @@ -218,6 +218,13 @@ inline sample_t EnvelopeAndLfoParameters::lfoShapeSample( fpp_t _frame_offset ) case UserDefinedWave: shape_sample = m_userWave.userWaveSample( phase ); break; + case RandomWave: + if( frame == 0 ) + { + m_random = Oscillator::noiseSample( 0.0f ); + } + shape_sample = m_random; + break; case SineWave: default: shape_sample = Oscillator::sinSample( phase ); diff --git a/src/gui/widgets/EnvelopeAndLfoView.cpp b/src/gui/widgets/EnvelopeAndLfoView.cpp index 034e00d76..450724238 100644 --- a/src/gui/widgets/EnvelopeAndLfoView.cpp +++ b/src/gui/widgets/EnvelopeAndLfoView.cpp @@ -251,7 +251,7 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : tr( "Click here for a square-wave." ) ); m_userLfoBtn = new pixmapButton( this, NULL ); - m_userLfoBtn->move( LFO_SHAPES_X+60, LFO_SHAPES_Y ); + m_userLfoBtn->move( LFO_SHAPES_X+75, LFO_SHAPES_Y ); m_userLfoBtn->setActiveGraphic( embed::getIconPixmap( "usr_wave_active" ) ); m_userLfoBtn->setInactiveGraphic( embed::getIconPixmap( @@ -264,13 +264,22 @@ EnvelopeAndLfoView::EnvelopeAndLfoView( QWidget * _parent ) : connect( m_userLfoBtn, SIGNAL( toggled( bool ) ), this, SLOT( lfoUserWaveChanged() ) ); + pixmapButton * random_lfo_btn = new pixmapButton( this, NULL ); + random_lfo_btn->move( LFO_SHAPES_X+60, LFO_SHAPES_Y ); + random_lfo_btn->setActiveGraphic( embed::getIconPixmap( + "random_wave_active" ) ); + random_lfo_btn->setInactiveGraphic( embed::getIconPixmap( + "random_wave_inactive" ) ); + random_lfo_btn->setWhatsThis( + tr( "Click here for random wave." ) ); + m_lfoWaveBtnGrp = new automatableButtonGroup( this ); m_lfoWaveBtnGrp->addButton( sin_lfo_btn ); m_lfoWaveBtnGrp->addButton( triangle_lfo_btn ); m_lfoWaveBtnGrp->addButton( saw_lfo_btn ); m_lfoWaveBtnGrp->addButton( sqr_lfo_btn ); m_lfoWaveBtnGrp->addButton( m_userLfoBtn ); - + m_lfoWaveBtnGrp->addButton( random_lfo_btn ); m_x100Cb = new ledCheckBox( tr( "FREQ x 100" ), this ); m_x100Cb->setFont( pointSizeF( m_x100Cb->font(), 6.5 ) ); @@ -525,9 +534,17 @@ void EnvelopeAndLfoView::paintEvent( QPaintEvent * ) case EnvelopeAndLfoParameters::SquareWave: val = Oscillator::squareSample( phase ); break; + case EnvelopeAndLfoParameters::RandomWave: + if( x % (int)( 900 * m_lfoSpeedKnob->value() + 1 ) == 0 ) + { + m_randomGraph = Oscillator::noiseSample( 0.0f ); + } + val = m_randomGraph; + break; case EnvelopeAndLfoParameters::UserDefinedWave: val = m_params->m_userWave. userWaveSample( phase ); + break; } if( static_cast( cur_sample ) <= m_params->m_lfoAttackFrames )