create counter
Gendy • Captured in Codebox | jvkr •• home

Gendy • Captured in Codebox

As a variation on an earlier example, here is an implementation of Gendy based on the codebox object inside gen~. Select text below, copy and paste in the codebox object within a max patch. Let me know how you modify it.

<--- code --->
Param loFreq(10);
Param hiFreq(10000);
Param nrPoints(15);
Param tMaxRand(500);
Param aMaxRand(0.1);

//••••• Data Objects:
Data freqValues(50, 1); //args size, channels
Data ampValues(50, 1);

//••••• History Objects:
History prevAccum(0);
History prevCount(0);
History prevAmp(0);

trigNext = (delta(prevAccum)<0);
nowCount = (prevCount + trigNext) % nrPoints;
prevIndex = wrap((nowCount - 1), 0, nrPoints);

//••••• Horizontal Aspect
df = (peek(freqValues, prevIndex) + tMaxRand * noise() );
newFreqValue = sah( fold(df, loFreq, hiFreq), trigNext, 0.5);
poke(freqValues, newFreqValue, prevIndex); //poke(buffer name, value, index, channel, overdub mix)

//••••• Vertical Aspect
da = (peek(ampValues, prevIndex) + aMaxRand * noise() );
newAmpValue = sah( fold(da, -1, 1), trigNext, 0.5);
poke(ampValues, newAmpValue, prevIndex);

ampEnd = peek(ampValues, nowCount);
ampBegin = sah(prevAmp, trigNext, 0.5);

//••••• Generate output
out1 = mix(ampBegin, ampEnd, prevAccum);

accumValue = maximum(peek(freqValues, nowCount), loFreq)/samplerate; // peek(buffer name, index, channeloffset, channels=n)
nowAccum = (prevAccum + accumValue) % 1; // actual ramp

prevAccum = nowAccum;
prevCount = nowCount;
prevAmp = ampEnd;
<--- /code --->





•••
blog comments powered by Disqus
top