Here's GrayNoise. SC's version flips random bits of a 32-bit integer and then outputs the result. Since we don't have 32-bit integers in Pd, it has to be done with 24 bits. No matter, though, because the range between -1 and +1 has what, 25-bit resolution? So not much difference.

Source:

void GrayNoise_next(GrayNoise *unit, int inNumSamples)
{
​    ​
float *out = ZOUT(0);
​    ​
RGET
​    ​
int counter = unit->mCounter;
​    ​
LOOP1(inNumSamples,
​        ​
counter ^= 1L << (trand(s1,s2,s3) & 31);
​        ​
ZXP(out) = counter * 4.65661287308e-10f;
​    ​
);
​    ​
unit->mCounter = counter;
​    ​
RPUT
}

void GrayNoise_Ctor(GrayNoise* unit)
{
​    ​
SETCALC(GrayNoise_next);
​    ​
unit->mCounter = 0;
​    ​
GrayNoise_next(unit, 1);
}

On Sat, Nov 14, 2015 at 6:15 PM, Matt Barber <brbrofsvl@gmail.com> wrote:
​The nice thing about supercollider is that you have the code available, so you can try to replicate it. See code and attached patches below. Looks like SC's GrayNoise is not about color but rather generates something akin to a random Gray code.
https://en.wikipedia.org/wiki/Gray_code

void BrownNoise_next(BrownNoise *unit, int inNumSamples)
{
​    ​
float *out = ZOUT(0);
​    ​
RGET
​    ​
f
​​
loat z = unit->mLevel;
​    ​
LOOP1(inNumSamples,
​        ​
z += frand8(s1, s2, s3);
​ // random sample between -0.125 and +0.124999​

​        ​
if (z > 1.f) z = 2.f - z;
​        ​
else if (z < -1.f) z = -2.f - z;
​        ​
ZXP(out) = z;
​    ​
);
​    ​
unit->mLevel = z;
​    ​
RPUT
}

void BrownNoise_Ctor(BrownNoise* unit)
{
​    ​
SETCALC(BrownNoise_next);
​    ​
unit->mLevel = unit->mParent->mRGen->frand2();
​    ​
ZOUT0(0) = unit->mLevel;
}

On Sat, Nov 14, 2015 at 4:53 PM, Dan Wilcox <danomatika@gmail.com> wrote:
There is also s_pinknoise in rjlib which uses rpole filters. Not sure how accurate it is, but then again, I’ve never really needed that much accuracy for what I do :)


On Nov 14, 2015, at 2:38 PM, pd-list-request@lists.iem.at wrote:

From: Alexandre Torres Porres <porres@gmail.com>
Date: November 14, 2015 at 2:09:54 PM MST
To: Matt Barber <brbrofsvl@gmail.com>
Subject: Re: [PD] brown/grey noise in pd


was looking for a substitute/parallel object to BrownNoise  in Sc, which is described just as "Generates noise whose spectrum falls off in power by 6 dB per octave."

Another one would be GreyNoise, described as "Generates noise which results from flipping random bits in a word. This type of noise has a high RMS level relative to its peak to peak level. The spectrum is emphasized towards lower frequencies."


thanks


_______________________________________________
Pd-list@lists.iem.at mailing list
UNSUBSCRIBE and account-management -> http://lists.puredata.info/listinfo/pd-list