Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import("stdfaust.lib");
- // Maximum size of the delay buffer; a power of two because `fdelay` expects
- // it so, as it allows for bit masking instead of modulus for index wrapping.
- maxDelayLength = 1<<12;
- // User parameters
- grainLength = hslider("Grain Size (ms)", 100.0, 100.0, 30000.0, 1.0) : si.smooth(0.995);
- grainPitch = hslider("Transpose (half-steps)", 0.0, -36.0, 36.0, 1.0) : si.smooth(0.995);
- // Grain implementation.
- grainFreq = ((2^(grainPitch / 12)) - 1) * (ma.SR / grainLength);
- grainPhasor = os.phasor(4096, grainFreq);
- maxGrainOffset = (grainLength * 1000 / ma.SR) : ba.latch(grainPhasor);
- grainReadIndex = (grainPhasor * -1.0) : +(1.0) : *(maxGrainOffset);
- // Hanning window on the range [0, 1].
- win(x) = 0.5 * (1.0 - cos(x * 2 * ma.PI));
- // process = de.fdelay(maxDelayLength, grainReadIndex) * win(grainPhasor);
- process = de.sdelay(maxDelayLength, 1024, grainReadIndex) * win(grainPhasor);
Advertisement
Add Comment
Please, Sign In to add comment