FastLED 3.9.15
Loading...
Searching...
No Matches
fft_impl.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/hash_map_lru.h"
4#include "fl/pair.h"
5#include "fl/scoped_ptr.h"
6#include "fl/slice.h"
7#include "fl/vector.h"
8
9namespace fl {
10
11class AudioSample;
12class FFTContext;
13struct FFT_Args;
14
15// Example:
16// FFTImpl fft(512, 16);
17// auto sample = SINE WAVE OF 512 SAMPLES
18// fft.run(buffer, &out);
19// FASTLED_WARN("FFTImpl output: " << out); // 16 bands of output.
20class FFTImpl : public fl::Referent {
21 public:
22 // Result indicating success or failure of the FFTImpl run (in which case
23 // there will be an error message).
24 struct Result {
25 Result(bool ok, const Str &error) : ok(ok), error(error) {}
26 bool ok = false;
28 };
29 // Default values for the FFTImpl.
30 FFTImpl(const FFT_Args &args);
31 ~FFTImpl();
32
33 size_t sampleSize() const;
34 // Note that the sample sizes MUST match the samples size passed into the
35 // constructor.
36 Result run(const AudioSample &sample, FFTBins *out);
38 // Info on what the frequency the bins represent
39 fl::Str info() const;
40
41 // Detail.
42 static int DefaultSamples() { return 512; }
43 static int DefaultBands() { return 16; }
44 static float DefaultMinFrequency() { return 174.6f; }
45 static float DefaultMaxFrequency() { return 4698.3f; }
46 static int DefaultSampleRate() { return 44100; }
47
48 // Disable copy and move constructors and assignment operators
49 FFTImpl(const FFTImpl &) = delete;
50 FFTImpl &operator=(const FFTImpl &) = delete;
51 FFTImpl(FFTImpl &&) = delete;
52 FFTImpl &operator=(FFTImpl &&) = delete;
53
54 private:
56};
57
58}; // namespace fl
FFTImpl(FFTImpl &&)=delete
FFTImpl(const FFT_Args &args)
Definition fft_impl.cpp:127
FFTImpl(const FFTImpl &)=delete
static int DefaultSampleRate()
Definition fft_impl.h:46
FFTImpl & operator=(const FFTImpl &)=delete
Result run(const AudioSample &sample, FFTBins *out)
Definition fft_impl.cpp:150
size_t sampleSize() const
Definition fft_impl.cpp:143
fl::Str info() const
Definition fft_impl.cpp:134
FFTImpl & operator=(FFTImpl &&)=delete
fl::scoped_ptr< FFTContext > mContext
Definition fft_impl.h:55
static int DefaultSamples()
Definition fft_impl.h:42
static int DefaultBands()
Definition fft_impl.h:43
static float DefaultMaxFrequency()
Definition fft_impl.h:45
static float DefaultMinFrequency()
Definition fft_impl.h:44
Definition str.h:388
Implements a simple red square effect for 2D LED grids.
Definition crgb.h:16
Result(bool ok, const Str &error)
Definition fft_impl.h:25