Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Phaser effect to LMMS #5168

Closed
wants to merge 32 commits into from
Closed
Show file tree
Hide file tree
Changes from 23 commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
7f1c954
Merge pull request #8 from LMMS/master
LostRobotMusic Jun 21, 2019
0bb50a8
Merge pull request #11 from LMMS/master
LostRobotMusic Aug 7, 2019
a332d47
Merge pull request #12 from LMMS/master
LostRobotMusic Aug 30, 2019
5f0aacc
Merge pull request #13 from LMMS/master
LostRobotMusic Sep 4, 2019
6f4afb1
Add Phaser effect, upgrade Flanger effect
LostRobotMusic Sep 4, 2019
b41a6a9
Resolve code/style reviews
LostRobotMusic Sep 4, 2019
b9d1b45
Resolve code/style reviews, don't calulate LFO rate every loop
LostRobotMusic Sep 4, 2019
9a8fdfa
Rename Phaser.cpp and Phaser.h to PhaserEffect.cpp and PhaserEffect.h
LostRobotMusic Sep 4, 2019
4e1ba1d
Remove unnecessary Phaser disconnection
LostRobotMusic Sep 5, 2019
b7dd6d1
Fix Phaser artwork LFO font
LostRobotMusic Sep 5, 2019
779d1b5
Merge branch 'master' into phaser
LostRobotMusic Nov 24, 2019
bd9ee92
Add Phaser to plugin list
LostRobotMusic Nov 24, 2019
8534cab
Add many enhancements for the Phaser effect
LostRobotMusic Feb 17, 2020
34221f3
Fix stuff
LostRobotMusic Feb 17, 2020
ed7c1b2
Fix stuff 2: Electric Boogaloo
LostRobotMusic Feb 17, 2020
b467652
Fix stuff 3: No joke here
LostRobotMusic Feb 17, 2020
47e6f6a
Resolve code and style reviews
LostRobotMusic Feb 26, 2020
185ce06
Resolve more code and style reviews
LostRobotMusic Apr 18, 2020
fbd62a6
Input follower range buff
LostRobotMusic May 17, 2020
81bbf89
Make LFO Rate logarithmic by default
LostRobotMusic May 17, 2020
df143d1
Remove RMS from input follower
LostRobotMusic Oct 26, 2020
c5ce560
Fix compilation complaints
LostRobotMusic Oct 26, 2020
6b97fb5
Major update
LostRobotMusic Dec 11, 2020
9e9a824
Fix stuffs
LostRobotMusic Dec 15, 2020
9cd0ecf
Fix more stuffs
LostRobotMusic Dec 15, 2020
801acf4
Add Input Follower enable button
LostRobotMusic Dec 16, 2020
3211fe6
Initialize QuadratureLfo's frequency and phase in constructor
LostRobotMusic Dec 16, 2020
ab2dee9
Why is it called oven when you of in the cold food of out hot eat the…
LostRobotMusic Jan 15, 2021
b4bac58
Revert one of the modes to its original naming, due to very high demand.
LostRobotMusic Feb 25, 2021
e597a2c
Fix merge conflicts with Flanger upgrade PR
LostRobotMusic Mar 25, 2021
f436816
Continue running Phaser while LFO is disabled
LostRobotMusic Mar 25, 2021
f679542
Fix inaccurate comment
LostRobotMusic Mar 25, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cmake/modules/PluginList.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ SET(LMMS_PLUGIN_LIST
FreeBoy
patman
peak_controller_effect
Phaser
GigPlayer
ReverbSC
sf2_player
Expand Down
2 changes: 1 addition & 1 deletion plugins/Flanger/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
INCLUDE(BuildPlugin)

BUILD_PLUGIN(flanger FlangerEffect.cpp FlangerControls.cpp FlangerControlsDialog.cpp Noise.cpp QuadratureLfo.cpp MonoDelay.cpp MOCFILES FlangerControls.h FlangerControlsDialog.h EMBEDDED_RESOURCES artwork.png logo.png)
BUILD_PLUGIN(flanger FlangerEffect.cpp FlangerControls.cpp FlangerControlsDialog.cpp Noise.cpp MonoDelay.cpp MOCFILES FlangerEffect.h FlangerControls.h FlangerControlsDialog.h EMBEDDED_RESOURCES artwork.png logo.png)
34 changes: 9 additions & 25 deletions plugins/Flanger/FlangerControls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,23 +27,21 @@
#include "FlangerControls.h"
#include "FlangerEffect.h"
#include "Engine.h"
#include "Song.h"



FlangerControls::FlangerControls( FlangerEffect *effect ) :
EffectControls ( effect ),
m_effect ( effect ),
m_delayTimeModel(0.001, 0.0001, 0.050, 0.0001, this, tr( "Delay samples" ) ) ,
m_lfoFrequencyModel( 0.25, 0.01, 60, 0.0001, 60000.0 ,this, tr( "LFO frequency" ) ),
m_lfoAmountModel( 0.0, 0.0, 0.0025 , 0.0001 , this , tr( "Seconds" ) ),
m_feedbackModel( 0.0 , 0.0 , 1.0 , 0.0001, this, tr( "Regen" ) ),
m_whiteNoiseAmountModel( 0.0 , 0.0 , 0.05 , 0.0001, this, tr( "Noise" ) ),
m_invertFeedbackModel ( false , this, tr( "Invert" ) )
m_delayTimeModel(0.001, 0.0001, 0.050, 0.0001, this, tr( "Delay samples" ) ),
m_lfoFrequencyModel( 0.25, 0.01, 60, 0.0001, 60000.0, this, tr( "LFO frequency" ) ),
m_lfoAmountModel( 0.0, 0.0, 0.0025, 0.0001, this, tr( "Seconds" ) ),
m_lfoPhaseModel( 90.0, 0.0, 360.0, 0.0001, this, tr( "Stereo Phase" ) ),
m_feedbackModel( 0.0, -1.0, 1.0, 0.0001, this, tr( "Regen" ) ),
m_whiteNoiseAmountModel( 0.0, 0.0, 0.05, 0.0001, this, tr( "Noise" ) ),
m_invertFeedbackModel ( false, this, tr( "Invert" ) )

{
connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changedSampleRate() ) );
connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), this, SLOT( changedPlaybackState() ) );
}


Expand All @@ -54,6 +52,7 @@ void FlangerControls::loadSettings( const QDomElement &_this )
m_delayTimeModel.loadSettings( _this, "DelayTimeSamples" );
m_lfoFrequencyModel.loadSettings( _this, "LfoFrequency" );
m_lfoAmountModel.loadSettings( _this, "LfoAmount" );
m_lfoPhaseModel.loadSettings( _this, "LfoPhase" );
m_feedbackModel.loadSettings( _this, "Feedback" );
m_whiteNoiseAmountModel.loadSettings( _this, "WhiteNoise" );
m_invertFeedbackModel.loadSettings( _this, "Invert" );
Expand All @@ -68,23 +67,8 @@ void FlangerControls::saveSettings( QDomDocument &doc, QDomElement &parent )
m_delayTimeModel.saveSettings( doc , parent, "DelayTimeSamples" );
m_lfoFrequencyModel.saveSettings( doc, parent , "LfoFrequency" );
m_lfoAmountModel.saveSettings( doc, parent , "LfoAmount" );
m_lfoPhaseModel.saveSettings( doc, parent , "LfoPhase" );
m_feedbackModel.saveSettings( doc, parent, "Feedback" ) ;
m_whiteNoiseAmountModel.saveSettings( doc, parent , "WhiteNoise" ) ;
m_invertFeedbackModel.saveSettings( doc, parent, "Invert" );
}




void FlangerControls::changedSampleRate()
{
m_effect->changeSampleRate();
}




void FlangerControls::changedPlaybackState()
{
m_effect->restartLFO();
}
7 changes: 2 additions & 5 deletions plugins/Flanger/FlangerControls.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,22 +48,19 @@ class FlangerControls : public EffectControls
}
virtual int controlCount()
{
return 5;
return 7;
}
virtual EffectControlDialog* createView()
{
return new FlangerControlsDialog( this );
}

private slots:
void changedSampleRate();
void changedPlaybackState();

private:
FlangerEffect* m_effect;
FloatModel m_delayTimeModel;
TempoSyncKnobModel m_lfoFrequencyModel;
FloatModel m_lfoAmountModel;
FloatModel m_lfoPhaseModel;
FloatModel m_feedbackModel;
FloatModel m_whiteNoiseAmountModel;
BoolModel m_invertFeedbackModel;
Expand Down
13 changes: 10 additions & 3 deletions plugins/Flanger/FlangerControlsDialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ FlangerControlsDialog::FlangerControlsDialog( FlangerControls *controls ) :
QPalette pal;
pal.setBrush( backgroundRole(), PLUGIN_NAME::getIconPixmap( "artwork" ) );
setPalette( pal );
setFixedSize( 195, 75 );
setFixedSize( 233, 75 );

Knob* delayKnob = new Knob( knobBright_26, this );
delayKnob->move( 10,10 );
Expand All @@ -61,15 +61,22 @@ FlangerControlsDialog::FlangerControlsDialog( FlangerControls *controls ) :
lfoAmtKnob->setLabel( tr( "AMNT" ) );
lfoAmtKnob->setHintText( tr( "Amount:" ) , "" );

Knob * lfoPhaseKnob = new Knob( knobBright_26, this );
lfoPhaseKnob->move( 123,10 );
lfoPhaseKnob->setVolumeKnob( false );
lfoPhaseKnob->setModel( &controls->m_lfoPhaseModel );
lfoPhaseKnob->setLabel( tr( "PHASE" ) );
lfoPhaseKnob->setHintText( tr( "Phase:" ) , "" );

Knob * feedbackKnob = new Knob( knobBright_26, this );
feedbackKnob->move( 122,10 );
feedbackKnob->move( 160,10 );
feedbackKnob->setVolumeKnob( true) ;
feedbackKnob->setModel( &controls->m_feedbackModel );
feedbackKnob->setLabel( tr( "FDBK" ) );
feedbackKnob->setHintText( tr( "Feedback amount:" ) , "" );

Knob * whiteNoiseKnob = new Knob( knobBright_26, this );
whiteNoiseKnob->move( 156,10 );
whiteNoiseKnob->move( 196,10 );
whiteNoiseKnob->setVolumeKnob( true) ;
whiteNoiseKnob->setModel( &controls->m_whiteNoiseAmountModel );
whiteNoiseKnob->setLabel( tr( "NOISE" ) );
Expand Down
14 changes: 12 additions & 2 deletions plugins/Flanger/FlangerEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

#include "FlangerEffect.h"
#include "Engine.h"
#include "Song.h"

#include "embed.h"
#include "plugin_export.h"
Expand Down Expand Up @@ -55,6 +56,11 @@ FlangerEffect::FlangerEffect( Model *parent, const Plugin::Descriptor::SubPlugin
m_lDelay = new MonoDelay( 1, Engine::mixer()->processingSampleRate() );
m_rDelay = new MonoDelay( 1, Engine::mixer()->processingSampleRate() );
m_noise = new Noise;

connect( Engine::mixer(), SIGNAL( sampleRateChanged() ), this, SLOT( changeSampleRate() ) );
connect( Engine::getSong(), SIGNAL( playbackStateChanged() ), this, SLOT( restartLFO() ) );

connect( &m_flangerControls.m_lfoPhaseModel, SIGNAL( dataChanged() ), this, SLOT( updatePhase() ) );
}


Expand Down Expand Up @@ -140,14 +146,18 @@ void FlangerEffect::changeSampleRate()
}




void FlangerEffect::restartLFO()
{
m_lfo->restart();
}


void FlangerEffect::updatePhase()
{
m_lfo->setOffset( m_flangerControls.m_lfoPhaseModel.value() / 180 * D_PI );
}




extern "C"
Expand Down
6 changes: 6 additions & 0 deletions plugins/Flanger/FlangerEffect.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@

class FlangerEffect : public Effect
{
Q_OBJECT
public:
FlangerEffect( Model* parent , const Descriptor::SubPluginFeatures::Key* key );
virtual ~FlangerEffect();
Expand All @@ -43,7 +44,10 @@ class FlangerEffect : public Effect
{
return &m_flangerControls;
}

private slots:
void changeSampleRate();
void updatePhase();
void restartLFO();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't like putting slots to effects because the corresponding control class is supposed to handle them by design, at least in existing plugins.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it would be best to do it this way since it's modifying variables in PhaserEffect rather than PhaserControls. Would it be better for me to put those functions into PhaserControls and modify the values in PhaserEffect from there? I feel like that wouldn't look as neat. What's the reason for keeping these things in PhaserControls?


private:
Expand All @@ -53,6 +57,8 @@ class FlangerEffect : public Effect
QuadratureLfo* m_lfo;
Noise* m_noise;

friend class FlangerControls;

};

#endif // FLANGEREFFECT_H
31 changes: 22 additions & 9 deletions plugins/Flanger/QuadratureLfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,51 +30,64 @@
class QuadratureLfo
{
public:
QuadratureLfo( int sampleRate );
QuadratureLfo( int sampleRate )
{
setSampleRate(sampleRate);
}
~QuadratureLfo()
{
}

inline void setFrequency( double frequency )
{
if( frequency < 0 || frequency > ( m_samplerate / 2.0 ) || frequency == m_frequency )
if( frequency < 0 || frequency > m_samplerate / 2.0 || frequency == m_frequency )
{
return;
}
m_frequency = frequency;
m_increment = m_frequency * m_twoPiOverSr;

if( m_phase >= F_2PI )
if( m_phase >= D_2PI )
{
m_phase -= F_2PI;
m_phase -= D_2PI;
}
}




inline void restart()
{
m_phase = 0;
}




inline void setSampleRate ( int samplerate )
{
m_samplerate = samplerate;
m_twoPiOverSr = F_2PI / samplerate;
m_increment = m_frequency * m_twoPiOverSr;
}

void tick( float *s, float *c );

inline void setOffset( double offsetVal )
{
m_offset = offsetVal;
}


void tick( float *l, float *r )
{
*l = sinf( m_phase );
*r = sinf( m_phase + m_offset );
m_phase += m_increment;

}

private:
double m_frequency;
double m_phase;
double m_increment;
double m_twoPiOverSr;
double m_offset = D_PI;
int m_samplerate;

};
Expand Down
3 changes: 3 additions & 0 deletions plugins/Phaser/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
INCLUDE(BuildPlugin)

BUILD_PLUGIN(Phaser PhaserEffect.cpp PhaserControls.cpp PhaserControlDialog.cpp MOCFILES PhaserEffect.h PhaserControls.h PhaserControlDialog.h ../Eq/EqFader.h EMBEDDED_RESOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.png")
Loading