-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix half freq issue, rm comments, add one more fail check to tests
- Loading branch information
Showing
6 changed files
with
114 additions
and
107 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,7 @@ | |
* This program is free software under the GNU General Public License v3. | ||
* See <https://www.gnu.org/licenses/> for details. | ||
* Author: Dmitry Ponomarev <[email protected]> | ||
* Author: Anastasiia Stepanova <[email protected]> | ||
*/ | ||
|
||
#ifndef SRC_MODULES_IMU_HPP_ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,10 @@ | ||
/* | ||
* Copyright (C) 2024 Anastasiia Stepanova <[email protected]> | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef SRC_PLATFORM_STM32_MATH_RFFT_HPP_ | ||
#define SRC_PLATFORM_STM32_MATH_RFFT_HPP_ | ||
|
||
|
@@ -6,13 +13,13 @@ | |
typedef q15_t real_t; | ||
#define M_2PI 6.28318530717958647692 | ||
|
||
namespace fft { | ||
namespace rfft { | ||
/* | ||
The function specifies arm_rfft_instance_q15 from CMSIS-DSP library based on the window size. | ||
@param window_size: The size of the input array. | ||
@param hanning_window: Pointer to the Hanning window container. | ||
@param in: used fo incompatability with ubuntu version | ||
@param out: used fo incompatability with ubuntu version | ||
@param in: used for compatability with ubuntu version | ||
@param out: used for compatability with ubuntu version | ||
@param N: The size of the Hanning window. | ||
@return: The plan for the r2c transform. | ||
*/ | ||
|
@@ -50,13 +57,6 @@ namespace fft { | |
_rfft_q15.ifftFlagR = 0; | ||
_rfft_q15.bitReverseFlagR = 1; | ||
|
||
// *in = new real_t[N]; | ||
// *out = new real_t[N * 2]; | ||
// *hanning_window = new real_t[N]; | ||
|
||
// *in = (real_t*)calloc(*N, sizeof(real_t)); | ||
// *out = (real_t*)calloc(*N * 2, sizeof(real_t)); | ||
// *hanning_window = (real_t*)calloc(*N, sizeof(real_t)); | ||
for (int n = 0; n < *N; n++) { | ||
const float hanning_value = 0.5f * (1.f - cos(M_2PI * n / (*N - 1))); | ||
hanning_window[n] = hanning_value; | ||
|
@@ -113,6 +113,6 @@ namespace fft { | |
inline T get_imag_by_index(T* in, int index) { | ||
return in[index + 1]; | ||
} | ||
} // namespace fft | ||
} // namespace rfft | ||
|
||
#endif // SRC_PLATFORM_STM32_MATH_RFFT_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
/* These definitions need to be changed depending on the floating-point precision */ | ||
#pragma once | ||
/* | ||
* Copyright (C) 2024 Anastasiia Stepanova <[email protected]> | ||
* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. | ||
*/ | ||
|
||
#ifndef SRC_PLATFORM_UBUNTU_MATH_RFFT_HPP_ | ||
#define SRC_PLATFORM_UBUNTU_MATH_RFFT_HPP_ | ||
|
||
|
@@ -10,16 +15,21 @@ typedef double real_t; | |
#include <complex> | ||
|
||
#define M_2PI 6.28318530717958647692 | ||
namespace fft { | ||
namespace rfft { | ||
/* | ||
The function specifies fftw_plan from the FFTW3 library. | ||
@param window_size: The size of the input array. | ||
@param hanning_window: Pointer to the Hanning window container. | ||
@param in: input data buffer | ||
@param out: rfft output data buffer | ||
@param N: The size of the Hanning window. | ||
@return: The plan for the r2c transform. | ||
*/ | ||
inline fftw_plan init_rfft(real_t* hanning_window, real_t* in, real_t* out, uint16_t *N) { | ||
// *hanning_window = fftw_alloc_real(*N); | ||
for (int n = 0; n < *N; n++) { | ||
const float hanning_value = 0.5f * (1.f - cos(M_2PI * n / (*N - 1))); | ||
hanning_window[n] = hanning_value; | ||
} | ||
// Allocate input and output arrays | ||
// *in = (real_t*) fftw_alloc_real(sizeof(real_t)* (*N)); | ||
// *out = (real_t*) fftw_alloc_real(sizeof(real_t)* 2 * *N); | ||
// Create plan | ||
return fftw_plan_r2r_1d(*N, in, out, FFTW_R2HC, FFTW_ESTIMATE); | ||
} | ||
|
@@ -76,6 +86,6 @@ namespace fft { | |
out[n] = (real_t)in[n]; | ||
} | ||
} | ||
} // namespace fft | ||
} // namespace rfft | ||
|
||
#endif // SRC_PLATFORM_UBUNTU_MATH_RFFT_HPP_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters