FastLED 3.10.6
Loading...
Searching...
No Matches
fft_impl.h
Go to the documentation of this file.
1#pragma once
2
3#include "fl/stl/span.h"
4#include "fl/stl/string.h"
5#include "fl/stl/unique_ptr.h"
6#include "fl/stl/noexcept.h"
7#include "fl/stl/int.h"
8
9namespace fl {
10namespace audio {
11
12class Sample; // Forward declare in fl::audio (correct namespace)
13
14namespace fft {
15
16class Context;
17struct Args;
18
19// Example:
20// Impl fft(512, 16);
21// auto sample = SINE WAVE OF 512 SAMPLES
22// fft.run(buffer, &out);
23// FL_WARN("Impl output: " << out); // 16 bands of output.
24class Impl {
25 public:
26 // Result indicating success or failure of the Impl run (in which case
27 // there will be an error message).
28 struct Result {
29 Result(bool ok, const string &error) : ok(ok), error(error) {}
30 bool ok = false;
32 };
33 // Default values for the Impl.
34 Impl(const Args &args);
36
37 fl::size sampleSize() const;
38 // Note that the sample sizes MUST match the samples size passed into the
39 // constructor.
40 Result run(const Sample &sample, Bins *out);
41 Result run(span<const i16> sample, Bins *out);
42 // Info on what the frequency the bins represent
43 fl::string info() const;
44
45 // Disable copy and move constructors and assignment operators
46 Impl(const Impl &) FL_NO_EXCEPT = delete;
47 Impl &operator=(const Impl &) FL_NO_EXCEPT = delete;
48 Impl(Impl &&) FL_NO_EXCEPT = delete;
49 Impl &operator=(Impl &&) FL_NO_EXCEPT = delete;
50
51 private:
53};
54
55namespace detail {
56
62inline bool coverageFloorApplies(u32 fftMag, u32 cqMag,
63 u32 localCqMax) FL_NO_EXCEPT {
64 return localCqMax < 20u &&
65 static_cast<u64>(fftMag) > static_cast<u64>(cqMag) * 50u;
66}
67
68} // namespace detail
69
70} // namespace fft
71} // namespace audio
72}; // namespace fl
Result run(const Sample &sample, Bins *out)
Impl(const Args &args)
fl::unique_ptr< Context > mContext
Definition fft_impl.h:52
fl::size sampleSize() const
fl::string info() const
bool coverageFloorApplies(u32 fftMag, u32 cqMag, u32 localCqMax) FL_NO_EXCEPT
CQ_OCTAVE coverage supplement decision (FastLED#4301/#4540), integer form used in FIXED16: the full-r...
Definition fft_impl.h:62
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode)
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
Definition sample.cpp.hpp:9
InputGamut g FL_NO_EXCEPT
Definition rgbw.h:121
Base definition for an LED controller.
Definition crgb.hpp:179
corkscrew_args args
Definition old.h:149
fl::u64 u64
Definition stdint.h:220
Result(bool ok, const string &error)
Definition fft_impl.h:29