[net.micro.amiga] white and pink noise

roberts@nbs-vms.ARPA (03/26/86)

From: "ROBERTS, JOHN" <roberts@nbs-vms.ARPA>


About 8 or 10 years ago, Popular Electronics ran an article describing
the properties of white and pink noise, and telling how to build 
generators. It seems to me that white noise was made by generating 
random numbers at regular intervals and using them to represent 
amplitude of the waveform, indexed from a base value. Pink noise was
generated by computing random numbers at regular intervals, putting in 
an offset, and using the resulting value to increment or decrement the
amplitude value from the previous interval. The maximum frequencies of 
either would of course be a function of the sampling frequency (and the
nonlinearities of the generating equipment). Clearly, such a white noise
generator would put out a lot more energy around the sampling frequency
than would the pink noise generator. 

It has been said that an ideal white noise generator puts out the same
It has been said that an ideal white noise generator puts out the same
power per unit bandwidth across its spectrum (i.e. .15mW/Hz) while an 
ideal pink noise generator puts out constant power per logarithmic 
frequency range (i.e. 300mW/Octave). By this description, white noise 
would have more emphasis on high frequencies, and ators are widely used
more emphasis on low frequencies. Pink noise generrators are widely used
to test audio systems. 
I think knowledge of the implementation of such features is definitely 
important to those who wish to take advantage of the Amiga as a sound
generator. (Question: If the Amiga gererates sound only by repeating a
previously programmed waveform, can it ever generate good random noise?
How rapidly can the waveform be updated?)

(Standard disclaimers. Before you make a million of them, I suggest you
read the article. Also, I'm sure the IEEE must have published something
at some time [perhaps in audio engineers' journals] that discusses the 
issue in detail.)

"It turned out to be one of those                 John Roberts
all-night wicker places...." -Police Squad        roberts@nbs-vms.ARPA
------

sam@amiga.UUCP (Samuel C. Dicker) (03/27/86)

In article <1637@caip.RUTGERS.EDU> roberts@nbs-vms.ARPA writes:
>            Question: If the Amiga gererates sound only by repeating a
>previously programmed waveform, can it ever generate good random noise?
A lot depends on the length of the waveform.  If the waveform plays for a
second and repeats it can produce good quality white noise.  The lowest
possible frequency is the repetition rate of the table, and all other
components of the 'noise' are integer multiples (harmonics) of that frequency.
For pink noise, where lower frequencies are much more prevalent, a longer
buffer may be required.

If you generate the noise waveform while it is playing by double-buffering,
you can play a noise waveform that doesn't repeat for a long time, without
using much memory.  Double-buffering the audio device is explained in
the Amiga ROM Kernal Manual and there is an example program at the end
of the Audio Device chapter: the 'Double-duffered(sic!) Sound Synthesis
Example.'

You can modify the double-buffered example to make it play a continuous noise
(instead a mouse - pitch controlled sine wave) by adding the global:

> long seed;

and replacing:

<           *buffer++ = sineTable[(angle += frequency) >>
<                   (32 - SINETABLEPOWER2)];
with:
>           *buffer++ = seed = FastRand(seed);

This will generate while noise with a waveform that repeats every few *days*.

Generating thousands of random numbers per second can keep the CPU pretty
busy.  If you plan on doing anything else while you make noise, you may want
to down code the buffer generating routine (newBuffer()) to assembler.

Believe it or not this:

	ADD.L   D0,D0
	BHI.S   1$
	EORI.L  #$1D872B41,D0
1$

is all it takes to generate random numbers.

Sam Dicker
{decwrl|glacier|hplabs}!pyramid!amiga!sam

jgray@pilchuck.UUCP (03/29/86)

**** munch munch *******


> From: "ROBERTS, JOHN" <roberts@nbs-vms.ARPA>
> 
> I think knowledge of the implementation of such features is definitely 
> important to those who wish to take advantage of the Amiga as a sound
> generator. (Question: If the Amiga gererates sound only by repeating a
> previously programmed waveform, can it ever generate good random noise?
> How rapidly can the waveform be updated?)
> 

One needs not generate thine noise from repeated invokations of thy
random generator consort. Tis said that many a noise wizard hath faithfully
deceived foolish mortals of the "golden ear" by merely conjuring up
a small sample of this devilish substance and proffering it to their
adepts of sound. These champions of sound, in turn, cast a spell of replication
which subjects the mortal to unending bombardment of samples (least the mortal
find his interrupt key). For a ask you. Canst thou tell the difference
from one snowflake to another amidst a storm?


			Writing a somewhat diffent Unix spell program,

				Jerrold L. Gray
				uw-beaver!teltone!dataio!pilchuck!jgray

				USNAIL:	10525 Willows Road N.E. /C-46
					Redmond, Wa.  98052
					(206) 881 - 6444 x478

				Telex:  15-2167


"Be seeing you"