Multimedia: examples coding style unification
Change-Id: Iffae3a276bb2b01f871aee76dc069ce006d69fce Reviewed-by: David Schulz <david.schulz@digia.com>
This commit is contained in:
@@ -6,7 +6,7 @@ TEMPLATE = app
|
||||
|
||||
TARGET = spectrum
|
||||
|
||||
QT += multimedia
|
||||
QT += multimedia widgets
|
||||
|
||||
SOURCES += main.cpp \
|
||||
engine.cpp \
|
||||
@@ -89,6 +89,3 @@ macx {
|
||||
QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
QT+=widgets
|
||||
|
||||
@@ -44,14 +44,14 @@
|
||||
|
||||
#include <math.h>
|
||||
|
||||
#include <QAudioInput>
|
||||
#include <QAudioOutput>
|
||||
#include <QCoreApplication>
|
||||
#include <QDebug>
|
||||
#include <QFile>
|
||||
#include <QMetaObject>
|
||||
#include <QSet>
|
||||
#include <QtMultimedia/QAudioInput>
|
||||
#include <QtMultimedia/QAudioOutput>
|
||||
#include <QDebug>
|
||||
#include <QThread>
|
||||
#include <QFile>
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Constants
|
||||
|
||||
@@ -45,12 +45,13 @@
|
||||
#include "spectrumanalyser.h"
|
||||
#include "wavfile.h"
|
||||
|
||||
#include <QObject>
|
||||
#include <QByteArray>
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QAudioFormat>
|
||||
#include <QBuffer>
|
||||
#include <QByteArray>
|
||||
#include <QDir>
|
||||
#include <QObject>
|
||||
#include <QVector>
|
||||
#include <QtMultimedia/QAudioDeviceInfo>
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
|
||||
#ifdef DUMP_CAPTURED_AUDIO
|
||||
#define DUMP_DATA
|
||||
@@ -60,14 +61,11 @@
|
||||
#define DUMP_DATA
|
||||
#endif
|
||||
|
||||
#ifdef DUMP_DATA
|
||||
#include <QDir>
|
||||
#endif
|
||||
|
||||
class FrequencySpectrum;
|
||||
QT_FORWARD_DECLARE_CLASS(QAudioInput)
|
||||
QT_FORWARD_DECLARE_CLASS(QAudioOutput)
|
||||
QT_FORWARD_DECLARE_CLASS(QFile)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAudioInput;
|
||||
class QAudioOutput;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* This class interfaces with the QtMultimedia audio classes, and also with
|
||||
@@ -75,26 +73,28 @@ QT_FORWARD_DECLARE_CLASS(QFile)
|
||||
* of audio data, meanwhile performing real-time analysis of the audio level
|
||||
* and frequency spectrum.
|
||||
*/
|
||||
class Engine : public QObject {
|
||||
class Engine : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Engine(QObject *parent = 0);
|
||||
explicit Engine(QObject *parent = 0);
|
||||
~Engine();
|
||||
|
||||
const QList<QAudioDeviceInfo>& availableAudioInputDevices() const
|
||||
const QList<QAudioDeviceInfo> &availableAudioInputDevices() const
|
||||
{ return m_availableAudioInputDevices; }
|
||||
|
||||
const QList<QAudioDeviceInfo>& availableAudioOutputDevices() const
|
||||
const QList<QAudioDeviceInfo> &availableAudioOutputDevices() const
|
||||
{ return m_availableAudioOutputDevices; }
|
||||
|
||||
QAudio::Mode mode() const { return m_mode; }
|
||||
QAudio::State state() const { return m_state; }
|
||||
QAudio::Mode mode() const { return m_mode; }
|
||||
QAudio::State state() const { return m_state; }
|
||||
|
||||
/**
|
||||
* \return Current audio format
|
||||
* \note May be QAudioFormat() if engine is not initialized
|
||||
*/
|
||||
const QAudioFormat& format() const { return m_format; }
|
||||
const QAudioFormat& format() const { return m_format; }
|
||||
|
||||
/**
|
||||
* Stop any ongoing recording or playback, and reset to ground state.
|
||||
@@ -125,25 +125,25 @@ public:
|
||||
* Position of the audio input device.
|
||||
* \return Position in bytes.
|
||||
*/
|
||||
qint64 recordPosition() const { return m_recordPosition; }
|
||||
qint64 recordPosition() const { return m_recordPosition; }
|
||||
|
||||
/**
|
||||
* RMS level of the most recently processed set of audio samples.
|
||||
* \return Level in range (0.0, 1.0)
|
||||
*/
|
||||
qreal rmsLevel() const { return m_rmsLevel; }
|
||||
qreal rmsLevel() const { return m_rmsLevel; }
|
||||
|
||||
/**
|
||||
* Peak level of the most recently processed set of audio samples.
|
||||
* \return Level in range (0.0, 1.0)
|
||||
*/
|
||||
qreal peakLevel() const { return m_peakLevel; }
|
||||
qreal peakLevel() const { return m_peakLevel; }
|
||||
|
||||
/**
|
||||
* Position of the audio output device.
|
||||
* \return Position in bytes.
|
||||
*/
|
||||
qint64 playPosition() const { return m_playPosition; }
|
||||
qint64 playPosition() const { return m_playPosition; }
|
||||
|
||||
/**
|
||||
* Length of the internal engine buffer.
|
||||
@@ -155,7 +155,7 @@ public:
|
||||
* Amount of data held in the buffer.
|
||||
* \return Data length in bytes.
|
||||
*/
|
||||
qint64 dataLength() const { return m_dataLength; }
|
||||
qint64 dataLength() const { return m_dataLength; }
|
||||
|
||||
/**
|
||||
* Set window function applied to audio data before spectral analysis.
|
||||
|
||||
@@ -58,12 +58,12 @@ int FrequencySpectrum::count() const
|
||||
return m_elements.count();
|
||||
}
|
||||
|
||||
FrequencySpectrum::Element& FrequencySpectrum::operator[](int index)
|
||||
FrequencySpectrum::Element &FrequencySpectrum::operator[](int index)
|
||||
{
|
||||
return m_elements[index];
|
||||
}
|
||||
|
||||
const FrequencySpectrum::Element& FrequencySpectrum::operator[](int index) const
|
||||
const FrequencySpectrum::Element &FrequencySpectrum::operator[](int index) const
|
||||
{
|
||||
return m_elements[index];
|
||||
}
|
||||
|
||||
@@ -49,10 +49,12 @@
|
||||
* RMS and peak levels of the window of audio samples most recently analyzed
|
||||
* by the Engine.
|
||||
*/
|
||||
class LevelMeter : public QWidget {
|
||||
class LevelMeter : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
LevelMeter(QWidget *parent = 0);
|
||||
explicit LevelMeter(QWidget *parent = 0);
|
||||
~LevelMeter();
|
||||
|
||||
void paintEvent(QPaintEvent *event);
|
||||
|
||||
@@ -38,15 +38,15 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtWidgets/QApplication>
|
||||
#include "mainwidget.h"
|
||||
#include <QApplication>
|
||||
|
||||
int main(int argc, char **argv)
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
QApplication app(argc, argv);
|
||||
app.setApplicationName("QtMultimedia spectrum analyzer");
|
||||
MainWidget w;
|
||||
|
||||
MainWidget w;
|
||||
w.show();
|
||||
|
||||
return app.exec();
|
||||
|
||||
@@ -445,4 +445,3 @@ void MainWidget::updateModeMenu()
|
||||
m_generateToneAction->setChecked(GenerateToneMode == m_mode);
|
||||
m_recordAction->setChecked(RecordMode == m_mode);
|
||||
}
|
||||
|
||||
|
||||
@@ -41,33 +41,37 @@
|
||||
#ifndef MAINWIDGET_H
|
||||
#define MAINWIDGET_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QAudio>
|
||||
#include <QIcon>
|
||||
#include <QtMultimedia/qaudio.h>
|
||||
#include <QWidget>
|
||||
|
||||
class Engine;
|
||||
class FrequencySpectrum;
|
||||
class ProgressBar;
|
||||
class Spectrograph;
|
||||
class Waveform;
|
||||
class LevelMeter;
|
||||
class ProgressBar;
|
||||
class SettingsDialog;
|
||||
class Spectrograph;
|
||||
class ToneGeneratorDialog;
|
||||
class Waveform;
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
|
||||
QT_FORWARD_DECLARE_CLASS(QLabel)
|
||||
QT_FORWARD_DECLARE_CLASS(QPushButton)
|
||||
QT_FORWARD_DECLARE_CLASS(QMenu)
|
||||
QT_FORWARD_DECLARE_CLASS(QAction)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAction;
|
||||
class QAudioFormat;
|
||||
class QLabel;
|
||||
class QMenu;
|
||||
class QPushButton;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* Main application widget, responsible for connecting the various UI
|
||||
* elements to the Engine.
|
||||
*/
|
||||
class MainWidget : public QWidget {
|
||||
class MainWidget : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
MainWidget(QWidget *parent = 0);
|
||||
explicit MainWidget(QWidget *parent = 0);
|
||||
~MainWidget();
|
||||
|
||||
// QObject
|
||||
@@ -138,7 +142,6 @@ private:
|
||||
QAction* m_loadFileAction;
|
||||
QAction* m_generateToneAction;
|
||||
QAction* m_recordAction;
|
||||
|
||||
};
|
||||
|
||||
#endif // MAINWIDGET_H
|
||||
|
||||
@@ -47,10 +47,12 @@
|
||||
* Widget which displays a the current fill state of the Engine's internal
|
||||
* buffer, and the current play/record position within that buffer.
|
||||
*/
|
||||
class ProgressBar : public QWidget {
|
||||
class ProgressBar : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ProgressBar(QWidget *parent = 0);
|
||||
explicit ProgressBar(QWidget *parent = 0);
|
||||
~ProgressBar();
|
||||
|
||||
void reset();
|
||||
@@ -68,7 +70,6 @@ private:
|
||||
qint64 m_playPosition;
|
||||
qint64 m_windowPosition;
|
||||
qint64 m_windowLength;
|
||||
|
||||
};
|
||||
|
||||
#endif // PROGRESSBAR_H
|
||||
|
||||
@@ -39,14 +39,14 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "settingsdialog.h"
|
||||
#include <QCheckBox>
|
||||
#include <QComboBox>
|
||||
#include <QDialogButtonBox>
|
||||
#include <QLabel>
|
||||
#include <QPushButton>
|
||||
#include <QVBoxLayout>
|
||||
#include <QCheckBox>
|
||||
#include <QSlider>
|
||||
#include <QSpinBox>
|
||||
#include <QVBoxLayout>
|
||||
|
||||
SettingsDialog::SettingsDialog(
|
||||
const QList<QAudioDeviceInfo> &availableInputDevices,
|
||||
|
||||
@@ -43,29 +43,33 @@
|
||||
|
||||
#include "spectrum.h"
|
||||
#include <QDialog>
|
||||
#include <QtMultimedia/QAudioDeviceInfo>
|
||||
#include <QAudioDeviceInfo>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QComboBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QSlider)
|
||||
QT_FORWARD_DECLARE_CLASS(QSpinBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QGridLayout)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QComboBox;
|
||||
class QCheckBox;
|
||||
class QSlider;
|
||||
class QSpinBox;
|
||||
class QGridLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* Dialog used to control settings such as the audio input / output device
|
||||
* and the windowing function.
|
||||
*/
|
||||
class SettingsDialog : public QDialog {
|
||||
class SettingsDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SettingsDialog(const QList<QAudioDeviceInfo> &availableInputDevices,
|
||||
const QList<QAudioDeviceInfo> &availableOutputDevices,
|
||||
QWidget *parent = 0);
|
||||
~SettingsDialog();
|
||||
|
||||
WindowFunction windowFunction() const { return m_windowFunction; }
|
||||
const QAudioDeviceInfo& inputDevice() const { return m_inputDevice; }
|
||||
const QAudioDeviceInfo& outputDevice() const { return m_outputDevice; }
|
||||
WindowFunction windowFunction() const { return m_windowFunction; }
|
||||
const QAudioDeviceInfo &inputDevice() const { return m_inputDevice; }
|
||||
const QAudioDeviceInfo &outputDevice() const { return m_outputDevice; }
|
||||
|
||||
private slots:
|
||||
void windowFunctionChanged(int index);
|
||||
@@ -77,11 +81,9 @@ private:
|
||||
QAudioDeviceInfo m_inputDevice;
|
||||
QAudioDeviceInfo m_outputDevice;
|
||||
|
||||
QComboBox* m_inputDeviceComboBox;
|
||||
QComboBox* m_outputDeviceComboBox;
|
||||
|
||||
QComboBox* m_windowFunctionComboBox;
|
||||
|
||||
QComboBox *m_inputDeviceComboBox;
|
||||
QComboBox *m_outputDeviceComboBox;
|
||||
QComboBox *m_windowFunctionComboBox;
|
||||
};
|
||||
|
||||
#endif // SETTINGSDIALOG_H
|
||||
|
||||
@@ -39,9 +39,9 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include "spectrograph.h"
|
||||
#include <QPainter>
|
||||
#include <QMouseEvent>
|
||||
#include <QDebug>
|
||||
#include <QMouseEvent>
|
||||
#include <QPainter>
|
||||
#include <QTimerEvent>
|
||||
|
||||
const int NullTimerId = -1;
|
||||
|
||||
@@ -41,19 +41,20 @@
|
||||
#ifndef SPECTROGRAPH_H
|
||||
#define SPECTROGRAPH_H
|
||||
|
||||
#include <QWidget>
|
||||
#include "frequencyspectrum.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QMouseEvent)
|
||||
#include <QWidget>
|
||||
|
||||
/**
|
||||
* Widget which displays a spectrograph showing the frequency spectrum
|
||||
* of the window of audio samples most recently analyzed by the Engine.
|
||||
*/
|
||||
class Spectrograph : public QWidget {
|
||||
class Spectrograph : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Spectrograph(QWidget *parent = 0);
|
||||
explicit Spectrograph(QWidget *parent = 0);
|
||||
~Spectrograph();
|
||||
|
||||
void setParams(int numBars, qreal lowFreq, qreal highFreq);
|
||||
@@ -92,8 +93,6 @@ private:
|
||||
qreal m_lowFreq;
|
||||
qreal m_highFreq;
|
||||
FrequencySpectrum m_spectrum;
|
||||
|
||||
|
||||
};
|
||||
|
||||
#endif // SPECTROGRAPH_H
|
||||
|
||||
@@ -41,7 +41,7 @@
|
||||
#ifndef SPECTRUM_H
|
||||
#define SPECTRUM_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <qglobal.h>
|
||||
#include "utils.h"
|
||||
#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo
|
||||
|
||||
@@ -89,7 +89,8 @@ enum WindowFunction {
|
||||
|
||||
const WindowFunction DefaultWindowFunction = HannWindow;
|
||||
|
||||
struct Tone {
|
||||
struct Tone
|
||||
{
|
||||
Tone(qreal freq = 0.0, qreal amp = 0.0)
|
||||
: frequency(freq), amplitude(amp)
|
||||
{ }
|
||||
@@ -101,7 +102,8 @@ struct Tone {
|
||||
qreal amplitude;
|
||||
};
|
||||
|
||||
struct SweptTone {
|
||||
struct SweptTone
|
||||
{
|
||||
SweptTone(qreal start = 0.0, qreal end = 0.0, qreal amp = 0.0)
|
||||
: startFreq(start), endFreq(end), amplitude(amp)
|
||||
{ Q_ASSERT(end >= start); }
|
||||
|
||||
@@ -40,14 +40,13 @@
|
||||
|
||||
#include "spectrumanalyser.h"
|
||||
#include "utils.h"
|
||||
|
||||
#include <QtCore/qmath.h>
|
||||
#include <QtCore/qmetatype.h>
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
#include <QThread>
|
||||
|
||||
#include "fftreal_wrapper.h"
|
||||
|
||||
#include <qmath.h>
|
||||
#include <qmetatype.h>
|
||||
#include <QAudioFormat>
|
||||
#include <QThread>
|
||||
|
||||
SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent)
|
||||
: QObject(parent)
|
||||
#ifndef DISABLE_FFT
|
||||
@@ -275,7 +274,3 @@ void SpectrumAnalyser::calculationComplete(const FrequencySpectrum &spectrum)
|
||||
emit spectrumChanged(spectrum);
|
||||
m_state = Idle;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -72,6 +72,7 @@ class SpectrumAnalyserThreadPrivate;
|
||||
class SpectrumAnalyserThread : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpectrumAnalyserThread(QObject *parent);
|
||||
~SpectrumAnalyserThread();
|
||||
@@ -121,6 +122,7 @@ private:
|
||||
class SpectrumAnalyser : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
SpectrumAnalyser(QObject *parent = 0);
|
||||
~SpectrumAnalyser();
|
||||
|
||||
@@ -41,9 +41,9 @@
|
||||
#include "spectrum.h"
|
||||
#include "utils.h"
|
||||
#include <QByteArray>
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
#include <QtCore/qmath.h>
|
||||
#include <QtCore/qendian.h>
|
||||
#include <QAudioFormat>
|
||||
#include <qmath.h>
|
||||
#include <qendian.h>
|
||||
|
||||
void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray &buffer)
|
||||
{
|
||||
@@ -88,4 +88,3 @@ void generateTone(const SweptTone &tone, const QAudioFormat &format, QByteArray
|
||||
phaseStep += phaseStepStep;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -41,11 +41,13 @@
|
||||
#ifndef TONEGENERATOR_H
|
||||
#define TONEGENERATOR_H
|
||||
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <qglobal.h>
|
||||
#include "spectrum.h"
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
|
||||
QT_FORWARD_DECLARE_CLASS(QByteArray)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QAudioFormat;
|
||||
class QByteArray;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* Generate a sine wave
|
||||
|
||||
@@ -77,26 +77,23 @@ ToneGeneratorDialog::ToneGeneratorDialog(QWidget *parent)
|
||||
m_amplitudeSlider->setValue(ToneGeneratorAmplitudeDefault);
|
||||
|
||||
// Add widgets to layout
|
||||
|
||||
QScopedPointer<QGridLayout> frequencyControlLayout(new QGridLayout);
|
||||
QGridLayout *frequencyControlLayout = new QGridLayout;
|
||||
QLabel *frequencyLabel = new QLabel(tr("Frequency (Hz)"), this);
|
||||
frequencyControlLayout->addWidget(frequencyLabel, 0, 0, 2, 1);
|
||||
frequencyControlLayout->addWidget(m_frequencySlider, 0, 1);
|
||||
frequencyControlLayout->addWidget(m_frequencySpinBox, 1, 1);
|
||||
m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout.data());
|
||||
frequencyControlLayout.take(); // ownership transferred to m_toneGeneratorFrequencyControl
|
||||
m_toneGeneratorFrequencyControl->setLayout(frequencyControlLayout);
|
||||
m_toneGeneratorFrequencyControl->setEnabled(false);
|
||||
|
||||
QScopedPointer<QGridLayout> toneGeneratorLayout(new QGridLayout);
|
||||
QGridLayout *toneGeneratorLayout = new QGridLayout;
|
||||
QLabel *amplitudeLabel = new QLabel(tr("Amplitude"), this);
|
||||
toneGeneratorLayout->addWidget(m_toneGeneratorSweepCheckBox, 0, 1);
|
||||
toneGeneratorLayout->addWidget(m_toneGeneratorFrequencyControl, 1, 0, 1, 2);
|
||||
toneGeneratorLayout->addWidget(amplitudeLabel, 2, 0);
|
||||
toneGeneratorLayout->addWidget(m_amplitudeSlider, 2, 1);
|
||||
m_toneGeneratorControl->setLayout(toneGeneratorLayout.data());
|
||||
m_toneGeneratorControl->setLayout(toneGeneratorLayout);
|
||||
m_toneGeneratorControl->setSizePolicy(QSizePolicy::Preferred, QSizePolicy::Fixed);
|
||||
dialogLayout->addWidget(m_toneGeneratorControl);
|
||||
toneGeneratorLayout.take(); // ownership transferred
|
||||
|
||||
// Connect
|
||||
CHECKED_CONNECT(m_toneGeneratorSweepCheckBox, SIGNAL(toggled(bool)),
|
||||
|
||||
@@ -42,21 +42,25 @@
|
||||
#define TONEGENERATORDIALOG_H
|
||||
|
||||
#include "spectrum.h"
|
||||
#include <QAudioDeviceInfo>
|
||||
#include <QDialog>
|
||||
#include <QtMultimedia/QAudioDeviceInfo>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QCheckBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QSlider)
|
||||
QT_FORWARD_DECLARE_CLASS(QSpinBox)
|
||||
QT_FORWARD_DECLARE_CLASS(QGridLayout)
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
class QSlider;
|
||||
class QSpinBox;
|
||||
class QGridLayout;
|
||||
QT_END_NAMESPACE
|
||||
|
||||
/**
|
||||
* Dialog which controls the parameters of the tone generator.
|
||||
*/
|
||||
class ToneGeneratorDialog : public QDialog {
|
||||
class ToneGeneratorDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
ToneGeneratorDialog(QWidget *parent = 0);
|
||||
explicit ToneGeneratorDialog(QWidget *parent = 0);
|
||||
~ToneGeneratorDialog();
|
||||
|
||||
bool isFrequencySweepEnabled() const;
|
||||
@@ -67,15 +71,14 @@ private slots:
|
||||
void frequencySweepEnabled(bool enabled);
|
||||
|
||||
private:
|
||||
QCheckBox* m_toneGeneratorSweepCheckBox;
|
||||
bool m_frequencySweepEnabled;
|
||||
QWidget* m_toneGeneratorControl;
|
||||
QWidget* m_toneGeneratorFrequencyControl;
|
||||
QSlider* m_frequencySlider;
|
||||
QSpinBox* m_frequencySpinBox;
|
||||
qreal m_frequency;
|
||||
QSlider* m_amplitudeSlider;
|
||||
|
||||
QCheckBox *m_toneGeneratorSweepCheckBox;
|
||||
bool m_frequencySweepEnabled;
|
||||
QWidget *m_toneGeneratorControl;
|
||||
QWidget *m_toneGeneratorFrequencyControl;
|
||||
QSlider *m_frequencySlider;
|
||||
QSpinBox *m_frequencySpinBox;
|
||||
qreal m_frequency;
|
||||
QSlider *m_amplitudeSlider;
|
||||
};
|
||||
|
||||
#endif // TONEGENERATORDIALOG_H
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
#include <QAudioFormat>
|
||||
#include "utils.h"
|
||||
|
||||
qint64 audioDuration(const QAudioFormat &format, qint64 bytes)
|
||||
@@ -119,10 +119,10 @@ bool isPCM(const QAudioFormat &format)
|
||||
|
||||
bool isPCMS16LE(const QAudioFormat &format)
|
||||
{
|
||||
return (isPCM(format) &&
|
||||
format.sampleType() == QAudioFormat::SignedInt &&
|
||||
format.sampleSize() == 16 &&
|
||||
format.byteOrder() == QAudioFormat::LittleEndian);
|
||||
return isPCM(format) &&
|
||||
format.sampleType() == QAudioFormat::SignedInt &&
|
||||
format.sampleSize() == 16 &&
|
||||
format.byteOrder() == QAudioFormat::LittleEndian;
|
||||
}
|
||||
|
||||
const qint16 PCMS16MaxValue = 32767;
|
||||
|
||||
@@ -41,12 +41,10 @@
|
||||
#ifndef WAVEFORM_H
|
||||
#define WAVEFORM_H
|
||||
|
||||
#include <QWidget>
|
||||
#include <QtMultimedia/QAudioFormat>
|
||||
#include <QAudioFormat>
|
||||
#include <QPixmap>
|
||||
#include <QScopedPointer>
|
||||
|
||||
QT_FORWARD_DECLARE_CLASS(QByteArray)
|
||||
#include <QWidget>
|
||||
|
||||
/**
|
||||
* Widget which displays a section of the audio waveform.
|
||||
@@ -57,10 +55,12 @@ QT_FORWARD_DECLARE_CLASS(QByteArray)
|
||||
* outside the widget, it is moved to the right end of the tile array and
|
||||
* painted with the next section of the waveform.
|
||||
*/
|
||||
class Waveform : public QWidget {
|
||||
class Waveform : public QWidget
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
Waveform(QWidget *parent = 0);
|
||||
explicit Waveform(QWidget *parent = 0);
|
||||
~Waveform();
|
||||
|
||||
// QWidget
|
||||
@@ -197,7 +197,6 @@ private:
|
||||
|
||||
qint64 m_windowPosition;
|
||||
qint64 m_windowLength;
|
||||
|
||||
};
|
||||
|
||||
#endif // WAVEFORM_H
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include <QtCore/qendian.h>
|
||||
#include <qendian.h>
|
||||
#include <QVector>
|
||||
#include <QDebug>
|
||||
#include "utils.h"
|
||||
|
||||
@@ -38,13 +38,12 @@
|
||||
**
|
||||
****************************************************************************/
|
||||
|
||||
|
||||
#ifndef WAVFILE_H
|
||||
#define WAVFILE_H
|
||||
|
||||
#include <QtCore/qobject.h>
|
||||
#include <QtCore/qfile.h>
|
||||
#include <QtMultimedia/qaudioformat.h>
|
||||
#include <QObject>
|
||||
#include <QFile>
|
||||
#include <QAudioFormat>
|
||||
|
||||
class WavFile : public QFile
|
||||
{
|
||||
@@ -62,8 +61,6 @@ private:
|
||||
private:
|
||||
QAudioFormat m_fileFormat;
|
||||
qint64 m_headerLength;
|
||||
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
#endif // WAVFILE_H
|
||||
|
||||
@@ -4,11 +4,9 @@ TEMPLATE = subdirs
|
||||
|
||||
# Ensure that library is built before application
|
||||
CONFIG += ordered
|
||||
QT += widgets
|
||||
|
||||
!contains(DEFINES, DISABLE_FFT) {
|
||||
SUBDIRS += 3rdparty/fftreal
|
||||
}
|
||||
|
||||
!contains(DEFINES, DISABLE_FFT): SUBDIRS += 3rdparty/fftreal
|
||||
SUBDIRS += app
|
||||
|
||||
TARGET = spectrum
|
||||
@@ -16,5 +14,3 @@ TARGET = spectrum
|
||||
sources.files = README.txt spectrum.pri spectrum.pro TODO.txt
|
||||
sources.path = $$[QT_INSTALL_EXAMPLES]/qtmultimedia/spectrum
|
||||
INSTALLS += sources
|
||||
|
||||
QT+=widgets
|
||||
|
||||
Reference in New Issue
Block a user