kwave  18.07.70
SonagramPlugin.h
Go to the documentation of this file.
1 /***************************************************************************
2  SonagramPlugin.h - plugin that shows a sonagram window
3  -------------------
4  begin : Fri Jul 28 2000
5  copyright : (C) 2000 by Thomas Eschenbacher
6  email : Thomas.Eschenbacher@gmx.de
7  ***************************************************************************/
8 
9 /***************************************************************************
10  * *
11  * This program is free software; you can redistribute it and/or modify *
12  * it under the terms of the GNU General Public License as published by *
13  * the Free Software Foundation; either version 2 of the License, or *
14  * (at your option) any later version. *
15  * *
16  ***************************************************************************/
17 
18 #ifndef SONAGRAM_PLUGIN_H
19 #define SONAGRAM_PLUGIN_H
20 
21 #include "config.h"
22 
23 #include <complex>
24 #include <fftw3.h>
25 
26 #include <QBitArray>
27 #include <QByteArray>
28 #include <QFuture>
29 #include <QList>
30 #include <QMutex>
31 #include <QQueue>
32 #include <QReadWriteLock>
33 #include <QString>
34 #include <QTimer>
35 #include <QUuid>
36 
37 #include "libkwave/FixedPool.h"
38 #include "libkwave/Plugin.h"
40 
41 class QImage;
42 class QStringList;
43 
45 #define MAX_FFT_POINTS 32767
46 
48 #define MAX_FFT_JOBS 256
49 
51 #define MAX_SLICES 32767
52 
53 namespace Kwave
54 {
55  class MultiTrackReader;
56  class OverViewCache;
57  class PluginContext;
58  class SelectionTracker;
59  class SonagramWindow;
60 
65  {
66  Q_OBJECT
67  public:
68 
74  SonagramPlugin(QObject *parent, const QVariantList &args);
75 
77  virtual ~SonagramPlugin() Q_DECL_OVERRIDE;
78 
80  virtual QStringList *setup(QStringList &previous_params)
81  Q_DECL_OVERRIDE;
82 
84  virtual int start(QStringList &params) Q_DECL_OVERRIDE;
85 
92  virtual void run(QStringList params) Q_DECL_OVERRIDE;
93 
94  private:
95 
97  typedef struct {
99  unsigned int m_index;
100 
102  double m_input[MAX_FFT_POINTS];
103 
105  fftw_complex m_output[MAX_FFT_POINTS];
106 
108  unsigned char m_result[MAX_FFT_POINTS];
109  } Slice;
110 
111  signals:
112 
118 
119  private slots:
120 
124  void validate();
125 
130  void windowDestroyed();
131 
140 
144  void refreshOverview();
145 
151  void slotTrackInserted(const QUuid &track_id);
152 
158  void slotTrackDeleted(const QUuid &track_id);
159 
166  void slotInvalidated(const QUuid *track_id,
167  sample_index_t first,
168  sample_index_t last);
169 
170  protected:
171 
178  int interpreteParameters(QStringList &params);
179 
180  private:
181 
186  void makeAllValid();
187 
191  void requestValidation();
192 
198 
209  void createNewImage(const unsigned int width,
210  const unsigned int height);
211 
212  private:
213 
216 
219 
221  unsigned int m_slices;
222 
224  unsigned int m_fft_points;
225 
228 
230  bool m_color;
231 
234 
237 
239  QImage m_image;
240 
243 
246 
248  QBitArray m_valid;
249 
251  QReadWriteLock m_pending_jobs;
252 
255 
257  QFuture<void> m_future;
258 
261  };
262 }
263 
264 #endif /* SONAGRAM_PLUGIN_H */
265 
266 //***************************************************************************
267 //***************************************************************************
unsigned int m_fft_points
QFuture< void > m_future
Definition: App.h:33
window_function_t
void slotTrackDeleted(const QUuid &track_id)
int interpreteParameters(QStringList &params)
Kwave::FixedPool< MAX_FFT_JOBS, Slice > m_slice_pool
void sliceAvailable(Kwave::SonagramPlugin::Slice *slice)
quint64 sample_index_t
Definition: Sample.h:28
SonagramPlugin(QObject *parent, const QVariantList &args)
QReadWriteLock m_pending_jobs
virtual ~SonagramPlugin() Q_DECL_OVERRIDE
Kwave::SonagramWindow * m_sonagram_window
virtual void run(QStringList params) Q_DECL_OVERRIDE
Kwave::window_function_t m_window_type
virtual int start(QStringList &params) Q_DECL_OVERRIDE
void calculateSlice(Kwave::SonagramPlugin::Slice *slice)
void slotTrackInserted(const QUuid &track_id)
void slotInvalidated(const QUuid *track_id, sample_index_t first, sample_index_t last)
Kwave::SelectionTracker * m_selection
Kwave::OverViewCache * m_overview_cache
void createNewImage(const unsigned int width, const unsigned int height)
virtual QStringList * setup(QStringList &previous_params) Q_DECL_OVERRIDE
void insertSlice(Kwave::SonagramPlugin::Slice *slice)
#define MAX_FFT_POINTS