From b2937de0ce85e9207219d5171ed472d5e74f9635 Mon Sep 17 00:00:00 2001 From: Claude Date: Thu, 18 Jun 2026 14:21:02 +0000 Subject: [PATCH] Fix slow random walk in Random8 Perlin/FBM styles The Perlin and FBM walk styles advance a phase counter (positionX) by one step per trigger and sample 1D Perlin noise at the normalized position. The 16-bit VCV port mechanically replaced TWELVE_BIT_MAX with SIXTEEN_BIT_MAX throughout these cores. That is correct for the output scaling, but it also widened the phase period/normalization from 4095 to 65535. Since the counter still increments by one per trigger, each step through the noise lattice shrank ~16x, so the output barely changed between triggers. Restore the phase resolution to the hardware 12-bit range (TWELVE_BIT_MAX) while keeping the 16-bit output scaling, so the walk advances at the intended rate. Measured average per-trigger movement rises from ~370/65535 to ~6677/65535 while remaining smooth and correlated. Co-Authored-By: Claude Opus 4.8 (1M context) Claude-Session: https://claude.ai/code/session_01XhmS8keJMsemMnAnASu1Gg --- src/random8_core/random_cores/R_Perlin_Styles.h | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/random8_core/random_cores/R_Perlin_Styles.h b/src/random8_core/random_cores/R_Perlin_Styles.h index 58e8e34..c6042e3 100644 --- a/src/random8_core/random_cores/R_Perlin_Styles.h +++ b/src/random8_core/random_cores/R_Perlin_Styles.h @@ -28,8 +28,11 @@ namespace R8{ } uint16_t generate() override { - positionX = (positionX + 1) % SIXTEEN_BIT_MAX; - float pos = (float)positionX / (float)SIXTEEN_BIT_MAX; + // positionX advances one phase step per trigger. The walk speed is set by the + // phase resolution (the hardware 12-bit range), not the 16-bit output range: + // normalizing over SIXTEEN_BIT_MAX would shrink each step ~16x and stall the walk. + positionX = (positionX + 1) % TWELVE_BIT_MAX; + float pos = (float)positionX / (float)TWELVE_BIT_MAX; return (uint16_t)(perlin1d(pos, 920.666, 2) * SIXTEEN_BIT_MAX); } @@ -60,8 +63,11 @@ namespace R8{ } uint16_t generate() override { - positionX = (positionX + 1) % SIXTEEN_BIT_MAX; - float pos = (float)positionX / (float)SIXTEEN_BIT_MAX; + // positionX advances one phase step per trigger. The walk speed is set by the + // phase resolution (the hardware 12-bit range), not the 16-bit output range: + // normalizing over SIXTEEN_BIT_MAX would shrink each step ~16x and stall the walk. + positionX = (positionX + 1) % TWELVE_BIT_MAX; + float pos = (float)positionX / (float)TWELVE_BIT_MAX; return (uint16_t)(perlin1d(pos, 720.1459, 10) * SIXTEEN_BIT_MAX); }