[PD] brown/grey noise in pd

Matt Barber brbrofsvl at gmail.com
Sun Nov 15 00:43:21 CET 2015


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 at 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 at 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 :)
>>
>> --------
>> Dan Wilcox
>> @danomatika <https://twitter.com/danomatika>
>> danomatika.com
>> robotcowboy.com
>>
>> On Nov 14, 2015, at 2:38 PM, pd-list-request at lists.iem.at wrote:
>>
>> *From: *Alexandre Torres Porres <porres at gmail.com>
>> *Date: *November 14, 2015 at 2:09:54 PM MST
>> *To: *Matt Barber <brbrofsvl at gmail.com>
>> *Cc: *"pd-list at lists.iem.at" <pd-list at lists.iem.at>
>> *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 at lists.iem.at mailing list
>> UNSUBSCRIBE and account-management ->
>> http://lists.puredata.info/listinfo/pd-list
>>
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20151114/2cb0a8ff/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graynoise~-help.pd
Type: application/octet-stream
Size: 451 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20151114/2cb0a8ff/attachment.obj>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graynoise~.pd
Type: application/octet-stream
Size: 438 bytes
Desc: not available
URL: <http://lists.puredata.info/pipermail/pd-list/attachments/20151114/2cb0a8ff/attachment-0001.obj>


More information about the Pd-list mailing list