"What about the noise~ object?"
^haha, i don't think that's what he meant, but it's funny because it's true!
can't give any awesomely advanced answers here as i've never felt like studying noise-generation(only noise-shaping :D)...
but one place i'd start is looking at code from musicdsp.org(or anywhere else you can search for 'noise' code), and figure out the max patch from the code.
and here's a quick max patch version of it, albeit perhaps not as exact/efficient as i could have been in gen~ or using code, particularly to create the initial 19.19191919191919... :p
one of the quickest ways i've found to learn both dsp and max/msp at the same time(not that i've learnt all that much of either ;p).
hope it helps.
EDIT: OH WAIT! you said 'only max objects' meaning no signal objects either, i'm an idiot :p
but then hopefully everyone here already knows that! >:D
still... you get the idea... go there, do that, this time only using max(you could still use peek~ for any possible recursion at non-signal rate), easypeasy, teeee heeee! >;D
Raja's example is noisy, but it's not white noise. At all.
Your standard white noise is simply a bog-standard random number generator (RNG) producing values at the sampling rate.
If the goal is to get something to a DAC, there are going to have to be some MSP objects involved somewhere down the road (so I don't read the challenge as "no MSP objects allowed", rather as MSP objects being part of Max). So noise~ is the obvious candidate.
Otherwise, you can implement a simple RNG as x[n+1] = a * x[n] + b mod c with arbitrary values for a, b, and c (although the values should be fairly large and, ideally, mutually prime). That is typically used for integer values in a range like 0
While Peter's answer is true (is always :) ), if you want white noise in the Max domain, you just need to bang a random object at scheduler rate.
Well, what you get is not white noise at audio sample rate, but at max's sample rate(scheduler rate). It's the best max can do.
Otherwise, to make noise you can actually hear: peters answer.
Hey. I am looking for the same in pink. That seems a bit more complicated. I know the deviation of the random values must look like a bell curve or one half of it. Can this be done with some math behind a random object.
I think not. I found algorithm examples to generate "pink numbers" in C.
But they use multiple rng to do it. I not fully understand the code example yet. O.
"Raja’s example is noisy, but it’s not white noise. At all."
haha, sorry, maybe i should've clarified, but i thought this was obvious before i posted... and was merely trying to be helpful in showing where to go in order to try your own research :)
also, since they wrote, "but it’s more for purposes of study than anything else"
it actually sounds like the goal would not necessarily be to get audio to the dac.
x[n+1] = a * x[n] + b mod c
is the answer we ALL needed! :D Thanks!
(when i look through the source for noise~... ooops... i mean... dream of it in my head... ya that's it... i don't still have the source code to max5, don't even think it!... but ya, it looks similar :D
seems o imply we can filter white noise tyo get something fairly pink. I'd take the first example right away, seems most straight forward. (although I guess the others might be more accurate)
Sorry for any misunderstanding, Raja. But if I misunderstood, others may have, as well.
Regarding the formula I gave: it's a standard formula in the literature (see, for instance, Knuth Art of Computer Programming vol. III). I don't have access to source code for Max, either, but DDZ wrote the the list many years ago that he simply took the RNG from Numerical Recipes in C, which is yet another implementation of the algorithm given by Knuth.
As to pink noise: yes, the samples in pink noise have a Gaussian distribution, but that's not what makes it pink. What makes pink noise "pink" is the correlation between samples.
This is easy to confirm if you have Litter Pro: lp.gsss~ is a plain, uncorrelated Gaussian generator, mainly used for dithering. It actually sounds the same as white noise at audio levels (to the extent that I doubt anyone could reliably tell the difference in A/B tests). The objects lp.sss~ and lp.zzz~ produce pink noise (using two different algorithms, of which lp.zzz~ is generally considered "superior"... James McCartney developed the algorithm used here, so of course it's good!).
You can produce pink noise by filtering white noise, but that's a relatively expensive operation, and it's only an approximation of "real" pink noise. Tim Place wrote an external using this approach, and it uses a third- or fifth-order filter (sorry, forget which). At the time I wrote lp.zzz~ I compared it to Tim's implementation, and the Litter implementation used only about 1/8 of the CPU as the filter approach.
OTOH, the filter approach is pretty easy to write in Max/MSP. Direct generation of correlated samples not so easy (although it might be possible to do something clever by adding a series of square waves at octave intervals, going right up to Nyquist, with the amplitudes set by a RNG).
@peter thanks for clarifying. So it's not only the distribution.
@woyteg i know nearly nothing about dsp calculations. if i now try to translate this filter example to max
b0 = 0.99765 * b0 + white * 0.0990460;
b1 = 0.96300 * b1 + white * 0.2965164;
b2 = 0.57000 * b2 + white * 1.0526913;
tmp = b0 + b1 + b2 + white * 0.1848;
it seem not to work the way i understand it in max:
what's wrong? how is this filter calculated correctly and what is the init value for b0-2?
another problem is the floats in the example are too long for max.
ah what the heck, below is the max version attached. I wrote the values in a buffer too to look at the buffers spectrum (using the spectrumdraw external from the HIRT) for confirming that it works. cheers!