kwave  18.07.70
Kwave::NotchFilterPlugin Class Reference

#include <NotchFilterPlugin.h>

Inheritance diagram for Kwave::NotchFilterPlugin:
Inheritance graph
Collaboration diagram for Kwave::NotchFilterPlugin:
Collaboration graph

Public Member Functions

 NotchFilterPlugin (QObject *parent, const QVariantList &args)
 
virtual ~NotchFilterPlugin () Q_DECL_OVERRIDE
 
virtual Kwave::PluginSetupDialogcreateDialog (QWidget *parent) Q_DECL_OVERRIDE
 
virtual Kwave::SampleSourcecreateFilter (unsigned int tracks) Q_DECL_OVERRIDE
 
virtual bool paramsChanged () Q_DECL_OVERRIDE
 
virtual void updateFilter (Kwave::SampleSource *filter, bool force=false) Q_DECL_OVERRIDE
 
virtual QString actionName () Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::FilterPlugin
 FilterPlugin (QObject *parent, const QVariantList &args)
 
virtual ~FilterPlugin () Q_DECL_OVERRIDE
 
virtual QStringList * setup (QStringList &previous_params) Q_DECL_OVERRIDE
 
virtual void run (QStringList params) Q_DECL_OVERRIDE
 
virtual QString progressText () Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::Plugin
 Plugin (QObject *parent, const QVariantList &args)
 
virtual ~Plugin () Q_DECL_OVERRIDE
 
virtual QString name () const
 
virtual QString description () const
 
virtual bool canClose () const
 
bool isRunning () const
 
bool shouldStop () const
 
virtual void load (QStringList &params)
 
virtual void unload ()
 
virtual int start (QStringList &params)
 
virtual int stop ()
 
Kwave::PluginManagermanager () const
 
Kwave::SignalManagersignalManager ()
 
QWidget * parentWidget () const
 
QString signalName ()
 
virtual sample_index_t signalLength ()
 
virtual double signalRate ()
 
virtual const QList< unsigned int > selectedTracks ()
 
virtual sample_index_t selection (QList< unsigned int > *tracks=Q_NULLPTR, sample_index_t *left=Q_NULLPTR, sample_index_t *right=Q_NULLPTR, bool expand_if_empty=false)
 
virtual void selectRange (sample_index_t offset, sample_index_t length)
 
virtual void migrateToActiveContext ()
 
- Public Member Functions inherited from Kwave::Runnable
virtual ~Runnable ()
 

Protected Slots

void setFreqValue (double frequency)
 
void setBwValue (double bw)
 
- Protected Slots inherited from Kwave::FilterPlugin
void startPreListen ()
 
void stopPreListen ()
 

Protected Member Functions

virtual int interpreteParameters (QStringList &params) Q_DECL_OVERRIDE
 
- Protected Member Functions inherited from Kwave::Plugin
int execute (QStringList &params)
 
void emitCommand (const QString &command)
 
void use ()
 
void setPluginManager (Kwave::PluginManager *new_plugin_manager)
 
virtual void run_wrapper (const QVariant &params) Q_DECL_OVERRIDE
 

Private Attributes

double m_frequency
 
double m_last_freq
 
double m_bw
 
double m_last_bw
 

Additional Inherited Members

- Public Slots inherited from Kwave::Plugin
virtual void setProgressDialogEnabled (bool enable)
 
virtual void updateProgress (qreal progress)
 
virtual void cancel ()
 
virtual void close ()
 
void release ()
 
- Signals inherited from Kwave::FilterPlugin
void sigCancelPressed ()
 
- Signals inherited from Kwave::Plugin
void sigRunning (Kwave::Plugin *plugin)
 
void sigDone (Kwave::Plugin *plugin)
 
void sigClosed (Kwave::Plugin *p)
 
void sigCommand (const QString &command)
 
void setProgressText (const QString &text)
 

Detailed Description

Definition at line 37 of file NotchFilterPlugin.h.

Constructor & Destructor Documentation

◆ NotchFilterPlugin()

Kwave::NotchFilterPlugin::NotchFilterPlugin ( QObject *  parent,
const QVariantList &  args 
)

Constructor

Parameters
parentreference to our plugin manager
argsargument list [unused]

Definition at line 35 of file NotchFilterPlugin.cpp.

◆ ~NotchFilterPlugin()

Kwave::NotchFilterPlugin::~NotchFilterPlugin ( )
virtual

Destructor

Definition at line 43 of file NotchFilterPlugin.cpp.

44 {
45 }

Member Function Documentation

◆ actionName()

QString Kwave::NotchFilterPlugin::actionName ( )
virtual

Returns a verbose name of the performed action. Used for giving the undo action a readable name.

Implements Kwave::FilterPlugin.

Definition at line 119 of file NotchFilterPlugin.cpp.

120 {
121  return i18n("Notch Filter");
122 }

◆ createDialog()

Kwave::PluginSetupDialog * Kwave::NotchFilterPlugin::createDialog ( QWidget *  parent)
virtual

Creates the setup dialog and connects it's signals

Implements Kwave::FilterPlugin.

Definition at line 70 of file NotchFilterPlugin.cpp.

References Kwave::connect(), setBwValue(), setFreqValue(), and Kwave::Plugin::signalRate().

71 {
72  Kwave::NotchFilterDialog *dialog =
73  new Kwave::NotchFilterDialog(parent, signalRate());
74  Q_ASSERT(dialog);
75  if (!dialog) return Q_NULLPTR;
76 
77  // connect the signals for detecting value changes in pre-listen mode
78  connect(dialog, SIGNAL(freqChanged(double)),
79  this, SLOT(setFreqValue(double)));
80  connect(dialog, SIGNAL(bwChanged(double)),
81  this, SLOT(setBwValue(double)));
82  return dialog;
83 }
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
void setFreqValue(double frequency)
virtual double signalRate()
Definition: Plugin.cpp:468
Here is the call graph for this function:

◆ createFilter()

Kwave::SampleSource * Kwave::NotchFilterPlugin::createFilter ( unsigned int  tracks)
virtual

Creates a multi-track filter with the given number of tracks

Parameters
tracksnumber of tracks that the filter should have
Returns
pointer to the filter or null if failed

Implements Kwave::FilterPlugin.

Definition at line 86 of file NotchFilterPlugin.cpp.

◆ interpreteParameters()

int Kwave::NotchFilterPlugin::interpreteParameters ( QStringList &  params)
protectedvirtual

Reads values from the parameter list

Implements Kwave::FilterPlugin.

Definition at line 48 of file NotchFilterPlugin.cpp.

References m_bw, and m_frequency.

49 {
50  bool ok;
51  QString param;
52 
53  // evaluate the parameter list
54  if (params.count() != 2) return -EINVAL;
55 
56  param = params[0];
57  m_frequency = param.toDouble(&ok);
58  Q_ASSERT(ok);
59  if (!ok) return -EINVAL;
60 
61  param = params[1];
62  m_bw = param.toDouble(&ok);
63  Q_ASSERT(ok);
64  if (!ok) return -EINVAL;
65 
66  return 0;
67 }

◆ paramsChanged()

bool Kwave::NotchFilterPlugin::paramsChanged ( )
virtual

Returns true if the parameters have changed during pre-listen.

Reimplemented from Kwave::FilterPlugin.

Definition at line 92 of file NotchFilterPlugin.cpp.

References m_bw, m_frequency, m_last_bw, and m_last_freq.

93 {
94  return (!qFuzzyCompare(m_frequency, m_last_freq) ||
95  !qFuzzyCompare(m_bw, m_last_bw));
96 }

◆ setBwValue

void Kwave::NotchFilterPlugin::setBwValue ( double  bw)
protectedslot

set a new bandwidth

Parameters
bwbandwidth [Hz]

Definition at line 131 of file NotchFilterPlugin.cpp.

References m_bw.

Referenced by createDialog().

132 {
133  m_bw = bw;
134 }
Here is the caller graph for this function:

◆ setFreqValue

void Kwave::NotchFilterPlugin::setFreqValue ( double  frequency)
protectedslot

Called when the parameter changed during pre-listen

Parameters
frequencythe frequency parameter in Hz

Definition at line 125 of file NotchFilterPlugin.cpp.

References m_frequency.

Referenced by createDialog().

126 {
127  m_frequency = frequency;
128 }
Here is the caller graph for this function:

◆ updateFilter()

void Kwave::NotchFilterPlugin::updateFilter ( Kwave::SampleSource filter,
bool  force = false 
)
virtual

Update the filter with new parameters if it has changed changed during the pre-listen.

Parameters
filterthe Kwave::SampleSource to be updated, should be the same one as created with createFilter()
forceif true, even update if no settings have changed

Reimplemented from Kwave::FilterPlugin.

Definition at line 99 of file NotchFilterPlugin.cpp.

References m_bw, m_frequency, m_last_bw, m_last_freq, Kwave::StreamObject::setAttribute(), and Kwave::Plugin::signalRate().

101 {
102  double sr = signalRate();
103 
104  if (!filter) return;
105 
106  if (!qFuzzyCompare(m_frequency, m_last_freq) || force)
107  filter->setAttribute(SLOT(setFrequency(QVariant)),
108  QVariant((m_frequency * 2.0 * M_PI) / sr));
109 
110  if (!qFuzzyCompare(m_bw, m_last_bw) || force)
111  filter->setAttribute(SLOT(setBandwidth(QVariant)),
112  QVariant((m_bw * 2.0 * M_PI) / sr));
113 
115  m_last_bw = m_bw;
116 }
virtual double signalRate()
Definition: Plugin.cpp:468
void setAttribute(const char *attribute, const QVariant &value)
Here is the call graph for this function:

Member Data Documentation

◆ m_bw

double Kwave::NotchFilterPlugin::m_bw
private

bandwidth value [Hz]

Definition at line 114 of file NotchFilterPlugin.h.

Referenced by interpreteParameters(), paramsChanged(), setBwValue(), and updateFilter().

◆ m_frequency

double Kwave::NotchFilterPlugin::m_frequency
private

cutoff frequency [Hz]

Definition at line 108 of file NotchFilterPlugin.h.

Referenced by interpreteParameters(), paramsChanged(), setFreqValue(), and updateFilter().

◆ m_last_bw

double Kwave::NotchFilterPlugin::m_last_bw
private

last value of m_bw

Definition at line 117 of file NotchFilterPlugin.h.

Referenced by paramsChanged(), and updateFilter().

◆ m_last_freq

double Kwave::NotchFilterPlugin::m_last_freq
private

last value of m_frequency

Definition at line 111 of file NotchFilterPlugin.h.

Referenced by paramsChanged(), and updateFilter().


The documentation for this class was generated from the following files: