utils.h Example File
multimedia/spectrum/app/utils.h
#ifndef UTILS_H
#define UTILS_H
#include <QtCore/qglobal.h>
#include <QDebug>
QT_FORWARD_DECLARE_CLASS(QAudioFormat)
qint64 audioDuration(const QAudioFormat &format, qint64 bytes);
qint64 audioLength(const QAudioFormat &format, qint64 microSeconds);
QString formatToString(const QAudioFormat &format);
qreal nyquistFrequency(const QAudioFormat &format);
qreal pcmToReal(qint16 pcm);
qint16 realToPcm(qreal real);
bool isPCM(const QAudioFormat &format);
bool isPCMS16LE(const QAudioFormat &format);
template<int N> class PowerOfTwo
{ public: static const int Result = PowerOfTwo<N-1>::Result * 2; };
template<> class PowerOfTwo<0>
{ public: static const int Result = 1; };
class NullDebug
{
public:
template <typename T>
NullDebug& operator<<(const T&) { return *this; }
};
inline NullDebug nullDebug() { return NullDebug(); }
#ifdef LOG_ENGINE
# define ENGINE_DEBUG qDebug()
#else
# define ENGINE_DEBUG nullDebug()
#endif
#ifdef LOG_SPECTRUMANALYSER
# define SPECTRUMANALYSER_DEBUG qDebug()
#else
# define SPECTRUMANALYSER_DEBUG nullDebug()
#endif
#ifdef LOG_WAVEFORM
# define WAVEFORM_DEBUG qDebug()
#else
# define WAVEFORM_DEBUG nullDebug()
#endif
#endif // UTILS_H