1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364
|
/*************************************************************************
RecordDialog.h - dialog window for controlling audio recording
-------------------
begin : Wed Aug 20 2003
copyright : (C) 2003 by Thomas Eschenbacher
email : Thomas.Eschenbacher@gmx.de
***************************************************************************/
/***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef RECORD_DIALOG_H
#define RECORD_DIALOG_H
#include "config.h"
#include <QList>
#include <QMap>
#include <QString>
#include <QStringList>
#include <QTimer>
#include "libkwave/Compression.h"
#include "libkwave/Sample.h"
#include "libkwave/SampleArray.h"
#include "libkwave/SampleFormat.h"
#include "RecordController.h"
#include "RecordParams.h"
#include "RecordState.h"
#include "RecordTypesMap.h"
#include "StatusWidget.h"
#include "ui_RecordDlg.h"
class QDateTime;
class QLabel;
class QTreeWidgetItem;
class QWidget;
namespace Kwave
{
class RecordDialog: public QDialog,
public Ui::RecordDlg
{
Q_OBJECT
public:
typedef enum {
SETTINGS_DEFAULT = 0, /**< default page (setup, tab 0) */
SETTINGS_FORMAT, /**< format settings */
SETTINGS_SOURCE, /**< source settings */
START_RECORDING /**< directly start recording! */
} Mode;
/** Constructor */
RecordDialog(QWidget *parent, QStringList ¶ms,
Kwave::RecordController *controller,
Mode mode);
/** Destructor */
~RecordDialog() override;
/** returns the list of record parameters, for the next time */
Kwave::RecordParams ¶ms();
/** selects a new recording method */
void setMethod(Kwave::record_method_t method);
/**
* Sets the list of supported devices, just entries
* for the device selection combo box.
*/
void setSupportedDevices(QStringList devices);
/** sets the range of supported tracks */
void setSupportedTracks(unsigned int min, unsigned int max);
/** sets a new number of tracks */
void setTracks(unsigned int tracks);
/** sets the list of supported sample rates */
void setSupportedSampleRates(const QList<double> &rates);
/**
* sets a new sample rate
* @param new_rate the new sample rate [samples/second]
*/
void setSampleRate(double new_rate);
/**
* sets the list of supported compressions
* @param comps list of supported compressions, can be empty
*/
void setSupportedCompressions(
const QList<Kwave::Compression::Type> &comps
);
/**
* sets a new compression type
* @param compression type of the compression, numeric
* @see Kwave::Compression
*/
void setCompression(int compression);
/** sets a list of supported number of bits per sample */
void setSupportedBits(const QList<unsigned int> &bits);
/** sets a new resolution in bits per sample */
void setBitsPerSample(unsigned int bits);
/**
* Convert a sample rate into a string, using current locale settings.
* Trailing zeroes and thousands separators are removed, the precision
* is set to three digits.
* @param rate sample rate [samples/second]
* @return the rate formatted as string
*/
QString rate2string(double rate) const;
/**
* sets the list of supported sample formats
* @param formats list of supported sample formats, must not be empty
*/
void setSupportedSampleFormats(
const QList<Kwave::SampleFormat::Format> &formats
);
/**
* sets a new sample format
* @param sample_format format of the samples, like signed/unsigned
* @see SampleFormat
*/
void setSampleFormat(Kwave::SampleFormat::Format sample_format);
/**
* updates the progress bar with the buffer fill state.
* @param count number of filled/available buffers
* @param total maximum amount of buffers
*/
void updateBufferState(unsigned int count, unsigned int total);
/**
* updates all enabled visual effects
* @param track index of the track that is updated
* @param buffer array with Kwave sample data
*/
void updateEffects(unsigned int track, Kwave::SampleArray &buffer);
/**
* Show the "source" device tab, usually if the setup was
* not successful.
*/
void showDevicePage();
signals:
/** emits changes in the currently selected record method */
void sigMethodChanged(Kwave::record_method_t method);
/** emitted when a new record device has been selected */
void sigDeviceChanged(const QString &device);
/** emitted when the number of tracks has changed */
void sigTracksChanged(unsigned int tracks);
/** emitted when a new sample rate has been selected */
void sampleRateChanged(double rate);
/** emitted when the compression has changed */
void sigCompressionChanged(Kwave::Compression::Type compression);
/** emitted when the resoluton in bits per sample changed */
void sigBitsPerSampleChanged(unsigned int bits);
/** emitted when the sample format has changed */
void sigSampleFormatChanged(Kwave::SampleFormat::Format sample_format);
/** emitted when the number and/or size of buffers has changed */
void sigBuffersChanged();
/** emitted when the record time has been changed */
void sigRecordTimeChanged(int limit);
/** emitted when the record trigger has been enabled/disabled */
void sigTriggerChanged(bool enabled);
/** emitted when the prerecording has been enabled/disabled */
void sigPreRecordingChanged(bool enabled);
public slots:
/** selects a new record device */
void setDevice(const QString &device);
/** set the file filter used for the "Select..." dialog */
void setFileFilter(const QString &filter);
/** updates the number of recorded samples */
void setRecordedSamples(sample_index_t samples_recorded);
/** show a message in the status bar */
void message(const QString &message);
private slots:
/**
* called when a new recording method has been selected
* from the combo box
* @param index the position within the combo box
*/
void methodSelected(int index);
/** updates the record buffer count */
void sourceBufferCountChanged(int value);
/** updates the record buffer size */
void sourceBufferSizeChanged(int value);
/** show a "file open" dialog for selecting a record device */
void selectRecordDevice();
/** selection in the device list view has changed */
void listEntrySelected(QTreeWidgetItem *current,
QTreeWidgetItem *previous);
/** selection in the device list view has changed */
void listItemExpanded(QTreeWidgetItem *item);
/**
* updates/fixes the device selection when the tree view has
* lost focus, to avoid that nothing is selected
*/
void updateListSelection();
/** forwards a sigTracksChanged signal */
void tracksChanged(int tracks);
/** called when another sample rate has been selected */
void sampleRateChanged(const QString &rate);
/** called when a new compression type has been set */
void compressionChanged(int index);
/** called when the resolution in bits per sample has changed */
void bitsPerSampleChanged(int bits);
/** called when a new sample format has been selected */
void sampleFormatChanged(int index);
/** sets a new state of the dialog, enable/disable controls etc... */
void setState(Kwave::RecordState state);
/** updates the buffer progress bar */
void updateBufferProgressBar();
/** prerecording has been enabled/disabled */
void preRecordingChecked(bool enabled);
/** the prerecording time has been changed */
void preRecordingTimeChanged(int time);
/** record time has been enabled/disabled */
void recordTimeChecked(bool limited);
/** record time has been changed */
void recordTimeChanged(int record_time);
/** start time has been enabled/disabled */
void startTimeChecked(bool enabled);
/** start time has been changed */
void startTimeChanged(const QDateTime &datetime);
/** record trigger has been enabled/disabled */
void triggerChecked(bool enabled);
/** record trigger has changed */
void triggerChanged(int trigger);
/** invoke the online help */
void invokeHelp();
private:
/**
* Convert a formated sample rate string back to a numeric sample
* rate (the opposite of rate2string() )
* @param rate the sample rate, formatted as string
* @return the numeric sample rate [samples/second]
*/
double string2rate(const QString &rate) const;
/**
* enabled or disables the record button by evaluating
* m_record_enabled and m_seconds_recording
*/
void updateRecordButton();
private:
/** map of playback methods/types */
Kwave::RecordTypesMap m_methods_map;
/** file filter for the "Select..." dialog (optional) */
QString m_file_filter;
/** map for items in the list view */
QMap<QTreeWidgetItem *, QString> m_devices_list_map;
/** state of the record plugin */
Kwave::RecordState m_state;
/** list of parameters */
Kwave::RecordParams m_params;
/** a list with supported bits per sample */
QList<unsigned int> m_supported_resolutions;
/** accumulated current buffer progress */
unsigned int m_buffer_progress_count;
/** accumulated total buffer progress */
unsigned int m_buffer_progress_total;
/** timer for slowly updating the buffer progress bar */
QTimer m_buffer_progress_timer;
/** determines if recording is to be enabled by the current state */
bool m_record_enabled;
/**
* holds the recorded samples for comparing with the recording
* time limit, for determining if recording should be enabled
* or not. Also used in status bar for displaying the recorded time.
*/
sample_index_t m_samples_recorded;
/** if false, do nothing in setDevice */
bool m_enable_setDevice;
/** widget with a icon in the status bar */
Kwave::StatusWidget *m_state_icon_widget;
struct {
QLabel *m_state; /**< status bar id: state text */
QLabel *m_time; /**< status bar id: recorded time */
QLabel *m_sample_rate; /**< status bar id: sample rate */
QLabel *m_bits_per_sample; /**< status bar id: number of tracks */
QLabel *m_tracks; /**< status bar id: number of tracks */
} m_status_bar;
};
}
#endif /* RECORD_DIALOG_H */
//***************************************************************************
//***************************************************************************
|