Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions core/src/features/crestfactor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,16 @@ void CrestFactor::extract()
for (int i = 0; i < x_size; ++i) {
square_sum += x[i] * x[i];

peak_tmp = abs(x[i]);
peak_tmp = std::fabs(x[i]);
peak_max = peak_tmp > peak_max ? peak_tmp : peak_max;
}

square_sum = square_sum / x_size;
square_root = std::sqrt(square_sum);

crr_y = peak_max / square_root;
// Silence: peak and RMS are both 0 and the ratio would be NaN, which then rides into
// every object downstream. Report 0, like the spectral features do with no energy.
crr_y = square_root > 0.0 ? peak_max / square_root : 0.0;
}

void CrestFactor::reset() { _reset_param(); }
Expand Down
2 changes: 2 additions & 0 deletions docs/releases/max-v0.3.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@ First release of Zerr* for Max, as a package for Max 9 on Apple Silicon (arm64,
silently on the audio thread. (#30)
- `zerr.combinator~` builds the core combinator for real; before #19 the mode argument was parsed
and discarded. (#19)
- `zerr.features~ cf` outputs 0 on silence instead of NaN (0/0), which used to poison every
object downstream once the input went quiet.

## Build and tooling

Expand Down
2 changes: 2 additions & 0 deletions docs/releases/pd-next.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,5 @@ since 2026-10-15 only; everything earlier since `v0.2` still has to be enumerate
- `zerr_features~` says why it refuses a block size instead of printing the two numbers:
the block must be 1 to 2048 samples, the analysis window, and the sample rate non-zero (#43).
The help patch documents the limit.
- `zerr_features~ cf` outputs 0 on silence instead of NaN (0/0), which used to poison every
object downstream once the input went quiet.
Loading