Back to Browse

Huygens rain wavetable - Max/MSP

964 views
Aug 24, 2025
4:18

Rain-scan wavetable: stereo Huygens wavefield in Max patch code: https://pastebin.com/xLif8WkR ———— what this is ———— A playable wavetable instrument built from a 2D “rain on a membrane” simulation. Inspired by scanned-synthesis ideas and Huygens-style wavefront thinking. We evolve a damped wavefield on a grid, then sample it at audio rate along user-defined circular scanlines. Each scanline writes to a channel of buffer~ huygens, so you can drive wave~ (or anything else) with living, geometry-shaped tables. ———— how it works ———— Wavefield: simple 5-point Laplacian + leap-frog integrator with damping. Excitation: droplets as velocity kicks with zero-mean shapes (no DC creep). Boundaries: switchable reflective or clamped edges; we also remove the exact spatial mean each tick for stability. Scanlines: two independent circles (centre, radius, angle) → buffer ch.1 and ch.2. Readout: any oscillator can read the tables; demo uses phasor~ → wave~ huygens. Visuals: heatmap of the grid, both circles with direction markers, and a stereo waveform panel at the bottom (per-pixel min/max). ———— on-screen controls ———— - Drag to move a circle’s centre. - Shift-drag to change radius. - Alt/Option-drag to change angle. - Click picks the nearest circle; or send select 1/2. ———— key messages (send to the v8ui script) ———— start / stop fps Hz // 30–120 grid w h // e.g. 128 128 or 192 192 tension csq // 0.10–0.24 (wave speed^2) damp amount // 0.004–0.014 rain rate R amp // drops/sec, radius (cells), amplitude circle1 x y r // circle 1 (0..1 coords) angle1 radians // circle 1 angle circle2 x y r // circle 2 angle2 radians // circle 2 angle edge clamp|reflect vis gain // heatmap display gain waves 0/1 // show/hide oscilloscope waveh 0.10–0. // oscilloscope height wavegain 0.1–10 // oscilloscope vertical gain stats // print mean/min/max for sanity clear // zero the field ———— minimal patch setup ———— buffer~ huygens @samps 2048 @chan 2 phasor~ → wave~ huygens 0 0 1 → *~ → dac~ phasor~ 111 → wave~ huygens 0 0 2 → *~ → dac~ v8ui running the script from the source code below ———— why it doesn’t blow up ———— Early versions drifted positive because droplets added displacement and reflective boundaries preserved the DC eigenmode. We fixed it by exciting velocity, shaping droplets to zero mean, clamping (optional), and subtracting the exact spatial mean each step. ———— nice parameter ranges ———— grid 128 128 or 192 192 for richness vs CPU tension 0.18–0.24, damp 0.008–0.012 Sparse to storm: rain 5 3 0.5 → rain 120 6 0.4 Subtle stereo: offset the two angles by ~π/3

Download

1 formats

Video Formats

360pmp47.4 MB

Right-click 'Download' and select 'Save Link As' if the file opens in a new tab.

Huygens rain wavetable - Max/MSP | NatokHD