kwave  18.07.70
Kwave::SonagramDialog Class Reference

#include <SonagramDialog.h>

Inheritance diagram for Kwave::SonagramDialog:
Inheritance graph
Collaboration diagram for Kwave::SonagramDialog:
Collaboration graph

Public Slots

void setPoints (int points)
 
void setWindowFunction (Kwave::window_function_t type)
 
void setColorMode (int color)
 
void setTrackChanges (bool track_changes)
 
void setFollowSelection (bool follow_selection)
 
void setBoxPoints (int num)
 

Public Member Functions

 SonagramDialog (Kwave::Plugin &p)
 
virtual ~SonagramDialog ()
 
void parameters (QStringList &list)
 

Private Slots

void invokeHelp ()
 

Private Attributes

sample_index_t m_length
 
double m_rate
 

Detailed Description

Definition at line 36 of file SonagramDialog.h.

Constructor & Destructor Documentation

◆ SonagramDialog()

Kwave::SonagramDialog::SonagramDialog ( Kwave::Plugin p)
explicit

Constructor

Definition at line 46 of file SonagramDialog.cpp.

References Kwave::connect(), Kwave::WindowFunction::count(), Kwave::WindowFunction::description(), invokeHelp(), m_length, setBoxPoints(), setPoints(), Kwave::toInt(), and Kwave::WINDOW_FUNC_NONE.

47  :QDialog(p.parentWidget()), Ui::SonagramDlg(),
48  m_length(p.selection(Q_NULLPTR, Q_NULLPTR, Q_NULLPTR, true)),
49  m_rate(p.signalRate())
50 {
51  setupUi(this);
52  setModal(true);
53 
54  Q_ASSERT(pointbox);
55  Q_ASSERT(pointslider);
56  Q_ASSERT(windowtypebox);
57  if (!pointbox) return;
58  if (!pointslider) return;
59  if (!windowtypebox) return;
60 
61  pointslider->setMaximum(Kwave::toInt(m_length / 16));
62 
64  for (unsigned int i = 0; i < Kwave::WindowFunction::count(); i++) {
65  windowtypebox->addItem(Kwave::WindowFunction::description(wf, true));
66  ++wf;
67  }
68 
69  setPoints(1); // must set the minimum number of points to get
70  setBoxPoints(0); // the largest windowlabel
71 
72  // Set a size hint:
73  // try to make the image's aspect ratio (a) = sqrt(2)
74  //
75  // samples: s
76  // fft_points: np
77  // image_width: w = s / np
78  // image_height: h = np / 2
79  // a = w / h = 2*s / (np^2)
80  // => np = sqrt( 2 * s / a) )
81  const double aspect_ratio = sqrt(2);
82  double np = sqrt(2.0 * static_cast<double>(m_length) / aspect_ratio);
83 
84  // round down to an exponent of 2, this makes the image more
85  // wide than heigh and gives a fast calculation
86  int bits = Kwave::toInt(floor(log(np) / log(2)));
87  if (bits < 2) bits = 2;
88  if (bits > 16) bits = 16;
89  setPoints(1 << (bits-1));
90  setBoxPoints(0);
91 
92  connect(
93  buttonBox->button(QDialogButtonBox::Help), SIGNAL(clicked()),
94  this, SLOT(invokeHelp())
95  );
96  connect(pointslider, SIGNAL(valueChanged(int)), SLOT(setPoints(int)));
97  connect(pointbox, SIGNAL(activated(int)), SLOT(setBoxPoints(int)));
98 
99  // set the focus onto the "OK" button
100  buttonBox->button(QDialogButtonBox::Ok)->setFocus();
101 }
static QString description(window_function_t type, bool localized)
window_function_t
QWidget * parentWidget() const
Definition: Plugin.cpp:450
bool connect(Kwave::StreamObject &source, const char *output, Kwave::StreamObject &sink, const char *input)
Definition: Connect.cpp:48
void setBoxPoints(int num)
int toInt(T x)
Definition: Utils.h:127
sample_index_t m_length
static unsigned int count()
virtual double signalRate()
Definition: Plugin.cpp:468
void setPoints(int points)
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)
Definition: Plugin.cpp:480
Here is the call graph for this function:

◆ ~SonagramDialog()

Kwave::SonagramDialog::~SonagramDialog ( )
virtual

Destructor

Definition at line 200 of file SonagramDialog.cpp.

201 {
202 }

Member Function Documentation

◆ invokeHelp

void Kwave::SonagramDialog::invokeHelp ( )
privateslot

invoke the online help

Definition at line 205 of file SonagramDialog.cpp.

References _.

Referenced by SonagramDialog().

206 {
207  KHelpClient::invokeHelp(_("plugin_sect_sonagram"));
208 }
#define _(m)
Definition: memcpy.c:66
Here is the caller graph for this function:

◆ parameters()

void Kwave::SonagramDialog::parameters ( QStringList &  list)

Fills the current parameters into a parameter list. The list always is cleared before it gets filled. The first parameter will contain the number of fft points [1...n] The second parameter will contain the id of a window function or zero if no window function was selected ("<none>").

Definition at line 104 of file SonagramDialog.cpp.

References Kwave::WindowFunction::findFromIndex(), and Kwave::WindowFunction::name().

Referenced by Kwave::SonagramPlugin::setup().

105 {
106  Q_ASSERT(pointbox);
107  Q_ASSERT(windowtypebox);
108  Q_ASSERT(rbColor);
109 
110  QString param;
111  list.clear();
112 
113  // parameter #0: number of fft points
114  param = pointbox ? pointbox->currentText() : QString();
115  list.append(param);
116 
117  // parameter #1: index of the window function
119  (windowtypebox) ? windowtypebox->currentIndex() : 0);
120  param = Kwave::WindowFunction::name(wf);
121  list.append(param);
122 
123  // parameter #2: flag: use color instead of greyscale
124  param.setNum(rbColor ? (rbColor->isChecked() ? 1 : 0) : 0);
125  list.append(param);
126 
127  // parameter #3: flag: track changes
128  param.setNum((cbTrackChanges && cbTrackChanges->isChecked())
129  ? 1 : 0);
130  list.append(param);
131 
132  // parameter #4: flag: follow selection
133  param.setNum((cbFollowSelection && cbFollowSelection->isChecked())
134  ? 1 : 0);
135  list.append(param);
136 
137 }
window_function_t
static window_function_t findFromIndex(unsigned int index)
static const QString name(window_function_t type)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setBoxPoints

void Kwave::SonagramDialog::setBoxPoints ( int  num)
slot

Definition at line 192 of file SonagramDialog.cpp.

Referenced by SonagramDialog().

193 {
194  Q_ASSERT(num >= 0);
195  int points = pointbox->itemText(num).toInt();
196  pointslider->setValue(points / 2);
197 }
Here is the caller graph for this function:

◆ setColorMode

void Kwave::SonagramDialog::setColorMode ( int  color)
slot

sets the color mode. Currently only black/white (0) and rainbow color (1) are supported.

Definition at line 166 of file SonagramDialog.cpp.

Referenced by Kwave::SonagramPlugin::setup().

167 {
168  Q_ASSERT(rbColor);
169  if (!rbColor) return;
170 
171  rbColor->setChecked(color);
172  rbGreyScale->setChecked(!color);
173 }
Here is the caller graph for this function:

◆ setFollowSelection

void Kwave::SonagramDialog::setFollowSelection ( bool  follow_selection)
slot

enables/disables the "follow selection mode

Definition at line 184 of file SonagramDialog.cpp.

Referenced by Kwave::SonagramPlugin::setup().

185 {
186  Q_ASSERT(cbFollowSelection);
187  if (!cbFollowSelection) return;
188  cbFollowSelection->setChecked(follow_selection);
189 }
Here is the caller graph for this function:

◆ setPoints

void Kwave::SonagramDialog::setPoints ( int  points)
slot

sets the number of fft points

Definition at line 140 of file SonagramDialog.cpp.

References m_length, m_rate, and Kwave::ms2string().

Referenced by SonagramDialog().

141 {
142  Q_ASSERT(points >= 0);
143  QString text;
144  points *= 2;
145 
146  text.setNum(points);
147  pointbox->setEditText(text);
148 
149  windowlabel->setText(i18n("(resulting window size: %1)",
150  Kwave::ms2string(points * 1.0E3 / m_rate)));
151 
152  bitmaplabel->setText(i18n("Size of bitmap: %1x%2",
153  (m_length / points) + 1,
154  points/2));
155 }
QString Q_DECL_EXPORT ms2string(double ms, int precision=6)
Definition: Utils.cpp:66
sample_index_t m_length
Here is the call graph for this function:
Here is the caller graph for this function:

◆ setTrackChanges

void Kwave::SonagramDialog::setTrackChanges ( bool  track_changes)
slot

enables/disables the "track changes" mode

Definition at line 176 of file SonagramDialog.cpp.

Referenced by Kwave::SonagramPlugin::setup().

177 {
178  Q_ASSERT(cbTrackChanges);
179  if (!cbTrackChanges) return;
180  cbTrackChanges->setChecked(track_changes);
181 }
Here is the caller graph for this function:

◆ setWindowFunction

void Kwave::SonagramDialog::setWindowFunction ( Kwave::window_function_t  type)
slot

selects a window function

Definition at line 158 of file SonagramDialog.cpp.

References Kwave::WindowFunction::index().

Referenced by Kwave::SonagramPlugin::setup().

159 {
160  Q_ASSERT(windowtypebox);
161  if (!windowtypebox) return;
162  windowtypebox->setCurrentIndex(Kwave::WindowFunction::index(type));
163 }
static unsigned int index(window_function_t type)
Here is the call graph for this function:
Here is the caller graph for this function:

Member Data Documentation

◆ m_length

sample_index_t Kwave::SonagramDialog::m_length
private

length of the selection

Definition at line 86 of file SonagramDialog.h.

Referenced by setPoints(), and SonagramDialog().

◆ m_rate

double Kwave::SonagramDialog::m_rate
private

sample rate of the signal

Definition at line 89 of file SonagramDialog.h.

Referenced by setPoints().


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