About

Pass a number in, get a number back. Behind that one promise lives a curated set of 34 wave shapes: smooth sines and sharp sawteeth, gentle bumps and noise-flecked chaos, each one a tiny formula tuned to drive motion, color, shape, or pattern in a sketch.

A Java twin

processing.waves is the Java sibling of p5.waves, a p5.js library originally built for the browser side of generative coding. The Java port carries the same vocabulary across to Processing 4: same names, same indices, same numerical output. If you sketch in p5.js today and in Processing tomorrow, you bring the same building blocks with you.

Processing 4 has been a home for creative coders for two decades. It runs offline, exports to native apps, and handles pixel-by-pixel work without browser overhead. Artists, educators and students live there. Until now, the wave vocabulary from p5.waves stopped at the JavaScript boundary; this port hands those users the same set of shapes, behaving the same way, in the language they already use.

The challenge of a faithful port

Porting between two languages with similar surface syntax is usually a chore: rename, retype, recompile. Making the output of two implementations match is something else entirely. Floating-point math is full of subtle traps: signed vs unsigned 32-bit ints, hash functions that wrap differently across languages, pseudo-random sequences that drift apart by the fifth decimal. processing.waves takes those traps seriously:

Trust, then verify

To prove the port works, the repo ships a numerical validator. It runs the JS reference (loaded via Node), captures 35 input/output pairs across all 34 waves and every code path, then runs the Java port over the same inputs and asserts equality within tolerance.

MetricValue
Cases35 (covers all 34 waves + 1 shift case)
Stable-mode tolerance1e-3
Wild-mode tolerance0.5
Current status35 / 35 pass

Wild mode's looser tolerance is intentional: noise modulation amplifies tiny float-vs-double differences. The wave envelope still matches across the languages; only the per-sample chaos detail diverges within the noise budget. Visually you cannot tell them apart.

34 shapes, three temperaments

Every wave has a character. The library splits them into three groups so you can lean into the one you want:

You don't have to pick by hand. Ask the library for "a gentle one" and let a seed decide. Ask for a specific name. Ask for two names and crossfade between them with mix. Flip shift on and watch the library cycle through random formulas at a tempo you set. All from one function call.

How it differs from its parent

License & credits

processing.waves is MIT, like its parent. The original p5.waves library lives at seb-prjcts-be/p5.waves.

Bug reports, sketches built with the library, and pull requests are all welcome on GitHub.

Makers & Contributors

Maker

Contributors (wave formula dataset)

References