Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extra window functions #51

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ set(Aquila_HEADERS
aquila/source/window/HammingWindow.h
aquila/source/window/HannWindow.h
aquila/source/window/RectangularWindow.h
aquila/source/window/WelchWindow.h
aquila/source/window/CosineWindow.h
aquila/source/window/NuttallWindow.h
aquila/source/window/BlackmanNuttallWindow.h
aquila/source/window/BlackmanHarrisWindow.h
aquila/transform/Fft.h
aquila/transform/Dft.h
aquila/transform/AquilaFft.h
Expand Down Expand Up @@ -117,6 +122,11 @@ set(Aquila_SOURCES
aquila/source/window/GaussianWindow.cpp
aquila/source/window/HammingWindow.cpp
aquila/source/window/HannWindow.cpp
aquila/source/window/WelchWindow.cpp
aquila/source/window/CosineWindow.cpp
aquila/source/window/NuttallWindow.cpp
aquila/source/window/BlackmanNuttallWindow.cpp
aquila/source/window/BlackmanHarrisWindow.cpp
aquila/transform/Dft.cpp
aquila/transform/AquilaFft.cpp
aquila/transform/OouraFft.cpp
Expand Down
5 changes: 5 additions & 0 deletions aquila/source.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,5 +39,10 @@
#include "source/window/HammingWindow.h"
#include "source/window/HannWindow.h"
#include "source/window/RectangularWindow.h"
#include "source/window/WelchWindow.h"
#include "source/window/BlackmanHarrisWindow.h"
#include "source/window/NuttallWindow.h"
#include "source/window/BlackmanNuttallWindow.h"
#include "source/window/CosineWindow.h"

#endif // AQUILA_SOURCE_H
41 changes: 41 additions & 0 deletions aquila/source/window/BlackmanHarrisWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @file BlackmanHarrisWindow.cpp
*
* Blackman-Harris window.
*
* This file is part of the Aquila DSP library.
* Aquila is free software, licensed under the MIT/X11 License. A copy of
* the license is provided with the library in the LICENSE file.
*
* @package Aquila
* @version 3.0.0-dev
* @author Zbigniew Siciarz
* @date 2007-2014
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since 3.0.0
*/

#include "BlackmanHarrisWindow.h"
#include <cmath>

namespace Aquila
{
/**
* Creates Blackman-Harris window of given size.
*
* @param size window length
*/
BlackmanHarrisWindow::BlackmanHarrisWindow(std::size_t size):
SignalSource()
{
m_data.reserve(size);
for (std::size_t n = 0; n < size; ++n)
{
m_data.push_back(
0.35875 - 0.48829 * std::cos(2.0 * M_PI * n / double(size - 1)) +
0.14128 * std::cos(4.0 * M_PI * n / double(size - 1)) -
0.01168 * std::cos(6.0 * M_PI * n / double(size - 1))
);
}
}
}
37 changes: 37 additions & 0 deletions aquila/source/window/BlackmanHarrisWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file BlackmanHarrisWindow.h
*
* Blackman-Harris window.
*
* This file is part of the Aquila DSP library.
* Aquila is free software, licensed under the MIT/X11 License. A copy of
* the license is provided with the library in the LICENSE file.
*
* @package Aquila
* @version 3.0.0-dev
* @author Zbigniew Siciarz
* @date 2007-2014
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since 3.0.0
*/

#ifndef BLACKMANHARRISWINDOW_H
#define BLACKMANHARRISWINDOW_H

#include "../../global.h"
#include "../SignalSource.h"
#include <cstddef>

namespace Aquila
{
/**
* Nuttall window.
*/
class AQUILA_EXPORT BlackmanHarrisWindow : public SignalSource
{
public:
BlackmanHarrisWindow(std::size_t size);
};
}

#endif // BLACKMANHARRISWINDOW_H
41 changes: 41 additions & 0 deletions aquila/source/window/BlackmanNuttallWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @file BlackmanNuttallWindow.cpp
*
* Blackman-Nuttall window.
*
* This file is part of the Aquila DSP library.
* Aquila is free software, licensed under the MIT/X11 License. A copy of
* the license is provided with the library in the LICENSE file.
*
* @package Aquila
* @version 3.0.0-dev
* @author Zbigniew Siciarz
* @date 2007-2014
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since 3.0.0
*/

#include "BlackmanNuttallWindow.h"
#include <cmath>

namespace Aquila
{
/**
* Creates Blackman-Nuttall window of given size.
*
* @param size window length
*/
BlackmanNuttallWindow::BlackmanNuttallWindow(std::size_t size):
SignalSource()
{
m_data.reserve(size);
for (std::size_t n = 0; n < size; ++n)
{
m_data.push_back(
0.3635819 - 0.4891775 * std::cos(2.0 * M_PI * n / double(size - 1)) +
0.1365995 * std::cos(4.0 * M_PI * n / double(size - 1)) -
0.0106411 * std::cos(6.0 * M_PI * n / double(size - 1))
);
}
}
}
37 changes: 37 additions & 0 deletions aquila/source/window/BlackmanNuttallWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file BlackmanNuttallWindow.h
*
* Blackman-Nuttall window.
*
* This file is part of the Aquila DSP library.
* Aquila is free software, licensed under the MIT/X11 License. A copy of
* the license is provided with the library in the LICENSE file.
*
* @package Aquila
* @version 3.0.0-dev
* @author Zbigniew Siciarz
* @date 2007-2014
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since 3.0.0
*/

#ifndef BLACKMANNUTTALLWINDOW_H
#define BLACKMANNUTTALLWINDOW_H

#include "../../global.h"
#include "../SignalSource.h"
#include <cstddef>

namespace Aquila
{
/**
* Nuttall window.
*/
class AQUILA_EXPORT BlackmanNuttallWindow : public SignalSource
{
public:
BlackmanNuttallWindow(std::size_t size);
};
}

#endif // BLACKMANNUTTALLWINDOW_H
38 changes: 38 additions & 0 deletions aquila/source/window/CosineWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* @file CosineWindow.cpp
*
* Cosine window.
*
* This file is part of the Aquila DSP library.
* Aquila is free software, licensed under the MIT/X11 License. A copy of
* the license is provided with the library in the LICENSE file.
*
* @package Aquila
* @version 3.0.0-dev
* @author Zbigniew Siciarz
* @date 2007-2014
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since 3.0.0
*/

#include "CosineWindow.h"
#include <cmath>

namespace Aquila
{
/**
* Creates Cosine window of given size.
*
* @param size window length
*/
CosineWindow::CosineWindow(std::size_t size):
SignalSource()
{

const double lhalf = ((double)size - 1.0) / 2.0; // L / 2
m_data.reserve(size);
for (std::size_t n = 0; n < size; ++n) {
m_data.push_back(std::sin(n * M_PI / double(size - 1)));
}
}
}
37 changes: 37 additions & 0 deletions aquila/source/window/CosineWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file CosineWindow.h
*
* Cosine window.
*
* This file is part of the Aquila DSP library.
* Aquila is free software, licensed under the MIT/X11 License. A copy of
* the license is provided with the library in the LICENSE file.
*
* @package Aquila
* @version 3.0.0-dev
* @author Zbigniew Siciarz
* @date 2007-2014
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since 3.0.0
*/

#ifndef COSINEWINDOW_H
#define COSINEWINDOW_H

#include "../../global.h"
#include "../SignalSource.h"
#include <cstddef>

namespace Aquila
{
/**
* Cosine window.
*/
class AQUILA_EXPORT CosineWindow : public SignalSource
{
public:
CosineWindow(std::size_t size);
};
}

#endif // COSINEWINDOW_H
41 changes: 41 additions & 0 deletions aquila/source/window/NuttallWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/**
* @file NuttallWindow.cpp
*
* Nuttall window.
*
* This file is part of the Aquila DSP library.
* Aquila is free software, licensed under the MIT/X11 License. A copy of
* the license is provided with the library in the LICENSE file.
*
* @package Aquila
* @version 3.0.0-dev
* @author Zbigniew Siciarz
* @date 2007-2014
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since 3.0.0
*/

#include "NuttallWindow.h"
#include <cmath>

namespace Aquila
{
/**
* Creates Nuttall window of given size.
*
* @param size window length
*/
NuttallWindow::NuttallWindow(std::size_t size):
SignalSource()
{
m_data.reserve(size);
for (std::size_t n = 0; n < size; ++n)
{
m_data.push_back(
0.355768 - 0.487396 * std::cos(2.0 * M_PI * n / double(size - 1)) +
0.144232 * std::cos(4.0 * M_PI * n / double(size - 1)) -
0.012604 * std::cos(6.0 * M_PI * n / double(size - 1))
);
}
}
}
37 changes: 37 additions & 0 deletions aquila/source/window/NuttallWindow.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/**
* @file NuttallWindow.h
*
* Nuttall window.
*
* This file is part of the Aquila DSP library.
* Aquila is free software, licensed under the MIT/X11 License. A copy of
* the license is provided with the library in the LICENSE file.
*
* @package Aquila
* @version 3.0.0-dev
* @author Zbigniew Siciarz
* @date 2007-2014
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since 3.0.0
*/

#ifndef NUTTALWINDOW_H
#define NUTTALWINDOW_H

#include "../../global.h"
#include "../SignalSource.h"
#include <cstddef>

namespace Aquila
{
/**
* Nuttall window.
*/
class AQUILA_EXPORT NuttallWindow : public SignalSource
{
public:
NuttallWindow(std::size_t size);
};
}

#endif // NUTTALWINDOW_H
40 changes: 40 additions & 0 deletions aquila/source/window/WelchWindow.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/**
* @file WelchWindow.cpp
*
* Welch window.
*
* This file is part of the Aquila DSP library.
* Aquila is free software, licensed under the MIT/X11 License. A copy of
* the license is provided with the library in the LICENSE file.
*
* @package Aquila
* @version 3.0.0-dev
* @author Zbigniew Siciarz
* @date 2007-2014
* @license http://www.opensource.org/licenses/mit-license.php MIT
* @since 3.0.0
*/

#include "WelchWindow.h"
#include <cmath>

namespace Aquila
{
/**
* Creates Welch window of given size.
*
* @param size window length
*/
WelchWindow::WelchWindow(std::size_t size):
SignalSource()
{

const double lhalf = ((double)size - 1.0) / 2.0; // L / 2
m_data.reserve(size);
for (std::size_t n = 0; n < size; ++n)
{
double v = ((double)n - lhalf) / lhalf;
m_data.push_back(1 - (v * v));
}
}
}
Loading