diff --git a/ChangeLog b/ChangeLog index c84dc7944..7a429b93d 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2006-03-16 Andreas Brandmaier + + * plugins/organic/organic.cpp + * plugins/organic/organic.h + * plugins/organic/randomise.png + added "randomise preset" button to organic plugin + 2006-03-14 Tobias Doerffel * include/types.h: diff --git a/plugins/organic/organic.cpp b/plugins/organic/organic.cpp index c901f8c53..d64ab3e01 100644 --- a/plugins/organic/organic.cpp +++ b/plugins/organic/organic.cpp @@ -179,7 +179,21 @@ organicInstrument::organicInstrument( channelTrack * _channel_track ) : volKnob->setInitValue( 100 ); volKnob->setHintText( tr( "Osc %1 volume:" ).arg( 1 ) + " ", "%" ); + + // randomise + m_randBtn = new pixmapButton( this ); + m_randBtn->move( 100, 200 ); + m_randBtn->setActiveGraphic( PLUGIN_NAME::getIconPixmap( + "randomise" ) ); + m_randBtn->setInactiveGraphic( PLUGIN_NAME::getIconPixmap( + "randomise" ) ); + //m_randBtn->setMask( QBitmap( PLUGIN_NAME::getIconPixmap( "btn_mask" ). + // createHeuristicMask() ) ); + connect( m_randBtn, SIGNAL ( toggled(bool) ), + this, SLOT( randomiseSettings() ) ); + + // set harmonics m_osc[0].harmonic = 0.5f; // one octave below m_osc[1].harmonic = 0.75f; // a fifth below @@ -479,6 +493,41 @@ void organicInstrument::oscButtonChanged( ) } } +void organicInstrument::randomiseSettings() +{ + + for (int i=0; i < m_num_oscillators; i++) + { + m_osc[i].volKnob->setValue( + intRand(0,100) + ); + + m_osc[i].detuneKnob->setValue( + intRand(-5, 5) + ); + + m_osc[i].panKnob->setValue( + //(int)gaussRand(PANNING_LEFT, PANNING_RIGHT,1,0) + 0 + ); + + m_osc[i].oscKnob->setValue( + intRand(0, 5) + ); + } + +} + +int organicInstrument::intRand( int min, int max ) +{ +// int randn = min+int((max-min)*rand()/(RAND_MAX + 1.0)); +// cout << randn << endl; + int randn = ( rand() % (max-min) ) + min ; + return randn; +} + + + extern "C" { diff --git a/plugins/organic/organic.h b/plugins/organic/organic.h index 15cf2c18c..63b44a8f2 100644 --- a/plugins/organic/organic.h +++ b/plugins/organic/organic.h @@ -66,17 +66,19 @@ public: virtual void FASTCALL loadSettings( const QDomElement & _this ); virtual QString nodeName( void ) const; + + int intRand( int min, int max ); + public slots: void oscButtonChanged( void ); + void randomiseSettings(); private: - float foldback(float in, float threshold); - float saturate(float x, float t); - float distort(float in, float dist); - float waveshape(float in, float amount); + float inline waveshape(float in, float amount); + // fast atan, fast rather than accurate inline float fastatan( float x ) @@ -108,6 +110,7 @@ private: knob * fx1Knob; knob * volKnob; + pixmapButton * m_randBtn; } ; diff --git a/plugins/organic/randomise.png b/plugins/organic/randomise.png new file mode 100644 index 000000000..7b18872b0 Binary files /dev/null and b/plugins/organic/randomise.png differ