Skip to content

Conversation

@NickFlach
Copy link

Adds waveshaper.h with three new clipping functions that complement the existing distortion.h primitives:

  • fold_back(x, threshold): Foldback distortion for synth-fuzz tones. Signal folds back when exceeding threshold, creating complex harmonics. Includes iteration limiting to prevent infinite loops on extreme input.

  • tube_clip(x): Polynomial tube approximation with soft knee. Based on y = x * (1.5 - 0.5 * x^2), provides gentle compression similar to tube saturation.

  • diode_clip(x, ratio): Asymmetric diode emulation. Uses internal soft clip helper to create even harmonics with configurable asymmetry ratio.

Design Notes

  • All functions are static inline following existing patterns
  • Self-contained with no external dependencies (includes internal _ws_soft_clip helper)
  • No assumed imports - pure C with no math.h requirements
  • Complements rather than duplicates distortion.h functions

Testing

These primitives are building blocks for future effects (fuzz, wah, etc.) as discussed in #63.

Addresses #63

Signed-off-by: The Hand [email protected]

Adds waveshaper.h with three new clipping functions that complement
the existing distortion.h primitives:

 - fold_back(x, threshold): foldback distortion for synth-fuzz tones
 - tube_clip(x): polynomial tube approximation with soft knee
 - diode_clip(x, ratio): asymmetric diode emulation

All functions are self-contained with no external dependencies.
fold_back includes iteration limiting to prevent infinite loops.

Addresses issue torvalds#63

Signed-off-by: The Hand <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants