Skip to content

Commit b0e4c69

Browse files
committed
Fix issue 84
1 parent 78ec583 commit b0e4c69

File tree

4 files changed

+10
-8
lines changed

4 files changed

+10
-8
lines changed

Examples/FFT_02/FFT_02.ino

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
Example of use of the FFT library to compute FFT for several signals over a range of frequencies.
44
The exponent is calculated once before the execution since it is a constant.
55
This saves resources during the execution of the sketch and reduces the compiled size.
6-
The sketch shows the time that the computing is taking.
6+
The sketch shows the time that the computation takes.
77
Copyright (C) 2014 Enrique Condes
88
99
This program is free software: you can redistribute it and/or modify

library.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
"email": "contact@arduinoos.com"
2121
}
2222
],
23-
"version": "1.6",
23+
"version": "1.6.1",
2424
"frameworks": ["arduino","mbed","espidf"],
2525
"platforms": "*",
2626
"headers": "arduinoFFT.h"

library.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
name=arduinoFFT
2-
version=1.6
2+
version=1.6.1
33
author=Enrique Condes <enrique@shapeoko.com>
44
maintainer=Enrique Condes <enrique@shapeoko.com>
55
sentence=A library for implementing floating point Fast Fourier Transform calculations on Arduino.

src/arduinoFFT.cpp

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -103,9 +103,10 @@ void arduinoFFT::Compute(FFTDirection dir) {
103103
}
104104
// Scaling for reverse transform /
105105
if (dir != FFT_FORWARD) {
106+
double reciprocal = 1.0 / this->_samples;
106107
for (uint16_t i = 0; i < this->_samples; i++) {
107-
this->_vReal[i] /= this->_samples;
108-
this->_vImag[i] /= this->_samples;
108+
this->_vReal[i] *= reciprocal;
109+
this->_vImag[i] *= reciprocal;
109110
}
110111
}
111112
}
@@ -169,9 +170,10 @@ void arduinoFFT::Compute(double *vReal, double *vImag, uint16_t samples,
169170
}
170171
// Scaling for reverse transform
171172
if (dir != FFT_FORWARD) {
173+
double reciprocal = 1.0 / samples;
172174
for (uint16_t i = 0; i < samples; i++) {
173-
vReal[i] /= samples;
174-
vImag[i] /= samples;
175+
vReal[i] *= reciprocal;
176+
vImag[i] *= reciprocal;
175177
}
176178
}
177179
}
@@ -535,7 +537,7 @@ uint8_t arduinoFFT::Exponent(uint16_t value) {
535537
#warning("This method may not be accessible on future revisions.")
536538
// Calculates the base 2 logarithm of a value
537539
uint8_t result = 0;
538-
while (((value >> result) & 1) != 1)
540+
while (value >>= 1)
539541
result++;
540542
return (result);
541543
}

0 commit comments

Comments
 (0)