kwave  18.07.70
Kwave::LowPassDialog Class Reference

#include <LowPassDialog.h>

Inheritance diagram for Kwave::LowPassDialog:
Inheritance graph
Collaboration diagram for Kwave::LowPassDialog:
Collaboration graph

Signals

void changed (double freq)
 
void startPreListen ()
 
void stopPreListen ()
 

Public Member Functions

 LowPassDialog (QWidget *parent, double sample_rate)
 
virtual ~LowPassDialog () Q_DECL_OVERRIDE
 
virtual QStringList params () Q_DECL_OVERRIDE
 
virtual void setParams (QStringList &params) Q_DECL_OVERRIDE
 
virtual QDialog * dialog () Q_DECL_OVERRIDE
 
- Public Member Functions inherited from Kwave::PluginSetupDialog
virtual ~PluginSetupDialog ()
 

Protected Slots

void valueChanged (int pos)
 
void listenToggled (bool listen)
 
void listenStopped ()
 

Protected Member Functions

void updateDisplay ()
 

Private Slots

void invokeHelp ()
 

Private Attributes

double m_frequency
 
double m_sample_rate
 
Kwave::LowPassFilterm_filter
 

Detailed Description

Definition at line 38 of file LowPassDialog.h.

Constructor & Destructor Documentation

◆ LowPassDialog()

Kwave::LowPassDialog::LowPassDialog ( QWidget *  parent,
double  sample_rate 
)

Constructor.

Parameters
parentparent widget
sample_ratesample rate of the audio data to be processed, needed for determining the allowed range of the cutoff frequency

Definition at line 42 of file LowPassDialog.cpp.

References Kwave::connect(), invokeHelp(), listenToggled(), m_filter, m_frequency, Kwave::toInt(), updateDisplay(), and valueChanged().

43  :QDialog(parent), Ui::LowPassDlg(), Kwave::PluginSetupDialog(),
44  m_frequency(3500),
45  m_sample_rate(sample_rate), m_filter(Q_NULLPTR)
46 {
47  setupUi(this);
48  setModal(true);
49 
50  // set maximum frequency to sample rate / 2
51  double f_max = sample_rate / 2.0;
52 
53  slider->setMaximum(Kwave::toInt(f_max));
54  spinbox->setMaximum(Kwave::toInt(f_max));
55 
56  // initialize the frequency scale widget
57  scale_freq->setMinMax(0, Kwave::toInt(f_max));
58  scale_freq->setLogMode(false);
59  scale_freq->setUnit(i18n("Hz"));
60 
61  // initialize the attenuation scale widget
62  scale_db->setMinMax(-24, +6);
63  scale_db->setLogMode(false);
64  scale_db->setUnit(i18n("dB"));
65 
66  // initialize the frequency response widget
67  freq_response->init(f_max, -24, +6);
68 
69  // set up the low pass filter dunction
71  freq_response->setFilter(m_filter);
72 
73  // initialize the controls and the curve display
74  slider->setValue(Kwave::toInt(m_frequency));
75  spinbox->setValue(Kwave::toInt(m_frequency));
76  updateDisplay();
77 
78  // changes in the slider or spinbox
79  connect(spinbox, SIGNAL(valueChanged(int)),
80  this, SLOT(valueChanged(int)));
81  // click to the "Listen" button
82  connect(btListen, SIGNAL(toggled(bool)),
83  this, SLOT(listenToggled(bool)));
84 
85  // expand the "Listen" button to it's maximum width
86  listenToggled(true);
87  if (btListen->width() > btListen->minimumWidth())
88  btListen->setMinimumWidth(btListen->width());
89  listenToggled(false);
90  if (btListen->width() > btListen->minimumWidth())
91  btListen->setMinimumWidth(btListen->width());
92 
93  // set the initial size of the dialog
94  int h = (width() * 3) / 5;
95  if (height() < h) resize(width(), h);
96  int w = (height() * 5) / 3;
97  if (width() < w) resize(w, height());
98 
99  connect(buttonBox_Help->button(QDialogButtonBox::Help), SIGNAL(clicked()),
100  this, SLOT(invokeHelp()));
101 
102  // set the focus onto the "OK" button
103  buttonBox->button(QDialogButtonBox::Ok)->setFocus();
104 }
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
int toInt(T x)
Definition: Utils.h:127
void valueChanged(int pos)
void listenToggled(bool listen)
Kwave::LowPassFilter * m_filter
Here is the call graph for this function:

◆ ~LowPassDialog()

Kwave::LowPassDialog::~LowPassDialog ( )
virtual

Destructor

Definition at line 107 of file LowPassDialog.cpp.

References listenToggled(), and m_filter.

108 {
109  // better stop pre-listen now
110  listenToggled(false);
111 
112  if (freq_response) freq_response->setFilter(Q_NULLPTR);
113  if (m_filter) delete m_filter;
114 }
void listenToggled(bool listen)
Kwave::LowPassFilter * m_filter
Here is the call graph for this function:

Member Function Documentation

◆ changed

void Kwave::LowPassDialog::changed ( double  freq)
signal

Emitted whenever the frequency changes

Parameters
freqthe frequency parameter in Hz

Referenced by dialog(), and valueChanged().

Here is the caller graph for this function:

◆ dialog()

virtual QDialog* Kwave::LowPassDialog::dialog ( )
inlinevirtual

retruns a pointer to this as a QDialog

Implements Kwave::PluginSetupDialog.

Definition at line 64 of file LowPassDialog.h.

References changed(), invokeHelp(), listenStopped(), listenToggled(), startPreListen(), stopPreListen(), updateDisplay(), and valueChanged().

64 { return this; }
Here is the call graph for this function:

◆ invokeHelp

void Kwave::LowPassDialog::invokeHelp ( )
privateslot

invoke the online help

Definition at line 185 of file LowPassDialog.cpp.

References _.

Referenced by dialog(), and LowPassDialog().

186 {
187  KHelpClient::invokeHelp(_("plugin_sect_lowpass"));
188 }
#define _(m)
Definition: memcpy.c:66
Here is the caller graph for this function:

◆ listenStopped

void Kwave::LowPassDialog::listenStopped ( )
protectedslot

called when the pre-listen mode stopped/aborted

Definition at line 179 of file LowPassDialog.cpp.

Referenced by dialog().

180 {
181  if (!btListen) btListen->setChecked(false);
182 }
Here is the caller graph for this function:

◆ listenToggled

void Kwave::LowPassDialog::listenToggled ( bool  listen)
protectedslot

called when the "Listen" button has been toggled, to start or stop the pre-listen mode

Definition at line 162 of file LowPassDialog.cpp.

References startPreListen(), and stopPreListen().

Referenced by dialog(), LowPassDialog(), and ~LowPassDialog().

163 {
164  Q_ASSERT(btListen);
165  if (!btListen) return;
166 
167  if (listen) {
168  // start pre-listen mode
169  emit startPreListen();
170  btListen->setText(i18n("&Stop"));
171  } else {
172  // stop pre-listen mode
173  emit stopPreListen();
174  btListen->setText(i18n("&Listen"));
175  }
176 }
Here is the caller graph for this function:

◆ params()

QStringList Kwave::LowPassDialog::params ( )
virtual

Returns the parameters as string list

Implements Kwave::PluginSetupDialog.

Definition at line 128 of file LowPassDialog.cpp.

References m_frequency.

129 {
130  QStringList list;
131  list << QString::number(m_frequency);
132  return list;
133 }

◆ setParams()

void Kwave::LowPassDialog::setParams ( QStringList &  params)
virtual

Sets the from a list of parameters

Implements Kwave::PluginSetupDialog.

Definition at line 136 of file LowPassDialog.cpp.

References m_frequency, Kwave::toInt(), and updateDisplay().

137 {
138  // evaluate the parameter list
139  bool ok;
140  double frequency = params[0].toDouble(&ok);
141  Q_ASSERT(ok);
142  if (ok) m_frequency = frequency;
143 
144  slider->setValue(Kwave::toInt(m_frequency));
145  spinbox->setValue(Kwave::toInt(m_frequency));
146 
147  updateDisplay();
148 }
int toInt(T x)
Definition: Utils.h:127
virtual QStringList params() Q_DECL_OVERRIDE
Here is the call graph for this function:

◆ startPreListen

void Kwave::LowPassDialog::startPreListen ( )
signal

Pre-listen mode has been started

Referenced by dialog(), and listenToggled().

Here is the caller graph for this function:

◆ stopPreListen

void Kwave::LowPassDialog::stopPreListen ( )
signal

Pre-listen mode has been stopped

Referenced by dialog(), and listenToggled().

Here is the caller graph for this function:

◆ updateDisplay()

void Kwave::LowPassDialog::updateDisplay ( )
protected

Update the graphic display

Definition at line 151 of file LowPassDialog.cpp.

References m_filter, m_frequency, m_sample_rate, and Kwave::LowPassFilter::setFrequency().

Referenced by dialog(), LowPassDialog(), setParams(), and valueChanged().

152 {
153  double fs = m_sample_rate;
154  if (m_filter && (fs > 0.0))
155  {
156  m_filter->setFrequency(QVariant(2.0 * M_PI * m_frequency / fs));
157  if (freq_response) freq_response->repaint();
158  }
159 }
void setFrequency(const QVariant fc)
Kwave::LowPassFilter * m_filter
Here is the call graph for this function:
Here is the caller graph for this function:

◆ valueChanged

void Kwave::LowPassDialog::valueChanged ( int  pos)
protectedslot

called when the spinbox or spinbox value has changed

Definition at line 117 of file LowPassDialog.cpp.

References changed(), m_frequency, Kwave::toInt(), and updateDisplay().

Referenced by dialog(), and LowPassDialog().

118 {
119  if (Kwave::toInt(m_frequency) != pos) {
120  m_frequency = pos;
121  updateDisplay();
122 
123  emit changed(m_frequency);
124  }
125 }
void changed(double freq)
int toInt(T x)
Definition: Utils.h:127
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_filter

Kwave::LowPassFilter* Kwave::LowPassDialog::m_filter
private

filter function for calculating the frequency response

Definition at line 115 of file LowPassDialog.h.

Referenced by LowPassDialog(), updateDisplay(), and ~LowPassDialog().

◆ m_frequency

double Kwave::LowPassDialog::m_frequency
private

the cutoff frequency in Hz

Definition at line 109 of file LowPassDialog.h.

Referenced by LowPassDialog(), params(), setParams(), updateDisplay(), and valueChanged().

◆ m_sample_rate

double Kwave::LowPassDialog::m_sample_rate
private

sample rate of the signal in samples/sec

Definition at line 112 of file LowPassDialog.h.

Referenced by updateDisplay().


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