Login / Register 0 items | $0.00 New @ KVR
User avatar
tesselode
KVRist
 
66 posts since 18 Jan, 2018

Postby tesselode; Fri Mar 02, 2018 9:53 pm Simple drift generator

Here's a drift generator I'm using in Mika Micro to add pitch and filter cutoff fluctuation. It's based on one I found in the musicdsp.org archive, but it's smoother and less noisy.

 
Code: Select all
// init //
double driftVelocity = 0.0;
double driftPhase = 0.0;

// loop //
// acceleration - how fast the value drifts (10000)
// damping - how much the value returns to 0 (2)
// amount - total amount of drift (0.0001)
driftVelocity += acceleration * random / sampleRate; // random is a random double from -1 to 1
driftVelocity -= driftVelocity * damping  * dt;
driftPhase += driftVelocity / sampleRate;
double driftValue = amount * sin(driftPhase);


Here's the code used in Mika Micro.

Moderator: Moderators (Main)

Return to DSP and Plug-in Development