Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Posting-Version: version B 2.10.3 4.3bsd-beta 6/6/85; site amiga.amiga.UUCP Path: utzoo!watmath!clyde!burl!ulysses!gamma!epsilon!zeta!sabre!petrus!bellcore!decvax!decwrl!pyramid!amiga!sam From: sam@amiga.UUCP (Samuel C. Dicker) Newsgroups: net.micro.amiga Subject: Re: white and pink noise Message-ID: <910@amiga.amiga.UUCP> Date: Thu, 27-Mar-86 05:46:20 EST Article-I.D.: amiga.910 Posted: Thu Mar 27 05:46:20 1986 Date-Received: Sat, 29-Mar-86 05:43:01 EST References: <1637@caip.RUTGERS.EDU> Reply-To: sam@snidely.UUCP (Samuel C. Dicker) Organization: Commodore-Amiga Inc., 983 University Ave #D, Los Gatos CA 95030 Lines: 46 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