kwave  18.07.70
Kwave::PitchShiftPlugin Class Reference

#include <PitchShiftPlugin.h>

Inheritance diagram for Kwave::PitchShiftPlugin:
Inheritance graph
Collaboration diagram for Kwave::PitchShiftPlugin:
Collaboration graph

Public Member Functions

 PitchShiftPlugin (QObject *parent, const QVariantList &args)
 
virtual ~PitchShiftPlugin () 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 setValues (double speed, double frequency)
 
- 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_speed
 
double m_frequency
 
bool m_percentage_mode
 
double m_last_speed
 
double m_last_freq
 

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 PitchShiftPlugin.h.

Constructor & Destructor Documentation

◆ PitchShiftPlugin()

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

Constructor

Parameters
parentreference to our plugin manager
argsargument list [unused]

Definition at line 34 of file PitchShiftPlugin.cpp.

◆ ~PitchShiftPlugin()

Kwave::PitchShiftPlugin::~PitchShiftPlugin ( )
virtual

Destructor

Definition at line 43 of file PitchShiftPlugin.cpp.

44 {
45 }

Member Function Documentation

◆ actionName()

QString Kwave::PitchShiftPlugin::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 122 of file PitchShiftPlugin.cpp.

123 {
124  return i18n("Pitch Shift");
125 }

◆ createDialog()

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

Creates the setup dialog and connects it's signals

Implements Kwave::FilterPlugin.

Definition at line 75 of file PitchShiftPlugin.cpp.

References Kwave::connect(), and setValues().

76 {
78  Q_ASSERT(dialog);
79  if (!dialog) return Q_NULLPTR;
80 
81  // connect the signals for detecting value changes in pre-listen mode
82  connect(dialog, SIGNAL(changed(double,double)),
83  this, SLOT(setValues(double,double)));
84 
85  return dialog;
86 }
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
void setValues(double speed, double frequency)
Here is the call graph for this function:

◆ createFilter()

Kwave::SampleSource * Kwave::PitchShiftPlugin::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 89 of file PitchShiftPlugin.cpp.

◆ interpreteParameters()

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

Reads values from the parameter list

Implements Kwave::FilterPlugin.

Definition at line 48 of file PitchShiftPlugin.cpp.

References m_frequency, m_percentage_mode, and m_speed.

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

◆ paramsChanged()

bool Kwave::PitchShiftPlugin::paramsChanged ( )
virtual

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

Reimplemented from Kwave::FilterPlugin.

Definition at line 95 of file PitchShiftPlugin.cpp.

References m_frequency, m_last_freq, m_last_speed, and m_speed.

96 {
97  return (!qFuzzyCompare(m_speed, m_last_speed) ||
98  !qFuzzyCompare(m_frequency, m_last_freq));
99 }

◆ setValues

void Kwave::PitchShiftPlugin::setValues ( double  speed,
double  frequency 
)
protectedslot

Called when the parameters of the pre-listen have changed

Parameters
speedthe speed factor, floating point
frequencythe frequency parameter in Hz

Definition at line 128 of file PitchShiftPlugin.cpp.

References m_frequency, and m_speed.

Referenced by createDialog().

129 {
130  m_frequency = frequency;
131  m_speed = speed;
132 }
Here is the caller graph for this function:

◆ updateFilter()

void Kwave::PitchShiftPlugin::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 102 of file PitchShiftPlugin.cpp.

References m_frequency, m_last_freq, m_last_speed, m_speed, Kwave::StreamObject::setAttribute(), and Kwave::Plugin::signalRate().

104 {
105  double sr = signalRate();
106 
107  if (!filter) return;
108 
109  if (!qFuzzyCompare(m_frequency, m_last_freq) || force)
110  filter->setAttribute(SLOT(setFrequency(QVariant)),
111  QVariant((m_frequency * 2.0 * M_PI) / sr));
112 
113  if (!qFuzzyCompare(m_speed, m_last_speed) || force)
114  filter->setAttribute(SLOT(setSpeed(QVariant)),
115  QVariant(m_speed));
116 
119 }
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_frequency

double Kwave::PitchShiftPlugin::m_frequency
private

base frequency

Definition at line 106 of file PitchShiftPlugin.h.

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

◆ m_last_freq

double Kwave::PitchShiftPlugin::m_last_freq
private

last value of m_frequency

Definition at line 115 of file PitchShiftPlugin.h.

Referenced by paramsChanged(), and updateFilter().

◆ m_last_speed

double Kwave::PitchShiftPlugin::m_last_speed
private

last value of m_speed

Definition at line 112 of file PitchShiftPlugin.h.

Referenced by paramsChanged(), and updateFilter().

◆ m_percentage_mode

bool Kwave::PitchShiftPlugin::m_percentage_mode
private

mode for selecting speed (factor or percentage)

Definition at line 109 of file PitchShiftPlugin.h.

Referenced by interpreteParameters().

◆ m_speed

double Kwave::PitchShiftPlugin::m_speed
private

speed factor

Definition at line 103 of file PitchShiftPlugin.h.

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


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