22 fl::unique_lock<fl::mutex> lock(
mtx);
37 fl::unique_lock<fl::mutex> lock(
mutex);
50 fl::unique_lock<fl::mutex> lock(
mutex);
52 SampleImplPtr impl =
pool.back();
93 return mImpl->pcm().size();
108 if (
mImpl == other.mImpl) {
111 if (
mImpl ==
nullptr || other.mImpl ==
nullptr) {
114 if (
mImpl->pcm().size() != other.mImpl->pcm().size()) {
117 for (fl::size i = 0; i <
mImpl->pcm().
size(); ++i) {
118 if (
mImpl->pcm()[i] != other.mImpl->pcm()[i]) {
126 return !(*
this == other);
130 static fl::i16 empty_data[1] = {0};
139 return mImpl->timestamp();
164 for (fl::size i = 0; i < count; ++i) {
165 double s = samples[i] / 32768.0;
168 double p = sum_sq / count;
169 double dbfs = 10.0 *
log10(p + 1e-12);
191 args.bands = out->bands();
201 if (!
isValid() || gain == 1.0f)
return;
202 auto& samples =
mImpl->pcm_mutable();
203 for (fl::size i = 0; i < samples.size(); ++i) {
204 fl::i32 val =
static_cast<fl::i32
>(
static_cast<float>(samples[i]) * gain);
205 if (val > 32767) val = 32767;
206 if (val < -32768) val = -32768;
207 samples[i] =
static_cast<fl::i16
>(val);
209 mImpl->pcmDidChange();
static T & instance() FL_NO_EXCEPT
void fft(fft::Bins *out) const FL_NO_EXCEPT
bool operator==(const Sample &other) const FL_NO_EXCEPT
const VectorPCM & pcm() const FL_NO_EXCEPT
const fl::i16 & at(fl::size i) const FL_NO_EXCEPT
const_iterator end() const FL_NO_EXCEPT
const_iterator begin() const FL_NO_EXCEPT
fl::u32 timestamp() const FL_NO_EXCEPT
bool isValid() const FL_NO_EXCEPT
const fl::i16 & operator[](fl::size i) const FL_NO_EXCEPT
fl::vector< fl::i16 > VectorPCM
float zcf() const FL_NO_EXCEPT
static const VectorPCM & empty() FL_NO_EXCEPT
bool operator!=(const Sample &other) const FL_NO_EXCEPT
fl::size size() const FL_NO_EXCEPT
Sample & operator=(const Sample &other) FL_NO_EXCEPT
float rms() const FL_NO_EXCEPT
void applyGain(float gain) FL_NO_EXCEPT
Apply a digital gain multiplier to all PCM samples in-place.
void initZeroCrossings() FL_NO_EXCEPT
void pcmDidChange() FL_NO_EXCEPT
SoundLevelMeter(double spl_floor=33.0, double smoothing_alpha=0.0) FL_NO_EXCEPT
void processBlock(const fl::i16 *samples, fl::size count) FL_NO_EXCEPT
Process a block of int16 PCM samples.
const T * data() const FL_NO_EXCEPT
constexpr fl::size size() const FL_NO_EXCEPT
#define FL_INFINITY_DOUBLE
Platform-independent mutex interface.
constexpr remove_reference< T >::type && move(T &&t) FL_NO_EXCEPT
shared_ptr< T > make_shared(Args &&... args) FL_NO_EXCEPT
u8 u8 fract8 blur_amount FL_NO_EXCEPT
CRGB sample(const CRGB *grid, const XYMap &xyMap, float x, float y, SampleMode mode) FL_NO_EXCEPT
Sample a pixel from a 2D CRGB grid at floating-point coordinates.
double log10(double value) FL_NO_EXCEPT
fl::platforms::mutex mutex
Base definition for an LED controller.
static constexpr fl::size MAX_POOL_SIZE
SampleImplPtr getOrCreate() FL_NO_EXCEPT
fl::vector< SampleImplPtr > pool
void put(SampleImplPtr &&impl) FL_NO_EXCEPT
void run(fl::span< const fl::i16 > sample, fft::Bins *out, const fft::Args &args) FL_NO_EXCEPT
static int DefaultSampleRate() FL_NO_EXCEPT
static float DefaultMinFrequency() FL_NO_EXCEPT
static float DefaultMaxFrequency() FL_NO_EXCEPT