Skip to content

Commit

Permalink
Minor sin_f32_table correction and comments
Browse files Browse the repository at this point in the history
  • Loading branch information
Brumi-2021 committed Dec 29, 2022
1 parent 2970638 commit 64ca9f6
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions firmware/common/sine_table.hpp
Expand Up @@ -35,7 +35,10 @@ w = numpy.arange(length, dtype=numpy.float64) * (2 * numpy.pi / length)
v = numpy.sin(w)
print(v)
*/
constexpr uint16_t sine_table_f32_period = 256;
constexpr uint16_t sine_table_f32_period = 256;
// periode is 256 . means sine_table_f32[0]= sine_table_f32[0+256], sine_table_f32[1]=sine_table_f32[1+256] (those two added manualy)
// Then table has 257 values , [0,..255] + [256] and [257], those two are used when we interpolate[255] with [255+1], and [256] with [256+1]
// [256] index is needed in the function sin_f32() when we are inputing very small radian values , example , sin_f32((-1e-14) in radians)

static constexpr std::array<float, sine_table_f32_period + 2> sine_table_f32{
0.00000000e+00, 2.45412285e-02, 4.90676743e-02,
Expand Down Expand Up @@ -123,7 +126,7 @@ static constexpr std::array<float, sine_table_f32_period + 2> sine_table_f32{
-2.42980180e-01, -2.19101240e-01, -1.95090322e-01,
-1.70961889e-01, -1.46730474e-01, -1.22410675e-01,
-9.80171403e-02, -7.35645636e-02, -4.90676743e-02,
-2.45412285e-02, 0.00000000e+00, 0.00000000e+00
-2.45412285e-02, 0.00000000e+00, 2.45412285e-02
};

inline float sin_f32(const float w) {
Expand Down

0 comments on commit 64ca9f6

Please sign in to comment.