Skip to content

Commit

Permalink
Fix issue 84
Browse files Browse the repository at this point in the history
  • Loading branch information
kosme committed Jul 25, 2023
1 parent 78ec583 commit b0e4c69
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Examples/FFT_02/FFT_02.ino
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Example of use of the FFT library to compute FFT for several signals over a range of frequencies.
The exponent is calculated once before the execution since it is a constant.
This saves resources during the execution of the sketch and reduces the compiled size.
The sketch shows the time that the computing is taking.
The sketch shows the time that the computation takes.
Copyright (C) 2014 Enrique Condes
This program is free software: you can redistribute it and/or modify
Expand Down
2 changes: 1 addition & 1 deletion library.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"email": "contact@arduinoos.com"
}
],
"version": "1.6",
"version": "1.6.1",
"frameworks": ["arduino","mbed","espidf"],
"platforms": "*",
"headers": "arduinoFFT.h"
Expand Down
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=arduinoFFT
version=1.6
version=1.6.1
author=Enrique Condes <enrique@shapeoko.com>
maintainer=Enrique Condes <enrique@shapeoko.com>
sentence=A library for implementing floating point Fast Fourier Transform calculations on Arduino.
Expand Down
12 changes: 7 additions & 5 deletions src/arduinoFFT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,9 +103,10 @@ void arduinoFFT::Compute(FFTDirection dir) {
}
// Scaling for reverse transform /
if (dir != FFT_FORWARD) {
double reciprocal = 1.0 / this->_samples;
for (uint16_t i = 0; i < this->_samples; i++) {
this->_vReal[i] /= this->_samples;
this->_vImag[i] /= this->_samples;
this->_vReal[i] *= reciprocal;
this->_vImag[i] *= reciprocal;
}
}
}
Expand Down Expand Up @@ -169,9 +170,10 @@ void arduinoFFT::Compute(double *vReal, double *vImag, uint16_t samples,
}
// Scaling for reverse transform
if (dir != FFT_FORWARD) {
double reciprocal = 1.0 / samples;
for (uint16_t i = 0; i < samples; i++) {
vReal[i] /= samples;
vImag[i] /= samples;
vReal[i] *= reciprocal;
vImag[i] *= reciprocal;
}
}
}
Expand Down Expand Up @@ -535,7 +537,7 @@ uint8_t arduinoFFT::Exponent(uint16_t value) {
#warning("This method may not be accessible on future revisions.")
// Calculates the base 2 logarithm of a value
uint8_t result = 0;
while (((value >> result) & 1) != 1)
while (value >>= 1)
result++;
return (result);
}
Expand Down

0 comments on commit b0e4c69

Please sign in to comment.