Distortion effect added
This commit is contained in:
parent
fd91c88e6a
commit
27e46d5331
|
@ -327,6 +327,8 @@ audacity_SOURCES = \
|
|||
effects/Compressor.h \
|
||||
effects/Contrast.cpp \
|
||||
effects/Contrast.h \
|
||||
effects/Distortion.cpp \
|
||||
effects/Distortion.h \
|
||||
effects/DtmfGen.cpp \
|
||||
effects/DtmfGen.h \
|
||||
effects/Echo.cpp \
|
||||
|
|
|
@ -351,6 +351,7 @@ am__audacity_SOURCES_DIST = BlockFile.cpp BlockFile.h DirManager.cpp \
|
|||
effects/ChangeTempo.h effects/ClickRemoval.cpp \
|
||||
effects/ClickRemoval.h effects/Compressor.cpp \
|
||||
effects/Compressor.h effects/Contrast.cpp effects/Contrast.h \
|
||||
effects/Distortion.cpp effects/Distortion.h \
|
||||
effects/DtmfGen.cpp effects/DtmfGen.h effects/Echo.cpp \
|
||||
effects/Echo.h effects/Effect.cpp effects/Effect.h \
|
||||
effects/EffectManager.cpp effects/EffectManager.h \
|
||||
|
@ -599,6 +600,7 @@ am_audacity_OBJECTS = $(am__objects_1) audacity-AboutDialog.$(OBJEXT) \
|
|||
effects/audacity-ClickRemoval.$(OBJEXT) \
|
||||
effects/audacity-Compressor.$(OBJEXT) \
|
||||
effects/audacity-Contrast.$(OBJEXT) \
|
||||
effects/audacity-Distortion.$(OBJEXT) \
|
||||
effects/audacity-DtmfGen.$(OBJEXT) \
|
||||
effects/audacity-Echo.$(OBJEXT) \
|
||||
effects/audacity-Effect.$(OBJEXT) \
|
||||
|
@ -1223,6 +1225,7 @@ audacity_SOURCES = $(libaudacity_la_SOURCES) AboutDialog.cpp \
|
|||
effects/ChangeTempo.h effects/ClickRemoval.cpp \
|
||||
effects/ClickRemoval.h effects/Compressor.cpp \
|
||||
effects/Compressor.h effects/Contrast.cpp effects/Contrast.h \
|
||||
effects/Distortion.cpp effects/Distortion.h \
|
||||
effects/DtmfGen.cpp effects/DtmfGen.h effects/Echo.cpp \
|
||||
effects/Echo.h effects/Effect.cpp effects/Effect.h \
|
||||
effects/EffectManager.cpp effects/EffectManager.h \
|
||||
|
@ -1603,6 +1606,8 @@ effects/audacity-Compressor.$(OBJEXT): effects/$(am__dirstamp) \
|
|||
effects/$(DEPDIR)/$(am__dirstamp)
|
||||
effects/audacity-Contrast.$(OBJEXT): effects/$(am__dirstamp) \
|
||||
effects/$(DEPDIR)/$(am__dirstamp)
|
||||
effects/audacity-Distortion.$(OBJEXT): effects/$(am__dirstamp) \
|
||||
effects/$(DEPDIR)/$(am__dirstamp)
|
||||
effects/audacity-DtmfGen.$(OBJEXT): effects/$(am__dirstamp) \
|
||||
effects/$(DEPDIR)/$(am__dirstamp)
|
||||
effects/audacity-Echo.$(OBJEXT): effects/$(am__dirstamp) \
|
||||
|
@ -2142,6 +2147,7 @@ distclean-compile:
|
|||
@AMDEP_TRUE@@am__include@ @am__quote@effects/$(DEPDIR)/audacity-ClickRemoval.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@effects/$(DEPDIR)/audacity-Compressor.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@effects/$(DEPDIR)/audacity-Contrast.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@effects/$(DEPDIR)/audacity-Distortion.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@effects/$(DEPDIR)/audacity-DtmfGen.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@effects/$(DEPDIR)/audacity-Echo.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@effects/$(DEPDIR)/audacity-Effect.Po@am__quote@
|
||||
|
@ -4146,6 +4152,20 @@ effects/audacity-Contrast.obj: effects/Contrast.cpp
|
|||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o effects/audacity-Contrast.obj `if test -f 'effects/Contrast.cpp'; then $(CYGPATH_W) 'effects/Contrast.cpp'; else $(CYGPATH_W) '$(srcdir)/effects/Contrast.cpp'; fi`
|
||||
|
||||
effects/audacity-Distortion.o: effects/Distortion.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT effects/audacity-Distortion.o -MD -MP -MF effects/$(DEPDIR)/audacity-Distortion.Tpo -c -o effects/audacity-Distortion.o `test -f 'effects/Distortion.cpp' || echo '$(srcdir)/'`effects/Distortion.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) effects/$(DEPDIR)/audacity-Distortion.Tpo effects/$(DEPDIR)/audacity-Distortion.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='effects/Distortion.cpp' object='effects/audacity-Distortion.o' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o effects/audacity-Distortion.o `test -f 'effects/Distortion.cpp' || echo '$(srcdir)/'`effects/Distortion.cpp
|
||||
|
||||
effects/audacity-Distortion.obj: effects/Distortion.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT effects/audacity-Distortion.obj -MD -MP -MF effects/$(DEPDIR)/audacity-Distortion.Tpo -c -o effects/audacity-Distortion.obj `if test -f 'effects/Distortion.cpp'; then $(CYGPATH_W) 'effects/Distortion.cpp'; else $(CYGPATH_W) '$(srcdir)/effects/Distortion.cpp'; fi`
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) effects/$(DEPDIR)/audacity-Distortion.Tpo effects/$(DEPDIR)/audacity-Distortion.Po
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ $(AM_V_CXX)source='effects/Distortion.cpp' object='effects/audacity-Distortion.obj' libtool=no @AMDEPBACKSLASH@
|
||||
@AMDEP_TRUE@@am__fastdepCXX_FALSE@ DEPDIR=$(DEPDIR) $(CXXDEPMODE) $(depcomp) @AMDEPBACKSLASH@
|
||||
@am__fastdepCXX_FALSE@ $(AM_V_CXX@am__nodep@)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -c -o effects/audacity-Distortion.obj `if test -f 'effects/Distortion.cpp'; then $(CYGPATH_W) 'effects/Distortion.cpp'; else $(CYGPATH_W) '$(srcdir)/effects/Distortion.cpp'; fi`
|
||||
|
||||
effects/audacity-DtmfGen.o: effects/DtmfGen.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_CXX)$(CXX) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(audacity_CPPFLAGS) $(CPPFLAGS) $(audacity_CXXFLAGS) $(CXXFLAGS) -MT effects/audacity-DtmfGen.o -MD -MP -MF effects/$(DEPDIR)/audacity-DtmfGen.Tpo -c -o effects/audacity-DtmfGen.o `test -f 'effects/DtmfGen.cpp' || echo '$(srcdir)/'`effects/DtmfGen.cpp
|
||||
@am__fastdepCXX_TRUE@ $(AM_V_at)$(am__mv) effects/$(DEPDIR)/audacity-DtmfGen.Tpo effects/$(DEPDIR)/audacity-DtmfGen.Po
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,218 @@
|
|||
/**********************************************************************
|
||||
|
||||
Audacity: A Digital Audio Editor
|
||||
|
||||
Distortion.h
|
||||
|
||||
Steve Daulton
|
||||
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef __AUDACITY_EFFECT_DISTORTION__
|
||||
#define __AUDACITY_EFFECT_DISTORTION__
|
||||
|
||||
#include <wx/arrstr.h>
|
||||
#include <wx/string.h>
|
||||
#include <wx/slider.h>
|
||||
#include <wx/textctrl.h>
|
||||
#include <wx/checkbox.h>
|
||||
|
||||
#include <queue>
|
||||
|
||||
#include "Effect.h"
|
||||
|
||||
class ShuttleGui;
|
||||
|
||||
#define DISTORTION_PLUGIN_SYMBOL XO("Distortion")
|
||||
#define STEPS 1024 // number of +ve or -ve steps in lookup tabe
|
||||
#define TABLESIZE 2049 // size of lookup table (steps * 2 + 1)
|
||||
|
||||
class EffectDistortionState
|
||||
{
|
||||
public:
|
||||
float samplerate;
|
||||
sampleCount skipcount;
|
||||
int tablechoiceindx;
|
||||
bool dcblock;
|
||||
double threshold;
|
||||
double noisefloor;
|
||||
double param1;
|
||||
double param2;
|
||||
int repeats;
|
||||
|
||||
// DC block filter variables
|
||||
std::queue<float> queuesamples;
|
||||
double queuetotal;
|
||||
};
|
||||
|
||||
WX_DECLARE_OBJARRAY(EffectDistortionState, EffectDistortionStateArray);
|
||||
|
||||
class EffectDistortion final : public Effect
|
||||
{
|
||||
public:
|
||||
EffectDistortion();
|
||||
virtual ~EffectDistortion();
|
||||
|
||||
struct Params
|
||||
{
|
||||
int mTableChoiceIndx;
|
||||
bool mDCBlock;
|
||||
double mThreshold_dB;
|
||||
double mNoiseFloor;
|
||||
double mParam1;
|
||||
double mParam2;
|
||||
int mRepeats;
|
||||
};
|
||||
|
||||
// IdentInterface implementation
|
||||
|
||||
wxString GetSymbol() override;
|
||||
wxString GetDescription() override;
|
||||
|
||||
// EffectIdentInterface implementation
|
||||
|
||||
EffectType GetType() override;
|
||||
bool SupportsRealtime() override;
|
||||
|
||||
// EffectClientInterface implementation
|
||||
|
||||
int GetAudioInCount() override;
|
||||
int GetAudioOutCount() override;
|
||||
bool ProcessInitialize(sampleCount totalLen, ChannelNames chanMap = NULL) override;
|
||||
sampleCount ProcessBlock(float **inBlock, float **outBlock, sampleCount blockLen) override;
|
||||
bool RealtimeInitialize() override;
|
||||
bool RealtimeAddProcessor(int numChannels, float sampleRate) override;
|
||||
bool RealtimeFinalize() override;
|
||||
sampleCount RealtimeProcess(int group,
|
||||
float **inbuf,
|
||||
float **outbuf,
|
||||
sampleCount numSamples) override;
|
||||
bool GetAutomationParameters(EffectAutomationParameters & parms) override;
|
||||
bool SetAutomationParameters(EffectAutomationParameters & parms) override;
|
||||
wxArrayString GetFactoryPresets() override;
|
||||
bool LoadFactoryPreset(int id) override;
|
||||
|
||||
// Effect implementation
|
||||
|
||||
void PopulateOrExchange(ShuttleGui & S) override;
|
||||
bool TransferDataToWindow() override;
|
||||
bool TransferDataFromWindow() override;
|
||||
|
||||
private:
|
||||
|
||||
enum control
|
||||
{
|
||||
ID_Type = 10000,
|
||||
ID_DCBlock,
|
||||
ID_Threshold,
|
||||
ID_NoiseFloor,
|
||||
ID_Param1,
|
||||
ID_Param2,
|
||||
ID_Repeats,
|
||||
};
|
||||
// EffectDistortion implementation
|
||||
|
||||
void InstanceInit(EffectDistortionState & data, float sampleRate);
|
||||
sampleCount InstanceProcess(EffectDistortionState & data,
|
||||
float **inBlock,
|
||||
float **outBlock,
|
||||
sampleCount blockLen);
|
||||
|
||||
// Control Handlers
|
||||
|
||||
void OnTypeChoice(wxCommandEvent & evt);
|
||||
void OnDCBlockCheckbox(wxCommandEvent & evt);
|
||||
void OnThresholdText(wxCommandEvent & evt);
|
||||
void OnThresholdSlider(wxCommandEvent & evt);
|
||||
void OnNoiseFloorText(wxCommandEvent & evt);
|
||||
void OnNoiseFloorSlider(wxCommandEvent & evt);
|
||||
void OnParam1Text(wxCommandEvent & evt);
|
||||
void OnParam1Slider(wxCommandEvent & evt);
|
||||
void OnParam2Text(wxCommandEvent & evt);
|
||||
void OnParam2Slider(wxCommandEvent & evt);
|
||||
void OnRepeatsText(wxCommandEvent & evt);
|
||||
void OnRepeatsSlider(wxCommandEvent & evt);
|
||||
void UpdateUI();
|
||||
void UpdateControl(control id, bool enable, wxString name);
|
||||
void UpdateControlText(wxTextCtrl *textCtrl, wxString &string, bool enabled);
|
||||
|
||||
void MakeTable();
|
||||
float WaveShaper(float sample);
|
||||
float DCFilter(EffectDistortionState & data, float sample);
|
||||
|
||||
// Preset tables for gain lookup
|
||||
|
||||
void HardClip(); // hard clipping
|
||||
void SoftClip(); // soft clipping
|
||||
void ExponentialTable(); // exponential mapping
|
||||
void LogarithmicTable(); // logarithmic mapping
|
||||
void HalfSinTable();
|
||||
void CubicTable();
|
||||
void EvenHarmonicTable();
|
||||
void SineTable();
|
||||
void Leveller(); // 'Leveller' wavetable is modeled on the legacy effect of the same name.
|
||||
void Rectifier(); // 0% = Dry, 50% = half-wave rectified, 100% = full-wave rectified (abs value).
|
||||
void HardLimiter(); // Same effect as the LADSPA "hardLimiter 1413"
|
||||
|
||||
// Wavetable helper functions
|
||||
|
||||
void CopyHalfTable(); // for symmetric tables
|
||||
|
||||
// Used by Soft Clipping but could be used for other tables.
|
||||
// Log curve formula: y = T + (((e^(RT - Rx)) - 1) / -R)
|
||||
// where R is the ratio, T is the threshold, and x is from T to 1.
|
||||
inline float LogCurve(double threshold, float value, double ratio);
|
||||
|
||||
// Used by Cubic curve but could be used for other tables
|
||||
// Cubic formula: y = x - (x^3 / 3.0)
|
||||
inline double Cubic(double x);
|
||||
|
||||
|
||||
private:
|
||||
EffectDistortionState mMaster;
|
||||
EffectDistortionStateArray mSlaves;
|
||||
|
||||
double mTable[TABLESIZE];
|
||||
double mThreshold;
|
||||
bool mbSavedFilterState;
|
||||
|
||||
// mMakeupGain is used by some distortion types to pass the
|
||||
// amount of gain required to bring overall effect gain to unity
|
||||
double mMakeupGain;
|
||||
|
||||
int mTypChoiceIndex;
|
||||
wxArrayString mTableTypes;
|
||||
|
||||
wxChoice *mTypeChoiceCtrl;
|
||||
wxTextCtrl *mThresholdT;
|
||||
wxTextCtrl *mNoiseFloorT;
|
||||
wxTextCtrl *mParam1T;
|
||||
wxTextCtrl *mParam2T;
|
||||
wxTextCtrl *mRepeatsT;
|
||||
|
||||
wxSlider *mThresholdS;
|
||||
wxSlider *mNoiseFloorS;
|
||||
wxSlider *mParam1S;
|
||||
wxSlider *mParam2S;
|
||||
wxSlider *mRepeatsS;
|
||||
|
||||
wxCheckBox *mDCBlockCheckBox;
|
||||
|
||||
wxStaticText *mThresholdTxt;
|
||||
wxStaticText *mNoiseFloorTxt;
|
||||
wxStaticText *mParam1Txt;
|
||||
wxStaticText *mParam2Txt;
|
||||
wxStaticText *mRepeatsTxt;
|
||||
|
||||
wxString mOldThresholdTxt;
|
||||
wxString mOldmNoiseFloorTxt;
|
||||
wxString mOldParam1Txt;
|
||||
wxString mOldParam2Txt;
|
||||
wxString mOldRepeatsTxt;
|
||||
|
||||
Params mParams;
|
||||
|
||||
DECLARE_EVENT_TABLE();
|
||||
};
|
||||
|
||||
#endif
|
|
@ -23,6 +23,7 @@
|
|||
#include "ChangeSpeed.h"
|
||||
#include "ClickRemoval.h"
|
||||
#include "Compressor.h"
|
||||
#include "Distortion.h"
|
||||
#include "DtmfGen.h"
|
||||
#include "Echo.h"
|
||||
#include "Paulstretch.h"
|
||||
|
@ -116,6 +117,7 @@
|
|||
EFFECT( CHANGESPEED, EffectChangeSpeed, () ) \
|
||||
EFFECT( CLICKREMOVAL, EffectClickRemoval, () ) \
|
||||
EFFECT( COMPRESSOR, EffectCompressor, () ) \
|
||||
EFFECT( DISTORTION, EffectDistortion, () ) \
|
||||
EFFECT( ECHO, EffectEcho, () ) \
|
||||
EFFECT( EQUALIZATION, EffectEqualization, () ) \
|
||||
EFFECT( FADEIN, EffectFade, (true) ) \
|
||||
|
|
Loading…
Reference in New Issue