From 12f78f8ed991d816411b1ba6718a34e8e26e2eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tomi=20Korpip=C3=A4=C3=A4?= Date: Tue, 3 Sep 2013 09:03:37 +0300 Subject: Fixed issues from Improve examples task Task-number: QTRD-2239 + Moved spectrum to tests + Added audiolevels to examples (implementation pending..) Change-Id: If20ce3014211a82dbe0142557beee5776cf51708 Change-Id: If20ce3014211a82dbe0142557beee5776cf51708 Reviewed-by: Mika Salmela --- examples/audiolevels/audiolevels.pro | 11 + examples/audiolevels/doc/src/audiolevels.qdoc | 28 + examples/audiolevels/main.cpp | 198 +++++ examples/examples.pro | 4 +- examples/spectrum/3rdparty/fftreal/Array.h | 97 --- examples/spectrum/3rdparty/fftreal/Array.hpp | 98 --- examples/spectrum/3rdparty/fftreal/DynArray.h | 100 --- examples/spectrum/3rdparty/fftreal/DynArray.hpp | 143 ---- examples/spectrum/3rdparty/fftreal/FFTReal.dsp | 273 ------ examples/spectrum/3rdparty/fftreal/FFTReal.dsw | 29 - examples/spectrum/3rdparty/fftreal/FFTReal.h | 142 ---- examples/spectrum/3rdparty/fftreal/FFTReal.hpp | 916 --------------------- examples/spectrum/3rdparty/fftreal/FFTRealFixLen.h | 130 --- .../spectrum/3rdparty/fftreal/FFTRealFixLen.hpp | 322 -------- .../spectrum/3rdparty/fftreal/FFTRealFixLenParam.h | 93 --- .../spectrum/3rdparty/fftreal/FFTRealPassDirect.h | 96 --- .../3rdparty/fftreal/FFTRealPassDirect.hpp | 204 ----- .../spectrum/3rdparty/fftreal/FFTRealPassInverse.h | 101 --- .../3rdparty/fftreal/FFTRealPassInverse.hpp | 229 ------ examples/spectrum/3rdparty/fftreal/FFTRealSelect.h | 77 -- .../spectrum/3rdparty/fftreal/FFTRealSelect.hpp | 62 -- .../spectrum/3rdparty/fftreal/FFTRealUseTrigo.h | 101 --- .../spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp | 91 -- examples/spectrum/3rdparty/fftreal/OscSinCos.h | 106 --- examples/spectrum/3rdparty/fftreal/OscSinCos.hpp | 122 --- examples/spectrum/3rdparty/fftreal/TestAccuracy.h | 105 --- .../spectrum/3rdparty/fftreal/TestAccuracy.hpp | 472 ----------- .../spectrum/3rdparty/fftreal/TestHelperFixLen.h | 93 --- .../spectrum/3rdparty/fftreal/TestHelperFixLen.hpp | 93 --- .../spectrum/3rdparty/fftreal/TestHelperNormal.h | 94 --- .../spectrum/3rdparty/fftreal/TestHelperNormal.hpp | 99 --- examples/spectrum/3rdparty/fftreal/TestSpeed.h | 95 --- examples/spectrum/3rdparty/fftreal/TestSpeed.hpp | 223 ----- .../spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h | 95 --- .../3rdparty/fftreal/TestWhiteNoiseGen.hpp | 91 -- examples/spectrum/3rdparty/fftreal/def.h | 60 -- examples/spectrum/3rdparty/fftreal/fftreal.pas | 661 --------------- examples/spectrum/3rdparty/fftreal/fftreal.pro | 44 - .../spectrum/3rdparty/fftreal/fftreal_wrapper.cpp | 54 -- .../spectrum/3rdparty/fftreal/fftreal_wrapper.h | 63 -- examples/spectrum/3rdparty/fftreal/license.txt | 459 ----------- examples/spectrum/3rdparty/fftreal/readme.txt | 242 ------ examples/spectrum/3rdparty/fftreal/test.cpp | 267 ------ examples/spectrum/3rdparty/fftreal/test_fnc.h | 53 -- examples/spectrum/3rdparty/fftreal/test_fnc.hpp | 56 -- examples/spectrum/3rdparty/fftreal/test_settings.h | 45 - examples/spectrum/3rdparty/fftreal/testapp.dpr | 150 ---- examples/spectrum/README.txt | 103 --- examples/spectrum/doc/images/spectrum-example.png | Bin 79769 -> 0 bytes examples/spectrum/doc/src/spectrum.qdoc | 28 - examples/spectrum/spectrum.pri | 18 - examples/spectrum/spectrum.pro | 13 - examples/spectrum/spectrumapp/engine.cpp | 613 -------------- examples/spectrum/spectrumapp/engine.h | 247 ------ .../spectrum/spectrumapp/frequencyspectrum.cpp | 67 -- examples/spectrum/spectrumapp/frequencyspectrum.h | 76 -- examples/spectrum/spectrumapp/main.cpp | 201 ----- .../spectrum/spectrumapp/soundFiles/Rockhop.wav | Bin 1059308 -> 0 bytes .../spectrumapp/soundFiles/futurebells_beat.wav | Bin 352084 -> 0 bytes ..._thuille_terzo-tempo_sestetto_small-version.wav | Bin 1055502 -> 0 bytes examples/spectrum/spectrumapp/spectrum.h | 111 --- examples/spectrum/spectrumapp/spectrum.qrc | 7 - examples/spectrum/spectrumapp/spectrumanalyser.cpp | 209 ----- examples/spectrum/spectrumapp/spectrumanalyser.h | 150 ---- examples/spectrum/spectrumapp/spectrumapp.pro | 80 -- examples/spectrum/spectrumapp/utils.cpp | 117 --- examples/spectrum/spectrumapp/utils.h | 90 -- examples/spectrum/spectrumapp/wavfile.cpp | 129 --- examples/spectrum/spectrumapp/wavfile.h | 44 - 69 files changed, 239 insertions(+), 9451 deletions(-) create mode 100644 examples/audiolevels/audiolevels.pro create mode 100644 examples/audiolevels/doc/src/audiolevels.qdoc create mode 100644 examples/audiolevels/main.cpp delete mode 100644 examples/spectrum/3rdparty/fftreal/Array.h delete mode 100644 examples/spectrum/3rdparty/fftreal/Array.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/DynArray.h delete mode 100644 examples/spectrum/3rdparty/fftreal/DynArray.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTReal.dsp delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTReal.dsw delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTReal.h delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTReal.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealFixLen.h delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealPassDirect.h delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealPassInverse.h delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealSelect.h delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealSelect.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h delete mode 100644 examples/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/OscSinCos.h delete mode 100644 examples/spectrum/3rdparty/fftreal/OscSinCos.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/TestAccuracy.h delete mode 100644 examples/spectrum/3rdparty/fftreal/TestAccuracy.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/TestHelperFixLen.h delete mode 100644 examples/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/TestHelperNormal.h delete mode 100644 examples/spectrum/3rdparty/fftreal/TestHelperNormal.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/TestSpeed.h delete mode 100644 examples/spectrum/3rdparty/fftreal/TestSpeed.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h delete mode 100644 examples/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/def.h delete mode 100644 examples/spectrum/3rdparty/fftreal/fftreal.pas delete mode 100644 examples/spectrum/3rdparty/fftreal/fftreal.pro delete mode 100644 examples/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp delete mode 100644 examples/spectrum/3rdparty/fftreal/fftreal_wrapper.h delete mode 100644 examples/spectrum/3rdparty/fftreal/license.txt delete mode 100644 examples/spectrum/3rdparty/fftreal/readme.txt delete mode 100644 examples/spectrum/3rdparty/fftreal/test.cpp delete mode 100644 examples/spectrum/3rdparty/fftreal/test_fnc.h delete mode 100644 examples/spectrum/3rdparty/fftreal/test_fnc.hpp delete mode 100644 examples/spectrum/3rdparty/fftreal/test_settings.h delete mode 100644 examples/spectrum/3rdparty/fftreal/testapp.dpr delete mode 100644 examples/spectrum/README.txt delete mode 100644 examples/spectrum/doc/images/spectrum-example.png delete mode 100644 examples/spectrum/doc/src/spectrum.qdoc delete mode 100644 examples/spectrum/spectrum.pri delete mode 100644 examples/spectrum/spectrum.pro delete mode 100644 examples/spectrum/spectrumapp/engine.cpp delete mode 100644 examples/spectrum/spectrumapp/engine.h delete mode 100644 examples/spectrum/spectrumapp/frequencyspectrum.cpp delete mode 100644 examples/spectrum/spectrumapp/frequencyspectrum.h delete mode 100644 examples/spectrum/spectrumapp/main.cpp delete mode 100644 examples/spectrum/spectrumapp/soundFiles/Rockhop.wav delete mode 100644 examples/spectrum/spectrumapp/soundFiles/futurebells_beat.wav delete mode 100644 examples/spectrum/spectrumapp/soundFiles/onclassical_demo_fiati-di-parma_thuille_terzo-tempo_sestetto_small-version.wav delete mode 100644 examples/spectrum/spectrumapp/spectrum.h delete mode 100644 examples/spectrum/spectrumapp/spectrum.qrc delete mode 100644 examples/spectrum/spectrumapp/spectrumanalyser.cpp delete mode 100644 examples/spectrum/spectrumapp/spectrumanalyser.h delete mode 100644 examples/spectrum/spectrumapp/spectrumapp.pro delete mode 100644 examples/spectrum/spectrumapp/utils.cpp delete mode 100644 examples/spectrum/spectrumapp/utils.h delete mode 100644 examples/spectrum/spectrumapp/wavfile.cpp delete mode 100644 examples/spectrum/spectrumapp/wavfile.h (limited to 'examples') diff --git a/examples/audiolevels/audiolevels.pro b/examples/audiolevels/audiolevels.pro new file mode 100644 index 00000000..8a75e6f3 --- /dev/null +++ b/examples/audiolevels/audiolevels.pro @@ -0,0 +1,11 @@ +!include( ../examples.pri ) { + error( "Couldn't find the examples.pri file!" ) +} + +TARGET = audiolevels + +QT += multimedia + +SOURCES += main.cpp + +INSTALLS += target diff --git a/examples/audiolevels/doc/src/audiolevels.qdoc b/examples/audiolevels/doc/src/audiolevels.qdoc new file mode 100644 index 00000000..612c31cd --- /dev/null +++ b/examples/audiolevels/doc/src/audiolevels.qdoc @@ -0,0 +1,28 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVis3D module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +/*! + \example spectrum + \title Spectrum Example + + The spectrum example shows how feed dynamic data to a graph using Q3DBars. + + \image spectrum-example.png + + TODO +*/ diff --git a/examples/audiolevels/main.cpp b/examples/audiolevels/main.cpp new file mode 100644 index 00000000..c31b35cc --- /dev/null +++ b/examples/audiolevels/main.cpp @@ -0,0 +1,198 @@ +/**************************************************************************** +** +** Copyright (C) 2013 Digia Plc +** All rights reserved. +** For any questions to Digia, please use contact form at http://qt.digia.com +** +** This file is part of the QtDataVis3D module. +** +** Licensees holding valid Qt Enterprise licenses may use this file in +** accordance with the Qt Enterprise License Agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and Digia. +** +** If you have questions regarding the use of this file, please use +** contact form at http://qt.digia.com +** +****************************************************************************/ + +#include +#include +#include + +#include +#include +#include + +//#define USE_CONES + +using namespace QtDataVis3D; +#if 0 +class AudioLevels : public QObject +{ +public: + AudioLevels(Q3DBars *window); + ~AudioLevels(); + + void start(QString fileName); + +public slots: + void spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum); + void stateChanged(QAudio::Mode mode, QAudio::State state); + +private slots: + void restart(); + +private: + int barIndex(qreal frequency) const; + +private: + Q3DBars *m_chart; + Engine *m_engine; + QTimer *m_restartTimer; + // Lower bound of first band in the spectrum in Hz + qreal m_lowFreq; + // Upper band of last band in the spectrum in Hz + qreal m_highFreq; +}; + +AudioLevels::AudioLevels(Q3DBars *window) + : m_chart(window), + m_engine(new Engine(this)), + m_restartTimer(new QTimer(this)), + m_lowFreq(SpectrumLowFreq), + m_highFreq(SpectrumHighFreq) +{ + m_chart->setDataWindow(SpectrumNumBands * 2, SpectrumNumBands); + // Disable grid + m_chart->setGridVisible(false); + // Disable auto-scaling of height by defining explicit range + m_chart->valueAxis()->setRange(0.0, 1.0); + // Disable shadows + m_chart->setShadowQuality(QDataVis::ShadowNone); +#if USE_CONES + // Set bar specifications; make them a bit wider than deep and make them be drawn 75% + // inside each other + m_chart->setBarSpecs(1.25), QSizeF(0.2, -0.75)); + // Set bar type, smooth cones + m_chart->setBarType(QDataVis::Cones, true); + // Adjust zoom manually; automatic zoom level calculation does not work well with negative + // spacings (in setBarSpecs) + m_chart->setCameraPosition(10.0f, 5.0f, 70); +#else + // Set bar specifications; make them twice as wide as they're deep + m_chart->setBarSpecs(2.0, QSizeF(0.0, 0.0)); + // Set bar type, flat bars + m_chart->setBarType(QDataVis::Bars, false); + // Adjust camera position + m_chart->setCameraPosition(10.0f, 7.5f, 75); +#endif + // Set color scheme + m_chart->setBarColor(QColor(Qt::black), QColor(Qt::red), QColor(Qt::darkYellow)); + // Disable selection + m_chart->setSelectionMode(QDataVis::ModeNone); + QObject::connect(m_engine, &Engine::changedSpectrum, this, &AudioLevels::spectrumChanged); + QObject::connect(m_engine, &Engine::stateChanged, this, &AudioLevels::stateChanged); + m_restartTimer->setSingleShot(true); + QObject::connect(m_restartTimer, &QTimer::timeout, this, &AudioLevels::restart); + + QBarDataProxy *proxy = new QBarDataProxy; + m_chart->setActiveDataProxy(proxy); +} + +AudioLevels::~AudioLevels() +{ + delete m_engine; + delete m_restartTimer; +} + +void AudioLevels::start(QString fileName) +{ + m_engine->loadFile(fileName); + m_engine->startPlayback(); +} + +//----------------------------------------------------------------------------- +// Public slots +//----------------------------------------------------------------------------- + +void AudioLevels::spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum) +{ + Q_UNUSED(position); + Q_UNUSED(length); + //qDebug() << "updating bar values" << position << length; + QBarDataRow *data = new QBarDataRow(SpectrumNumBands); + for (int bar = 0; bar < SpectrumNumBands; bar++) { + // init data set + (*data)[bar].setValue(qreal(0.0)); + } + FrequencySpectrum::const_iterator i = spectrum.begin(); + const FrequencySpectrum::const_iterator end = spectrum.end(); + for ( ; i != end; ++i) { + const FrequencySpectrum::Element e = *i; + if (e.frequency >= m_lowFreq && e.frequency < m_highFreq) { + (*data)[barIndex(e.frequency)].setValue(qMax(data->at(barIndex(e.frequency)).value(), qreal(e.amplitude))); + } + } + static_cast(m_chart->activeDataProxy())->insertRow(0, data); +} + +void AudioLevels::stateChanged(QAudio::Mode mode, QAudio::State state) +{ + //qDebug() << "mode:" << mode << " state: " << state; + // Restart once playback is finished + if (QAudio::AudioOutput == mode && QAudio::StoppedState == state) + m_restartTimer->start(500); +} + +//----------------------------------------------------------------------------- +// Private slots +//----------------------------------------------------------------------------- + +void AudioLevels::restart() +{ + // Change file each time + QString fileToLoad = QStringLiteral(":/file"); + static int fileNo = 3; + QString nrStr; + nrStr.setNum(fileNo); + fileToLoad.append(nrStr); + //qDebug() << fileToLoad; + start(fileToLoad); + fileNo++; + if (fileNo > 3) + fileNo = 1; +} + +//----------------------------------------------------------------------------- +// Private functions +//----------------------------------------------------------------------------- + +int AudioLevels::barIndex(qreal frequency) const +{ + Q_ASSERT(frequency >= m_lowFreq && frequency < m_highFreq); + const qreal bandWidth = (m_highFreq - m_lowFreq) / SpectrumNumBands; + const int index = (frequency - m_lowFreq) / bandWidth; + if (index < 0 || index >= SpectrumNumBands) + Q_ASSERT(false); + //qDebug() << "insert to" << index; + return index; +} +#endif +//----------------------------------------------------------------------------- +// main +//----------------------------------------------------------------------------- +int main(int argc, char *argv[]) +{ + QGuiApplication app(argc, argv); + app.setApplicationName("QtDataVis3D spectrum analyzer"); + + Q3DBars window; + window.resize(1024, 768); + window.show(); + +// AudioLevels *AudioLevels = new AudioLevels(&window); +// AudioLevels->start(QStringLiteral(":/file2")); + + return app.exec(); +} diff --git a/examples/examples.pro b/examples/examples.pro index 4db7ed2f..4712e0d0 100644 --- a/examples/examples.pro +++ b/examples/examples.pro @@ -2,11 +2,11 @@ TEMPLATE = subdirs SUBDIRS += barchart \ rainfall \ widget \ - mapdata \ + #mapdata \ qmlbarchart \ #qmlmaps \ qmlscatter \ surfacechart \ scatterchart -qtHaveModule(multimedia):!android: SUBDIRS += spectrum +qtHaveModule(multimedia):!android: SUBDIRS += audiolevels diff --git a/examples/spectrum/3rdparty/fftreal/Array.h b/examples/spectrum/3rdparty/fftreal/Array.h deleted file mode 100644 index a08e3cf2..00000000 --- a/examples/spectrum/3rdparty/fftreal/Array.h +++ /dev/null @@ -1,97 +0,0 @@ -/***************************************************************************** - - Array.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (Array_HEADER_INCLUDED) -#define Array_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class Array -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef T DataType; - - Array (); - - inline const DataType & - operator [] (long pos) const; - inline DataType & - operator [] (long pos); - - static inline long - size (); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - DataType _data_arr [LEN]; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - Array (const Array &other); - Array & operator = (const Array &other); - bool operator == (const Array &other); - bool operator != (const Array &other); - -}; // class Array - - - -#include "Array.hpp" - - - -#endif // Array_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/Array.hpp b/examples/spectrum/3rdparty/fftreal/Array.hpp deleted file mode 100644 index 8300077e..00000000 --- a/examples/spectrum/3rdparty/fftreal/Array.hpp +++ /dev/null @@ -1,98 +0,0 @@ -/***************************************************************************** - - Array.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (Array_CURRENT_CODEHEADER) - #error Recursive inclusion of Array code header. -#endif -#define Array_CURRENT_CODEHEADER - -#if ! defined (Array_CODEHEADER_INCLUDED) -#define Array_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -Array ::Array () -{ - // Nothing -} - - - -template -const typename Array ::DataType & Array ::operator [] (long pos) const -{ - assert (pos >= 0); - assert (pos < LEN); - - return (_data_arr [pos]); -} - - - -template -typename Array ::DataType & Array ::operator [] (long pos) -{ - assert (pos >= 0); - assert (pos < LEN); - - return (_data_arr [pos]); -} - - - -template -long Array ::size () -{ - return (LEN); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // Array_CODEHEADER_INCLUDED - -#undef Array_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/DynArray.h b/examples/spectrum/3rdparty/fftreal/DynArray.h deleted file mode 100644 index 8041a0c1..00000000 --- a/examples/spectrum/3rdparty/fftreal/DynArray.h +++ /dev/null @@ -1,100 +0,0 @@ -/***************************************************************************** - - DynArray.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (DynArray_HEADER_INCLUDED) -#define DynArray_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class DynArray -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef T DataType; - - DynArray (); - explicit DynArray (long size); - ~DynArray (); - - inline long size () const; - inline void resize (long size); - - inline const DataType & - operator [] (long pos) const; - inline DataType & - operator [] (long pos); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - DataType * _data_ptr; - long _len; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - DynArray (const DynArray &other); - DynArray & operator = (const DynArray &other); - bool operator == (const DynArray &other); - bool operator != (const DynArray &other); - -}; // class DynArray - - - -#include "DynArray.hpp" - - - -#endif // DynArray_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/DynArray.hpp b/examples/spectrum/3rdparty/fftreal/DynArray.hpp deleted file mode 100644 index e62b10f8..00000000 --- a/examples/spectrum/3rdparty/fftreal/DynArray.hpp +++ /dev/null @@ -1,143 +0,0 @@ -/***************************************************************************** - - DynArray.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (DynArray_CURRENT_CODEHEADER) - #error Recursive inclusion of DynArray code header. -#endif -#define DynArray_CURRENT_CODEHEADER - -#if ! defined (DynArray_CODEHEADER_INCLUDED) -#define DynArray_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -DynArray ::DynArray () -: _data_ptr (0) -, _len (0) -{ - // Nothing -} - - - -template -DynArray ::DynArray (long size) -: _data_ptr (0) -, _len (0) -{ - assert (size >= 0); - if (size > 0) - { - _data_ptr = new DataType [size]; - _len = size; - } -} - - - -template -DynArray ::~DynArray () -{ - delete [] _data_ptr; - _data_ptr = 0; - _len = 0; -} - - - -template -long DynArray ::size () const -{ - return (_len); -} - - - -template -void DynArray ::resize (long size) -{ - assert (size >= 0); - if (size > 0) - { - DataType * old_data_ptr = _data_ptr; - DataType * tmp_data_ptr = new DataType [size]; - - _data_ptr = tmp_data_ptr; - _len = size; - - delete [] old_data_ptr; - } -} - - - -template -const typename DynArray ::DataType & DynArray ::operator [] (long pos) const -{ - assert (pos >= 0); - assert (pos < _len); - - return (_data_ptr [pos]); -} - - - -template -typename DynArray ::DataType & DynArray ::operator [] (long pos) -{ - assert (pos >= 0); - assert (pos < _len); - - return (_data_ptr [pos]); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // DynArray_CODEHEADER_INCLUDED - -#undef DynArray_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTReal.dsp b/examples/spectrum/3rdparty/fftreal/FFTReal.dsp deleted file mode 100644 index fe970db0..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTReal.dsp +++ /dev/null @@ -1,273 +0,0 @@ -# Microsoft Developer Studio Project File - Name="FFTReal" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=FFTReal - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "FFTReal.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "FFTReal.mak" CFG="FFTReal - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "FFTReal - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "FFTReal - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "FFTReal - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GR /GX /O2 /Ob2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD BASE RSC /l 0x40c /d "NDEBUG" -# ADD RSC /l 0x40c /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 - -!ELSEIF "$(CFG)" == "FFTReal - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /G6 /MTd /W3 /Gm /GR /GX /Zi /Od /Gf /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /FR /YX /FD /c -# ADD BASE RSC /l 0x40c /d "_DEBUG" -# ADD RSC /l 0x40c /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "FFTReal - Win32 Release" -# Name "FFTReal - Win32 Debug" -# Begin Group "Library" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\Array.h -# End Source File -# Begin Source File - -SOURCE=.\Array.hpp -# End Source File -# Begin Source File - -SOURCE=.\def.h -# End Source File -# Begin Source File - -SOURCE=.\DynArray.h -# End Source File -# Begin Source File - -SOURCE=.\DynArray.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTReal.h -# End Source File -# Begin Source File - -SOURCE=.\FFTReal.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealFixLen.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealFixLen.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealFixLenParam.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealPassDirect.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealPassDirect.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealPassInverse.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealPassInverse.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealSelect.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealSelect.hpp -# End Source File -# Begin Source File - -SOURCE=.\FFTRealUseTrigo.h -# End Source File -# Begin Source File - -SOURCE=.\FFTRealUseTrigo.hpp -# End Source File -# Begin Source File - -SOURCE=.\OscSinCos.h -# End Source File -# Begin Source File - -SOURCE=.\OscSinCos.hpp -# End Source File -# End Group -# Begin Group "Test" - -# PROP Default_Filter "" -# Begin Group "stopwatch" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\stopwatch\ClockCycleCounter.cpp -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\ClockCycleCounter.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\ClockCycleCounter.hpp -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\def.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\fnc.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\fnc.hpp -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\Int64.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\StopWatch.cpp -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\StopWatch.h -# End Source File -# Begin Source File - -SOURCE=.\stopwatch\StopWatch.hpp -# End Source File -# End Group -# Begin Source File - -SOURCE=.\test.cpp -# End Source File -# Begin Source File - -SOURCE=.\test_fnc.h -# End Source File -# Begin Source File - -SOURCE=.\test_fnc.hpp -# End Source File -# Begin Source File - -SOURCE=.\test_settings.h -# End Source File -# Begin Source File - -SOURCE=.\TestAccuracy.h -# End Source File -# Begin Source File - -SOURCE=.\TestAccuracy.hpp -# End Source File -# Begin Source File - -SOURCE=.\TestHelperFixLen.h -# End Source File -# Begin Source File - -SOURCE=.\TestHelperFixLen.hpp -# End Source File -# Begin Source File - -SOURCE=.\TestHelperNormal.h -# End Source File -# Begin Source File - -SOURCE=.\TestHelperNormal.hpp -# End Source File -# Begin Source File - -SOURCE=.\TestSpeed.h -# End Source File -# Begin Source File - -SOURCE=.\TestSpeed.hpp -# End Source File -# Begin Source File - -SOURCE=.\TestWhiteNoiseGen.h -# End Source File -# Begin Source File - -SOURCE=.\TestWhiteNoiseGen.hpp -# End Source File -# End Group -# End Target -# End Project diff --git a/examples/spectrum/3rdparty/fftreal/FFTReal.dsw b/examples/spectrum/3rdparty/fftreal/FFTReal.dsw deleted file mode 100644 index 076b0aeb..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTReal.dsw +++ /dev/null @@ -1,29 +0,0 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "FFTReal"=.\FFTReal.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - diff --git a/examples/spectrum/3rdparty/fftreal/FFTReal.h b/examples/spectrum/3rdparty/fftreal/FFTReal.h deleted file mode 100644 index 9fb27250..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTReal.h +++ /dev/null @@ -1,142 +0,0 @@ -/***************************************************************************** - - FFTReal.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTReal_HEADER_INCLUDED) -#define FFTReal_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "DynArray.h" -#include "OscSinCos.h" - - - -template -class FFTReal -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - enum { MAX_BIT_DEPTH = 30 }; // So length can be represented as long int - - typedef DT DataType; - - explicit FFTReal (long length); - virtual ~FFTReal () {} - - long get_length () const; - void do_fft (DataType f [], const DataType x []) const; - void do_ifft (const DataType f [], DataType x []) const; - void rescale (DataType x []) const; - DataType * use_buffer () const; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - // Over this bit depth, we use direct calculation for sin/cos - enum { TRIGO_BD_LIMIT = 12 }; - - typedef OscSinCos OscType; - - void init_br_lut (); - void init_trigo_lut (); - void init_trigo_osc (); - - FORCEINLINE const long * - get_br_ptr () const; - FORCEINLINE const DataType * - get_trigo_ptr (int level) const; - FORCEINLINE long - get_trigo_level_index (int level) const; - - inline void compute_fft_general (DataType f [], const DataType x []) const; - inline void compute_direct_pass_1_2 (DataType df [], const DataType x []) const; - inline void compute_direct_pass_3 (DataType df [], const DataType sf []) const; - inline void compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const; - inline void compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const; - inline void compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const; - - inline void compute_ifft_general (const DataType f [], DataType x []) const; - inline void compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const; - inline void compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const; - inline void compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const; - inline void compute_inverse_pass_3 (DataType df [], const DataType sf []) const; - inline void compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const; - - const long _length; - const int _nbr_bits; - DynArray - _br_lut; - DynArray - _trigo_lut; - mutable DynArray - _buffer; - mutable DynArray - _trigo_osc; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTReal (); - FFTReal (const FFTReal &other); - FFTReal & operator = (const FFTReal &other); - bool operator == (const FFTReal &other); - bool operator != (const FFTReal &other); - -}; // class FFTReal - - - -#include "FFTReal.hpp" - - - -#endif // FFTReal_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTReal.hpp b/examples/spectrum/3rdparty/fftreal/FFTReal.hpp deleted file mode 100644 index 335d771d..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTReal.hpp +++ /dev/null @@ -1,916 +0,0 @@ -/***************************************************************************** - - FFTReal.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTReal_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTReal code header. -#endif -#define FFTReal_CURRENT_CODEHEADER - -#if ! defined (FFTReal_CODEHEADER_INCLUDED) -#define FFTReal_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include -#include - - - -static inline bool FFTReal_is_pow2 (long x) -{ - assert (x > 0); - - return ((x & -x) == x); -} - - - -static inline int FFTReal_get_next_pow2 (long x) -{ - --x; - - int p = 0; - while ((x & ~0xFFFFL) != 0) - { - p += 16; - x >>= 16; - } - while ((x & ~0xFL) != 0) - { - p += 4; - x >>= 4; - } - while (x > 0) - { - ++p; - x >>= 1; - } - - return (p); -} - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/* -============================================================================== -Name: ctor -Input parameters: - - length: length of the array on which we want to do a FFT. Range: power of - 2 only, > 0. -Throws: std::bad_alloc -============================================================================== -*/ - -template -FFTReal
::FFTReal (long length) -: _length (length) -, _nbr_bits (FFTReal_get_next_pow2 (length)) -, _br_lut () -, _trigo_lut () -, _buffer (length) -, _trigo_osc () -{ - assert (FFTReal_is_pow2 (length)); - assert (_nbr_bits <= MAX_BIT_DEPTH); - - init_br_lut (); - init_trigo_lut (); - init_trigo_osc (); -} - - - -/* -============================================================================== -Name: get_length -Description: - Returns the number of points processed by this FFT object. -Returns: The number of points, power of 2, > 0. -Throws: Nothing -============================================================================== -*/ - -template -long FFTReal
::get_length () const -{ - return (_length); -} - - - -/* -============================================================================== -Name: do_fft -Description: - Compute the FFT of the array. -Input parameters: - - x: pointer on the source array (time). -Output parameters: - - f: pointer on the destination array (frequencies). - f [0...length(x)/2] = real values, - f [length(x)/2+1...length(x)-1] = negative imaginary values of - coefficents 1...length(x)/2-1. -Throws: Nothing -============================================================================== -*/ - -template -void FFTReal
::do_fft (DataType f [], const DataType x []) const -{ - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); - - // General case - if (_nbr_bits > 2) - { - compute_fft_general (f, x); - } - - // 4-point FFT - else if (_nbr_bits == 2) - { - f [1] = x [0] - x [2]; - f [3] = x [1] - x [3]; - - const DataType b_0 = x [0] + x [2]; - const DataType b_2 = x [1] + x [3]; - - f [0] = b_0 + b_2; - f [2] = b_0 - b_2; - } - - // 2-point FFT - else if (_nbr_bits == 1) - { - f [0] = x [0] + x [1]; - f [1] = x [0] - x [1]; - } - - // 1-point FFT - else - { - f [0] = x [0]; - } -} - - - -/* -============================================================================== -Name: do_ifft -Description: - Compute the inverse FFT of the array. Note that data must be post-scaled: - IFFT (FFT (x)) = x * length (x). -Input parameters: - - f: pointer on the source array (frequencies). - f [0...length(x)/2] = real values - f [length(x)/2+1...length(x)-1] = negative imaginary values of - coefficents 1...length(x)/2-1. -Output parameters: - - x: pointer on the destination array (time). -Throws: Nothing -============================================================================== -*/ - -template -void FFTReal
::do_ifft (const DataType f [], DataType x []) const -{ - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); - - // General case - if (_nbr_bits > 2) - { - compute_ifft_general (f, x); - } - - // 4-point IFFT - else if (_nbr_bits == 2) - { - const DataType b_0 = f [0] + f [2]; - const DataType b_2 = f [0] - f [2]; - - x [0] = b_0 + f [1] * 2; - x [2] = b_0 - f [1] * 2; - x [1] = b_2 + f [3] * 2; - x [3] = b_2 - f [3] * 2; - } - - // 2-point IFFT - else if (_nbr_bits == 1) - { - x [0] = f [0] + f [1]; - x [1] = f [0] - f [1]; - } - - // 1-point IFFT - else - { - x [0] = f [0]; - } -} - - - -/* -============================================================================== -Name: rescale -Description: - Scale an array by divide each element by its length. This function should - be called after FFT + IFFT. -Input parameters: - - x: pointer on array to rescale (time or frequency). -Throws: Nothing -============================================================================== -*/ - -template -void FFTReal
::rescale (DataType x []) const -{ - const DataType mul = DataType (1.0 / _length); - - if (_length < 4) - { - long i = _length - 1; - do - { - x [i] *= mul; - --i; - } - while (i >= 0); - } - - else - { - assert ((_length & 3) == 0); - - // Could be optimized with SIMD instruction sets (needs alignment check) - long i = _length - 4; - do - { - x [i + 0] *= mul; - x [i + 1] *= mul; - x [i + 2] *= mul; - x [i + 3] *= mul; - i -= 4; - } - while (i >= 0); - } -} - - - -/* -============================================================================== -Name: use_buffer -Description: - Access the internal buffer, whose length is the FFT one. - Buffer content will be erased at each do_fft() / do_ifft() call! - This buffer cannot be used as: - - source for FFT or IFFT done with this object - - destination for FFT or IFFT done with this object -Returns: - Buffer start address -Throws: Nothing -============================================================================== -*/ - -template -typename FFTReal
::DataType * FFTReal
::use_buffer () const -{ - return (&_buffer [0]); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void FFTReal
::init_br_lut () -{ - const long length = 1L << _nbr_bits; - _br_lut.resize (length); - - _br_lut [0] = 0; - long br_index = 0; - for (long cnt = 1; cnt < length; ++cnt) - { - // ++br_index (bit reversed) - long bit = length >> 1; - while (((br_index ^= bit) & bit) == 0) - { - bit >>= 1; - } - - _br_lut [cnt] = br_index; - } -} - - - -template -void FFTReal
::init_trigo_lut () -{ - using namespace std; - - if (_nbr_bits > 3) - { - const long total_len = (1L << (_nbr_bits - 1)) - 4; - _trigo_lut.resize (total_len); - - for (int level = 3; level < _nbr_bits; ++level) - { - const long level_len = 1L << (level - 1); - DataType * const level_ptr = - &_trigo_lut [get_trigo_level_index (level)]; - const double mul = PI / (level_len << 1); - - for (long i = 0; i < level_len; ++ i) - { - level_ptr [i] = static_cast (cos (i * mul)); - } - } - } -} - - - -template -void FFTReal
::init_trigo_osc () -{ - const int nbr_osc = _nbr_bits - TRIGO_BD_LIMIT; - if (nbr_osc > 0) - { - _trigo_osc.resize (nbr_osc); - - for (int osc_cnt = 0; osc_cnt < nbr_osc; ++osc_cnt) - { - OscType & osc = _trigo_osc [osc_cnt]; - - const long len = 1L << (TRIGO_BD_LIMIT + osc_cnt); - const double mul = (0.5 * PI) / len; - osc.set_step (mul); - } - } -} - - - -template -const long * FFTReal
::get_br_ptr () const -{ - return (&_br_lut [0]); -} - - - -template -const typename FFTReal
::DataType * FFTReal
::get_trigo_ptr (int level) const -{ - assert (level >= 3); - - return (&_trigo_lut [get_trigo_level_index (level)]); -} - - - -template -long FFTReal
::get_trigo_level_index (int level) const -{ - assert (level >= 3); - - return ((1L << (level - 1)) - 4); -} - - - -// Transform in several passes -template -void FFTReal
::compute_fft_general (DataType f [], const DataType x []) const -{ - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); - - DataType * sf; - DataType * df; - - if ((_nbr_bits & 1) != 0) - { - df = use_buffer (); - sf = f; - } - else - { - df = f; - sf = use_buffer (); - } - - compute_direct_pass_1_2 (df, x); - compute_direct_pass_3 (sf, df); - - for (int pass = 3; pass < _nbr_bits; ++ pass) - { - compute_direct_pass_n (df, sf, pass); - - DataType * const temp_ptr = df; - df = sf; - sf = temp_ptr; - } -} - - - -template -void FFTReal
::compute_direct_pass_1_2 (DataType df [], const DataType x []) const -{ - assert (df != 0); - assert (x != 0); - assert (df != x); - - const long * const bit_rev_lut_ptr = get_br_ptr (); - long coef_index = 0; - do - { - const long rev_index_0 = bit_rev_lut_ptr [coef_index]; - const long rev_index_1 = bit_rev_lut_ptr [coef_index + 1]; - const long rev_index_2 = bit_rev_lut_ptr [coef_index + 2]; - const long rev_index_3 = bit_rev_lut_ptr [coef_index + 3]; - - DataType * const df2 = df + coef_index; - df2 [1] = x [rev_index_0] - x [rev_index_1]; - df2 [3] = x [rev_index_2] - x [rev_index_3]; - - const DataType sf_0 = x [rev_index_0] + x [rev_index_1]; - const DataType sf_2 = x [rev_index_2] + x [rev_index_3]; - - df2 [0] = sf_0 + sf_2; - df2 [2] = sf_0 - sf_2; - - coef_index += 4; - } - while (coef_index < _length); -} - - - -template -void FFTReal
::compute_direct_pass_3 (DataType df [], const DataType sf []) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - long coef_index = 0; - do - { - DataType v; - - df [coef_index] = sf [coef_index] + sf [coef_index + 4]; - df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; - df [coef_index + 2] = sf [coef_index + 2]; - df [coef_index + 6] = sf [coef_index + 6]; - - v = (sf [coef_index + 5] - sf [coef_index + 7]) * sqrt2_2; - df [coef_index + 1] = sf [coef_index + 1] + v; - df [coef_index + 3] = sf [coef_index + 1] - v; - - v = (sf [coef_index + 5] + sf [coef_index + 7]) * sqrt2_2; - df [coef_index + 5] = v + sf [coef_index + 3]; - df [coef_index + 7] = v - sf [coef_index + 3]; - - coef_index += 8; - } - while (coef_index < _length); -} - - - -template -void FFTReal
::compute_direct_pass_n (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); - - if (pass <= TRIGO_BD_LIMIT) - { - compute_direct_pass_n_lut (df, sf, pass); - } - else - { - compute_direct_pass_n_osc (df, sf, pass); - } -} - - - -template -void FFTReal
::compute_direct_pass_n_lut (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); - - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - const DataType * const cos_ptr = get_trigo_ptr (pass); - do - { - const DataType * const sf1r = sf + coef_index; - const DataType * const sf2r = sf1r + nbr_coef; - DataType * const dfr = df + coef_index; - DataType * const dfi = dfr + nbr_coef; - - // Extreme coefficients are always real - dfr [0] = sf1r [0] + sf2r [0]; - dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = - dfr [h_nbr_coef] = sf1r [h_nbr_coef]; - dfi [h_nbr_coef] = sf2r [h_nbr_coef]; - - // Others are conjugate complex numbers - const DataType * const sf1i = sf1r + h_nbr_coef; - const DataType * const sf2i = sf1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); - const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); - DataType v; - - v = sf2r [i] * c - sf2i [i] * s; - dfr [i] = sf1r [i] + v; - dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = - - v = sf2r [i] * s + sf2i [i] * c; - dfi [i] = v + sf1i [i]; - dfi [nbr_coef - i] = v - sf1i [i]; - } - - coef_index += d_nbr_coef; - } - while (coef_index < _length); -} - - - -template -void FFTReal
::compute_direct_pass_n_osc (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass > TRIGO_BD_LIMIT); - assert (pass < _nbr_bits); - - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; - do - { - const DataType * const sf1r = sf + coef_index; - const DataType * const sf2r = sf1r + nbr_coef; - DataType * const dfr = df + coef_index; - DataType * const dfi = dfr + nbr_coef; - - osc.clear_buffers (); - - // Extreme coefficients are always real - dfr [0] = sf1r [0] + sf2r [0]; - dfi [0] = sf1r [0] - sf2r [0]; // dfr [nbr_coef] = - dfr [h_nbr_coef] = sf1r [h_nbr_coef]; - dfi [h_nbr_coef] = sf2r [h_nbr_coef]; - - // Others are conjugate complex numbers - const DataType * const sf1i = sf1r + h_nbr_coef; - const DataType * const sf2i = sf1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - osc.step (); - const DataType c = osc.get_cos (); - const DataType s = osc.get_sin (); - DataType v; - - v = sf2r [i] * c - sf2i [i] * s; - dfr [i] = sf1r [i] + v; - dfi [-i] = sf1r [i] - v; // dfr [nbr_coef - i] = - - v = sf2r [i] * s + sf2i [i] * c; - dfi [i] = v + sf1i [i]; - dfi [nbr_coef - i] = v - sf1i [i]; - } - - coef_index += d_nbr_coef; - } - while (coef_index < _length); -} - - - -// Transform in several pass -template -void FFTReal
::compute_ifft_general (const DataType f [], DataType x []) const -{ - assert (f != 0); - assert (f != use_buffer ()); - assert (x != 0); - assert (x != use_buffer ()); - assert (x != f); - - DataType * sf = const_cast (f); - DataType * df; - DataType * df_temp; - - if (_nbr_bits & 1) - { - df = use_buffer (); - df_temp = x; - } - else - { - df = x; - df_temp = use_buffer (); - } - - for (int pass = _nbr_bits - 1; pass >= 3; -- pass) - { - compute_inverse_pass_n (df, sf, pass); - - if (pass < _nbr_bits - 1) - { - DataType * const temp_ptr = df; - df = sf; - sf = temp_ptr; - } - else - { - sf = df; - df = df_temp; - } - } - - compute_inverse_pass_3 (df, sf); - compute_inverse_pass_1_2 (x, df); -} - - - -template -void FFTReal
::compute_inverse_pass_n (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); - - if (pass <= TRIGO_BD_LIMIT) - { - compute_inverse_pass_n_lut (df, sf, pass); - } - else - { - compute_inverse_pass_n_osc (df, sf, pass); - } -} - - - -template -void FFTReal
::compute_inverse_pass_n_lut (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass >= 3); - assert (pass < _nbr_bits); - - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - const DataType * const cos_ptr = get_trigo_ptr (pass); - do - { - const DataType * const sfr = sf + coef_index; - const DataType * const sfi = sfr + nbr_coef; - DataType * const df1r = df + coef_index; - DataType * const df2r = df1r + nbr_coef; - - // Extreme coefficients are always real - df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] - df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] - df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; - df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; - - // Others are conjugate complex numbers - DataType * const df1i = df1r + h_nbr_coef; - DataType * const df2i = df1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] - df1i [i] = sfi [i] - sfi [nbr_coef - i]; - - const DataType c = cos_ptr [i]; // cos (i*PI/nbr_coef); - const DataType s = cos_ptr [h_nbr_coef - i]; // sin (i*PI/nbr_coef); - const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] - const DataType vi = sfi [i] + sfi [nbr_coef - i]; - - df2r [i] = vr * c + vi * s; - df2i [i] = vi * c - vr * s; - } - - coef_index += d_nbr_coef; - } - while (coef_index < _length); -} - - - -template -void FFTReal
::compute_inverse_pass_n_osc (DataType df [], const DataType sf [], int pass) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - assert (pass > TRIGO_BD_LIMIT); - assert (pass < _nbr_bits); - - const long nbr_coef = 1 << pass; - const long h_nbr_coef = nbr_coef >> 1; - const long d_nbr_coef = nbr_coef << 1; - long coef_index = 0; - OscType & osc = _trigo_osc [pass - (TRIGO_BD_LIMIT + 1)]; - do - { - const DataType * const sfr = sf + coef_index; - const DataType * const sfi = sfr + nbr_coef; - DataType * const df1r = df + coef_index; - DataType * const df2r = df1r + nbr_coef; - - osc.clear_buffers (); - - // Extreme coefficients are always real - df1r [0] = sfr [0] + sfi [0]; // + sfr [nbr_coef] - df2r [0] = sfr [0] - sfi [0]; // - sfr [nbr_coef] - df1r [h_nbr_coef] = sfr [h_nbr_coef] * 2; - df2r [h_nbr_coef] = sfi [h_nbr_coef] * 2; - - // Others are conjugate complex numbers - DataType * const df1i = df1r + h_nbr_coef; - DataType * const df2i = df1i + nbr_coef; - for (long i = 1; i < h_nbr_coef; ++ i) - { - df1r [i] = sfr [i] + sfi [-i]; // + sfr [nbr_coef - i] - df1i [i] = sfi [i] - sfi [nbr_coef - i]; - - osc.step (); - const DataType c = osc.get_cos (); - const DataType s = osc.get_sin (); - const DataType vr = sfr [i] - sfi [-i]; // - sfr [nbr_coef - i] - const DataType vi = sfi [i] + sfi [nbr_coef - i]; - - df2r [i] = vr * c + vi * s; - df2i [i] = vi * c - vr * s; - } - - coef_index += d_nbr_coef; - } - while (coef_index < _length); -} - - - -template -void FFTReal
::compute_inverse_pass_3 (DataType df [], const DataType sf []) const -{ - assert (df != 0); - assert (sf != 0); - assert (df != sf); - - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - long coef_index = 0; - do - { - df [coef_index] = sf [coef_index] + sf [coef_index + 4]; - df [coef_index + 4] = sf [coef_index] - sf [coef_index + 4]; - df [coef_index + 2] = sf [coef_index + 2] * 2; - df [coef_index + 6] = sf [coef_index + 6] * 2; - - df [coef_index + 1] = sf [coef_index + 1] + sf [coef_index + 3]; - df [coef_index + 3] = sf [coef_index + 5] - sf [coef_index + 7]; - - const DataType vr = sf [coef_index + 1] - sf [coef_index + 3]; - const DataType vi = sf [coef_index + 5] + sf [coef_index + 7]; - - df [coef_index + 5] = (vr + vi) * sqrt2_2; - df [coef_index + 7] = (vi - vr) * sqrt2_2; - - coef_index += 8; - } - while (coef_index < _length); -} - - - -template -void FFTReal
::compute_inverse_pass_1_2 (DataType x [], const DataType sf []) const -{ - assert (x != 0); - assert (sf != 0); - assert (x != sf); - - const long * bit_rev_lut_ptr = get_br_ptr (); - const DataType * sf2 = sf; - long coef_index = 0; - do - { - { - const DataType b_0 = sf2 [0] + sf2 [2]; - const DataType b_2 = sf2 [0] - sf2 [2]; - const DataType b_1 = sf2 [1] * 2; - const DataType b_3 = sf2 [3] * 2; - - x [bit_rev_lut_ptr [0]] = b_0 + b_1; - x [bit_rev_lut_ptr [1]] = b_0 - b_1; - x [bit_rev_lut_ptr [2]] = b_2 + b_3; - x [bit_rev_lut_ptr [3]] = b_2 - b_3; - } - { - const DataType b_0 = sf2 [4] + sf2 [6]; - const DataType b_2 = sf2 [4] - sf2 [6]; - const DataType b_1 = sf2 [5] * 2; - const DataType b_3 = sf2 [7] * 2; - - x [bit_rev_lut_ptr [4]] = b_0 + b_1; - x [bit_rev_lut_ptr [5]] = b_0 - b_1; - x [bit_rev_lut_ptr [6]] = b_2 + b_3; - x [bit_rev_lut_ptr [7]] = b_2 - b_3; - } - - sf2 += 8; - coef_index += 8; - bit_rev_lut_ptr += 8; - } - while (coef_index < _length); -} - - - -#endif // FFTReal_CODEHEADER_INCLUDED - -#undef FFTReal_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealFixLen.h b/examples/spectrum/3rdparty/fftreal/FFTRealFixLen.h deleted file mode 100644 index 0b802668..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealFixLen.h +++ /dev/null @@ -1,130 +0,0 @@ -/***************************************************************************** - - FFTRealFixLen.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealFixLen_HEADER_INCLUDED) -#define FFTRealFixLen_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "Array.h" -#include "DynArray.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - - -template -class FFTRealFixLen -{ - typedef int CompileTimeCheck1 [(LL2 >= 0) ? 1 : -1]; - typedef int CompileTimeCheck2 [(LL2 <= 30) ? 1 : -1]; - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; - - enum { FFT_LEN_L2 = LL2 }; - enum { FFT_LEN = 1 << FFT_LEN_L2 }; - - FFTRealFixLen (); - - inline long get_length () const; - void do_fft (DataType f [], const DataType x []); - void do_ifft (const DataType f [], DataType x []); - void rescale (DataType x []) const; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - enum { TRIGO_BD_LIMIT = FFTRealFixLenParam::TRIGO_BD_LIMIT }; - - enum { BR_ARR_SIZE_L2 = ((FFT_LEN_L2 - 3) < 0) ? 0 : (FFT_LEN_L2 - 2) }; - enum { BR_ARR_SIZE = 1 << BR_ARR_SIZE_L2 }; - - enum { TRIGO_BD = ((FFT_LEN_L2 - TRIGO_BD_LIMIT) < 0) - ? (int)FFT_LEN_L2 - : (int)TRIGO_BD_LIMIT }; - enum { TRIGO_TABLE_ARR_SIZE_L2 = (LL2 < 4) ? 0 : (TRIGO_BD - 2) }; - enum { TRIGO_TABLE_ARR_SIZE = 1 << TRIGO_TABLE_ARR_SIZE_L2 }; - - enum { NBR_TRIGO_OSC = FFT_LEN_L2 - TRIGO_BD }; - enum { TRIGO_OSC_ARR_SIZE = (NBR_TRIGO_OSC > 0) ? NBR_TRIGO_OSC : 1 }; - - void build_br_lut (); - void build_trigo_lut (); - void build_trigo_osc (); - - DynArray - _buffer; - DynArray - _br_data; - DynArray - _trigo_data; - Array - _trigo_osc; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealFixLen (const FFTRealFixLen &other); - FFTRealFixLen& operator = (const FFTRealFixLen &other); - bool operator == (const FFTRealFixLen &other); - bool operator != (const FFTRealFixLen &other); - -}; // class FFTRealFixLen - - - -#include "FFTRealFixLen.hpp" - - - -#endif // FFTRealFixLen_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp b/examples/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp deleted file mode 100644 index 6defb009..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealFixLen.hpp +++ /dev/null @@ -1,322 +0,0 @@ -/***************************************************************************** - - FFTRealFixLen.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealFixLen_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealFixLen code header. -#endif -#define FFTRealFixLen_CURRENT_CODEHEADER - -#if ! defined (FFTRealFixLen_CODEHEADER_INCLUDED) -#define FFTRealFixLen_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "FFTRealPassDirect.h" -#include "FFTRealPassInverse.h" -#include "FFTRealSelect.h" - -#include -#include - -namespace std { } - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -FFTRealFixLen ::FFTRealFixLen () -: _buffer (FFT_LEN) -, _br_data (BR_ARR_SIZE) -, _trigo_data (TRIGO_TABLE_ARR_SIZE) -, _trigo_osc () -{ - build_br_lut (); - build_trigo_lut (); - build_trigo_osc (); -} - - - -template -long FFTRealFixLen ::get_length () const -{ - return (FFT_LEN); -} - - - -// General case -template -void FFTRealFixLen ::do_fft (DataType f [], const DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - assert (FFT_LEN_L2 >= 3); - - // Do the transform in several passes - const DataType * cos_ptr = &_trigo_data [0]; - const long * br_ptr = &_br_data [0]; - - FFTRealPassDirect ::process ( - FFT_LEN, - f, - &_buffer [0], - x, - cos_ptr, - TRIGO_TABLE_ARR_SIZE, - br_ptr, - &_trigo_osc [0] - ); -} - -// 4-point FFT -template <> -void FFTRealFixLen <2>::do_fft (DataType f [], const DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - f [1] = x [0] - x [2]; - f [3] = x [1] - x [3]; - - const DataType b_0 = x [0] + x [2]; - const DataType b_2 = x [1] + x [3]; - - f [0] = b_0 + b_2; - f [2] = b_0 - b_2; -} - -// 2-point FFT -template <> -void FFTRealFixLen <1>::do_fft (DataType f [], const DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - f [0] = x [0] + x [1]; - f [1] = x [0] - x [1]; -} - -// 1-point FFT -template <> -void FFTRealFixLen <0>::do_fft (DataType f [], const DataType x []) -{ - assert (f != 0); - assert (x != 0); - - f [0] = x [0]; -} - - - -// General case -template -void FFTRealFixLen ::do_ifft (const DataType f [], DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - assert (FFT_LEN_L2 >= 3); - - // Do the transform in several passes - DataType * s_ptr = - FFTRealSelect ::sel_bin (&_buffer [0], x); - DataType * d_ptr = - FFTRealSelect ::sel_bin (x, &_buffer [0]); - const DataType * cos_ptr = &_trigo_data [0]; - const long * br_ptr = &_br_data [0]; - - FFTRealPassInverse ::process ( - FFT_LEN, - d_ptr, - s_ptr, - f, - cos_ptr, - TRIGO_TABLE_ARR_SIZE, - br_ptr, - &_trigo_osc [0] - ); -} - -// 4-point IFFT -template <> -void FFTRealFixLen <2>::do_ifft (const DataType f [], DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - const DataType b_0 = f [0] + f [2]; - const DataType b_2 = f [0] - f [2]; - - x [0] = b_0 + f [1] * 2; - x [2] = b_0 - f [1] * 2; - x [1] = b_2 + f [3] * 2; - x [3] = b_2 - f [3] * 2; -} - -// 2-point IFFT -template <> -void FFTRealFixLen <1>::do_ifft (const DataType f [], DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - x [0] = f [0] + f [1]; - x [1] = f [0] - f [1]; -} - -// 1-point IFFT -template <> -void FFTRealFixLen <0>::do_ifft (const DataType f [], DataType x []) -{ - assert (f != 0); - assert (x != 0); - assert (x != f); - - x [0] = f [0]; -} - - - - -template -void FFTRealFixLen ::rescale (DataType x []) const -{ - assert (x != 0); - - const DataType mul = DataType (1.0 / FFT_LEN); - - if (FFT_LEN < 4) - { - long i = FFT_LEN - 1; - do - { - x [i] *= mul; - --i; - } - while (i >= 0); - } - - else - { - assert ((FFT_LEN & 3) == 0); - - // Could be optimized with SIMD instruction sets (needs alignment check) - long i = FFT_LEN - 4; - do - { - x [i + 0] *= mul; - x [i + 1] *= mul; - x [i + 2] *= mul; - x [i + 3] *= mul; - i -= 4; - } - while (i >= 0); - } -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void FFTRealFixLen ::build_br_lut () -{ - _br_data [0] = 0; - for (long cnt = 1; cnt < BR_ARR_SIZE; ++cnt) - { - long index = cnt << 2; - long br_index = 0; - - int bit_cnt = FFT_LEN_L2; - do - { - br_index <<= 1; - br_index += (index & 1); - index >>= 1; - - -- bit_cnt; - } - while (bit_cnt > 0); - - _br_data [cnt] = br_index; - } -} - - - -template -void FFTRealFixLen ::build_trigo_lut () -{ - const double mul = (0.5 * PI) / TRIGO_TABLE_ARR_SIZE; - for (long i = 0; i < TRIGO_TABLE_ARR_SIZE; ++ i) - { - using namespace std; - - _trigo_data [i] = DataType (cos (i * mul)); - } -} - - - -template -void FFTRealFixLen ::build_trigo_osc () -{ - for (int i = 0; i < NBR_TRIGO_OSC; ++i) - { - OscType & osc = _trigo_osc [i]; - - const long len = static_cast (TRIGO_TABLE_ARR_SIZE) << (i + 1); - const double mul = (0.5 * PI) / len; - osc.set_step (mul); - } -} - - - -#endif // FFTRealFixLen_CODEHEADER_INCLUDED - -#undef FFTRealFixLen_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h b/examples/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h deleted file mode 100644 index 163c0832..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealFixLenParam.h +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - - FFTRealFixLenParam.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealFixLenParam_HEADER_INCLUDED) -#define FFTRealFixLenParam_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -class FFTRealFixLenParam -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - // Over this bit depth, we use direct calculation for sin/cos - enum { TRIGO_BD_LIMIT = 12 }; - - typedef float DataType; - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - -#if 0 // To avoid GCC warning: - // All member functions in class 'FFTRealFixLenParam' are private - FFTRealFixLenParam (); - ~FFTRealFixLenParam (); - FFTRealFixLenParam (const FFTRealFixLenParam &other); - FFTRealFixLenParam & - operator = (const FFTRealFixLenParam &other); - bool operator == (const FFTRealFixLenParam &other); - bool operator != (const FFTRealFixLenParam &other); -#endif - -}; // class FFTRealFixLenParam - - - -//#include "FFTRealFixLenParam.hpp" - - - -#endif // FFTRealFixLenParam_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealPassDirect.h b/examples/spectrum/3rdparty/fftreal/FFTRealPassDirect.h deleted file mode 100644 index 7d19c02e..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealPassDirect.h +++ /dev/null @@ -1,96 +0,0 @@ -/***************************************************************************** - - FFTRealPassDirect.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealPassDirect_HEADER_INCLUDED) -#define FFTRealPassDirect_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - - -template -class FFTRealPassDirect -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; - - FORCEINLINE static void - process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealPassDirect (); - ~FFTRealPassDirect (); - FFTRealPassDirect (const FFTRealPassDirect &other); - FFTRealPassDirect & - operator = (const FFTRealPassDirect &other); - bool operator == (const FFTRealPassDirect &other); - bool operator != (const FFTRealPassDirect &other); - -}; // class FFTRealPassDirect - - - -#include "FFTRealPassDirect.hpp" - - - -#endif // FFTRealPassDirect_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp b/examples/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp deleted file mode 100644 index db9d568e..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealPassDirect.hpp +++ /dev/null @@ -1,204 +0,0 @@ -/***************************************************************************** - - FFTRealPassDirect.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealPassDirect_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealPassDirect code header. -#endif -#define FFTRealPassDirect_CURRENT_CODEHEADER - -#if ! defined (FFTRealPassDirect_CODEHEADER_INCLUDED) -#define FFTRealPassDirect_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "FFTRealUseTrigo.h" - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template <> -void FFTRealPassDirect <1>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // First and second pass at once - const long qlen = len >> 2; - - long coef_index = 0; - do - { - // To do: unroll the loop (2x). - const long ri_0 = br_ptr [coef_index >> 2]; - const long ri_1 = ri_0 + 2 * qlen; // bit_rev_lut_ptr [coef_index + 1]; - const long ri_2 = ri_0 + 1 * qlen; // bit_rev_lut_ptr [coef_index + 2]; - const long ri_3 = ri_0 + 3 * qlen; // bit_rev_lut_ptr [coef_index + 3]; - - DataType * const df2 = dest_ptr + coef_index; - df2 [1] = x_ptr [ri_0] - x_ptr [ri_1]; - df2 [3] = x_ptr [ri_2] - x_ptr [ri_3]; - - const DataType sf_0 = x_ptr [ri_0] + x_ptr [ri_1]; - const DataType sf_2 = x_ptr [ri_2] + x_ptr [ri_3]; - - df2 [0] = sf_0 + sf_2; - df2 [2] = sf_0 - sf_2; - - coef_index += 4; - } - while (coef_index < len); -} - -template <> -void FFTRealPassDirect <2>::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Executes "previous" passes first. Inverts source and destination buffers - FFTRealPassDirect <1>::process ( - len, - src_ptr, - dest_ptr, - x_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - - // Third pass - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - - long coef_index = 0; - do - { - dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; - dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; - dest_ptr [coef_index + 2] = src_ptr [coef_index + 2]; - dest_ptr [coef_index + 6] = src_ptr [coef_index + 6]; - - DataType v; - - v = (src_ptr [coef_index + 5] - src_ptr [coef_index + 7]) * sqrt2_2; - dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + v; - dest_ptr [coef_index + 3] = src_ptr [coef_index + 1] - v; - - v = (src_ptr [coef_index + 5] + src_ptr [coef_index + 7]) * sqrt2_2; - dest_ptr [coef_index + 5] = v + src_ptr [coef_index + 3]; - dest_ptr [coef_index + 7] = v - src_ptr [coef_index + 3]; - - coef_index += 8; - } - while (coef_index < len); -} - -template -void FFTRealPassDirect ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType x_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Executes "previous" passes first. Inverts source and destination buffers - FFTRealPassDirect ::process ( - len, - src_ptr, - dest_ptr, - x_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - - const long dist = 1L << (PASS - 1); - const long c1_r = 0; - const long c1_i = dist; - const long c2_r = dist * 2; - const long c2_i = dist * 3; - const long cend = dist * 4; - const long table_step = cos_len >> (PASS - 1); - - enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; - enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; - - long coef_index = 0; - do - { - const DataType * const sf = src_ptr + coef_index; - DataType * const df = dest_ptr + coef_index; - - // Extreme coefficients are always real - df [c1_r] = sf [c1_r] + sf [c2_r]; - df [c2_r] = sf [c1_r] - sf [c2_r]; - df [c1_i] = sf [c1_i]; - df [c2_i] = sf [c2_i]; - - FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); - - // Others are conjugate complex numbers - for (long i = 1; i < dist; ++ i) - { - DataType c; - DataType s; - FFTRealUseTrigo ::iterate ( - osc_list [TRIGO_OSC], - c, - s, - cos_ptr, - i * table_step, - (dist - i) * table_step - ); - - const DataType sf_r_i = sf [c1_r + i]; - const DataType sf_i_i = sf [c1_i + i]; - - const DataType v1 = sf [c2_r + i] * c - sf [c2_i + i] * s; - df [c1_r + i] = sf_r_i + v1; - df [c2_r - i] = sf_r_i - v1; - - const DataType v2 = sf [c2_r + i] * s + sf [c2_i + i] * c; - df [c2_r + i] = v2 + sf_i_i; - df [cend - i] = v2 - sf_i_i; - } - - coef_index += cend; - } - while (coef_index < len); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // FFTRealPassDirect_CODEHEADER_INCLUDED - -#undef FFTRealPassDirect_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealPassInverse.h b/examples/spectrum/3rdparty/fftreal/FFTRealPassInverse.h deleted file mode 100644 index 2de89527..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealPassInverse.h +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - - FFTRealPassInverse.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealPassInverse_HEADER_INCLUDED) -#define FFTRealPassInverse_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - - - -template -class FFTRealPassInverse -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; - - FORCEINLINE static void - process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - FORCEINLINE static void - process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - FORCEINLINE static void - process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealPassInverse (); - ~FFTRealPassInverse (); - FFTRealPassInverse (const FFTRealPassInverse &other); - FFTRealPassInverse & - operator = (const FFTRealPassInverse &other); - bool operator == (const FFTRealPassInverse &other); - bool operator != (const FFTRealPassInverse &other); - -}; // class FFTRealPassInverse - - - -#include "FFTRealPassInverse.hpp" - - - -#endif // FFTRealPassInverse_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp b/examples/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp deleted file mode 100644 index 57375469..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealPassInverse.hpp +++ /dev/null @@ -1,229 +0,0 @@ -/***************************************************************************** - - FFTRealPassInverse.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealPassInverse_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealPassInverse code header. -#endif -#define FFTRealPassInverse_CURRENT_CODEHEADER - -#if ! defined (FFTRealPassInverse_CODEHEADER_INCLUDED) -#define FFTRealPassInverse_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "FFTRealUseTrigo.h" - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void FFTRealPassInverse ::process (long len, DataType dest_ptr [], DataType src_ptr [], const DataType f_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - process_internal ( - len, - dest_ptr, - f_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - FFTRealPassInverse ::process_rec ( - len, - src_ptr, - dest_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); -} - - - -template -void FFTRealPassInverse ::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - process_internal ( - len, - dest_ptr, - src_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); - FFTRealPassInverse ::process_rec ( - len, - src_ptr, - dest_ptr, - cos_ptr, - cos_len, - br_ptr, - osc_list - ); -} - -template <> -void FFTRealPassInverse <0>::process_rec (long len, DataType dest_ptr [], DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Stops recursion -} - - - -template -void FFTRealPassInverse ::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - const long dist = 1L << (PASS - 1); - const long c1_r = 0; - const long c1_i = dist; - const long c2_r = dist * 2; - const long c2_i = dist * 3; - const long cend = dist * 4; - const long table_step = cos_len >> (PASS - 1); - - enum { TRIGO_OSC = PASS - FFTRealFixLenParam::TRIGO_BD_LIMIT }; - enum { TRIGO_DIRECT = (TRIGO_OSC >= 0) ? 1 : 0 }; - - long coef_index = 0; - do - { - const DataType * const sf = src_ptr + coef_index; - DataType * const df = dest_ptr + coef_index; - - // Extreme coefficients are always real - df [c1_r] = sf [c1_r] + sf [c2_r]; - df [c2_r] = sf [c1_r] - sf [c2_r]; - df [c1_i] = sf [c1_i] * 2; - df [c2_i] = sf [c2_i] * 2; - - FFTRealUseTrigo ::prepare (osc_list [TRIGO_OSC]); - - // Others are conjugate complex numbers - for (long i = 1; i < dist; ++ i) - { - df [c1_r + i] = sf [c1_r + i] + sf [c2_r - i]; - df [c1_i + i] = sf [c2_r + i] - sf [cend - i]; - - DataType c; - DataType s; - FFTRealUseTrigo ::iterate ( - osc_list [TRIGO_OSC], - c, - s, - cos_ptr, - i * table_step, - (dist - i) * table_step - ); - - const DataType vr = sf [c1_r + i] - sf [c2_r - i]; - const DataType vi = sf [c2_r + i] + sf [cend - i]; - - df [c2_r + i] = vr * c + vi * s; - df [c2_i + i] = vi * c - vr * s; - } - - coef_index += cend; - } - while (coef_index < len); -} - -template <> -void FFTRealPassInverse <2>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Antepenultimate pass - const DataType sqrt2_2 = DataType (SQRT2 * 0.5); - - long coef_index = 0; - do - { - dest_ptr [coef_index ] = src_ptr [coef_index] + src_ptr [coef_index + 4]; - dest_ptr [coef_index + 4] = src_ptr [coef_index] - src_ptr [coef_index + 4]; - dest_ptr [coef_index + 2] = src_ptr [coef_index + 2] * 2; - dest_ptr [coef_index + 6] = src_ptr [coef_index + 6] * 2; - - dest_ptr [coef_index + 1] = src_ptr [coef_index + 1] + src_ptr [coef_index + 3]; - dest_ptr [coef_index + 3] = src_ptr [coef_index + 5] - src_ptr [coef_index + 7]; - - const DataType vr = src_ptr [coef_index + 1] - src_ptr [coef_index + 3]; - const DataType vi = src_ptr [coef_index + 5] + src_ptr [coef_index + 7]; - - dest_ptr [coef_index + 5] = (vr + vi) * sqrt2_2; - dest_ptr [coef_index + 7] = (vi - vr) * sqrt2_2; - - coef_index += 8; - } - while (coef_index < len); -} - -template <> -void FFTRealPassInverse <1>::process_internal (long len, DataType dest_ptr [], const DataType src_ptr [], const DataType cos_ptr [], long cos_len, const long br_ptr [], OscType osc_list []) -{ - // Penultimate and last pass at once - const long qlen = len >> 2; - - long coef_index = 0; - do - { - const long ri_0 = br_ptr [coef_index >> 2]; - - const DataType b_0 = src_ptr [coef_index ] + src_ptr [coef_index + 2]; - const DataType b_2 = src_ptr [coef_index ] - src_ptr [coef_index + 2]; - const DataType b_1 = src_ptr [coef_index + 1] * 2; - const DataType b_3 = src_ptr [coef_index + 3] * 2; - - dest_ptr [ri_0 ] = b_0 + b_1; - dest_ptr [ri_0 + 2 * qlen] = b_0 - b_1; - dest_ptr [ri_0 + 1 * qlen] = b_2 + b_3; - dest_ptr [ri_0 + 3 * qlen] = b_2 - b_3; - - coef_index += 4; - } - while (coef_index < len); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // FFTRealPassInverse_CODEHEADER_INCLUDED - -#undef FFTRealPassInverse_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealSelect.h b/examples/spectrum/3rdparty/fftreal/FFTRealSelect.h deleted file mode 100644 index bd722d4d..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealSelect.h +++ /dev/null @@ -1,77 +0,0 @@ -/***************************************************************************** - - FFTRealSelect.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealSelect_HEADER_INCLUDED) -#define FFTRealSelect_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" - - - -template -class FFTRealSelect -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - FORCEINLINE static float * - sel_bin (float *e_ptr, float *o_ptr); - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealSelect (); - ~FFTRealSelect (); - FFTRealSelect (const FFTRealSelect &other); - FFTRealSelect& operator = (const FFTRealSelect &other); - bool operator == (const FFTRealSelect &other); - bool operator != (const FFTRealSelect &other); - -}; // class FFTRealSelect - - - -#include "FFTRealSelect.hpp" - - - -#endif // FFTRealSelect_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealSelect.hpp b/examples/spectrum/3rdparty/fftreal/FFTRealSelect.hpp deleted file mode 100644 index 9ddf5864..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealSelect.hpp +++ /dev/null @@ -1,62 +0,0 @@ -/***************************************************************************** - - FFTRealSelect.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealSelect_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealSelect code header. -#endif -#define FFTRealSelect_CURRENT_CODEHEADER - -#if ! defined (FFTRealSelect_CODEHEADER_INCLUDED) -#define FFTRealSelect_CODEHEADER_INCLUDED - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -float * FFTRealSelect

::sel_bin (float *e_ptr, float *o_ptr) -{ - return (o_ptr); -} - - - -template <> -float * FFTRealSelect <0>::sel_bin (float *e_ptr, float *o_ptr) -{ - return (e_ptr); -} - - - -#endif // FFTRealSelect_CODEHEADER_INCLUDED - -#undef FFTRealSelect_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h b/examples/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h deleted file mode 100644 index c4368ee0..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealUseTrigo.h +++ /dev/null @@ -1,101 +0,0 @@ -/***************************************************************************** - - FFTRealUseTrigo.h - Copyright (c) 2005 Laurent de Soras - -Template parameters: - - ALGO: algorithm choice. 0 = table, other = oscillator - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (FFTRealUseTrigo_HEADER_INCLUDED) -#define FFTRealUseTrigo_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "FFTRealFixLenParam.h" -#include "OscSinCos.h" - - - -template -class FFTRealUseTrigo -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLenParam::DataType DataType; - typedef OscSinCos OscType; - - FORCEINLINE static void - prepare (OscType &osc); - FORCEINLINE static void - iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - FFTRealUseTrigo (); - ~FFTRealUseTrigo (); - FFTRealUseTrigo (const FFTRealUseTrigo &other); - FFTRealUseTrigo & - operator = (const FFTRealUseTrigo &other); - bool operator == (const FFTRealUseTrigo &other); - bool operator != (const FFTRealUseTrigo &other); - -}; // class FFTRealUseTrigo - - - -#include "FFTRealUseTrigo.hpp" - - - -#endif // FFTRealUseTrigo_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp b/examples/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp deleted file mode 100644 index aa968b81..00000000 --- a/examples/spectrum/3rdparty/fftreal/FFTRealUseTrigo.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************** - - FFTRealUseTrigo.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (FFTRealUseTrigo_CURRENT_CODEHEADER) - #error Recursive inclusion of FFTRealUseTrigo code header. -#endif -#define FFTRealUseTrigo_CURRENT_CODEHEADER - -#if ! defined (FFTRealUseTrigo_CODEHEADER_INCLUDED) -#define FFTRealUseTrigo_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "OscSinCos.h" - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void FFTRealUseTrigo ::prepare (OscType &osc) -{ - osc.clear_buffers (); -} - -template <> -void FFTRealUseTrigo <0>::prepare (OscType &osc) -{ - // Nothing -} - - - -template -void FFTRealUseTrigo ::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) -{ - osc.step (); - c = osc.get_cos (); - s = osc.get_sin (); -} - -template <> -void FFTRealUseTrigo <0>::iterate (OscType &osc, DataType &c, DataType &s, const DataType cos_ptr [], long index_c, long index_s) -{ - c = cos_ptr [index_c]; - s = cos_ptr [index_s]; -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // FFTRealUseTrigo_CODEHEADER_INCLUDED - -#undef FFTRealUseTrigo_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/OscSinCos.h b/examples/spectrum/3rdparty/fftreal/OscSinCos.h deleted file mode 100644 index 775fc14f..00000000 --- a/examples/spectrum/3rdparty/fftreal/OscSinCos.h +++ /dev/null @@ -1,106 +0,0 @@ -/***************************************************************************** - - OscSinCos.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (OscSinCos_HEADER_INCLUDED) -#define OscSinCos_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" - - - -template -class OscSinCos -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef T DataType; - - OscSinCos (); - - FORCEINLINE void - set_step (double angle_rad); - - FORCEINLINE DataType - get_cos () const; - FORCEINLINE DataType - get_sin () const; - FORCEINLINE void - step (); - FORCEINLINE void - clear_buffers (); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - DataType _pos_cos; // Current phase expressed with sin and cos. [-1 ; 1] - DataType _pos_sin; // - - DataType _step_cos; // Phase increment per step, [-1 ; 1] - DataType _step_sin; // - - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - OscSinCos (const OscSinCos &other); - OscSinCos & operator = (const OscSinCos &other); - bool operator == (const OscSinCos &other); - bool operator != (const OscSinCos &other); - -}; // class OscSinCos - - - -#include "OscSinCos.hpp" - - - -#endif // OscSinCos_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/OscSinCos.hpp b/examples/spectrum/3rdparty/fftreal/OscSinCos.hpp deleted file mode 100644 index 749aef04..00000000 --- a/examples/spectrum/3rdparty/fftreal/OscSinCos.hpp +++ /dev/null @@ -1,122 +0,0 @@ -/***************************************************************************** - - OscSinCos.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (OscSinCos_CURRENT_CODEHEADER) - #error Recursive inclusion of OscSinCos code header. -#endif -#define OscSinCos_CURRENT_CODEHEADER - -#if ! defined (OscSinCos_CODEHEADER_INCLUDED) -#define OscSinCos_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include - -namespace std { } - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -OscSinCos ::OscSinCos () -: _pos_cos (1) -, _pos_sin (0) -, _step_cos (1) -, _step_sin (0) -{ - // Nothing -} - - - -template -void OscSinCos ::set_step (double angle_rad) -{ - using namespace std; - - _step_cos = static_cast (cos (angle_rad)); - _step_sin = static_cast (sin (angle_rad)); -} - - - -template -typename OscSinCos ::DataType OscSinCos ::get_cos () const -{ - return (_pos_cos); -} - - - -template -typename OscSinCos ::DataType OscSinCos ::get_sin () const -{ - return (_pos_sin); -} - - - -template -void OscSinCos ::step () -{ - const DataType old_cos = _pos_cos; - const DataType old_sin = _pos_sin; - - _pos_cos = old_cos * _step_cos - old_sin * _step_sin; - _pos_sin = old_cos * _step_sin + old_sin * _step_cos; -} - - - -template -void OscSinCos ::clear_buffers () -{ - _pos_cos = static_cast (1); - _pos_sin = static_cast (0); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // OscSinCos_CODEHEADER_INCLUDED - -#undef OscSinCos_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestAccuracy.h b/examples/spectrum/3rdparty/fftreal/TestAccuracy.h deleted file mode 100644 index 4b07a6b6..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestAccuracy.h +++ /dev/null @@ -1,105 +0,0 @@ -/***************************************************************************** - - TestAccuracy.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestAccuracy_HEADER_INCLUDED) -#define TestAccuracy_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class TestAccuracy -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef typename FO::DataType DataType; - typedef long double BigFloat; // To get maximum accuracy during intermediate calculations - - static int perform_test_single_object (FO &fft); - static int perform_test_d (FO &fft, const char *class_name_0); - static int perform_test_i (FO &fft, const char *class_name_0); - static int perform_test_di (FO &fft, const char *class_name_0); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - enum { NBR_ACC_TESTS = 10 * 1000 * 1000 }; - enum { MAX_NBR_TESTS = 10000 }; - - static void compute_tf (DataType s [], const DataType x [], long length); - static void compute_itf (DataType x [], const DataType s [], long length); - static int compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel); - static BigFloat - compute_power (const DataType x_ptr [], long len); - static BigFloat - compute_power (const DataType x_ptr [], const DataType y_ptr [], long len); - static void compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len); - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestAccuracy (); - ~TestAccuracy (); - TestAccuracy (const TestAccuracy &other); - TestAccuracy & operator = (const TestAccuracy &other); - bool operator == (const TestAccuracy &other); - bool operator != (const TestAccuracy &other); - -}; // class TestAccuracy - - - -#include "TestAccuracy.hpp" - - - -#endif // TestAccuracy_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestAccuracy.hpp b/examples/spectrum/3rdparty/fftreal/TestAccuracy.hpp deleted file mode 100644 index 5c794f74..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestAccuracy.hpp +++ /dev/null @@ -1,472 +0,0 @@ -/***************************************************************************** - - TestAccuracy.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestAccuracy_CURRENT_CODEHEADER) - #error Recursive inclusion of TestAccuracy code header. -#endif -#define TestAccuracy_CURRENT_CODEHEADER - -#if ! defined (TestAccuracy_CODEHEADER_INCLUDED) -#define TestAccuracy_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "def.h" -#include "test_fnc.h" -#include "TestWhiteNoiseGen.h" - -#include -#include - -#include -#include - - - -static const double TestAccuracy_LN10 = 2.3025850929940456840179914546844; - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -int TestAccuracy ::perform_test_single_object (FO &fft) -{ - assert (&fft != 0); - - using namespace std; - - int ret_val = 0; - - const std::type_info & ti = typeid (fft); - const char * class_name_0 = ti.name (); - - if (ret_val == 0) - { - ret_val = perform_test_d (fft, class_name_0); - } - if (ret_val == 0) - { - ret_val = perform_test_i (fft, class_name_0); - } - if (ret_val == 0) - { - ret_val = perform_test_di (fft, class_name_0); - } - - if (ret_val == 0) - { - printf ("\n"); - } - - return (ret_val); -} - - - -template -int TestAccuracy ::perform_test_d (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - using namespace std; - - int ret_val = 0; - const long len = fft.get_length (); - const long nbr_tests = limit ( - NBR_ACC_TESTS / len / len, - 1L, - static_cast (MAX_NBR_TESTS) - ); - - printf ("Testing %s::do_fft () [%ld samples]... ", class_name_0, len); - fflush (stdout); - TestWhiteNoiseGen noise; - std::vector x (len); - std::vector s1 (len); - std::vector s2 (len); - BigFloat err_avg = 0; - - for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) - { - noise.generate (&x [0], len); - fft.do_fft (&s1 [0], &x [0]); - compute_tf (&s2 [0], &x [0], len); - - BigFloat max_err; - compare_vect_display (&s1 [0], &s2 [0], len, max_err); - err_avg += max_err; - } - err_avg /= NBR_ACC_TESTS; - - printf ("done.\n"); - printf ( - "Average maximum error: %.6f %% (%f dB)\n", - static_cast (err_avg * 100), - static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) - ); - - return (ret_val); -} - - - -template -int TestAccuracy ::perform_test_i (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - using namespace std; - - int ret_val = 0; - const long len = fft.get_length (); - const long nbr_tests = limit ( - NBR_ACC_TESTS / len / len, - 10L, - static_cast (MAX_NBR_TESTS) - ); - - printf ("Testing %s::do_ifft () [%ld samples]... ", class_name_0, len); - fflush (stdout); - TestWhiteNoiseGen noise; - std::vector s (len); - std::vector x1 (len); - std::vector x2 (len); - BigFloat err_avg = 0; - - for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) - { - noise.generate (&s [0], len); - fft.do_ifft (&s [0], &x1 [0]); - compute_itf (&x2 [0], &s [0], len); - - BigFloat max_err; - compare_vect_display (&x1 [0], &x2 [0], len, max_err); - err_avg += max_err; - } - err_avg /= NBR_ACC_TESTS; - - printf ("done.\n"); - printf ( - "Average maximum error: %.6f %% (%f dB)\n", - static_cast (err_avg * 100), - static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) - ); - - return (ret_val); -} - - - -template -int TestAccuracy ::perform_test_di (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - using namespace std; - - int ret_val = 0; - const long len = fft.get_length (); - const long nbr_tests = limit ( - NBR_ACC_TESTS / len / len, - 1L, - static_cast (MAX_NBR_TESTS) - ); - - printf ( - "Testing %s::do_fft () / do_ifft () / rescale () [%ld samples]... ", - class_name_0, - len - ); - fflush (stdout); - TestWhiteNoiseGen noise; - std::vector x (len); - std::vector s (len); - std::vector y (len); - BigFloat err_avg = 0; - - for (long test = 0; test < nbr_tests && ret_val == 0; ++ test) - { - noise.generate (&x [0], len); - fft.do_fft (&s [0], &x [0]); - fft.do_ifft (&s [0], &y [0]); - fft.rescale (&y [0]); - - BigFloat max_err; - compare_vect_display (&x [0], &y [0], len, max_err); - err_avg += max_err; - } - err_avg /= NBR_ACC_TESTS; - - printf ("done.\n"); - printf ( - "Average maximum error: %.6f %% (%f dB)\n", - static_cast (err_avg * 100), - static_cast ((20 / TestAccuracy_LN10) * log (err_avg)) - ); - - return (ret_val); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -// Positive transform -template -void TestAccuracy ::compute_tf (DataType s [], const DataType x [], long length) -{ - assert (s != 0); - assert (x != 0); - assert (length >= 2); - assert ((length & 1) == 0); - - const long nbr_bins = length >> 1; - - // DC and Nyquist - BigFloat dc = 0; - BigFloat ny = 0; - for (long pos = 0; pos < length; pos += 2) - { - const BigFloat even = x [pos ]; - const BigFloat odd = x [pos + 1]; - dc += even + odd; - ny += even - odd; - } - s [0 ] = static_cast (dc); - s [nbr_bins] = static_cast (ny); - - // Regular bins - for (long bin = 1; bin < nbr_bins; ++ bin) - { - BigFloat sum_r = 0; - BigFloat sum_i = 0; - - const BigFloat m = bin * static_cast (2 * PI) / length; - - for (long pos = 0; pos < length; ++pos) - { - using namespace std; - - const BigFloat phase = pos * m; - const BigFloat e_r = cos (phase); - const BigFloat e_i = sin (phase); - - sum_r += x [pos] * e_r; - sum_i += x [pos] * e_i; - } - - s [ bin] = static_cast (sum_r); - s [nbr_bins + bin] = static_cast (sum_i); - } -} - - - -// Negative transform -template -void TestAccuracy ::compute_itf (DataType x [], const DataType s [], long length) -{ - assert (s != 0); - assert (x != 0); - assert (length >= 2); - assert ((length & 1) == 0); - - const long nbr_bins = length >> 1; - - // DC and Nyquist - BigFloat dc = s [0 ]; - BigFloat ny = s [nbr_bins]; - - // Regular bins - for (long pos = 0; pos < length; ++pos) - { - BigFloat sum = dc + ny * (1 - 2 * (pos & 1)); - - const BigFloat m = pos * static_cast (-2 * PI) / length; - - for (long bin = 1; bin < nbr_bins; ++ bin) - { - using namespace std; - - const BigFloat phase = bin * m; - const BigFloat e_r = cos (phase); - const BigFloat e_i = sin (phase); - - sum += 2 * ( e_r * s [bin ] - - e_i * s [bin + nbr_bins]); - } - - x [pos] = static_cast (sum); - } -} - - - -template -int TestAccuracy ::compare_vect_display (const DataType x_ptr [], const DataType y_ptr [], long len, BigFloat &max_err_rel) -{ - assert (x_ptr != 0); - assert (y_ptr != 0); - assert (len > 0); - assert (&max_err_rel != 0); - - using namespace std; - - int ret_val = 0; - - BigFloat power = compute_power (&x_ptr [0], &y_ptr [0], len); - BigFloat power_dif; - long max_err_pos; - compare_vect (&x_ptr [0], &y_ptr [0], power_dif, max_err_pos, len); - - if (power == 0) - { - power = power_dif; - } - const BigFloat power_err_rel = power_dif / power; - - BigFloat max_err = 0; - max_err_rel = 0; - if (max_err_pos >= 0) - { - max_err = y_ptr [max_err_pos] - x_ptr [max_err_pos]; - max_err_rel = 2 * fabs (max_err) / ( fabs (y_ptr [max_err_pos]) - + fabs (x_ptr [max_err_pos])); - } - - if (power_err_rel > 0.001) - { - printf ("Power error : %f (%.6f %%)\n", - static_cast (power_err_rel), - static_cast (power_err_rel * 100) - ); - if (max_err_pos >= 0) - { - printf ( - "Maximum error: %f - %f = %f (%f)\n", - static_cast (y_ptr [max_err_pos]), - static_cast (x_ptr [max_err_pos]), - static_cast (max_err), - static_cast (max_err_pos) - ); - } - } - - return (ret_val); -} - - - -template -typename TestAccuracy ::BigFloat TestAccuracy ::compute_power (const DataType x_ptr [], long len) -{ - assert (x_ptr != 0); - assert (len > 0); - - BigFloat power = 0; - for (long pos = 0; pos < len; ++pos) - { - const BigFloat val = x_ptr [pos]; - - power += val * val; - } - - using namespace std; - - power = sqrt (power) / len; - - return (power); -} - - - -template -typename TestAccuracy ::BigFloat TestAccuracy ::compute_power (const DataType x_ptr [], const DataType y_ptr [], long len) -{ - assert (x_ptr != 0); - assert (y_ptr != 0); - assert (len > 0); - - return ((compute_power (x_ptr, len) + compute_power (y_ptr, len)) * 0.5); -} - - - -template -void TestAccuracy ::compare_vect (const DataType x_ptr [], const DataType y_ptr [], BigFloat &power, long &max_err_pos, long len) -{ - assert (x_ptr != 0); - assert (y_ptr != 0); - assert (len > 0); - assert (&power != 0); - assert (&max_err_pos != 0); - - power = 0; - BigFloat max_dif2 = 0; - max_err_pos = -1; - - for (long pos = 0; pos < len; ++pos) - { - const BigFloat x = x_ptr [pos]; - const BigFloat y = y_ptr [pos]; - const BigFloat dif = y - x; - const BigFloat dif2 = dif * dif; - - power += dif2; - if (dif2 > max_dif2) - { - max_err_pos = pos; - max_dif2 = dif2; - } - } - - using namespace std; - - power = sqrt (power) / len; -} - - - -#endif // TestAccuracy_CODEHEADER_INCLUDED - -#undef TestAccuracy_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestHelperFixLen.h b/examples/spectrum/3rdparty/fftreal/TestHelperFixLen.h deleted file mode 100644 index ecff96d3..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestHelperFixLen.h +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - - TestHelperFixLen.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestHelperFixLen_HEADER_INCLUDED) -#define TestHelperFixLen_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "FFTRealFixLen.h" - - - -template -class TestHelperFixLen -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef FFTRealFixLen FftType; - - static void perform_test_accuracy (int &ret_val); - static void perform_test_speed (int &ret_val); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestHelperFixLen (); - ~TestHelperFixLen (); - TestHelperFixLen (const TestHelperFixLen &other); - TestHelperFixLen & - operator = (const TestHelperFixLen &other); - bool operator == (const TestHelperFixLen &other); - bool operator != (const TestHelperFixLen &other); - -}; // class TestHelperFixLen - - - -#include "TestHelperFixLen.hpp" - - - -#endif // TestHelperFixLen_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp b/examples/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp deleted file mode 100644 index 25048b91..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestHelperFixLen.hpp +++ /dev/null @@ -1,93 +0,0 @@ -/***************************************************************************** - - TestHelperFixLen.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestHelperFixLen_CURRENT_CODEHEADER) - #error Recursive inclusion of TestHelperFixLen code header. -#endif -#define TestHelperFixLen_CURRENT_CODEHEADER - -#if ! defined (TestHelperFixLen_CODEHEADER_INCLUDED) -#define TestHelperFixLen_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "test_settings.h" - -#include "TestAccuracy.h" -#if defined (test_settings_SPEED_TEST_ENABLED) - #include "TestSpeed.h" -#endif - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void TestHelperFixLen ::perform_test_accuracy (int &ret_val) -{ - if (ret_val == 0) - { - FftType fft; - ret_val = TestAccuracy ::perform_test_single_object (fft); - } -} - - - -template -void TestHelperFixLen ::perform_test_speed (int &ret_val) -{ -#if defined (test_settings_SPEED_TEST_ENABLED) - - if (ret_val == 0) - { - FftType fft; - ret_val = TestSpeed ::perform_test_single_object (fft); - } - -#endif -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // TestHelperFixLen_CODEHEADER_INCLUDED - -#undef TestHelperFixLen_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestHelperNormal.h b/examples/spectrum/3rdparty/fftreal/TestHelperNormal.h deleted file mode 100644 index a7bff5c2..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestHelperNormal.h +++ /dev/null @@ -1,94 +0,0 @@ -/***************************************************************************** - - TestHelperNormal.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestHelperNormal_HEADER_INCLUDED) -#define TestHelperNormal_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "FFTReal.h" - - - -template -class TestHelperNormal -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef DT DataType; - typedef FFTReal FftType; - - static void perform_test_accuracy (int &ret_val); - static void perform_test_speed (int &ret_val); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestHelperNormal (); - ~TestHelperNormal (); - TestHelperNormal (const TestHelperNormal &other); - TestHelperNormal & - operator = (const TestHelperNormal &other); - bool operator == (const TestHelperNormal &other); - bool operator != (const TestHelperNormal &other); - -}; // class TestHelperNormal - - - -#include "TestHelperNormal.hpp" - - - -#endif // TestHelperNormal_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestHelperNormal.hpp b/examples/spectrum/3rdparty/fftreal/TestHelperNormal.hpp deleted file mode 100644 index e037696a..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestHelperNormal.hpp +++ /dev/null @@ -1,99 +0,0 @@ -/***************************************************************************** - - TestHelperNormal.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestHelperNormal_CURRENT_CODEHEADER) - #error Recursive inclusion of TestHelperNormal code header. -#endif -#define TestHelperNormal_CURRENT_CODEHEADER - -#if ! defined (TestHelperNormal_CODEHEADER_INCLUDED) -#define TestHelperNormal_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "test_settings.h" - -#include "TestAccuracy.h" -#if defined (test_settings_SPEED_TEST_ENABLED) - #include "TestSpeed.h" -#endif - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -void TestHelperNormal

::perform_test_accuracy (int &ret_val) -{ - const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12 }; - const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); - for (int k = 0; k < nbr_len && ret_val == 0; ++k) - { - const long len = 1L << (len_arr [k]); - FftType fft (len); - ret_val = TestAccuracy ::perform_test_single_object (fft); - } -} - - - -template -void TestHelperNormal
::perform_test_speed (int &ret_val) -{ -#if defined (test_settings_SPEED_TEST_ENABLED) - - const int len_arr [] = { 1, 2, 3, 4, 7, 8, 10, 12, 14, 16, 18, 20, 22 }; - const int nbr_len = sizeof (len_arr) / sizeof (len_arr [0]); - for (int k = 0; k < nbr_len && ret_val == 0; ++k) - { - const long len = 1L << (len_arr [k]); - FftType fft (len); - ret_val = TestSpeed ::perform_test_single_object (fft); - } - -#endif -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // TestHelperNormal_CODEHEADER_INCLUDED - -#undef TestHelperNormal_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestSpeed.h b/examples/spectrum/3rdparty/fftreal/TestSpeed.h deleted file mode 100644 index 22957818..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestSpeed.h +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - - TestSpeed.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestSpeed_HEADER_INCLUDED) -#define TestSpeed_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class TestSpeed -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef typename FO::DataType DataType; - - static int perform_test_single_object (FO &fft); - static int perform_test_d (FO &fft, const char *class_name_0); - static int perform_test_i (FO &fft, const char *class_name_0); - static int perform_test_di (FO &fft, const char *class_name_0); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - enum { NBR_SPD_TESTS = 10 * 1000 * 1000 }; - enum { MAX_NBR_TESTS = 10000 }; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestSpeed (); - ~TestSpeed (); - TestSpeed (const TestSpeed &other); - TestSpeed & operator = (const TestSpeed &other); - bool operator == (const TestSpeed &other); - bool operator != (const TestSpeed &other); - -}; // class TestSpeed - - - -#include "TestSpeed.hpp" - - - -#endif // TestSpeed_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestSpeed.hpp b/examples/spectrum/3rdparty/fftreal/TestSpeed.hpp deleted file mode 100644 index e716b2a7..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestSpeed.hpp +++ /dev/null @@ -1,223 +0,0 @@ -/***************************************************************************** - - TestSpeed.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestSpeed_CURRENT_CODEHEADER) - #error Recursive inclusion of TestSpeed code header. -#endif -#define TestSpeed_CURRENT_CODEHEADER - -#if ! defined (TestSpeed_CODEHEADER_INCLUDED) -#define TestSpeed_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "test_fnc.h" -#include "stopwatch/StopWatch.h" -#include "TestWhiteNoiseGen.h" - -#include - -#include - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -int TestSpeed ::perform_test_single_object (FO &fft) -{ - assert (&fft != 0); - - int ret_val = 0; - - const std::type_info & ti = typeid (fft); - const char * class_name_0 = ti.name (); - - if (ret_val == 0) - { - perform_test_d (fft, class_name_0); - } - if (ret_val == 0) - { - perform_test_i (fft, class_name_0); - } - if (ret_val == 0) - { - perform_test_di (fft, class_name_0); - } - - if (ret_val == 0) - { - printf ("\n"); - } - - return (ret_val); -} - - - -template -int TestSpeed ::perform_test_d (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - const long len = fft.get_length (); - const long nbr_tests = limit ( - static_cast (NBR_SPD_TESTS / len / len), - 1L, - static_cast (MAX_NBR_TESTS) - ); - - TestWhiteNoiseGen noise; - std::vector x (len, 0); - std::vector s (len); - noise.generate (&x [0], len); - - printf ( - "%s::do_fft () speed test [%ld samples]... ", - class_name_0, - len - ); - fflush (stdout); - - stopwatch::StopWatch chrono; - chrono.start (); - for (long test = 0; test < nbr_tests; ++ test) - { - fft.do_fft (&s [0], &x [0]); - chrono.stop_lap (); - } - - printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); - - return (0); -} - - - -template -int TestSpeed ::perform_test_i (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - const long len = fft.get_length (); - const long nbr_tests = limit ( - static_cast (NBR_SPD_TESTS / len / len), - 1L, - static_cast (MAX_NBR_TESTS) - ); - - TestWhiteNoiseGen noise; - std::vector x (len); - std::vector s (len, 0); - noise.generate (&s [0], len); - - printf ( - "%s::do_ifft () speed test [%ld samples]... ", - class_name_0, - len - ); - fflush (stdout); - - stopwatch::StopWatch chrono; - chrono.start (); - for (long test = 0; test < nbr_tests; ++ test) - { - fft.do_ifft (&s [0], &x [0]); - chrono.stop_lap (); - } - - printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); - - return (0); -} - - - -template -int TestSpeed ::perform_test_di (FO &fft, const char *class_name_0) -{ - assert (&fft != 0); - assert (class_name_0 != 0); - - const long len = fft.get_length (); - const long nbr_tests = limit ( - static_cast (NBR_SPD_TESTS / len / len), - 1L, - static_cast (MAX_NBR_TESTS) - ); - - TestWhiteNoiseGen noise; - std::vector x (len, 0); - std::vector s (len); - std::vector y (len); - noise.generate (&x [0], len); - - printf ( - "%s::do_fft () / do_ifft () / rescale () speed test [%ld samples]... ", - class_name_0, - len - ); - fflush (stdout); - - stopwatch::StopWatch chrono; - - chrono.start (); - for (long test = 0; test < nbr_tests; ++ test) - { - fft.do_fft (&s [0], &x [0]); - fft.do_ifft (&s [0], &y [0]); - fft.rescale (&y [0]); - chrono.stop_lap (); - } - - printf ("%.1f clocks/sample\n", chrono.get_time_best_lap (len)); - - return (0); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // TestSpeed_CODEHEADER_INCLUDED - -#undef TestSpeed_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h b/examples/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h deleted file mode 100644 index d815f8e3..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.h +++ /dev/null @@ -1,95 +0,0 @@ -/***************************************************************************** - - TestWhiteNoiseGen.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (TestWhiteNoiseGen_HEADER_INCLUDED) -#define TestWhiteNoiseGen_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -class TestWhiteNoiseGen -{ - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -public: - - typedef DT DataType; - - TestWhiteNoiseGen (); - virtual ~TestWhiteNoiseGen () {} - - void generate (DataType data_ptr [], long len); - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -protected: - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - typedef unsigned long StateType; - - StateType _rand_state; - - - -/*\\\ FORBIDDEN MEMBER FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -private: - - TestWhiteNoiseGen (const TestWhiteNoiseGen &other); - TestWhiteNoiseGen & - operator = (const TestWhiteNoiseGen &other); - bool operator == (const TestWhiteNoiseGen &other); - bool operator != (const TestWhiteNoiseGen &other); - -}; // class TestWhiteNoiseGen - - - -#include "TestWhiteNoiseGen.hpp" - - - -#endif // TestWhiteNoiseGen_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp b/examples/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp deleted file mode 100644 index 13b7eb3e..00000000 --- a/examples/spectrum/3rdparty/fftreal/TestWhiteNoiseGen.hpp +++ /dev/null @@ -1,91 +0,0 @@ -/***************************************************************************** - - TestWhiteNoiseGen.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (TestWhiteNoiseGen_CURRENT_CODEHEADER) - #error Recursive inclusion of TestWhiteNoiseGen code header. -#endif -#define TestWhiteNoiseGen_CURRENT_CODEHEADER - -#if ! defined (TestWhiteNoiseGen_CODEHEADER_INCLUDED) -#define TestWhiteNoiseGen_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PUBLIC \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -TestWhiteNoiseGen
::TestWhiteNoiseGen () -: _rand_state (0) -{ - _rand_state = reinterpret_cast (this); -} - - - -template -void TestWhiteNoiseGen
::generate (DataType data_ptr [], long len) -{ - assert (data_ptr != 0); - assert (len > 0); - - const DataType one = static_cast (1); - const DataType mul = one / static_cast (0x80000000UL); - - long pos = 0; - do - { - const DataType x = static_cast (_rand_state & 0xFFFFFFFFUL); - data_ptr [pos] = x * mul - one; - - _rand_state = _rand_state * 1234567UL + 890123UL; - - ++ pos; - } - while (pos < len); -} - - - -/*\\\ PROTECTED \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -/*\\\ PRIVATE \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -#endif // TestWhiteNoiseGen_CODEHEADER_INCLUDED - -#undef TestWhiteNoiseGen_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/def.h b/examples/spectrum/3rdparty/fftreal/def.h deleted file mode 100644 index 99c545f5..00000000 --- a/examples/spectrum/3rdparty/fftreal/def.h +++ /dev/null @@ -1,60 +0,0 @@ -/***************************************************************************** - - def.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (def_HEADER_INCLUDED) -#define def_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - - -const double PI = 3.1415926535897932384626433832795; -const double SQRT2 = 1.41421356237309514547462185873883; - -#if defined (_MSC_VER) - - #define FORCEINLINE __forceinline - -#else - - #define FORCEINLINE inline - -#endif - - - -#endif // def_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/fftreal.pas b/examples/spectrum/3rdparty/fftreal/fftreal.pas deleted file mode 100644 index ea637545..00000000 --- a/examples/spectrum/3rdparty/fftreal/fftreal.pas +++ /dev/null @@ -1,661 +0,0 @@ -(***************************************************************************** - - DIGITAL SIGNAL PROCESSING TOOLS - Version 1.03, 2001/06/15 - (c) 1999 - Laurent de Soras - - FFTReal.h - Fourier transformation of real number arrays. - Portable ISO C++ - ------------------------------------------------------------------------------- - - LEGAL - - Source code may be freely used for any purpose, including commercial - applications. Programs must display in their "About" dialog-box (or - documentation) a text telling they use these routines by Laurent de Soras. - Modified source code can be distributed, but modifications must be clearly - indicated. - - CONTACT - - Laurent de Soras - 92 avenue Albert 1er - 92500 Rueil-Malmaison - France - - ldesoras@club-internet.fr - ------------------------------------------------------------------------------- - - Translation to ObjectPascal by : - Frederic Vanmol - frederic@axiworld.be - -*****************************************************************************) - - -unit - FFTReal; - -interface - -uses - Windows; - -(* Change this typedef to use a different floating point type in your FFTs - (i.e. float, double or long double). *) -type - pflt_t = ^flt_t; - flt_t = single; - - pflt_array = ^flt_array; - flt_array = array[0..0] of flt_t; - - plongarray = ^longarray; - longarray = array[0..0] of longint; - -const - sizeof_flt : longint = SizeOf(flt_t); - - - -type - // Bit reversed look-up table nested class - TBitReversedLUT = class - private - _ptr : plongint; - public - constructor Create(const nbr_bits: integer); - destructor Destroy; override; - function get_ptr: plongint; - end; - - // Trigonometric look-up table nested class - TTrigoLUT = class - private - _ptr : pflt_t; - public - constructor Create(const nbr_bits: integer); - destructor Destroy; override; - function get_ptr(const level: integer): pflt_t; - end; - - TFFTReal = class - private - _bit_rev_lut : TBitReversedLUT; - _trigo_lut : TTrigoLUT; - _sqrt2_2 : flt_t; - _length : longint; - _nbr_bits : integer; - _buffer_ptr : pflt_t; - public - constructor Create(const length: longint); - destructor Destroy; override; - - procedure do_fft(f: pflt_array; const x: pflt_array); - procedure do_ifft(const f: pflt_array; x: pflt_array); - procedure rescale(x: pflt_array); - end; - - - - - - - -implementation - -uses - Math; - -{ TBitReversedLUT } - -constructor TBitReversedLUT.Create(const nbr_bits: integer); -var - length : longint; - cnt : longint; - br_index : longint; - bit : longint; -begin - inherited Create; - - length := 1 shl nbr_bits; - GetMem(_ptr, length*SizeOf(longint)); - - br_index := 0; - plongarray(_ptr)^[0] := 0; - for cnt := 1 to length-1 do - begin - // ++br_index (bit reversed) - bit := length shr 1; - br_index := br_index xor bit; - while br_index and bit = 0 do - begin - bit := bit shr 1; - br_index := br_index xor bit; - end; - - plongarray(_ptr)^[cnt] := br_index; - end; -end; - -destructor TBitReversedLUT.Destroy; -begin - FreeMem(_ptr); - _ptr := nil; - inherited; -end; - -function TBitReversedLUT.get_ptr: plongint; -begin - Result := _ptr; -end; - -{ TTrigLUT } - -constructor TTrigoLUT.Create(const nbr_bits: integer); -var - total_len : longint; - PI : double; - level : integer; - level_len : longint; - level_ptr : pflt_array; - mul : double; - i : longint; -begin - inherited Create; - - _ptr := nil; - - if (nbr_bits > 3) then - begin - total_len := (1 shl (nbr_bits - 1)) - 4; - GetMem(_ptr, total_len * sizeof_flt); - - PI := ArcTan(1) * 4; - for level := 3 to nbr_bits-1 do - begin - level_len := 1 shl (level - 1); - level_ptr := pointer(get_ptr(level)); - mul := PI / (level_len shl 1); - - for i := 0 to level_len-1 do - level_ptr^[i] := cos(i * mul); - end; - end; -end; - -destructor TTrigoLUT.Destroy; -begin - FreeMem(_ptr); - _ptr := nil; - inherited; -end; - -function TTrigoLUT.get_ptr(const level: integer): pflt_t; -var - tempp : pflt_t; -begin - tempp := _ptr; - inc(tempp, (1 shl (level-1)) - 4); - Result := tempp; -end; - -{ TFFTReal } - -constructor TFFTReal.Create(const length: longint); -begin - inherited Create; - - _length := length; - _nbr_bits := Floor(Ln(length) / Ln(2) + 0.5); - _bit_rev_lut := TBitReversedLUT.Create(Floor(Ln(length) / Ln(2) + 0.5)); - _trigo_lut := TTrigoLUT.Create(Floor(Ln(length) / Ln(2) + 0.05)); - _sqrt2_2 := Sqrt(2) * 0.5; - - _buffer_ptr := nil; - if _nbr_bits > 2 then - GetMem(_buffer_ptr, _length * sizeof_flt); -end; - -destructor TFFTReal.Destroy; -begin - if _buffer_ptr <> nil then - begin - FreeMem(_buffer_ptr); - _buffer_ptr := nil; - end; - - _bit_rev_lut.Free; - _bit_rev_lut := nil; - _trigo_lut.Free; - _trigo_lut := nil; - - inherited; -end; - -(*==========================================================================*/ -/* Name: do_fft */ -/* Description: Compute the FFT of the array. */ -/* Input parameters: */ -/* - x: pointer on the source array (time). */ -/* Output parameters: */ -/* - f: pointer on the destination array (frequencies). */ -/* f [0...length(x)/2] = real values, */ -/* f [length(x)/2+1...length(x)-1] = imaginary values of */ -/* coefficents 1...length(x)/2-1. */ -/*==========================================================================*) -procedure TFFTReal.do_fft(f: pflt_array; const x: pflt_array); -var - sf, df : pflt_array; - pass : integer; - nbr_coef : longint; - h_nbr_coef : longint; - d_nbr_coef : longint; - coef_index : longint; - bit_rev_lut_ptr : plongarray; - rev_index_0 : longint; - rev_index_1 : longint; - rev_index_2 : longint; - rev_index_3 : longint; - df2 : pflt_array; - n1, n2, n3 : integer; - sf_0, sf_2 : flt_t; - sqrt2_2 : flt_t; - v : flt_t; - cos_ptr : pflt_array; - i : longint; - sf1r, sf2r : pflt_array; - dfr, dfi : pflt_array; - sf1i, sf2i : pflt_array; - c, s : flt_t; - temp_ptr : pflt_array; - b_0, b_2 : flt_t; -begin - n1 := 1; - n2 := 2; - n3 := 3; - - (*______________________________________________ - * - * General case - *______________________________________________ - *) - - if _nbr_bits > 2 then - begin - if _nbr_bits and 1 <> 0 then - begin - df := pointer(_buffer_ptr); - sf := f; - end - else - begin - df := f; - sf := pointer(_buffer_ptr); - end; - - // - // Do the transformation in several passes - // - - // First and second pass at once - bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); - coef_index := 0; - - repeat - rev_index_0 := bit_rev_lut_ptr^[coef_index]; - rev_index_1 := bit_rev_lut_ptr^[coef_index + 1]; - rev_index_2 := bit_rev_lut_ptr^[coef_index + 2]; - rev_index_3 := bit_rev_lut_ptr^[coef_index + 3]; - - df2 := pointer(longint(df) + (coef_index*sizeof_flt)); - df2^[n1] := x^[rev_index_0] - x^[rev_index_1]; - df2^[n3] := x^[rev_index_2] - x^[rev_index_3]; - - sf_0 := x^[rev_index_0] + x^[rev_index_1]; - sf_2 := x^[rev_index_2] + x^[rev_index_3]; - - df2^[0] := sf_0 + sf_2; - df2^[n2] := sf_0 - sf_2; - - inc(coef_index, 4); - until (coef_index >= _length); - - - // Third pass - coef_index := 0; - sqrt2_2 := _sqrt2_2; - - repeat - sf^[coef_index] := df^[coef_index] + df^[coef_index + 4]; - sf^[coef_index + 4] := df^[coef_index] - df^[coef_index + 4]; - sf^[coef_index + 2] := df^[coef_index + 2]; - sf^[coef_index + 6] := df^[coef_index + 6]; - - v := (df [coef_index + 5] - df^[coef_index + 7]) * sqrt2_2; - sf^[coef_index + 1] := df^[coef_index + 1] + v; - sf^[coef_index + 3] := df^[coef_index + 1] - v; - - v := (df^[coef_index + 5] + df^[coef_index + 7]) * sqrt2_2; - sf [coef_index + 5] := v + df^[coef_index + 3]; - sf [coef_index + 7] := v - df^[coef_index + 3]; - - inc(coef_index, 8); - until (coef_index >= _length); - - - // Next pass - for pass := 3 to _nbr_bits-1 do - begin - coef_index := 0; - nbr_coef := 1 shl pass; - h_nbr_coef := nbr_coef shr 1; - d_nbr_coef := nbr_coef shl 1; - - cos_ptr := pointer(_trigo_lut.get_ptr(pass)); - repeat - sf1r := pointer(longint(sf) + (coef_index * sizeof_flt)); - sf2r := pointer(longint(sf1r) + (nbr_coef * sizeof_flt)); - dfr := pointer(longint(df) + (coef_index * sizeof_flt)); - dfi := pointer(longint(dfr) + (nbr_coef * sizeof_flt)); - - // Extreme coefficients are always real - dfr^[0] := sf1r^[0] + sf2r^[0]; - dfi^[0] := sf1r^[0] - sf2r^[0]; // dfr [nbr_coef] = - dfr^[h_nbr_coef] := sf1r^[h_nbr_coef]; - dfi^[h_nbr_coef] := sf2r^[h_nbr_coef]; - - // Others are conjugate complex numbers - sf1i := pointer(longint(sf1r) + (h_nbr_coef * sizeof_flt)); - sf2i := pointer(longint(sf1i) + (nbr_coef * sizeof_flt)); - - for i := 1 to h_nbr_coef-1 do - begin - c := cos_ptr^[i]; // cos (i*PI/nbr_coef); - s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); - - v := sf2r^[i] * c - sf2i^[i] * s; - dfr^[i] := sf1r^[i] + v; - dfi^[-i] := sf1r^[i] - v; // dfr [nbr_coef - i] = - - v := sf2r^[i] * s + sf2i^[i] * c; - dfi^[i] := v + sf1i^[i]; - dfi^[nbr_coef - i] := v - sf1i^[i]; - end; - - inc(coef_index, d_nbr_coef); - until (coef_index >= _length); - - // Prepare to the next pass - temp_ptr := df; - df := sf; - sf := temp_ptr; - end; - end - - (*______________________________________________ - * - * Special cases - *______________________________________________ - *) - - // 4-point FFT - else if _nbr_bits = 2 then - begin - f^[n1] := x^[0] - x^[n2]; - f^[n3] := x^[n1] - x^[n3]; - - b_0 := x^[0] + x^[n2]; - b_2 := x^[n1] + x^[n3]; - - f^[0] := b_0 + b_2; - f^[n2] := b_0 - b_2; - end - - // 2-point FFT - else if _nbr_bits = 1 then - begin - f^[0] := x^[0] + x^[n1]; - f^[n1] := x^[0] - x^[n1]; - end - - // 1-point FFT - else - f^[0] := x^[0]; -end; - - -(*==========================================================================*/ -/* Name: do_ifft */ -/* Description: Compute the inverse FFT of the array. Notice that */ -/* IFFT (FFT (x)) = x * length (x). Data must be */ -/* post-scaled. */ -/* Input parameters: */ -/* - f: pointer on the source array (frequencies). */ -/* f [0...length(x)/2] = real values, */ -/* f [length(x)/2+1...length(x)-1] = imaginary values of */ -/* coefficents 1...length(x)/2-1. */ -/* Output parameters: */ -/* - x: pointer on the destination array (time). */ -/*==========================================================================*) -procedure TFFTReal.do_ifft(const f: pflt_array; x: pflt_array); -var - n1, n2, n3 : integer; - n4, n5, n6, n7 : integer; - sf, df, df_temp : pflt_array; - pass : integer; - nbr_coef : longint; - h_nbr_coef : longint; - d_nbr_coef : longint; - coef_index : longint; - cos_ptr : pflt_array; - i : longint; - sfr, sfi : pflt_array; - df1r, df2r : pflt_array; - df1i, df2i : pflt_array; - c, s, vr, vi : flt_t; - temp_ptr : pflt_array; - sqrt2_2 : flt_t; - bit_rev_lut_ptr : plongarray; - sf2 : pflt_array; - b_0, b_1, b_2, b_3 : flt_t; -begin - n1 := 1; - n2 := 2; - n3 := 3; - n4 := 4; - n5 := 5; - n6 := 6; - n7 := 7; - - (*______________________________________________ - * - * General case - *______________________________________________ - *) - - if _nbr_bits > 2 then - begin - sf := f; - - if _nbr_bits and 1 <> 0 then - begin - df := pointer(_buffer_ptr); - df_temp := x; - end - else - begin - df := x; - df_temp := pointer(_buffer_ptr); - end; - - // Do the transformation in several pass - - // First pass - for pass := _nbr_bits-1 downto 3 do - begin - coef_index := 0; - nbr_coef := 1 shl pass; - h_nbr_coef := nbr_coef shr 1; - d_nbr_coef := nbr_coef shl 1; - - cos_ptr := pointer(_trigo_lut.get_ptr(pass)); - - repeat - sfr := pointer(longint(sf) + (coef_index*sizeof_flt)); - sfi := pointer(longint(sfr) + (nbr_coef*sizeof_flt)); - df1r := pointer(longint(df) + (coef_index*sizeof_flt)); - df2r := pointer(longint(df1r) + (nbr_coef*sizeof_flt)); - - // Extreme coefficients are always real - df1r^[0] := sfr^[0] + sfi^[0]; // + sfr [nbr_coef] - df2r^[0] := sfr^[0] - sfi^[0]; // - sfr [nbr_coef] - df1r^[h_nbr_coef] := sfr^[h_nbr_coef] * 2; - df2r^[h_nbr_coef] := sfi^[h_nbr_coef] * 2; - - // Others are conjugate complex numbers - df1i := pointer(longint(df1r) + (h_nbr_coef*sizeof_flt)); - df2i := pointer(longint(df1i) + (nbr_coef*sizeof_flt)); - - for i := 1 to h_nbr_coef-1 do - begin - df1r^[i] := sfr^[i] + sfi^[-i]; // + sfr [nbr_coef - i] - df1i^[i] := sfi^[i] - sfi^[nbr_coef - i]; - - c := cos_ptr^[i]; // cos (i*PI/nbr_coef); - s := cos_ptr^[h_nbr_coef - i]; // sin (i*PI/nbr_coef); - vr := sfr^[i] - sfi^[-i]; // - sfr [nbr_coef - i] - vi := sfi^[i] + sfi^[nbr_coef - i]; - - df2r^[i] := vr * c + vi * s; - df2i^[i] := vi * c - vr * s; - end; - - inc(coef_index, d_nbr_coef); - until (coef_index >= _length); - - - // Prepare to the next pass - if (pass < _nbr_bits - 1) then - begin - temp_ptr := df; - df := sf; - sf := temp_ptr; - end - else - begin - sf := df; - df := df_temp; - end - end; - - // Antepenultimate pass - sqrt2_2 := _sqrt2_2; - coef_index := 0; - - repeat - df^[coef_index] := sf^[coef_index] + sf^[coef_index + 4]; - df^[coef_index + 4] := sf^[coef_index] - sf^[coef_index + 4]; - df^[coef_index + 2] := sf^[coef_index + 2] * 2; - df^[coef_index + 6] := sf^[coef_index + 6] * 2; - - df^[coef_index + 1] := sf^[coef_index + 1] + sf^[coef_index + 3]; - df^[coef_index + 3] := sf^[coef_index + 5] - sf^[coef_index + 7]; - - vr := sf^[coef_index + 1] - sf^[coef_index + 3]; - vi := sf^[coef_index + 5] + sf^[coef_index + 7]; - - df^[coef_index + 5] := (vr + vi) * sqrt2_2; - df^[coef_index + 7] := (vi - vr) * sqrt2_2; - - inc(coef_index, 8); - until (coef_index >= _length); - - - // Penultimate and last pass at once - coef_index := 0; - bit_rev_lut_ptr := pointer(_bit_rev_lut.get_ptr); - sf2 := df; - - repeat - b_0 := sf2^[0] + sf2^[n2]; - b_2 := sf2^[0] - sf2^[n2]; - b_1 := sf2^[n1] * 2; - b_3 := sf2^[n3] * 2; - - x^[bit_rev_lut_ptr^[0]] := b_0 + b_1; - x^[bit_rev_lut_ptr^[n1]] := b_0 - b_1; - x^[bit_rev_lut_ptr^[n2]] := b_2 + b_3; - x^[bit_rev_lut_ptr^[n3]] := b_2 - b_3; - - b_0 := sf2^[n4] + sf2^[n6]; - b_2 := sf2^[n4] - sf2^[n6]; - b_1 := sf2^[n5] * 2; - b_3 := sf2^[n7] * 2; - - x^[bit_rev_lut_ptr^[n4]] := b_0 + b_1; - x^[bit_rev_lut_ptr^[n5]] := b_0 - b_1; - x^[bit_rev_lut_ptr^[n6]] := b_2 + b_3; - x^[bit_rev_lut_ptr^[n7]] := b_2 - b_3; - - inc(sf2, 8); - inc(coef_index, 8); - inc(bit_rev_lut_ptr, 8); - until (coef_index >= _length); - end - - (*______________________________________________ - * - * Special cases - *______________________________________________ - *) - - // 4-point IFFT - else if _nbr_bits = 2 then - begin - b_0 := f^[0] + f [n2]; - b_2 := f^[0] - f [n2]; - - x^[0] := b_0 + f [n1] * 2; - x^[n2] := b_0 - f [n1] * 2; - x^[n1] := b_2 + f [n3] * 2; - x^[n3] := b_2 - f [n3] * 2; - end - - // 2-point IFFT - else if _nbr_bits = 1 then - begin - x^[0] := f^[0] + f^[n1]; - x^[n1] := f^[0] - f^[n1]; - end - - // 1-point IFFT - else - x^[0] := f^[0]; -end; - -(*==========================================================================*/ -/* Name: rescale */ -/* Description: Scale an array by divide each element by its length. */ -/* This function should be called after FFT + IFFT. */ -/* Input/Output parameters: */ -/* - x: pointer on array to rescale (time or frequency). */ -/*==========================================================================*) -procedure TFFTReal.rescale(x: pflt_array); -var - mul : flt_t; - i : longint; -begin - mul := 1.0 / _length; - i := _length - 1; - - repeat - x^[i] := x^[i] * mul; - dec(i); - until (i < 0); -end; - -end. diff --git a/examples/spectrum/3rdparty/fftreal/fftreal.pro b/examples/spectrum/3rdparty/fftreal/fftreal.pro deleted file mode 100644 index f6abeeb1..00000000 --- a/examples/spectrum/3rdparty/fftreal/fftreal.pro +++ /dev/null @@ -1,44 +0,0 @@ -include(../../spectrum.pri) - -static: error(This library cannot be built for static linkage) - -TEMPLATE = lib -TARGET = fftreal - -# FFTReal -HEADERS += Array.h \ - Array.hpp \ - DynArray.h \ - DynArray.hpp \ - FFTRealFixLen.h \ - FFTRealFixLen.hpp \ - FFTRealFixLenParam.h \ - FFTRealPassDirect.h \ - FFTRealPassDirect.hpp \ - FFTRealPassInverse.h \ - FFTRealPassInverse.hpp \ - FFTRealSelect.h \ - FFTRealSelect.hpp \ - FFTRealUseTrigo.h \ - FFTRealUseTrigo.hpp \ - OscSinCos.h \ - OscSinCos.hpp \ - def.h - -# Wrapper used to export the required instantiation of the FFTRealFixLen template -HEADERS += fftreal_wrapper.h -SOURCES += fftreal_wrapper.cpp - -DEFINES += FFTREAL_LIBRARY - -macx { - CONFIG += lib_bundle -} else { - DESTDIR = ../..$${spectrum_build_dir} -} - -EXAMPLE_FILES = bwins/fftreal.def eabi/fftreal.def readme.txt license.txt - -target.path = $$[QT_INSTALL_EXAMPLES]/multimedia/spectrum -INSTALLS += target - diff --git a/examples/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp b/examples/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp deleted file mode 100644 index 45aee653..00000000 --- a/examples/spectrum/3rdparty/fftreal/fftreal_wrapper.cpp +++ /dev/null @@ -1,54 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of QtDataVis3D. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as -** published by the Free Software Foundation, either version 2.1. This -** program is distributed in the hope that it will be useful, but WITHOUT -** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -** for more details. You should have received a copy of the GNU General -** Public License along with this program. If not, see -** . -** -***************************************************************************/ - -#include "fftreal_wrapper.h" - -// FFTReal code generates quite a lot of 'unused parameter' compiler warnings, -// which we suppress here in order to get a clean build output. -#if defined Q_CC_MSVC -# pragma warning(disable:4100) -#elif defined Q_CC_GNU -# pragma GCC diagnostic ignored "-Wunused-parameter" -#elif defined Q_CC_MWERKS -# pragma warning off (10182) -#endif - -#include "FFTRealFixLen.h" - -class FFTRealWrapperPrivate { -public: - FFTRealFixLen m_fft; -}; - - -FFTRealWrapper::FFTRealWrapper() - : m_private(new FFTRealWrapperPrivate) -{ - -} - -FFTRealWrapper::~FFTRealWrapper() -{ - delete m_private; -} - -void FFTRealWrapper::calculateFFT(DataType in[], const DataType out[]) -{ - m_private->m_fft.do_fft(in, out); -} diff --git a/examples/spectrum/3rdparty/fftreal/fftreal_wrapper.h b/examples/spectrum/3rdparty/fftreal/fftreal_wrapper.h deleted file mode 100644 index 2fb602de..00000000 --- a/examples/spectrum/3rdparty/fftreal/fftreal_wrapper.h +++ /dev/null @@ -1,63 +0,0 @@ -/*************************************************************************** -** -** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the examples of QtDataVis3D. -** -** This program is free software: you can redistribute it and/or modify -** it under the terms of the GNU Lesser General Public License as -** published by the Free Software Foundation, either version 2.1. This -** program is distributed in the hope that it will be useful, but WITHOUT -** ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -** FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -** for more details. You should have received a copy of the GNU General -** Public License along with this program. If not, see -** . -** -***************************************************************************/ - -#ifndef FFTREAL_WRAPPER_H -#define FFTREAL_WRAPPER_H - -#include - -#if defined(FFTREAL_LIBRARY) -# define FFTREAL_EXPORT Q_DECL_EXPORT -#else -# define FFTREAL_EXPORT Q_DECL_IMPORT -#endif - -class FFTRealWrapperPrivate; - -// Each pass of the FFT processes 2^X samples, where X is the -// number below. -static const int FFTLengthPowerOfTwo = 12; - -/** - * Wrapper around the FFTRealFixLen template provided by the FFTReal - * library - * - * This class instantiates a single instance of FFTRealFixLen, using - * FFTLengthPowerOfTwo as the template parameter. It then exposes - * FFTRealFixLen::do_fft via the calculateFFT - * function, thereby allowing an application to dynamically link - * against the FFTReal implementation. - * - * See http://ldesoras.free.fr/prod.html - */ -class FFTREAL_EXPORT FFTRealWrapper -{ -public: - FFTRealWrapper(); - ~FFTRealWrapper(); - - typedef float DataType; - void calculateFFT(DataType in[], const DataType out[]); - -private: - FFTRealWrapperPrivate* m_private; -}; - -#endif // FFTREAL_WRAPPER_H - diff --git a/examples/spectrum/3rdparty/fftreal/license.txt b/examples/spectrum/3rdparty/fftreal/license.txt deleted file mode 100644 index 918fe68e..00000000 --- a/examples/spectrum/3rdparty/fftreal/license.txt +++ /dev/null @@ -1,459 +0,0 @@ - GNU LESSER GENERAL PUBLIC LICENSE - Version 2.1, February 1999 - - Copyright (C) 1991, 1999 Free Software Foundation, Inc. - 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - Everyone is permitted to copy and distribute verbatim copies - of this license document, but changing it is not allowed. - -[This is the first released version of the Lesser GPL. It also counts - as the successor of the GNU Library Public License, version 2, hence - the version number 2.1.] - - Preamble - - The licenses for most software are designed to take away your -freedom to share and change it. By contrast, the GNU General Public -Licenses are intended to guarantee your freedom to share and change -free software--to make sure the software is free for all its users. - - This license, the Lesser General Public License, applies to some -specially designated software packages--typically libraries--of the -Free Software Foundation and other authors who decide to use it. You -can use it too, but we suggest you first think carefully about whether -this license or the ordinary General Public License is the better -strategy to use in any particular case, based on the explanations below. - - When we speak of free software, we are referring to freedom of use, -not price. Our General Public Licenses are designed to make sure that -you have the freedom to distribute copies of free software (and charge -for this service if you wish); that you receive source code or can get -it if you want it; that you can change the software and use pieces of -it in new free programs; and that you are informed that you can do -these things. - - To protect your rights, we need to make restrictions that forbid -distributors to deny you these rights or to ask you to surrender these -rights. These restrictions translate to certain responsibilities for -you if you distribute copies of the library or if you modify it. - - For example, if you distribute copies of the library, whether gratis -or for a fee, you must give the recipients all the rights that we gave -you. You must make sure that they, too, receive or can get the source -code. If you link other code with the library, you must provide -complete object files to the recipients, so that they can relink them -with the library after making changes to the library and recompiling -it. And you must show them these terms so they know their rights. - - We protect your rights with a two-step method: (1) we copyright the -library, and (2) we offer you this license, which gives you legal -permission to copy, distribute and/or modify the library. - - To protect each distributor, we want to make it very clear that -there is no warranty for the free library. Also, if the library is -modified by someone else and passed on, the recipients should know -that what they have is not the original version, so that the original -author's reputation will not be affected by problems that might be -introduced by others. - - Finally, software patents pose a constant threat to the existence of -any free program. We wish to make sure that a company cannot -effectively restrict the users of a free program by obtaining a -restrictive license from a patent holder. Therefore, we insist that -any patent license obtained for a version of the library must be -consistent with the full freedom of use specified in this license. - - Most GNU software, including some libraries, is covered by the -ordinary GNU General Public License. This license, the GNU Lesser -General Public License, applies to certain designated libraries, and -is quite different from the ordinary General Public License. We use -this license for certain libraries in order to permit linking those -libraries into non-free programs. - - When a program is linked with a library, whether statically or using -a shared library, the combination of the two is legally speaking a -combined work, a derivative of the original library. The ordinary -General Public License therefore permits such linking only if the -entire combination fits its criteria of freedom. The Lesser General -Public License permits more lax criteria for linking other code with -the library. - - We call this license the "Lesser" General Public License because it -does Less to protect the user's freedom than the ordinary General -Public License. It also provides other free software developers Less -of an advantage over competing non-free programs. These disadvantages -are the reason we use the ordinary General Public License for many -libraries. However, the Lesser license provides advantages in certain -special circumstances. - - For example, on rare occasions, there may be a special need to -encourage the widest possible use of a certain library, so that it becomes -a de-facto standard. To achieve this, non-free programs must be -allowed to use the library. A more frequent case is that a free -library does the same job as widely used non-free libraries. In this -case, there is little to gain by limiting the free library to free -software only, so we use the Lesser General Public License. - - In other cases, permission to use a particular library in non-free -programs enables a greater number of people to use a large body of -free software. For example, permission to use the GNU C Library in -non-free programs enables many more people to use the whole GNU -operating system, as well as its variant, the GNU/Linux operating -system. - - Although the Lesser General Public License is Less protective of the -users' freedom, it does ensure that the user of a program that is -linked with the Library has the freedom and the wherewithal to run -that program using a modified version of the Library. - - The precise terms and conditions for copying, distribution and -modification follow. Pay close attention to the difference between a -"work based on the library" and a "work that uses the library". The -former contains code derived from the library, whereas the latter must -be combined with the library in order to run. - - GNU LESSER GENERAL PUBLIC LICENSE - TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION - - 0. This License Agreement applies to any software library or other -program which contains a notice placed by the copyright holder or -other authorized party saying it may be distributed under the terms of -this Lesser General Public License (also called "this License"). -Each licensee is addressed as "you". - - A "library" means a collection of software functions and/or data -prepared so as to be conveniently linked with application programs -(which use some of those functions and data) to form executables. - - The "Library", below, refers to any such software library or work -which has been distributed under these terms. A "work based on the -Library" means either the Library or any derivative work under -copyright law: that is to say, a work containing the Library or a -portion of it, either verbatim or with modifications and/or translated -straightforwardly into another language. (Hereinafter, translation is -included without limitation in the term "modification".) - - "Source code" for a work means the preferred form of the work for -making modifications to it. For a library, complete source code means -all the source code for all modules it contains, plus any associated -interface definition files, plus the scripts used to control compilation -and installation of the library. - - Activities other than copying, distribution and modification are not -covered by this License; they are outside its scope. The act of -running a program using the Library is not restricted, and output from -such a program is covered only if its contents constitute a work based -on the Library (independent of the use of the Library in a tool for -writing it). Whether that is true depends on what the Library does -and what the program that uses the Library does. - - 1. You may copy and distribute verbatim copies of the Library's -complete source code as you receive it, in any medium, provided that -you conspicuously and appropriately publish on each copy an -appropriate copyright notice and disclaimer of warranty; keep intact -all the notices that refer to this License and to the absence of any -warranty; and distribute a copy of this License along with the -Library. - - You may charge a fee for the physical act of transferring a copy, -and you may at your option offer warranty protection in exchange for a -fee. - - 2. You may modify your copy or copies of the Library or any portion -of it, thus forming a work based on the Library, and copy and -distribute such modifications or work under the terms of Section 1 -above, provided that you also meet all of these conditions: - - a) The modified work must itself be a software library. - - b) You must cause the files modified to carry prominent notices - stating that you changed the files and the date of any change. - - c) You must cause the whole of the work to be licensed at no - charge to all third parties under the terms of this License. - - d) If a facility in the modified Library refers to a function or a - table of data to be supplied by an application program that uses - the facility, other than as an argument passed when the facility - is invoked, then you must make a good faith effort to ensure that, - in the event an application does not supply such function or - table, the facility still operates, and performs whatever part of - its purpose remains meaningful. - - (For example, a function in a library to compute square roots has - a purpose that is entirely well-defined independent of the - application. Therefore, Subsection 2d requires that any - application-supplied function or table used by this function must - be optional: if the application does not supply it, the square - root function must still compute square roots.) - -These requirements apply to the modified work as a whole. If -identifiable sections of that work are not derived from the Library, -and can be reasonably considered independent and separate works in -themselves, then this License, and its terms, do not apply to those -sections when you distribute them as separate works. But when you -distribute the same sections as part of a whole which is a work based -on the Library, the distribution of the whole must be on the terms of -this License, whose permissions for other licensees extend to the -entire whole, and thus to each and every part regardless of who wrote -it. - -Thus, it is not the intent of this section to claim rights or contest -your rights to work written entirely by you; rather, the intent is to -exercise the right to control the distribution of derivative or -collective works based on the Library. - -In addition, mere aggregation of another work not based on the Library -with the Library (or with a work based on the Library) on a volume of -a storage or distribution medium does not bring the other work under -the scope of this License. - - 3. You may opt to apply the terms of the ordinary GNU General Public -License instead of this License to a given copy of the Library. To do -this, you must alter all the notices that refer to this License, so -that they refer to the ordinary GNU General Public License, version 2, -instead of to this License. (If a newer version than version 2 of the -ordinary GNU General Public License has appeared, then you can specify -that version instead if you wish.) Do not make any other change in -these notices. - - Once this change is made in a given copy, it is irreversible for -that copy, so the ordinary GNU General Public License applies to all -subsequent copies and derivative works made from that copy. - - This option is useful when you wish to copy part of the code of -the Library into a program that is not a library. - - 4. You may copy and distribute the Library (or a portion or -derivative of it, under Section 2) in object code or executable form -under the terms of Sections 1 and 2 above provided that you accompany -it with the complete corresponding machine-readable source code, which -must be distributed under the terms of Sections 1 and 2 above on a -medium customarily used for software interchange. - - If distribution of object code is made by offering access to copy -from a designated place, then offering equivalent access to copy the -source code from the same place satisfies the requirement to -distribute the source code, even though third parties are not -compelled to copy the source along with the object code. - - 5. A program that contains no derivative of any portion of the -Library, but is designed to work with the Library by being compiled or -linked with it, is called a "work that uses the Library". Such a -work, in isolation, is not a derivative work of the Library, and -therefore falls outside the scope of this License. - - However, linking a "work that uses the Library" with the Library -creates an executable that is a derivative of the Library (because it -contains portions of the Library), rather than a "work that uses the -library". The executable is therefore covered by this License. -Section 6 states terms for distribution of such executables. - - When a "work that uses the Library" uses material from a header file -that is part of the Library, the object code for the work may be a -derivative work of the Library even though the source code is not. -Whether this is true is especially significant if the work can be -linked without the Library, or if the work is itself a library. The -threshold for this to be true is not precisely defined by law. - - If such an object file uses only numerical parameters, data -structure layouts and accessors, and small macros and small inline -functions (ten lines or less in length), then the use of the object -file is unrestricted, regardless of whether it is legally a derivative -work. (Executables containing this object code plus portions of the -Library will still fall under Section 6.) - - Otherwise, if the work is a derivative of the Library, you may -distribute the object code for the work under the terms of Section 6. -Any executables containing that work also fall under Section 6, -whether or not they are linked directly with the Library itself. - - 6. As an exception to the Sections above, you may also combine or -link a "work that uses the Library" with the Library to produce a -work containing portions of the Library, and distribute that work -under terms of your choice, provided that the terms permit -modification of the work for the customer's own use and reverse -engineering for debugging such modifications. - - You must give prominent notice with each copy of the work that the -Library is used in it and that the Library and its use are covered by -this License. You must supply a copy of this License. If the work -during execution displays copyright notices, you must include the -copyright notice for the Library among them, as well as a reference -directing the user to the copy of this License. Also, you must do one -of these things: - - a) Accompany the work with the complete corresponding - machine-readable source code for the Library including whatever - changes were used in the work (which must be distributed under - Sections 1 and 2 above); and, if the work is an executable linked - with the Library, with the complete machine-readable "work that - uses the Library", as object code and/or source code, so that the - user can modify the Library and then relink to produce a modified - executable containing the modified Library. (It is understood - that the user who changes the contents of definitions files in the - Library will not necessarily be able to recompile the application - to use the modified definitions.) - - b) Use a suitable shared library mechanism for linking with the - Library. A suitable mechanism is one that (1) uses at run time a - copy of the library already present on the user's computer system, - rather than copying library functions into the executable, and (2) - will operate properly with a modified version of the library, if - the user installs one, as long as the modified version is - interface-compatible with the version that the work was made with. - - c) Accompany the work with a written offer, valid for at - least three years, to give the same user the materials - specified in Subsection 6a, above, for a charge no more - than the cost of performing this distribution. - - d) If distribution of the work is made by offering access to copy - from a designated place, offer equivalent access to copy the above - specified materials from the same place. - - e) Verify that the user has already received a copy of these - materials or that you have already sent this user a copy. - - For an executable, the required form of the "work that uses the -Library" must include any data and utility programs needed for -reproducing the executable from it. However, as a special exception, -the materials to be distributed need not include anything that is -normally distributed (in either source or binary form) with the major -components (compiler, kernel, and so on) of the operating system on -which the executable runs, unless that component itself accompanies -the executable. - - It may happen that this requirement contradicts the license -restrictions of other proprietary libraries that do not normally -accompany the operating system. Such a contradiction means you cannot -use both them and the Library together in an executable that you -distribute. - - 7. You may place library facilities that are a work based on the -Library side-by-side in a single library together with other library -facilities not covered by this License, and distribute such a combined -library, provided that the separate distribution of the work based on -the Library and of the other library facilities is otherwise -permitted, and provided that you do these two things: - - a) Accompany the combined library with a copy of the same work - based on the Library, uncombined with any other library - facilities. This must be distributed under the terms of the - Sections above. - - b) Give prominent notice with the combined library of the fact - that part of it is a work based on the Library, and explaining - where to find the accompanying uncombined form of the same work. - - 8. You may not copy, modify, sublicense, link with, or distribute -the Library except as expressly provided under this License. Any -attempt otherwise to copy, modify, sublicense, link with, or -distribute the Library is void, and will automatically terminate your -rights under this License. However, parties who have received copies, -or rights, from you under this License will not have their licenses -terminated so long as such parties remain in full compliance. - - 9. You are not required to accept this License, since you have not -signed it. However, nothing else grants you permission to modify or -distribute the Library or its derivative works. These actions are -prohibited by law if you do not accept this License. Therefore, by -modifying or distributing the Library (or any work based on the -Library), you indicate your acceptance of this License to do so, and -all its terms and conditions for copying, distributing or modifying -the Library or works based on it. - - 10. Each time you redistribute the Library (or any work based on the -Library), the recipient automatically receives a license from the -original licensor to copy, distribute, link with or modify the Library -subject to these terms and conditions. You may not impose any further -restrictions on the recipients' exercise of the rights granted herein. -You are not responsible for enforcing compliance by third parties with -this License. - - 11. If, as a consequence of a court judgment or allegation of patent -infringement or for any other reason (not limited to patent issues), -conditions are imposed on you (whether by court order, agreement or -otherwise) that contradict the conditions of this License, they do not -excuse you from the conditions of this License. If you cannot -distribute so as to satisfy simultaneously your obligations under this -License and any other pertinent obligations, then as a consequence you -may not distribute the Library at all. For example, if a patent -license would not permit royalty-free redistribution of the Library by -all those who receive copies directly or indirectly through you, then -the only way you could satisfy both it and this License would be to -refrain entirely from distribution of the Library. - -If any portion of this section is held invalid or unenforceable under any -particular circumstance, the balance of the section is intended to apply, -and the section as a whole is intended to apply in other circumstances. - -It is not the purpose of this section to induce you to infringe any -patents or other property right claims or to contest validity of any -such claims; this section has the sole purpose of protecting the -integrity of the free software distribution system which is -implemented by public license practices. Many people have made -generous contributions to the wide range of software distributed -through that system in reliance on consistent application of that -system; it is up to the author/donor to decide if he or she is willing -to distribute software through any other system and a licensee cannot -impose that choice. - -This section is intended to make thoroughly clear what is believed to -be a consequence of the rest of this License. - - 12. If the distribution and/or use of the Library is restricted in -certain countries either by patents or by copyrighted interfaces, the -original copyright holder who places the Library under this License may add -an explicit geographical distribution limitation excluding those countries, -so that distribution is permitted only in or among countries not thus -excluded. In such case, this License incorporates the limitation as if -written in the body of this License. - - 13. The Free Software Foundation may publish revised and/or new -versions of the Lesser General Public License from time to time. -Such new versions will be similar in spirit to the present version, -but may differ in detail to address new problems or concerns. - -Each version is given a distinguishing version number. If the Library -specifies a version number of this License which applies to it and -"any later version", you have the option of following the terms and -conditions either of that version or of any later version published by -the Free Software Foundation. If the Library does not specify a -license version number, you may choose any version ever published by -the Free Software Foundation. - - 14. If you wish to incorporate parts of the Library into other free -programs whose distribution conditions are incompatible with these, -write to the author to ask for permission. For software which is -copyrighted by the Free Software Foundation, write to the Free -Software Foundation; we sometimes make exceptions for this. Our -decision will be guided by the two goals of preserving the free status -of all derivatives of our free software and of promoting the sharing -and reuse of software generally. - - NO WARRANTY - - 15. BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO -WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW. -EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR -OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY -KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE -IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR -PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE -LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME -THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. - - 16. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN -WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY -AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU -FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE -LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING -RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A -FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF -SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH -DAMAGES. - - END OF TERMS AND CONDITIONS - diff --git a/examples/spectrum/3rdparty/fftreal/readme.txt b/examples/spectrum/3rdparty/fftreal/readme.txt deleted file mode 100644 index 0c5ce162..00000000 --- a/examples/spectrum/3rdparty/fftreal/readme.txt +++ /dev/null @@ -1,242 +0,0 @@ -============================================================================== - - FFTReal - Version 2.00, 2005/10/18 - - Fourier transformation (FFT, IFFT) library specialised for real data - Portable ISO C++ - - (c) Laurent de Soras - Object Pascal port (c) Frederic Vanmol - -============================================================================== - - - -1. Legal --------- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -Check the file license.txt to get full information about the license. - - - -2. Content ----------- - -FFTReal is a library to compute Discrete Fourier Transforms (DFT) with the -FFT algorithm (Fast Fourier Transform) on arrays of real numbers. It can -also compute the inverse transform. - -You should find in this package a lot of files ; some of them are of interest: -- readme.txt: you are reading it -- FFTReal.h: FFT, length fixed at run-time -- FFTRealFixLen.h: FFT, length fixed at compile-time -- FFTReal.pas: Pascal implementation (working but not up-to-date) -- stopwatch directory - - - -3. Using FFTReal ----------------- - -Important - if you were using older versions of FFTReal (up to 1.03), some -things have changed. FFTReal is now a template. Therefore use FFTReal -or FFTReal in your code depending on the application datatype. The -flt_t typedef has been removed. - -You have two ways to use FFTReal. In the first way, the FFT has its length -fixed at run-time, when the object is instanciated. It means that you have -not to know the length when you write the code. This is the usual way of -proceeding. - - -3.1 FFTReal - Length fixed at run-time --------------------------------------- - -Just instanciate one time a FFTReal object. Specify the data type you want -as template parameter (only floating point: float, double, long double or -custom type). The constructor precompute a lot of things, so it may be a bit -long. The parameter is the number of points used for the next FFTs. It must -be a power of 2: - - #include "FFTReal.h" - ... - long len = 1024; - ... - FFTReal fft_object (len); // 1024-point FFT object constructed. - -Then you can use this object to compute as many FFTs and IFFTs as you want. -They will be computed very quickly because a lot of work has been done in the -object construction. - - float x [1024]; - float f [1024]; - - ... - fft_object.do_fft (f, x); // x (real) --FFT---> f (complex) - ... - fft_object.do_ifft (f, x); // f (complex) --IFFT--> x (real) - fft_object.rescale (x); // Post-scaling should be done after FFT+IFFT - ... - -x [] and f [] are floating point number arrays. x [] is the real number -sequence which we want to compute the FFT. f [] is the result, in the -"frequency" domain. f has the same number of elements as x [], but f [] -elements are complex numbers. The routine uses some FFT properties to -optimize memory and to reduce calculations: the transformaton of a real -number sequence is a conjugate complex number sequence: F [k] = F [-k]*. - - -3.2 FFTRealFixLen - Length fixed at compile-time ------------------------------------------------- - -This class is significantly faster than the previous one, giving a speed -gain between 50 and 100 %. The template parameter is the base-2 logarithm of -the FFT length. The datatype is float; it can be changed by modifying the -DataType typedef in FFTRealFixLenParam.h. As FFTReal class, it supports -only floating-point types or equivalent. - -To instanciate the object, just proceed as below: - - #include "FFTRealFixLen.h" - ... - FFTRealFixLen <10> fft_object; // 1024-point (2^10) FFT object constructed. - -Use is similar as the one of FFTReal. - - -3.3 Data organisation ---------------------- - -Mathematically speaking, the formulas below show what does FFTReal: - -do_fft() : f(k) = sum (p = 0, N-1, x(p) * exp (+j*2*pi*k*p/N)) -do_ifft(): x(k) = sum (p = 0, N-1, f(p) * exp (-j*2*pi*k*p/N)) - -Where j is the square root of -1. The formulas differ only by the sign of -the exponential. When the sign is positive, the transform is called positive. -Common formulas for Fourier transform are negative for the direct tranform and -positive for the inverse one. - -However in these formulas, f is an array of complex numbers and doesn't -correspound exactly to the f[] array taken as function parameter. The -following table shows how the f[] sequence is mapped onto the usable FFT -coefficients (called bins): - - FFTReal output | Positive FFT equiv. | Negative FFT equiv. - ---------------+-----------------------+----------------------- - f [0] | Real (bin 0) | Real (bin 0) - f [...] | Real (bin ...) | Real (bin ...) - f [length/2] | Real (bin length/2) | Real (bin length/2) - f [length/2+1] | Imag (bin 1) | -Imag (bin 1) - f [...] | Imag (bin ...) | -Imag (bin ...) - f [length-1] | Imag (bin length/2-1) | -Imag (bin length/2-1) - -And FFT bins are distributed in f [] as above: - - | | Positive FFT | Negative FFT - Bin | Real part | imaginary part | imaginary part - ------------+----------------+-----------------+--------------- - 0 | f [0] | 0 | 0 - 1 | f [1] | f [length/2+1] | -f [length/2+1] - ... | f [...], | f [...] | -f [...] - length/2-1 | f [length/2-1] | f [length-1] | -f [length-1] - length/2 | f [length/2] | 0 | 0 - length/2+1 | f [length/2-1] | -f [length-1] | f [length-1] - ... | f [...] | -f [...] | f [...] - length-1 | f [1] | -f [length/2+1] | f [length/2+1] - -f [] coefficients have the same layout for FFT and IFFT functions. You may -notice that scaling must be done if you want to retrieve x after FFT and IFFT. -Actually, IFFT (FFT (x)) = x * length(x). This is a not a problem because -most of the applications don't care about absolute values. Thus, the operation -requires less calculation. If you want to use the FFT and IFFT to transform a -signal, you have to apply post- (or pre-) processing yourself. Multiplying -or dividing floating point numbers by a power of 2 doesn't generate extra -computation noise. - - - -4. Compilation and testing --------------------------- - -Drop the following files into your project or makefile: - -Array.* -def.h -DynArray.* -FFTReal*.cpp -FFTReal*.h* -OscSinCos.* - -Other files are for testing purpose only, do not include them if you just need -to use the library ; they are not needed to use FFTReal in your own programs. - -FFTReal may be compiled in two versions: release and debug. Debug version -has checks that could slow down the code. Define NDEBUG to set the Release -mode. For example, the command line to compile the test bench on GCC would -look like: - -Debug mode: -g++ -Wall -o fftreal_debug.exe *.cpp stopwatch/*.cpp - -Release mode: -g++ -Wall -o fftreal_release.exe -DNDEBUG -O3 *.cpp stopwatch/*.cpp - -It may be tricky to compile the test bench because the speed tests use the -stopwatch sub-library, which is not that cross-platform. If you encounter -any problem that you cannot easily fix while compiling it, edit the file -test_settings.h and un-define the speed test macro. Remove the stopwatch -directory from your source file list, too. - -If it's not done by default, you should activate the exception handling -of your compiler to get the class memory-leak-safe. Thus, when a memory -allocation fails (in the constructor), an exception is thrown and the entire -object is safely destructed. It reduces the permanent error checking overhead -in the client code. Also, the test bench requires Run-Time Type Information -(RTTI) to be enabled in order to display the names of the tested classes - -sometimes mangled, depending on the compiler. - -The test bench may take a long time to compile, especially in Release mode, -because a lot of recursive templates are instanciated. - - - -5. History ----------- - -v2.00 (2005.10.18) -- Turned FFTReal class into template (data type as parameter) -- Added FFTRealFixLen -- Trigonometric tables are size-limited in order to preserve cache memory; -over a given size, sin/cos functions are computed on the fly. -- Better test bench for accuracy and speed - -v1.03 (2001.06.15) -- Thanks to Frederic Vanmol for the Pascal port (works with Delphi). -- Documentation improvement - -v1.02 (2001.03.25) -- sqrt() is now precomputed when the object FFTReal is constructed, resulting -in speed impovement for small size FFT. - -v1.01 (2000) -- Small modifications, I don't remember what. - -v1.00 (1999.08.14) -- First version released - diff --git a/examples/spectrum/3rdparty/fftreal/test.cpp b/examples/spectrum/3rdparty/fftreal/test.cpp deleted file mode 100644 index 7b6ed2ca..00000000 --- a/examples/spectrum/3rdparty/fftreal/test.cpp +++ /dev/null @@ -1,267 +0,0 @@ -/***************************************************************************** - - test.cpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (_MSC_VER) - #pragma warning (4 : 4786) // "identifier was truncated to '255' characters in the debug information" - #pragma warning (4 : 4800) // "forcing value to bool 'true' or 'false' (performance warning)" -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - -#include "test_settings.h" -#include "TestHelperFixLen.h" -#include "TestHelperNormal.h" - -#if defined (_MSC_VER) -#include -#include -#endif // _MSC_VER - -#include - -#include -#include - - - -#define TEST_ - - -/*\\\ FUNCTIONS \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -static int TEST_perform_test_accuracy_all (); -static int TEST_perform_test_speed_all (); - -static void TEST_prog_init (); -static void TEST_prog_end (); - - - -int main (int argc, char *argv []) -{ - using namespace std; - - int ret_val = 0; - - TEST_prog_init (); - - try - { - if (ret_val == 0) - { - ret_val = TEST_perform_test_accuracy_all (); - } - - if (ret_val == 0) - { - ret_val = TEST_perform_test_speed_all (); - } - } - - catch (std::exception &e) - { - printf ("\n*** main(): Exception (std::exception) : %s\n", e.what ()); - ret_val = -1; - } - - catch (...) - { - printf ("\n*** main(): Undefined exception\n"); - ret_val = -1; - } - - TEST_prog_end (); - - return (ret_val); -} - - - -int TEST_perform_test_accuracy_all () -{ - int ret_val = 0; - - TestHelperNormal ::perform_test_accuracy (ret_val); - TestHelperNormal ::perform_test_accuracy (ret_val); - - TestHelperFixLen < 1>::perform_test_accuracy (ret_val); - TestHelperFixLen < 2>::perform_test_accuracy (ret_val); - TestHelperFixLen < 3>::perform_test_accuracy (ret_val); - TestHelperFixLen < 4>::perform_test_accuracy (ret_val); - TestHelperFixLen < 7>::perform_test_accuracy (ret_val); - TestHelperFixLen < 8>::perform_test_accuracy (ret_val); - TestHelperFixLen <10>::perform_test_accuracy (ret_val); - TestHelperFixLen <12>::perform_test_accuracy (ret_val); - TestHelperFixLen <13>::perform_test_accuracy (ret_val); - - return (ret_val); -} - - - -int TEST_perform_test_speed_all () -{ - int ret_val = 0; - -#if defined (test_settings_SPEED_TEST_ENABLED) - - TestHelperNormal ::perform_test_speed (ret_val); - TestHelperNormal ::perform_test_speed (ret_val); - - TestHelperFixLen < 1>::perform_test_speed (ret_val); - TestHelperFixLen < 2>::perform_test_speed (ret_val); - TestHelperFixLen < 3>::perform_test_speed (ret_val); - TestHelperFixLen < 4>::perform_test_speed (ret_val); - TestHelperFixLen < 7>::perform_test_speed (ret_val); - TestHelperFixLen < 8>::perform_test_speed (ret_val); - TestHelperFixLen <10>::perform_test_speed (ret_val); - TestHelperFixLen <12>::perform_test_speed (ret_val); - TestHelperFixLen <14>::perform_test_speed (ret_val); - TestHelperFixLen <16>::perform_test_speed (ret_val); - TestHelperFixLen <20>::perform_test_speed (ret_val); - -#endif - - return (ret_val); -} - - - -#if defined (_MSC_VER) -static int __cdecl TEST_new_handler_cb (size_t dummy) -{ - throw std::bad_alloc (); - return (0); -} -#endif // _MSC_VER - - - -#if defined (_MSC_VER) && ! defined (NDEBUG) -static int __cdecl TEST_debug_alloc_hook_cb (int alloc_type, void *user_data_ptr, size_t size, int block_type, long request_nbr, const unsigned char *filename_0, int line_nbr) -{ - if (block_type != _CRT_BLOCK) // Ignore CRT blocks to prevent infinite recursion - { - switch (alloc_type) - { - case _HOOK_ALLOC: - case _HOOK_REALLOC: - case _HOOK_FREE: - - // Put some debug code here - - break; - - default: - assert (false); // Undefined allocation type - break; - } - } - - return (1); -} -#endif - - - -#if defined (_MSC_VER) && ! defined (NDEBUG) -static int __cdecl TEST_debug_report_hook_cb (int report_type, char *user_msg_0, int *ret_val_ptr) -{ - *ret_val_ptr = 0; // 1 to override the CRT default reporting mode - - switch (report_type) - { - case _CRT_WARN: - case _CRT_ERROR: - case _CRT_ASSERT: - -// Put some debug code here - - break; - } - - return (*ret_val_ptr); -} -#endif - - - -static void TEST_prog_init () -{ -#if defined (_MSC_VER) - ::_set_new_handler (::TEST_new_handler_cb); -#endif // _MSC_VER - -#if defined (_MSC_VER) && ! defined (NDEBUG) - { - const int mode = (1 * _CRTDBG_MODE_DEBUG) - | (1 * _CRTDBG_MODE_WNDW); - ::_CrtSetReportMode (_CRT_WARN, mode); - ::_CrtSetReportMode (_CRT_ERROR, mode); - ::_CrtSetReportMode (_CRT_ASSERT, mode); - - const int old_flags = ::_CrtSetDbgFlag (_CRTDBG_REPORT_FLAG); - ::_CrtSetDbgFlag ( old_flags - | (1 * _CRTDBG_LEAK_CHECK_DF) - | (1 * _CRTDBG_CHECK_ALWAYS_DF)); - ::_CrtSetBreakAlloc (-1); // Specify here a memory bloc number - ::_CrtSetAllocHook (TEST_debug_alloc_hook_cb); - ::_CrtSetReportHook (TEST_debug_report_hook_cb); - - // Speed up I/O but breaks C stdio compatibility -// std::cout.sync_with_stdio (false); -// std::cin.sync_with_stdio (false); -// std::cerr.sync_with_stdio (false); -// std::clog.sync_with_stdio (false); - } -#endif // _MSC_VER, NDEBUG -} - - - -static void TEST_prog_end () -{ -#if defined (_MSC_VER) && ! defined (NDEBUG) - { - const int mode = (1 * _CRTDBG_MODE_DEBUG) - | (0 * _CRTDBG_MODE_WNDW); - ::_CrtSetReportMode (_CRT_WARN, mode); - ::_CrtSetReportMode (_CRT_ERROR, mode); - ::_CrtSetReportMode (_CRT_ASSERT, mode); - - ::_CrtMemState mem_state; - ::_CrtMemCheckpoint (&mem_state); - ::_CrtMemDumpStatistics (&mem_state); - } -#endif // _MSC_VER, NDEBUG -} - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/test_fnc.h b/examples/spectrum/3rdparty/fftreal/test_fnc.h deleted file mode 100644 index 26221566..00000000 --- a/examples/spectrum/3rdparty/fftreal/test_fnc.h +++ /dev/null @@ -1,53 +0,0 @@ -/***************************************************************************** - - test_fnc.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (test_fnc_HEADER_INCLUDED) -#define test_fnc_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -inline T limit (const T &x, const T &inf, const T &sup); - - - -#include "test_fnc.hpp" - - - -#endif // test_fnc_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/test_fnc.hpp b/examples/spectrum/3rdparty/fftreal/test_fnc.hpp deleted file mode 100644 index 4b5f9f59..00000000 --- a/examples/spectrum/3rdparty/fftreal/test_fnc.hpp +++ /dev/null @@ -1,56 +0,0 @@ -/***************************************************************************** - - test_fnc.hpp - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if defined (test_fnc_CURRENT_CODEHEADER) - #error Recursive inclusion of test_fnc code header. -#endif -#define test_fnc_CURRENT_CODEHEADER - -#if ! defined (test_fnc_CODEHEADER_INCLUDED) -#define test_fnc_CODEHEADER_INCLUDED - - - -/*\\\ INCLUDE FILES \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ - - - -template -T limit (const T &x, const T &inf, const T &sup) -{ - assert (! (sup < inf)); - - return ((x < inf) ? inf : ((sup < x) ? sup : x)); -} - - - -#endif // test_fnc_CODEHEADER_INCLUDED - -#undef test_fnc_CURRENT_CODEHEADER - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/test_settings.h b/examples/spectrum/3rdparty/fftreal/test_settings.h deleted file mode 100644 index b893afc8..00000000 --- a/examples/spectrum/3rdparty/fftreal/test_settings.h +++ /dev/null @@ -1,45 +0,0 @@ -/***************************************************************************** - - test_settings.h - Copyright (c) 2005 Laurent de Soras - ---- Legal stuff --- - -This library is free software; you can redistribute it and/or -modify it under the terms of the GNU Lesser General Public -License as published by the Free Software Foundation; either -version 2.1 of the License, or (at your option) any later version. - -This library is distributed in the hope that it will be useful, -but WITHOUT ANY WARRANTY; without even the implied warranty of -MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU -Lesser General Public License for more details. - -You should have received a copy of the GNU Lesser General Public -License along with this library; if not, write to the Free Software -Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - -*Tab=3***********************************************************************/ - - - -#if ! defined (test_settings_HEADER_INCLUDED) -#define test_settings_HEADER_INCLUDED - -#if defined (_MSC_VER) - #pragma once - #pragma warning (4 : 4250) // "Inherits via dominance." -#endif - - - -// #undef this label to avoid speed test compilation. -#define test_settings_SPEED_TEST_ENABLED - - - -#endif // test_settings_HEADER_INCLUDED - - - -/*\\\ EOF \\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/ diff --git a/examples/spectrum/3rdparty/fftreal/testapp.dpr b/examples/spectrum/3rdparty/fftreal/testapp.dpr deleted file mode 100644 index 54f2eb99..00000000 --- a/examples/spectrum/3rdparty/fftreal/testapp.dpr +++ /dev/null @@ -1,150 +0,0 @@ -program testapp; -{$APPTYPE CONSOLE} -uses - SysUtils, - fftreal in 'fftreal.pas', - Math, - Windows; - -var - nbr_points : longint; - x, f : pflt_array; - fft : TFFTReal; - i : longint; - PI : double; - areal, img : double; - f_abs : double; - buffer_size : longint; - nbr_tests : longint; - time0, time1, time2 : int64; - timereso : int64; - offset : longint; - t0, t1 : double; - nbr_s_chn : longint; - tempp1, tempp2 : pflt_array; - -begin - (*______________________________________________ - * - * Exactness test - *______________________________________________ - *) - - WriteLn('Accuracy test:'); - WriteLn; - - nbr_points := 16; // Power of 2 - GetMem(x, nbr_points * sizeof_flt); - GetMem(f, nbr_points * sizeof_flt); - fft := TFFTReal.Create(nbr_points); // FFT object initialized here - - // Test signal - PI := ArcTan(1) * 4; - for i := 0 to nbr_points-1 do - begin - x^[i] := -1 + sin (3*2*PI*i/nbr_points) - + cos (5*2*PI*i/nbr_points) * 2 - - sin (7*2*PI*i/nbr_points) * 3 - + cos (8*2*PI*i/nbr_points) * 5; - end; - - // Compute FFT and IFFT - fft.do_fft(f, x); - fft.do_ifft(f, x); - fft.rescale(x); - - // Display the result - WriteLn('FFT:'); - for i := 0 to nbr_points div 2 do - begin - areal := f^[i]; - if (i > 0) and (i < nbr_points div 2) then - img := f^[i + nbr_points div 2] - else - img := 0; - - f_abs := Sqrt(areal * areal + img * img); - WriteLn(Format('%5d: %12.6f %12.6f (%12.6f)', [i, areal, img, f_abs])); - end; - - WriteLn; - WriteLn('IFFT:'); - for i := 0 to nbr_points-1 do - WriteLn(Format('%5d: %f', [i, x^[i]])); - - WriteLn; - - FreeMem(x); - FreeMem(f); - fft.Free; - - - (*______________________________________________ - * - * Speed test - *______________________________________________ - *) - - WriteLn('Speed test:'); - WriteLn('Please wait...'); - WriteLn; - - nbr_points := 1024; // Power of 2 - buffer_size := 256*nbr_points; // Number of flt_t (float or double) - nbr_tests := 10000; - - assert(nbr_points <= buffer_size); - GetMem(x, buffer_size * sizeof_flt); - GetMem(f, buffer_size * sizeof_flt); - fft := TFFTReal.Create(nbr_points); // FFT object initialized here - - // Test signal: noise - for i := 0 to nbr_points-1 do - x^[i] := Random($7fff) - ($7fff shr 1); - - // timing - QueryPerformanceFrequency(timereso); - QueryPerformanceCounter(time0); - - for i := 0 to nbr_tests-1 do - begin - offset := (i * nbr_points) and (buffer_size - 1); - tempp1 := f; - inc(tempp1, offset); - tempp2 := x; - inc(tempp2, offset); - fft.do_fft(tempp1, tempp2); - end; - - QueryPerformanceCounter(time1); - - for i := 0 to nbr_tests-1 do - begin - offset := (i * nbr_points) and (buffer_size - 1); - tempp1 := f; - inc(tempp1, offset); - tempp2 := x; - inc(tempp2, offset); - fft.do_ifft(tempp1, tempp2); - fft.rescale(x); - end; - - QueryPerformanceCounter(time2); - - t0 := ((time1-time0) / timereso) / nbr_tests; - t1 := ((time2-time1) / timereso) / nbr_tests; - - WriteLn(Format('%d-points FFT : %.0f us.', [nbr_points, t0 * 1000000])); - WriteLn(Format('%d-points IFFT + scaling: %.0f us.', [nbr_points, t1 * 1000000])); - - nbr_s_chn := Floor(nbr_points / ((t0 + t1) * 44100 * 2)); - WriteLn(Format('Peak performance: FFT+IFFT on %d mono channels at 44.1 KHz (with overlapping)', [nbr_s_chn])); - WriteLn; - - FreeMem(x); - FreeMem(f); - fft.Free; - - WriteLn('Press [Return] key to terminate...'); - ReadLn; -end. diff --git a/examples/spectrum/README.txt b/examples/spectrum/README.txt deleted file mode 100644 index c39d4a70..00000000 --- a/examples/spectrum/README.txt +++ /dev/null @@ -1,103 +0,0 @@ -Spectrum analyser demo app -========================== - -Introduction ------------- - -This application is a demo which uses the QtMultimedia APIs to capture and play back PCM audio. While either recording or playback is ongoing, the application performs real-time level and frequency spectrum analysis, displaying the results in its main window. - - -Acknowledgments ---------------- - -The application uses the FFTReal v2.00 library by Laurent de Soras to perform frequency analysis of the audio signal. For further information, see the project home page: - http://ldesoras.free.fr/prod.html - - -Quick start ------------ - -Play generated tone -1. Select 'Play generated tone' from the mode menu -2. Ensure that the 'Frequency sweep' box is checked -3. Press 'OK' -4. Press the play button -You should hear a rising tone, and see progressively higher frequencies indicated by the spectrograph. - -Record and playback -1. Select 'Record and play back audio' from the mode menu -2. Press the record button, and speak into the microphone -3. Wait until the buffer is full (shown as a full blue bar in the top widget) -4. Press play, and wait until playback of the buffer is complete - -Play file -1. Select 'Play file' from the mode menu -2. Select a WAV file -3. Press the play button -You should hear the first few seconds of the file being played. The waveform, spectrograph and level meter should be updated as the file is played. - - -Things to play with -------------------- - -Try repeating the 'Play generated tone' sequence using different window functions. These can be selected from the settings dialog - launch it by pressing the spanner icon. The window function is applied to the audio signal before performing the frequency analysis; different windows should have a visible effect on the resulting frequency spectrum. - -Try clicking on one of the spectrograph bars while the tone is being played. The frequency range for that bar will be displayed at the top of the application window. - - -Troubleshooting ---------------- - -If either recording or playback do not work, you may need to select a different input / output audio device. This can be done in the settings dialog - launch it by pressing the spanner icon. - -If that doesn't work, there may be a problem either in the application or in Qt. Report a bug in the usual way. - - -Application interface ---------------------- - -The main window of the application contains the following widgets, starting at the top: - -Message box -This shows various messages during execution, such as the current audio format. - -Progress bar / waveform display -- While recording or playback is ongoing, the audio waveform is displayed, sliding from right to left. -- Superimposed on the waveform, the amount of data currently in the buffer is showed as a blue bar. When recording, this blue bar fills up from left to right; when playing, the bar gets consumed from left to right. -- A green window shows which part of the buffer has most recently been analysed. This window should be close to the 'leading edge' of recording or playback, i.e. the most recently recorded / played data, although it will lag slightly depending on the performance of the machine on which the application is running. - -Frequency spectrograph (on the left) -The spectrograph shows 10 bars, each representing a frequency range. The frequency range of each bar is displayed in the message box when the bar is clicked. The height of the bar shows the maximum amplitude of freqencies within its range. - -Level meter (on the right) -The current peak audio level is shown as a pink bar; the current RMS level is shown as a red bar. The 'high water mark' during a recent period is shown as a thin red line. - -Button panel -- The mode menu allows switching between the three operation modes - 'Play generated tone', 'Record and play back' and 'Play file'. -- The record button starts or resumes audio capture from the current input device. -- The pause button suspends either capture or recording. -- The play button starts or resumes audio playback to the current output device. -- The settings button launches the settings dialog. - - -Hacking -------- - -If you want to hack the application, here are some pointers to get started. - -The spectrum.pri file contains several macros which you can enable by uncommenting: -- LOG_FOO Enable logging from class Foo via qDebug() -- DUMP_FOO Dump data from class Foo to the file system - e.g. DUMP_SPECTRUMANALYSER writes files containing the raw FFT input and output. - Be aware that this can generate a *lot* of data and may slow the app down considerably. -- DISABLE_FOO Disable specified functionality - -If you don't like the combination of the waveform and progress bar in a single widget, separate them by commenting out SUPERIMPOSE_PROGRESS_ON_WAVEFORM. - -The spectrum.h file defines a number of parameters which can be played with. These control things such as the number of audio samples analysed per FFT calculation, the range and number of bands displayed by the spectrograph, and so on. - -The part of the application which interacts with QtMultimedia is in the Engine class. - -Some ideas for enhancements to the app are listed in TODO.txt. Feel free to start work on any of them :) - - diff --git a/examples/spectrum/doc/images/spectrum-example.png b/examples/spectrum/doc/images/spectrum-example.png deleted file mode 100644 index 2a703948..00000000 Binary files a/examples/spectrum/doc/images/spectrum-example.png and /dev/null differ diff --git a/examples/spectrum/doc/src/spectrum.qdoc b/examples/spectrum/doc/src/spectrum.qdoc deleted file mode 100644 index 612c31cd..00000000 --- a/examples/spectrum/doc/src/spectrum.qdoc +++ /dev/null @@ -1,28 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -/*! - \example spectrum - \title Spectrum Example - - The spectrum example shows how feed dynamic data to a graph using Q3DBars. - - \image spectrum-example.png - - TODO -*/ diff --git a/examples/spectrum/spectrum.pri b/examples/spectrum/spectrum.pri deleted file mode 100644 index 31a3767c..00000000 --- a/examples/spectrum/spectrum.pri +++ /dev/null @@ -1,18 +0,0 @@ -# The following macros allow certain features and debugging output -# to be disabled / enabled at compile time. - -# Debug output from spectrum calculation -#DEFINES += LOG_SPECTRUMANALYSER - -# Debug output from engine -#DEFINES += LOG_ENGINE - -# Disable level calculation -DEFINES += DISABLE_LEVEL - -# Perform spectrum analysis calculation in a separate thread -DEFINES += SPECTRUM_ANALYSER_SEPARATE_THREAD - -# Suppress warnings about strncpy potentially being unsafe, emitted by MSVC -win32: DEFINES += _CRT_SECURE_NO_WARNINGS - diff --git a/examples/spectrum/spectrum.pro b/examples/spectrum/spectrum.pro deleted file mode 100644 index 9a8d45ae..00000000 --- a/examples/spectrum/spectrum.pro +++ /dev/null @@ -1,13 +0,0 @@ -qtHaveModule(multimedia) { -include(spectrum.pri) - -TEMPLATE = subdirs - -# Ensure that library is built before application -CONFIG += ordered - -SUBDIRS += 3rdparty/fftreal -SUBDIRS += spectrumapp - -TARGET = spectrum -} diff --git a/examples/spectrum/spectrumapp/engine.cpp b/examples/spectrum/spectrumapp/engine.cpp deleted file mode 100644 index c23a4f78..00000000 --- a/examples/spectrum/spectrumapp/engine.cpp +++ /dev/null @@ -1,613 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#include "engine.h" -#include "utils.h" - -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -const qint64 BufferDurationUs = 10 * 1000000; -const int NotifyIntervalMs = 100; - -// Size of the level calculation window in microseconds -const int LevelWindowUs = 0.1 * 1000000; - -//----------------------------------------------------------------------------- -// Constructor and destructor -//----------------------------------------------------------------------------- - -Engine::Engine(QObject *parent) - : QObject(parent), - m_mode(QAudio::AudioInput), - m_state(QAudio::StoppedState), - m_generateTone(false), - m_file(0), - m_analysisFile(0), - m_availableAudioInputDevices - (QAudioDeviceInfo::availableDevices(QAudio::AudioInput)), - m_audioInputDevice(QAudioDeviceInfo::defaultInputDevice()), - m_audioInput(0), - m_audioInputIODevice(0), - m_recordPosition(0), - m_availableAudioOutputDevices - (QAudioDeviceInfo::availableDevices(QAudio::AudioOutput)), - m_audioOutputDevice(QAudioDeviceInfo::defaultOutputDevice()), - m_audioOutput(0), - m_playPosition(0), - m_bufferPosition(0), - m_bufferLength(0), - m_dataLength(0), - m_levelBufferLength(0), - m_rmsLevel(0.0), - m_peakLevel(0.0), - m_spectrumBufferLength(0), - m_spectrumAnalyser(), - m_spectrumPosition(0), - m_count(0) -{ - qRegisterMetaType("FrequencySpectrum"); - qRegisterMetaType("WindowFunction"); - CHECKED_CONNECT(&m_spectrumAnalyser, - SIGNAL(spectrumChanged(FrequencySpectrum)), - this, - SLOT(spectrumChanged(FrequencySpectrum))); - - initialize(); -} - -Engine::~Engine() -{ - -} - -//----------------------------------------------------------------------------- -// Public functions -//----------------------------------------------------------------------------- - -bool Engine::loadFile(const QString &fileName) -{ - reset(); - bool result = false; - Q_ASSERT(!m_generateTone); - Q_ASSERT(!m_file); - Q_ASSERT(!fileName.isEmpty()); - m_file = new WavFile(this); - if (m_file->open(fileName)) { - if (isPCMS16LE(m_file->fileFormat())) { - result = initialize(); - } else { - ENGINE_DEBUG << "Audio format not supported" << formatToString(m_file->fileFormat()); - } - } else { - ENGINE_DEBUG << "Could not open file" << fileName; - } - if (result) { - m_analysisFile = new WavFile(this); - m_analysisFile->open(fileName); - } - return result; -} - -qint64 Engine::bufferLength() const -{ - return m_file ? m_file->size() : m_bufferLength; -} - -void Engine::setWindowFunction(WindowFunction type) -{ - m_spectrumAnalyser.setWindowFunction(type); -} - - -//----------------------------------------------------------------------------- -// Public slots -//----------------------------------------------------------------------------- - -void Engine::startRecording() -{ - if (m_audioInput) { - if (QAudio::AudioInput == m_mode && - QAudio::SuspendedState == m_state) { - m_audioInput->resume(); - } else { - m_spectrumAnalyser.cancelCalculation(); - changedSpectrum(0, 0, FrequencySpectrum()); - - m_buffer.fill(0); - setRecordPosition(0, true); - stopPlayback(); - m_mode = QAudio::AudioInput; - CHECKED_CONNECT(m_audioInput, SIGNAL(stateChanged(QAudio::State)), - this, SLOT(audioStateChanged(QAudio::State))); - CHECKED_CONNECT(m_audioInput, SIGNAL(notify()), - this, SLOT(audioNotify())); - m_count = 0; - m_dataLength = 0; - emit dataLengthChanged(0); - m_audioInputIODevice = m_audioInput->start(); - CHECKED_CONNECT(m_audioInputIODevice, SIGNAL(readyRead()), - this, SLOT(audioDataReady())); - } - } -} - -void Engine::startPlayback() -{ - if (m_audioOutput) { - if (QAudio::AudioOutput == m_mode && - QAudio::SuspendedState == m_state) { -#ifdef Q_OS_WIN - // The Windows backend seems to internally go back into ActiveState - // while still returning SuspendedState, so to ensure that it doesn't - // ignore the resume() call, we first re-suspend - m_audioOutput->suspend(); -#endif - m_audioOutput->resume(); - } else { - m_spectrumAnalyser.cancelCalculation(); - changedSpectrum(0, 0, FrequencySpectrum()); - setPlayPosition(0, true); - stopRecording(); - m_mode = QAudio::AudioOutput; - CHECKED_CONNECT(m_audioOutput, SIGNAL(stateChanged(QAudio::State)), - this, SLOT(audioStateChanged(QAudio::State))); - CHECKED_CONNECT(m_audioOutput, SIGNAL(notify()), - this, SLOT(audioNotify())); - m_count = 0; - if (m_file) { - m_file->seek(0); - m_bufferPosition = 0; - m_dataLength = 0; - m_audioOutput->start(m_file); - } else { - m_audioOutputIODevice.close(); - m_audioOutputIODevice.setBuffer(&m_buffer); - m_audioOutputIODevice.open(QIODevice::ReadOnly); - m_audioOutput->start(&m_audioOutputIODevice); - } - } - } -} - -void Engine::suspend() -{ - if (QAudio::ActiveState == m_state || - QAudio::IdleState == m_state) { - switch (m_mode) { - case QAudio::AudioInput: - m_audioInput->suspend(); - break; - case QAudio::AudioOutput: - m_audioOutput->suspend(); - break; - } - } -} - -void Engine::setAudioInputDevice(const QAudioDeviceInfo &device) -{ - if (device.deviceName() != m_audioInputDevice.deviceName()) { - m_audioInputDevice = device; - initialize(); - } -} - -void Engine::setAudioOutputDevice(const QAudioDeviceInfo &device) -{ - if (device.deviceName() != m_audioOutputDevice.deviceName()) { - m_audioOutputDevice = device; - initialize(); - } -} - - -//----------------------------------------------------------------------------- -// Private slots -//----------------------------------------------------------------------------- - -void Engine::audioNotify() -{ - switch (m_mode) { - case QAudio::AudioInput: { - const qint64 recordPosition = qMin(m_bufferLength, audioLength(m_format, m_audioInput->processedUSecs())); - setRecordPosition(recordPosition); - const qint64 levelPosition = m_dataLength - m_levelBufferLength; - if (levelPosition >= 0) - calculateLevel(levelPosition, m_levelBufferLength); - if (m_dataLength >= m_spectrumBufferLength) { - const qint64 spectrumPosition = m_dataLength - m_spectrumBufferLength; - calculateSpectrum(spectrumPosition); - } - emit bufferChanged(0, m_dataLength, m_buffer); - } - break; - case QAudio::AudioOutput: { - const qint64 playPosition = audioLength(m_format, m_audioOutput->processedUSecs()); - setPlayPosition(qMin(bufferLength(), playPosition)); - const qint64 levelPosition = playPosition - m_levelBufferLength; - const qint64 spectrumPosition = playPosition - m_spectrumBufferLength; - if (m_file) { - if (levelPosition > m_bufferPosition || - spectrumPosition > m_bufferPosition || - qMax(m_levelBufferLength, m_spectrumBufferLength) > m_dataLength) { - m_bufferPosition = 0; - m_dataLength = 0; - // Data needs to be read into m_buffer in order to be analysed - const qint64 readPos = qMax(qint64(0), qMin(levelPosition, spectrumPosition)); - const qint64 readEnd = qMin(m_analysisFile->size(), qMax(levelPosition + m_levelBufferLength, spectrumPosition + m_spectrumBufferLength)); - const qint64 readLen = readEnd - readPos + audioLength(m_format, WaveformWindowDuration); - ENGINE_DEBUG << "Engine::audioNotify [1]" - << "analysisFileSize" << m_analysisFile->size() - << "readPos" << readPos - << "readLen" << readLen; - if (m_analysisFile->seek(readPos + m_analysisFile->headerLength())) { - m_buffer.resize(readLen); - m_bufferPosition = readPos; - m_dataLength = m_analysisFile->read(m_buffer.data(), readLen); - ENGINE_DEBUG << "Engine::audioNotify [2]" << "bufferPosition" << m_bufferPosition << "dataLength" << m_dataLength; - } else { - ENGINE_DEBUG << "Engine::audioNotify [2]" << "file seek error"; - } - emit bufferChanged(m_bufferPosition, m_dataLength, m_buffer); - } - } else { - if (playPosition >= m_dataLength) - stopPlayback(); - } - if (levelPosition >= 0 && levelPosition + m_levelBufferLength < m_bufferPosition + m_dataLength) - calculateLevel(levelPosition, m_levelBufferLength); - if (spectrumPosition >= 0 && spectrumPosition + m_spectrumBufferLength < m_bufferPosition + m_dataLength) - calculateSpectrum(spectrumPosition); - } - break; - } -} - -void Engine::audioStateChanged(QAudio::State state) -{ - ENGINE_DEBUG << "Engine::audioStateChanged from" << m_state - << "to" << state; - - if (QAudio::IdleState == state && m_file && m_file->pos() == m_file->size()) { - stopPlayback(); - } else { - if (QAudio::StoppedState == state) { - // Check error - QAudio::Error error = QAudio::NoError; - switch (m_mode) { - case QAudio::AudioInput: - error = m_audioInput->error(); - break; - case QAudio::AudioOutput: - error = m_audioOutput->error(); - break; - } - if (QAudio::NoError != error) { - reset(); - return; - } - } - setState(state); - } -} - -void Engine::audioDataReady() -{ - Q_ASSERT(0 == m_bufferPosition); - const qint64 bytesReady = m_audioInput->bytesReady(); - const qint64 bytesSpace = m_buffer.size() - m_dataLength; - const qint64 bytesToRead = qMin(bytesReady, bytesSpace); - - const qint64 bytesRead = m_audioInputIODevice->read( - m_buffer.data() + m_dataLength, - bytesToRead); - - if (bytesRead) { - m_dataLength += bytesRead; - emit dataLengthChanged(dataLength()); - } - - if (m_buffer.size() == m_dataLength) - stopRecording(); -} - -void Engine::spectrumChanged(const FrequencySpectrum &spectrum) -{ - ENGINE_DEBUG << "Engine::spectrumChanged" << "pos" << m_spectrumPosition; - emit changedSpectrum(m_spectrumPosition, m_spectrumBufferLength, spectrum); -} - - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -void Engine::resetAudioDevices() -{ - delete m_audioInput; - m_audioInput = 0; - m_audioInputIODevice = 0; - setRecordPosition(0); - delete m_audioOutput; - m_audioOutput = 0; - setPlayPosition(0); - m_spectrumPosition = 0; - setLevel(0.0, 0.0, 0); -} - -void Engine::reset() -{ - stopRecording(); - stopPlayback(); - setState(QAudio::AudioInput, QAudio::StoppedState); - setFormat(QAudioFormat()); - m_generateTone = false; - delete m_file; - m_file = 0; - delete m_analysisFile; - m_analysisFile = 0; - m_buffer.clear(); - m_bufferPosition = 0; - m_bufferLength = 0; - m_dataLength = 0; - emit dataLengthChanged(0); - resetAudioDevices(); -} - -bool Engine::initialize() -{ - bool result = false; - - QAudioFormat format = m_format; - - if (selectFormat()) { - resetAudioDevices(); - if (m_file) { - emit bufferLengthChanged(bufferLength()); - emit dataLengthChanged(dataLength()); - emit bufferChanged(0, 0, m_buffer); - setRecordPosition(bufferLength()); - result = true; - } - m_audioOutput = new QAudioOutput(m_audioOutputDevice, m_format, this); - m_audioOutput->setNotifyInterval(NotifyIntervalMs); - } else { - if (m_file) - ENGINE_DEBUG << "Audio format not supported" << formatToString(m_format); - else - ENGINE_DEBUG << "No common input / output format found"; - } - - ENGINE_DEBUG << "Engine::initialize" << "m_bufferLength" << m_bufferLength; - ENGINE_DEBUG << "Engine::initialize" << "m_dataLength" << m_dataLength; - ENGINE_DEBUG << "Engine::initialize" << "format" << m_format; - - return result; -} - -bool Engine::selectFormat() -{ - bool foundSupportedFormat = false; - - if (m_file || QAudioFormat() != m_format) { - QAudioFormat format = m_format; - if (m_file) - // Header is read from the WAV file; just need to check whether - // it is supported by the audio output device - format = m_file->fileFormat(); - if (m_audioOutputDevice.isFormatSupported(format)) { - setFormat(format); - foundSupportedFormat = true; - } - } else { - - QList sampleRatesList; -#ifdef Q_OS_WIN - // The Windows audio backend does not correctly report format support - // (see QTBUG-9100). Furthermore, although the audio subsystem captures - // at 11025Hz, the resulting audio is corrupted. - sampleRatesList += 8000; -#endif - - if (!m_generateTone) - sampleRatesList += m_audioInputDevice.supportedSampleRates(); - - sampleRatesList += m_audioOutputDevice.supportedSampleRates(); - sampleRatesList = sampleRatesList.toSet().toList(); // remove duplicates - qSort(sampleRatesList); - ENGINE_DEBUG << "Engine::initialize frequenciesList" << sampleRatesList; - - QList channelsList; - channelsList += m_audioInputDevice.supportedChannelCounts(); - channelsList += m_audioOutputDevice.supportedChannelCounts(); - channelsList = channelsList.toSet().toList(); - qSort(channelsList); - ENGINE_DEBUG << "Engine::initialize channelsList" << channelsList; - - QAudioFormat format; - format.setByteOrder(QAudioFormat::LittleEndian); - format.setCodec("audio/pcm"); - format.setSampleSize(16); - format.setSampleType(QAudioFormat::SignedInt); - int sampleRate, channels; - foreach (sampleRate, sampleRatesList) { - if (foundSupportedFormat) - break; - format.setSampleRate(sampleRate); - foreach (channels, channelsList) { - format.setChannelCount(channels); - const bool inputSupport = m_generateTone || - m_audioInputDevice.isFormatSupported(format); - const bool outputSupport = m_audioOutputDevice.isFormatSupported(format); - ENGINE_DEBUG << "Engine::initialize checking " << format - << "input" << inputSupport - << "output" << outputSupport; - if (inputSupport && outputSupport) { - foundSupportedFormat = true; - break; - } - } - } - - if (!foundSupportedFormat) - format = QAudioFormat(); - - setFormat(format); - } - - return foundSupportedFormat; -} - -void Engine::stopRecording() -{ - if (m_audioInput) { - m_audioInput->stop(); - QCoreApplication::instance()->processEvents(); - m_audioInput->disconnect(); - } - m_audioInputIODevice = 0; -} - -void Engine::stopPlayback() -{ - if (m_audioOutput) { - m_audioOutput->stop(); - QCoreApplication::instance()->processEvents(); - m_audioOutput->disconnect(); - setPlayPosition(0); - } -} - -void Engine::setState(QAudio::State state) -{ - const bool changed = (m_state != state); - m_state = state; - if (changed) - emit stateChanged(m_mode, m_state); -} - -void Engine::setState(QAudio::Mode mode, QAudio::State state) -{ - const bool changed = (m_mode != mode || m_state != state); - m_mode = mode; - m_state = state; - if (changed) - emit stateChanged(m_mode, m_state); -} - -void Engine::setRecordPosition(qint64 position, bool forceEmit) -{ - const bool changed = (m_recordPosition != position); - m_recordPosition = position; - if (changed || forceEmit) - emit recordPositionChanged(m_recordPosition); -} - -void Engine::setPlayPosition(qint64 position, bool forceEmit) -{ - const bool changed = (m_playPosition != position); - m_playPosition = position; - if (changed || forceEmit) - emit playPositionChanged(m_playPosition); -} - -void Engine::calculateLevel(qint64 position, qint64 length) -{ -#ifdef DISABLE_LEVEL - Q_UNUSED(position) - Q_UNUSED(length) -#else - Q_ASSERT(position + length <= m_bufferPosition + m_dataLength); - - qreal peakLevel = 0.0; - - qreal sum = 0.0; - const char *ptr = m_buffer.constData() + position - m_bufferPosition; - const char *const end = ptr + length; - while (ptr < end) { - const qint16 value = *reinterpret_cast(ptr); - const qreal fracValue = pcmToReal(value); - peakLevel = qMax(peakLevel, fracValue); - sum += fracValue * fracValue; - ptr += 2; - } - const int numSamples = length / 2; - qreal rmsLevel = sqrt(sum / numSamples); - - rmsLevel = qMax(qreal(0.0), rmsLevel); - rmsLevel = qMin(qreal(1.0), rmsLevel); - setLevel(rmsLevel, peakLevel, numSamples); - - ENGINE_DEBUG << "Engine::calculateLevel" << "pos" << position << "len" << length - << "rms" << rmsLevel << "peak" << peakLevel; -#endif -} - -void Engine::calculateSpectrum(qint64 position) -{ -#ifdef DISABLE_SPECTRUM - Q_UNUSED(position) -#else - Q_ASSERT(position + m_spectrumBufferLength <= m_bufferPosition + m_dataLength); - Q_ASSERT(0 == m_spectrumBufferLength % 2); // constraint of FFT algorithm - - // QThread::currentThread is marked 'for internal use only', but - // we're only using it for debug output here, so it's probably OK :) - ENGINE_DEBUG << "Engine::calculateSpectrum" << QThread::currentThread() - << "count" << m_count << "pos" << position << "len" << m_spectrumBufferLength - << "spectrumAnalyser.isReady" << m_spectrumAnalyser.isReady(); - - if (m_spectrumAnalyser.isReady()) { - m_spectrumBuffer = QByteArray::fromRawData(m_buffer.constData() + position - m_bufferPosition, - m_spectrumBufferLength); - m_spectrumPosition = position; - m_spectrumAnalyser.calculate(m_spectrumBuffer, m_format); - } -#endif -} - -void Engine::setFormat(const QAudioFormat &format) -{ - const bool changed = (format != m_format); - m_format = format; - m_levelBufferLength = audioLength(m_format, LevelWindowUs); - m_spectrumBufferLength = SpectrumLengthSamples * - (m_format.sampleSize() / 8) * m_format.channelCount(); - if (changed) - emit formatChanged(m_format); -} - -void Engine::setLevel(qreal rmsLevel, qreal peakLevel, int numSamples) -{ - m_rmsLevel = rmsLevel; - m_peakLevel = peakLevel; - emit levelChanged(m_rmsLevel, m_peakLevel, numSamples); -} diff --git a/examples/spectrum/spectrumapp/engine.h b/examples/spectrum/spectrumapp/engine.h deleted file mode 100644 index cdd8373f..00000000 --- a/examples/spectrum/spectrumapp/engine.h +++ /dev/null @@ -1,247 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#ifndef ENGINE_H -#define ENGINE_H - -#include "spectrum.h" -#include "spectrumanalyser.h" -#include "wavfile.h" - -#include -#include -#include -#include -#include -#include -#include - -class FrequencySpectrum; -QT_BEGIN_NAMESPACE -class QAudioInput; -class QAudioOutput; -QT_END_NAMESPACE - -/** - * This class interfaces with the QtMultimedia audio classes, and also with - * the SpectrumAnalyser class. Its role is to manage the capture and playback - * of audio data, meanwhile performing real-time analysis of the audio level - * and frequency spectrum. - */ -class Engine : public QObject -{ - Q_OBJECT - -public: - explicit Engine(QObject *parent = 0); - ~Engine(); - - const QList &availableAudioInputDevices() const - { return m_availableAudioInputDevices; } - - const QList &availableAudioOutputDevices() const - { return m_availableAudioOutputDevices; } - - 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; } - - /** - * Stop any ongoing recording or playback, and reset to ground state. - */ - void reset(); - - /** - * Load data from WAV file - */ - bool loadFile(const QString &fileName); - - /** - * Position of the audio input device. - * \return Position in bytes. - */ - 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; } - - /** - * 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; } - - /** - * Position of the audio output device. - * \return Position in bytes. - */ - qint64 playPosition() const { return m_playPosition; } - - /** - * Length of the internal engine buffer. - * \return Buffer length in bytes. - */ - qint64 bufferLength() const; - - /** - * Amount of data held in the buffer. - * \return Data length in bytes. - */ - qint64 dataLength() const { return m_dataLength; } - - /** - * Set window function applied to audio data before spectral analysis. - */ - void setWindowFunction(WindowFunction type); - -public slots: - void startRecording(); - void startPlayback(); - void suspend(); - void setAudioInputDevice(const QAudioDeviceInfo &device); - void setAudioOutputDevice(const QAudioDeviceInfo &device); - -signals: - void stateChanged(QAudio::Mode mode, QAudio::State state); - - /** - * Format of audio data has changed - */ - void formatChanged(const QAudioFormat &format); - - /** - * Length of buffer has changed. - * \param duration Duration in microseconds - */ - void bufferLengthChanged(qint64 duration); - - /** - * Amount of data in buffer has changed. - * \param Length of data in bytes - */ - void dataLengthChanged(qint64 duration); - - /** - * Position of the audio input device has changed. - * \param position Position in bytes - */ - void recordPositionChanged(qint64 position); - - /** - * Position of the audio output device has changed. - * \param position Position in bytes - */ - void playPositionChanged(qint64 position); - - /** - * Level changed - * \param rmsLevel RMS level in range 0.0 - 1.0 - * \param peakLevel Peak level in range 0.0 - 1.0 - * \param numSamples Number of audio samples analyzed - */ - void levelChanged(qreal rmsLevel, qreal peakLevel, int numSamples); - - /** - * Spectrum has changed. - * \param position Position of start of window in bytes - * \param length Length of window in bytes - * \param spectrum Resulting frequency spectrum - */ - void changedSpectrum(qint64 position, qint64 length, const FrequencySpectrum &spectrum); - - /** - * Buffer containing audio data has changed. - * \param position Position of start of buffer in bytes - * \param buffer Buffer - */ - void bufferChanged(qint64 position, qint64 length, const QByteArray &buffer); - -private slots: - void audioNotify(); - void audioStateChanged(QAudio::State state); - void audioDataReady(); - void spectrumChanged(const FrequencySpectrum &spectrum); - -private: - void resetAudioDevices(); - bool initialize(); - bool selectFormat(); - void stopRecording(); - void stopPlayback(); - void setState(QAudio::State state); - void setState(QAudio::Mode mode, QAudio::State state); - void setFormat(const QAudioFormat &format); - void setRecordPosition(qint64 position, bool forceEmit = false); - void setPlayPosition(qint64 position, bool forceEmit = false); - void calculateLevel(qint64 position, qint64 length); - void calculateSpectrum(qint64 position); - void setLevel(qreal rmsLevel, qreal peakLevel, int numSamples); - -private: - QAudio::Mode m_mode; - QAudio::State m_state; - - bool m_generateTone; - SweptTone m_tone; - - WavFile* m_file; - // We need a second file handle via which to read data into m_buffer - // for analysis - WavFile* m_analysisFile; - - QAudioFormat m_format; - - const QList m_availableAudioInputDevices; - QAudioDeviceInfo m_audioInputDevice; - QAudioInput* m_audioInput; - QIODevice* m_audioInputIODevice; - qint64 m_recordPosition; - - const QList m_availableAudioOutputDevices; - QAudioDeviceInfo m_audioOutputDevice; - QAudioOutput* m_audioOutput; - qint64 m_playPosition; - QBuffer m_audioOutputIODevice; - - QByteArray m_buffer; - qint64 m_bufferPosition; - qint64 m_bufferLength; - qint64 m_dataLength; - - int m_levelBufferLength; - qreal m_rmsLevel; - qreal m_peakLevel; - - int m_spectrumBufferLength; - QByteArray m_spectrumBuffer; - SpectrumAnalyser m_spectrumAnalyser; - qint64 m_spectrumPosition; - - int m_count; - -}; - -#endif // ENGINE_H diff --git a/examples/spectrum/spectrumapp/frequencyspectrum.cpp b/examples/spectrum/spectrumapp/frequencyspectrum.cpp deleted file mode 100644 index 013d0454..00000000 --- a/examples/spectrum/spectrumapp/frequencyspectrum.cpp +++ /dev/null @@ -1,67 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#include "frequencyspectrum.h" - -FrequencySpectrum::FrequencySpectrum(int numPoints) - : m_elements(numPoints) -{ - -} - -void FrequencySpectrum::reset() -{ - iterator i = begin(); - for ( ; i != end(); ++i) - *i = Element(); -} - -int FrequencySpectrum::count() const -{ - return m_elements.count(); -} - -FrequencySpectrum::Element &FrequencySpectrum::operator[](int index) -{ - return m_elements[index]; -} - -const FrequencySpectrum::Element &FrequencySpectrum::operator[](int index) const -{ - return m_elements[index]; -} - -FrequencySpectrum::iterator FrequencySpectrum::begin() -{ - return m_elements.begin(); -} - -FrequencySpectrum::iterator FrequencySpectrum::end() -{ - return m_elements.end(); -} - -FrequencySpectrum::const_iterator FrequencySpectrum::begin() const -{ - return m_elements.begin(); -} - -FrequencySpectrum::const_iterator FrequencySpectrum::end() const -{ - return m_elements.end(); -} diff --git a/examples/spectrum/spectrumapp/frequencyspectrum.h b/examples/spectrum/spectrumapp/frequencyspectrum.h deleted file mode 100644 index fac9a1b7..00000000 --- a/examples/spectrum/spectrumapp/frequencyspectrum.h +++ /dev/null @@ -1,76 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#ifndef FREQUENCYSPECTRUM_H -#define FREQUENCYSPECTRUM_H - -#include - -/** - * Represents a frequency spectrum as a series of elements, each of which - * consists of a frequency, an amplitude and a phase. - */ -class FrequencySpectrum { -public: - FrequencySpectrum(int numPoints = 0); - - struct Element { - Element() - : frequency(0.0), amplitude(0.0), phase(0.0), clipped(false) - { } - - /** - * Frequency in Hertz - */ - qreal frequency; - - /** - * Amplitude in range [0.0, 1.0] - */ - qreal amplitude; - - /** - * Phase in range [0.0, 2*PI] - */ - qreal phase; - - /** - * Indicates whether value has been clipped during spectrum analysis - */ - bool clipped; - }; - - typedef QVector::iterator iterator; - typedef QVector::const_iterator const_iterator; - - void reset(); - - int count() const; - Element& operator[](int index); - const Element& operator[](int index) const; - iterator begin(); - iterator end(); - const_iterator begin() const; - const_iterator end() const; - -private: - QVector m_elements; - -}; - -#endif // FREQUENCYSPECTRUM_H diff --git a/examples/spectrum/spectrumapp/main.cpp b/examples/spectrum/spectrumapp/main.cpp deleted file mode 100644 index 32076b88..00000000 --- a/examples/spectrum/spectrumapp/main.cpp +++ /dev/null @@ -1,201 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#include "engine.h" -#include "utils.h" - -#include -#include -#include - -#include -#include -#include - -//#define USE_CONES - -using namespace QtDataVis3D; - -class MainApp : public QObject -{ -public: - MainApp(Q3DBars *window); - ~MainApp(); - - void start(QString fileName); - -public slots: - void spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum); - void stateChanged(QAudio::Mode mode, QAudio::State state); - -private slots: - void restart(); - -private: - int barIndex(qreal frequency) const; - -private: - Q3DBars *m_chart; - Engine *m_engine; - QTimer *m_restartTimer; - // Lower bound of first band in the spectrum in Hz - qreal m_lowFreq; - // Upper band of last band in the spectrum in Hz - qreal m_highFreq; -}; - -MainApp::MainApp(Q3DBars *window) - : m_chart(window), - m_engine(new Engine(this)), - m_restartTimer(new QTimer(this)), - m_lowFreq(SpectrumLowFreq), - m_highFreq(SpectrumHighFreq) -{ - m_chart->setDataWindow(SpectrumNumBands * 2, SpectrumNumBands); - // Disable grid - m_chart->setGridVisible(false); - // Disable auto-scaling of height by defining explicit range - m_chart->valueAxis()->setRange(0.0, 1.0); - // Disable shadows - m_chart->setShadowQuality(QDataVis::ShadowNone); -#if USE_CONES - // Set bar specifications; make them a bit wider than deep and make them be drawn 75% - // inside each other - m_chart->setBarSpecs(1.25), QSizeF(0.2, -0.75)); - // Set bar type, smooth cones - m_chart->setBarType(QDataVis::Cones, true); - // Adjust zoom manually; automatic zoom level calculation does not work well with negative - // spacings (in setBarSpecs) - m_chart->setCameraPosition(10.0f, 5.0f, 70); -#else - // Set bar specifications; make them twice as wide as they're deep - m_chart->setBarSpecs(2.0, QSizeF(0.0, 0.0)); - // Set bar type, flat bars - m_chart->setBarType(QDataVis::Bars, false); - // Adjust camera position - m_chart->setCameraPosition(10.0f, 7.5f, 75); -#endif - // Set color scheme - m_chart->setBarColor(QColor(Qt::black), QColor(Qt::red), QColor(Qt::darkYellow)); - // Disable selection - m_chart->setSelectionMode(QDataVis::ModeNone); - QObject::connect(m_engine, &Engine::changedSpectrum, this, &MainApp::spectrumChanged); - QObject::connect(m_engine, &Engine::stateChanged, this, &MainApp::stateChanged); - m_restartTimer->setSingleShot(true); - QObject::connect(m_restartTimer, &QTimer::timeout, this, &MainApp::restart); - - QBarDataProxy *proxy = new QBarDataProxy; - m_chart->setActiveDataProxy(proxy); -} - -MainApp::~MainApp() -{ - delete m_engine; - delete m_restartTimer; -} - -void MainApp::start(QString fileName) -{ - m_engine->loadFile(fileName); - m_engine->startPlayback(); -} - -//----------------------------------------------------------------------------- -// Public slots -//----------------------------------------------------------------------------- - -void MainApp::spectrumChanged(qint64 position, qint64 length, const FrequencySpectrum &spectrum) -{ - Q_UNUSED(position); - Q_UNUSED(length); - //qDebug() << "updating bar values" << position << length; - QBarDataRow *data = new QBarDataRow(SpectrumNumBands); - for (int bar = 0; bar < SpectrumNumBands; bar++) { - // init data set - (*data)[bar].setValue(qreal(0.0)); - } - FrequencySpectrum::const_iterator i = spectrum.begin(); - const FrequencySpectrum::const_iterator end = spectrum.end(); - for ( ; i != end; ++i) { - const FrequencySpectrum::Element e = *i; - if (e.frequency >= m_lowFreq && e.frequency < m_highFreq) { - (*data)[barIndex(e.frequency)].setValue(qMax(data->at(barIndex(e.frequency)).value(), qreal(e.amplitude))); - } - } - static_cast(m_chart->activeDataProxy())->insertRow(0, data); -} - -void MainApp::stateChanged(QAudio::Mode mode, QAudio::State state) -{ - //qDebug() << "mode:" << mode << " state: " << state; - // Restart once playback is finished - if (QAudio::AudioOutput == mode && QAudio::StoppedState == state) - m_restartTimer->start(500); -} - -//----------------------------------------------------------------------------- -// Private slots -//----------------------------------------------------------------------------- - -void MainApp::restart() -{ - // Change file each time - QString fileToLoad = QStringLiteral(":/file"); - static int fileNo = 3; - QString nrStr; - nrStr.setNum(fileNo); - fileToLoad.append(nrStr); - //qDebug() << fileToLoad; - start(fileToLoad); - fileNo++; - if (fileNo > 3) - fileNo = 1; -} - -//----------------------------------------------------------------------------- -// Private functions -//----------------------------------------------------------------------------- - -int MainApp::barIndex(qreal frequency) const -{ - Q_ASSERT(frequency >= m_lowFreq && frequency < m_highFreq); - const qreal bandWidth = (m_highFreq - m_lowFreq) / SpectrumNumBands; - const int index = (frequency - m_lowFreq) / bandWidth; - if (index < 0 || index >= SpectrumNumBands) - Q_ASSERT(false); - //qDebug() << "insert to" << index; - return index; -} - -//----------------------------------------------------------------------------- -// main -//----------------------------------------------------------------------------- -int main(int argc, char *argv[]) -{ - QGuiApplication app(argc, argv); - app.setApplicationName("QtDataVis3D spectrum analyzer"); - - Q3DBars window; - window.resize(1024, 768); - window.show(); - - MainApp *mainApp = new MainApp(&window); - mainApp->start(QStringLiteral(":/file2")); - - return app.exec(); -} diff --git a/examples/spectrum/spectrumapp/soundFiles/Rockhop.wav b/examples/spectrum/spectrumapp/soundFiles/Rockhop.wav deleted file mode 100644 index e56e1c0f..00000000 Binary files a/examples/spectrum/spectrumapp/soundFiles/Rockhop.wav and /dev/null differ diff --git a/examples/spectrum/spectrumapp/soundFiles/futurebells_beat.wav b/examples/spectrum/spectrumapp/soundFiles/futurebells_beat.wav deleted file mode 100644 index c45cbc71..00000000 Binary files a/examples/spectrum/spectrumapp/soundFiles/futurebells_beat.wav and /dev/null differ diff --git a/examples/spectrum/spectrumapp/soundFiles/onclassical_demo_fiati-di-parma_thuille_terzo-tempo_sestetto_small-version.wav b/examples/spectrum/spectrumapp/soundFiles/onclassical_demo_fiati-di-parma_thuille_terzo-tempo_sestetto_small-version.wav deleted file mode 100644 index 78b8dbda..00000000 Binary files a/examples/spectrum/spectrumapp/soundFiles/onclassical_demo_fiati-di-parma_thuille_terzo-tempo_sestetto_small-version.wav and /dev/null differ diff --git a/examples/spectrum/spectrumapp/spectrum.h b/examples/spectrum/spectrumapp/spectrum.h deleted file mode 100644 index 015989d5..00000000 --- a/examples/spectrum/spectrumapp/spectrum.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#ifndef SPECTRUM_H -#define SPECTRUM_H - -#include "utils.h" -#include "fftreal_wrapper.h" // For FFTLengthPowerOfTwo -#include - -//----------------------------------------------------------------------------- -// Constants -//----------------------------------------------------------------------------- - -// Number of audio samples used to calculate the frequency spectrum -const int SpectrumLengthSamples = PowerOfTwo::Result; - -// Number of bands in the frequency spectrum -const int SpectrumNumBands = 30; - -// Lower bound of first band in the spectrum -const qreal SpectrumLowFreq = 0.0; // Hz - -// Upper band of last band in the spectrum -const qreal SpectrumHighFreq = 1000.0; // Hz - -// Waveform window size in microseconds -const qint64 WaveformWindowDuration = 500 * 1000; - -// Fudge factor used to calculate the spectrum bar heights -const qreal SpectrumAnalyserMultiplier = 0.15; - -// Disable message timeout -const int NullMessageTimeout = -1; - - -//----------------------------------------------------------------------------- -// Types and data structures -//----------------------------------------------------------------------------- - -enum WindowFunction { - NoWindow, - HannWindow -}; - -const WindowFunction DefaultWindowFunction = HannWindow; - -struct Tone -{ - Tone(qreal freq = 0.0, qreal amp = 0.0) - : frequency(freq), amplitude(amp) - { } - - // Start and end frequencies for swept tone generation - qreal frequency; - - // Amplitude in range [0.0, 1.0] - qreal amplitude; -}; - -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); } - - SweptTone(const Tone &tone) - : startFreq(tone.frequency), endFreq(tone.frequency), amplitude(tone.amplitude) - { } - - // Start and end frequencies for swept tone generation - qreal startFreq; - qreal endFreq; - - // Amplitude in range [0.0, 1.0] - qreal amplitude; -}; - - -//----------------------------------------------------------------------------- -// Macros -//----------------------------------------------------------------------------- - -// Macro which connects a signal to a slot, and which causes application to -// abort if the connection fails. This is intended to catch programming errors -// such as mis-typing a signal or slot name. It is necessary to write our own -// macro to do this - the following idiom -// Q_ASSERT(connect(source, signal, receiver, slot)); -// will not work because Q_ASSERT compiles to a no-op in release builds. - -#define CHECKED_CONNECT(source, signal, receiver, slot) \ - if (!connect(source, signal, receiver, slot)) \ - qt_assert_x(Q_FUNC_INFO, "CHECKED_CONNECT failed", __FILE__, __LINE__); - -#endif // SPECTRUM_H - diff --git a/examples/spectrum/spectrumapp/spectrum.qrc b/examples/spectrum/spectrumapp/spectrum.qrc deleted file mode 100644 index 9368abc7..00000000 --- a/examples/spectrum/spectrumapp/spectrum.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - soundFiles/onclassical_demo_fiati-di-parma_thuille_terzo-tempo_sestetto_small-version.wav - soundFiles/Rockhop.wav - soundFiles/futurebells_beat.wav - - diff --git a/examples/spectrum/spectrumapp/spectrumanalyser.cpp b/examples/spectrum/spectrumapp/spectrumanalyser.cpp deleted file mode 100644 index 4cebfde9..00000000 --- a/examples/spectrum/spectrumapp/spectrumanalyser.cpp +++ /dev/null @@ -1,209 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#include "spectrumanalyser.h" -#include "utils.h" -#include "fftreal_wrapper.h" - -#include -#include -#include -#include - -SpectrumAnalyserThread::SpectrumAnalyserThread(QObject *parent) - : QObject(parent), - m_fft(new FFTRealWrapper), - m_numSamples(SpectrumLengthSamples), - m_windowFunction(DefaultWindowFunction), - m_window(SpectrumLengthSamples, 0.0), - m_input(SpectrumLengthSamples, 0.0), - m_output(SpectrumLengthSamples, 0.0), - m_spectrum(SpectrumLengthSamples) - #ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD - , m_thread(new QThread(this)) - #endif -{ -#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD - // moveToThread() cannot be called on a QObject with a parent - setParent(0); - moveToThread(m_thread); - m_thread->start(); -#endif - calculateWindow(); -} - -SpectrumAnalyserThread::~SpectrumAnalyserThread() -{ - delete m_fft; -} - -void SpectrumAnalyserThread::setWindowFunction(WindowFunction type) -{ - m_windowFunction = type; - calculateWindow(); -} - -void SpectrumAnalyserThread::calculateWindow() -{ - for (int i=0; i(ptr); - // Scale down to range [-1.0, 1.0] - const DataType realSample = pcmToReal(pcmSample); - const DataType windowedSample = realSample * m_window[i]; - m_input[i] = windowedSample; - ptr += bytesPerSample; - } - - // Calculate the FFT - m_fft->calculateFFT(m_output.data(), m_input.data()); - - // Analyze output to obtain amplitude and phase for each frequency - for (int i=2; i<=m_numSamples/2; ++i) { - // Calculate frequency of this complex sample - m_spectrum[i].frequency = qreal(i * inputFrequency) / (m_numSamples); - - const qreal real = m_output[i]; - qreal imag = 0.0; - if (i>0 && i 1.0); - amplitude = qMax(qreal(0.0), amplitude); - amplitude = qMin(qreal(1.0), amplitude); - m_spectrum[i].amplitude = amplitude; - } - - emit calculationComplete(m_spectrum); -} - - -//============================================================================= -// SpectrumAnalyser -//============================================================================= - -SpectrumAnalyser::SpectrumAnalyser(QObject *parent) - : QObject(parent), - m_thread(new SpectrumAnalyserThread(this)), - m_state(Idle) -{ - CHECKED_CONNECT(m_thread, SIGNAL(calculationComplete(FrequencySpectrum)), - this, SLOT(calculationComplete(FrequencySpectrum))); -} - -SpectrumAnalyser::~SpectrumAnalyser() -{ - -} - -//----------------------------------------------------------------------------- -// Public functions -//----------------------------------------------------------------------------- - -void SpectrumAnalyser::setWindowFunction(WindowFunction type) -{ - const bool b = QMetaObject::invokeMethod(m_thread, "setWindowFunction", - Qt::AutoConnection, - Q_ARG(WindowFunction, type)); - Q_ASSERT(b); - Q_UNUSED(b) // suppress warnings in release builds -} - -void SpectrumAnalyser::calculate(const QByteArray &buffer, - const QAudioFormat &format) -{ - // QThread::currentThread is marked 'for internal use only', but - // we're only using it for debug output here, so it's probably OK :) - SPECTRUMANALYSER_DEBUG << "SpectrumAnalyser::calculate" - << QThread::currentThread() - << "state" << m_state; - - if (isReady()) { - Q_ASSERT(isPCMS16LE(format)); - - const int bytesPerSample = format.sampleSize() * format.channelCount() / 8; - - m_state = Busy; - - // Invoke SpectrumAnalyserThread::calculateSpectrum using QMetaObject. If - // m_thread is in a different thread from the current thread, the - // calculation will be done in the child thread. - // Once the calculation is finished, a calculationChanged signal will be - // emitted by m_thread. - const bool b = QMetaObject::invokeMethod(m_thread, "calculateSpectrum", - Qt::AutoConnection, - Q_ARG(QByteArray, buffer), - Q_ARG(int, format.sampleRate()), - Q_ARG(int, bytesPerSample)); - Q_ASSERT(b); - Q_UNUSED(b) // suppress warnings in release builds - } -} - -bool SpectrumAnalyser::isReady() const -{ - return (Idle == m_state); -} - -void SpectrumAnalyser::cancelCalculation() -{ - if (Busy == m_state) - m_state = Cancelled; -} - - -//----------------------------------------------------------------------------- -// Private slots -//----------------------------------------------------------------------------- - -void SpectrumAnalyser::calculationComplete(const FrequencySpectrum &spectrum) -{ - Q_ASSERT(Idle != m_state); - if (Busy == m_state) - emit spectrumChanged(spectrum); - m_state = Idle; -} diff --git a/examples/spectrum/spectrumapp/spectrumanalyser.h b/examples/spectrum/spectrumapp/spectrumanalyser.h deleted file mode 100644 index 6d9291ef..00000000 --- a/examples/spectrum/spectrumapp/spectrumanalyser.h +++ /dev/null @@ -1,150 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#ifndef SPECTRUMANALYSER_H -#define SPECTRUMANALYSER_H - -#include -#include -#include - -#include "frequencyspectrum.h" -#include "spectrum.h" - -#include "FFTRealFixLenParam.h" - -QT_FORWARD_DECLARE_CLASS(QAudioFormat) -QT_FORWARD_DECLARE_CLASS(QThread) - -class FFTRealWrapper; - -class SpectrumAnalyserThreadPrivate; - -/** - * Implementation of the spectrum analysis which can be run in a - * separate thread. - */ -class SpectrumAnalyserThread : public QObject -{ - Q_OBJECT - -public: - SpectrumAnalyserThread(QObject *parent); - ~SpectrumAnalyserThread(); - -public slots: - void setWindowFunction(WindowFunction type); - void calculateSpectrum(const QByteArray &buffer, - int inputFrequency, - int bytesPerSample); - -signals: - void calculationComplete(const FrequencySpectrum &spectrum); - -private: - void calculateWindow(); - -private: - FFTRealWrapper* m_fft; - - const int m_numSamples; - - WindowFunction m_windowFunction; - - typedef FFTRealFixLenParam::DataType DataType; - - QVector m_window; - - QVector m_input; - QVector m_output; - - FrequencySpectrum m_spectrum; - -#ifdef SPECTRUM_ANALYSER_SEPARATE_THREAD - QThread* m_thread; -#endif -}; - -/** - * Class which performs frequency spectrum analysis on a window of - * audio samples, provided to it by the Engine. - */ -class SpectrumAnalyser : public QObject -{ - Q_OBJECT - -public: - SpectrumAnalyser(QObject *parent = 0); - ~SpectrumAnalyser(); - -public: - /* - * Set the windowing function which is applied before calculating the FFT - */ - void setWindowFunction(WindowFunction type); - - /* - * Calculate a frequency spectrum - * - * \param buffer Audio data - * \param format Format of audio data - * - * Frequency spectrum is calculated asynchronously. The result is returned - * via the spectrumChanged signal. - * - * An ongoing calculation can be cancelled by calling cancelCalculation(). - * - */ - void calculate(const QByteArray &buffer, const QAudioFormat &format); - - /* - * Check whether the object is ready to perform another calculation - */ - bool isReady() const; - - /* - * Cancel an ongoing calculation - * - * Note that cancelling is asynchronous. - */ - void cancelCalculation(); - -signals: - void spectrumChanged(const FrequencySpectrum &spectrum); - -private slots: - void calculationComplete(const FrequencySpectrum &spectrum); - -private: - void calculateWindow(); - -private: - - SpectrumAnalyserThread* m_thread; - - enum State { - Idle, - Busy, - Cancelled - }; - - State m_state; -}; - -#endif // SPECTRUMANALYSER_H - diff --git a/examples/spectrum/spectrumapp/spectrumapp.pro b/examples/spectrum/spectrumapp/spectrumapp.pro deleted file mode 100644 index c2455f78..00000000 --- a/examples/spectrum/spectrumapp/spectrumapp.pro +++ /dev/null @@ -1,80 +0,0 @@ -!include( ../../examples.pri ) { - error( "Couldn't find the examples.pri file!" ) -} - -!include( ../spectrum.pri ) { - error( "Couldn't find the spectrum.pri file!" ) -} - -static: error(This application cannot be statically linked to the fftreal library) - -TEMPLATE = app - -TARGET = spectrum - -QT += multimedia - -SOURCES += main.cpp \ - engine.cpp \ - frequencyspectrum.cpp \ - spectrumanalyser.cpp \ - utils.cpp \ - wavfile.cpp - -HEADERS += engine.h \ - frequencyspectrum.h \ - spectrum.h \ - spectrumanalyser.h \ - utils.h \ - wavfile.h - -fftreal_dir = ../3rdparty/fftreal - -INCLUDEPATH += $${fftreal_dir} - -RESOURCES = spectrum.qrc - -# Dynamic linkage against FFTReal DLL -!contains(DEFINES, DISABLE_FFT) { - macx { - # Link to fftreal framework - LIBS += -F$${fftreal_dir} - LIBS += -framework fftreal - } else { - LIBS += -L..$${spectrum_build_dir} - LIBS += -lfftreal - } -} - - -android { - target.path = /libs/$$ANDROID_TARGET_ARCH -} else { - target.path = $$[QT_INSTALL_EXAMPLES]/datavis3d/spectrum -} -INSTALLS += target - -# Deployment - -DESTDIR = ..$${spectrum_build_dir} -macx { - !contains(DEFINES, DISABLE_FFT) { - # Relocate fftreal.framework into spectrum.app bundle - framework_dir = ../spectrum.app/Contents/Frameworks - framework_name = fftreal.framework/Versions/1/fftreal - QMAKE_POST_LINK = \ - mkdir -p $${framework_dir} &&\ - rm -rf $${framework_dir}/fftreal.framework &&\ - cp -R $${fftreal_dir}/fftreal.framework $${framework_dir} &&\ - install_name_tool -id @executable_path/../Frameworks/$${framework_name} \ - $${framework_dir}/$${framework_name} &&\ - install_name_tool -change $${framework_name} \ - @executable_path/../Frameworks/$${framework_name} \ - ../spectrum.app/Contents/MacOS/spectrum - } -} else { - linux-g++*: { - # Provide relative path from application to fftreal library - QMAKE_LFLAGS += -Wl,--rpath=\\\$\$ORIGIN - } -} diff --git a/examples/spectrum/spectrumapp/utils.cpp b/examples/spectrum/spectrumapp/utils.cpp deleted file mode 100644 index bad6cc48..00000000 --- a/examples/spectrum/spectrumapp/utils.cpp +++ /dev/null @@ -1,117 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#include -#include "utils.h" - -qint64 audioDuration(const QAudioFormat &format, qint64 bytes) -{ - return (bytes * 1000000) / - (format.sampleRate() * format.channelCount() * (format.sampleSize() / 8)); -} - -qint64 audioLength(const QAudioFormat &format, qint64 microSeconds) -{ - qint64 result = (format.sampleRate() * format.channelCount() * (format.sampleSize() / 8)) - * microSeconds / 1000000; - result -= result % (format.channelCount() * format.sampleSize()); - return result; -} - -qreal nyquistFrequency(const QAudioFormat &format) -{ - return format.sampleRate() / 2; -} - -QString formatToString(const QAudioFormat &format) -{ - QString result; - - if (QAudioFormat() != format) { - if (format.codec() == "audio/pcm") { - Q_ASSERT(format.sampleType() == QAudioFormat::SignedInt); - - const QString formatEndian = (format.byteOrder() == QAudioFormat::LittleEndian) - ? QString("LE") : QString("BE"); - - QString formatType; - switch (format.sampleType()) { - case QAudioFormat::SignedInt: - formatType = "signed"; - break; - case QAudioFormat::UnSignedInt: - formatType = "unsigned"; - break; - case QAudioFormat::Float: - formatType = "float"; - break; - case QAudioFormat::Unknown: - formatType = "unknown"; - break; - } - - QString formatChannels = QString("%1 channels").arg(format.channelCount()); - switch (format.channelCount()) { - case 1: - formatChannels = "mono"; - break; - case 2: - formatChannels = "stereo"; - break; - } - - result = QString("%1 Hz %2 bit %3 %4 %5") - .arg(format.sampleRate()) - .arg(format.sampleSize()) - .arg(formatType) - .arg(formatEndian) - .arg(formatChannels); - } else { - result = format.codec(); - } - } - - return result; -} - -bool isPCM(const QAudioFormat &format) -{ - return (format.codec() == "audio/pcm"); -} - - -bool isPCMS16LE(const QAudioFormat &format) -{ - return isPCM(format) && - format.sampleType() == QAudioFormat::SignedInt && - format.sampleSize() == 16 && - format.byteOrder() == QAudioFormat::LittleEndian; -} - -const qint16 PCMS16MaxValue = 32767; -const quint16 PCMS16MaxAmplitude = 32768; // because minimum is -32768 - -qreal pcmToReal(qint16 pcm) -{ - return qreal(pcm) / PCMS16MaxAmplitude; -} - -qint16 realToPcm(qreal real) -{ - return real * PCMS16MaxValue; -} diff --git a/examples/spectrum/spectrumapp/utils.h b/examples/spectrum/spectrumapp/utils.h deleted file mode 100644 index f0ae5633..00000000 --- a/examples/spectrum/spectrumapp/utils.h +++ /dev/null @@ -1,90 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#ifndef UTILS_H -#define UTILS_H - -#include -#include - -QT_FORWARD_DECLARE_CLASS(QAudioFormat) - -//----------------------------------------------------------------------------- -// Miscellaneous utility functions -//----------------------------------------------------------------------------- - -qint64 audioDuration(const QAudioFormat &format, qint64 bytes); -qint64 audioLength(const QAudioFormat &format, qint64 microSeconds); - -QString formatToString(const QAudioFormat &format); - -qreal nyquistFrequency(const QAudioFormat &format); - -// Scale PCM value to [-1.0, 1.0] -qreal pcmToReal(qint16 pcm); - -// Scale real value in [-1.0, 1.0] to PCM -qint16 realToPcm(qreal real); - -// Check whether the audio format is PCM -bool isPCM(const QAudioFormat &format); - -// Check whether the audio format is signed, little-endian, 16-bit PCM -bool isPCMS16LE(const QAudioFormat &format); - -// Compile-time calculation of powers of two - -template class PowerOfTwo -{ public: static const int Result = PowerOfTwo::Result * 2; }; - -template<> class PowerOfTwo<0> -{ public: static const int Result = 1; }; - - -//----------------------------------------------------------------------------- -// Debug output -//----------------------------------------------------------------------------- - -class NullDebug -{ -public: - template - 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 diff --git a/examples/spectrum/spectrumapp/wavfile.cpp b/examples/spectrum/spectrumapp/wavfile.cpp deleted file mode 100644 index 24482507..00000000 --- a/examples/spectrum/spectrumapp/wavfile.cpp +++ /dev/null @@ -1,129 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#include -#include -#include -#include "utils.h" -#include "wavfile.h" - -struct chunk -{ - char id[4]; - quint32 size; -}; - -struct RIFFHeader -{ - chunk descriptor; // "RIFF" - char type[4]; // "WAVE" -}; - -struct WAVEHeader -{ - chunk descriptor; - quint16 audioFormat; - quint16 numChannels; - quint32 sampleRate; - quint32 byteRate; - quint16 blockAlign; - quint16 bitsPerSample; -}; - -struct DATAHeader -{ - chunk descriptor; -}; - -struct CombinedHeader -{ - RIFFHeader riff; - WAVEHeader wave; -}; - -WavFile::WavFile(QObject *parent) - : QFile(parent), - m_headerLength(0) -{ - -} - -bool WavFile::open(const QString &fileName) -{ - close(); - setFileName(fileName); - return QFile::open(QIODevice::ReadOnly) && readHeader(); -} - -const QAudioFormat &WavFile::fileFormat() const -{ - return m_fileFormat; -} - -qint64 WavFile::headerLength() const -{ - return m_headerLength; -} - -bool WavFile::readHeader() -{ - seek(0); - CombinedHeader header; - bool result = read(reinterpret_cast(&header), sizeof(CombinedHeader)) == sizeof(CombinedHeader); - if (result) { - if ((memcmp(&header.riff.descriptor.id, "RIFF", 4) == 0 - || memcmp(&header.riff.descriptor.id, "RIFX", 4) == 0) - && memcmp(&header.riff.type, "WAVE", 4) == 0 - && memcmp(&header.wave.descriptor.id, "fmt ", 4) == 0 - && (header.wave.audioFormat == 1 || header.wave.audioFormat == 0)) { - - // Read off remaining header information - DATAHeader dataHeader; - - if (qFromLittleEndian(header.wave.descriptor.size) > sizeof(WAVEHeader)) { - // Extended data available - quint16 extraFormatBytes; - if (peek((char*)&extraFormatBytes, sizeof(quint16)) != sizeof(quint16)) - return false; - const qint64 throwAwayBytes = sizeof(quint16) + qFromLittleEndian(extraFormatBytes); - if (read(throwAwayBytes).size() != throwAwayBytes) - return false; - } - - if (read((char*)&dataHeader, sizeof(DATAHeader)) != sizeof(DATAHeader)) - return false; - - // Establish format - if (memcmp(&header.riff.descriptor.id, "RIFF", 4) == 0) - m_fileFormat.setByteOrder(QAudioFormat::LittleEndian); - else - m_fileFormat.setByteOrder(QAudioFormat::BigEndian); - - int bps = qFromLittleEndian(header.wave.bitsPerSample); - m_fileFormat.setChannelCount(qFromLittleEndian(header.wave.numChannels)); - m_fileFormat.setCodec("audio/pcm"); - m_fileFormat.setSampleRate(qFromLittleEndian(header.wave.sampleRate)); - m_fileFormat.setSampleSize(qFromLittleEndian(header.wave.bitsPerSample)); - m_fileFormat.setSampleType(bps == 8 ? QAudioFormat::UnSignedInt : QAudioFormat::SignedInt); - } else { - result = false; - } - } - m_headerLength = pos(); - return result; -} diff --git a/examples/spectrum/spectrumapp/wavfile.h b/examples/spectrum/spectrumapp/wavfile.h deleted file mode 100644 index e408911b..00000000 --- a/examples/spectrum/spectrumapp/wavfile.h +++ /dev/null @@ -1,44 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2013 Digia Plc -** All rights reserved. -** For any questions to Digia, please use contact form at http://qt.digia.com -** -** This file is part of the QtDataVis3D module. -** -** Licensees holding valid Qt Enterprise licenses may use this file in -** accordance with the Qt Enterprise License Agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. -** -** If you have questions regarding the use of this file, please use -** contact form at http://qt.digia.com -** -****************************************************************************/ - -#ifndef WAVFILE_H -#define WAVFILE_H - -#include -#include -#include - -class WavFile : public QFile -{ -public: - WavFile(QObject *parent = 0); - - using QFile::open; - bool open(const QString &fileName); - const QAudioFormat &fileFormat() const; - qint64 headerLength() const; - -private: - bool readHeader(); - -private: - QAudioFormat m_fileFormat; - qint64 m_headerLength; -}; - -#endif // WAVFILE_H -- cgit v1.2.3