kwave  18.07.70
RecordPlugin.h
Go to the documentation of this file.
1 /*************************************************************************
2  RecordPlugin.h - plugin for recording audio data
3  -------------------
4  begin : Wed Jul 09 2003
5  copyright : (C) 2003 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 RECORD_PLUGIN_H
19 #define RECORD_PLUGIN_H
20 
21 #include "config.h"
22 
23 #include <QByteArray>
24 #include <QList>
25 #include <QString>
26 #include <QStringList>
27 #include <QTimer>
28 #include <QVector>
29 
31 #include "libkwave/Plugin.h"
32 #include "libkwave/Sample.h"
33 #include "libkwave/SampleArray.h"
34 #include "libkwave/SampleFIFO.h"
35 #include "libkwave/SampleFormat.h"
36 
37 #include "RecordController.h"
38 #include "RecordParams.h"
39 #include "RecordState.h"
40 
41 class QStringList;
42 
43 namespace Kwave
44 {
45 
46  class RecordDevice;
47  class RecordDialog;
48  class RecordThread;
49  class SampleDecoder;
50 
52  {
53  Q_OBJECT
54  public:
55 
61  RecordPlugin(QObject *parent, const QVariantList &args);
62 
64  virtual ~RecordPlugin() Q_DECL_OVERRIDE;
65 
67  virtual QStringList *setup(QStringList &previous_params) Q_DECL_OVERRIDE;
68 
69  signals:
70 
72  void sigRecordedSamples(sample_index_t samples_recorded);
73 
74  protected:
75 
81  {
82  public:
85  :m_recorder(recorder)
86  {
88  }
89 
92  {
94  }
95 
96  private:
98  };
99 
100  protected:
101  friend class InhibitRecordGuard;
102 
104  void enterInhibit();
105 
107  void leaveInhibit();
108 
109  protected slots:
110 
116  void resetRecording(bool &accepted);
117 
122  void startRecording();
123 
125  void recordStopped(int reason);
126 
130  void stateChanged(Kwave::RecordState state);
131 
132  private slots:
133 
134  // setup functions
135 
140  void setMethod(Kwave::record_method_t method);
141 
143  void setDevice(const QString &device);
144 
146  void changeTracks(unsigned int new_tracks);
147 
149  void changeSampleRate(double new_rate);
150 
152  void changeCompression(Kwave::Compression::Type new_compression);
153 
155  void changeBitsPerSample(unsigned int new_bits);
156 
159 
161  void processBuffer();
162 
164  void buffersChanged();
165 
167  void prerecordingChanged(bool enable);
168 
170  void retryOpen();
171 
172  private:
173 
175  void closeDevice();
176 
182  void notice(QString message);
183 
185  void setupRecordThread();
186 
189 
196  bool checkTrigger(unsigned int track, const Kwave::SampleArray &buffer);
197 
207  void split(QByteArray &raw_data, QByteArray &dest,
208  unsigned int bytes_per_sample,
209  unsigned int track,
210  unsigned int tracks);
211 
219  void enqueuePrerecording(unsigned int track,
220  const Kwave::SampleArray &decoded);
221 
226  void flushPrerecordingQueue();
227 
232  bool paramsValid();
233 
234  private:
235 
238 
240  QString m_device_name;
241 
244 
247 
250 
253 
256 
259 
264  QVector<Kwave::SampleFIFO> m_prerecording_queue;
265 
268 
273  unsigned int m_buffers_recorded;
274 
276  unsigned int m_inhibit_count;
277 
279  QVector<float> m_trigger_value;
280 
283 
284  };
285 }
286 
287 #endif /* RECORD_PLUGIN_H */
288 
289 //***************************************************************************
290 //***************************************************************************
void notice(QString message)
void split(QByteArray &raw_data, QByteArray &dest, unsigned int bytes_per_sample, unsigned int track, unsigned int tracks)
void sigRecordedSamples(sample_index_t samples_recorded)
Kwave::SampleDecoder * m_decoder
Definition: RecordPlugin.h:258
void changeBitsPerSample(unsigned int new_bits)
Kwave::RecordThread * m_thread
Definition: RecordPlugin.h:255
Definition: App.h:33
void prerecordingChanged(bool enable)
void recordStopped(int reason)
void enqueuePrerecording(unsigned int track, const Kwave::SampleArray &decoded)
bool checkTrigger(unsigned int track, const Kwave::SampleArray &buffer)
Kwave::RecordState m_state
Definition: RecordPlugin.h:246
void changeTracks(unsigned int new_tracks)
RecordPlugin(QObject *parent, const QVariantList &args)
Kwave::record_method_t m_method
Definition: RecordPlugin.h:237
unsigned int m_buffers_recorded
Definition: RecordPlugin.h:273
quint64 sample_index_t
Definition: Sample.h:28
Kwave::MultiTrackWriter * m_writers
Definition: RecordPlugin.h:267
void resetRecording(bool &accepted)
QVector< float > m_trigger_value
Definition: RecordPlugin.h:279
virtual QStringList * setup(QStringList &previous_params) Q_DECL_OVERRIDE
record_method_t
Definition: RecordParams.h:37
void changeCompression(Kwave::Compression::Type new_compression)
void setMethod(Kwave::record_method_t method)
unsigned int m_inhibit_count
Definition: RecordPlugin.h:276
Kwave::RecordDialog * m_dialog
Definition: RecordPlugin.h:252
virtual ~RecordPlugin() Q_DECL_OVERRIDE
Kwave::RecordDevice * m_device
Definition: RecordPlugin.h:249
void stateChanged(Kwave::RecordState state)
void changeSampleRate(double new_rate)
Kwave::RecordController m_controller
Definition: RecordPlugin.h:243
QVector< Kwave::SampleFIFO > m_prerecording_queue
Definition: RecordPlugin.h:264
void changeSampleFormat(Kwave::SampleFormat::Format new_format)
void setDevice(const QString &device)
RecordState
Definition: RecordState.h:25
InhibitRecordGuard(Kwave::RecordPlugin &recorder)
Definition: RecordPlugin.h:84