Merge pull request #761 from zonkmachine/random-wave-2

Random wave for instrument plugin LFO
This commit is contained in:
Tobias Doerffel
2014-05-26 10:26:09 +02:00
6 changed files with 31 additions and 5 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 533 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 461 B

View File

@@ -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;

View File

@@ -90,7 +90,8 @@ private:
ledCheckBox * m_x100Cb;
ledCheckBox * m_controlEnvAmountCb;
float m_randomGraph;
} ;
#endif

View File

@@ -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 );

View File

@@ -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<float>() + 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<f_cnt_t>( cur_sample ) <=
m_params->m_lfoAttackFrames )