Maker Pro
Maker Pro

22.6us and ~10mips to create pink noise real time

Okay I've got an Atmel AVR ATTiny13V. Runs off 3V, 100ns instruction
time. I am trying to generate 8 bit pink noise real time, cd quality,
so I have 1/44100 = 22.6us to generate each sample. I can write it in
assembler, or C, but I only have 1k of program memory so assembler is
probably the way to go here. Where should I start? Is it possible to
make a -3db/octave digital filter in assembler which takes random 8 bit
numbers and spits out pink noise?
 
D

Dirk Bruere

Okay I've got an Atmel AVR ATTiny13V. Runs off 3V, 100ns instruction
time. I am trying to generate 8 bit pink noise real time, cd quality,
so I have 1/44100 = 22.6us to generate each sample. I can write it in
assembler, or C, but I only have 1k of program memory so assembler is
probably the way to go here. Where should I start? Is it possible to
make a -3db/octave digital filter in assembler which takes random 8 bit
numbers and spits out pink noise?

You could take this and modify it
http://www.moshier.net/pink.html

Dirk
 
B

Ben Jackson

I am trying to generate 8 bit pink noise real time, cd quality,

BTW, I did this experiment (burned a cd, though, instead of making a
signal generator). All I learned was that the frequency response of
my stereo was pitiful along axes I had no control over without
spending a lot of $$$. Good luck! :)
 
B

Ben Bradley

Okay I've got an Atmel AVR ATTiny13V. Runs off 3V, 100ns instruction
time. I am trying to generate 8 bit pink noise real time, cd quality,

For true "CD quality" you need a 16-bit sample.
so I have 1/44100 = 22.6us to generate each sample. I can write it in
assembler, or C, but I only have 1k of program memory so assembler is
probably the way to go here. Where should I start? Is it possible to
make a -3db/octave digital filter in assembler which takes random 8 bit
numbers and spits out pink noise?

At about 200 instructions per sample, 8-bit math and no hardware
multiply-accumulate function, I doubt you could do the filter.
If you use a DSPic or one of the MSP430's that has the MAC add-on,
you MAY be able to do an appropriate FFT filter in real time. I think
I would go for one of the inexpensive but 'real' DSP's from TI or
Moto, er, Freescale. With these you can do 'true 16bit' and at least
get 12-bit resolution, or even do fixed-point "double precision"
32-bit and get better than 16-bit performance, easily done at the CD
sample rate.
 
A

Ancient_Hacker

Okay I've got an Atmel AVR ATTiny13V. Runs off 3V, 100ns instruction
time. I am trying to generate 8 bit pink noise real time, cd quality,
so I have 1/44100 = 22.6us to generate each sample. I can write it in
assembler, or C, but I only have 1k of program memory so assembler is
probably the way to go here. Where should I start? Is it possible to
make a -3db/octave digital filter in assembler which takes random 8 bit
numbers and spits out pink noise?

Jeepers, in the old days we used these things called "analog" parts.
One zener diode, one resistor, one capacitor, one LM714, viola, noise
source. Nt a lick of programming and no problem looping the noise, as
it's all freshly made every microsecond.
 
D

Dirk Bruere

Ancient_Hacker said:
Jeepers, in the old days we used these things called "analog" parts.
One zener diode, one resistor, one capacitor, one LM714, viola, noise
source. Nt a lick of programming and no problem looping the noise, as
it's all freshly made every microsecond.

Generate white noise in s/w using pseudorandom numbers and filter it
using analogue? In which case er... why not use all analogue.

Dirk
 
A

Ancient_Hacker

We did use all analog-- the zener (or a transistor E-B junction reverse
biased) generates the noise. 7 cents, no programming, and very low
power consumption.
 
F

Fred Bartoli

Ancient_Hacker said:
We did use all analog-- the zener (or a transistor E-B junction reverse
biased) generates the noise. 7 cents, no programming, and very low
power consumption.

But you'll need more than a simple RC filter to mimic 3dB/octave.
First order filters give 6dB/o
 
I would think this is a good way to do it, but what about temperature
and part-to-part variances in spectrum of the noise? I cant tweak this
circuit at all, its got to roll off the assembly line ready to go. And
making the circuit from scratch is beyond my abilities, I'm just not
that good dealing with the junctions resistance and all the little
details which this kind of circuit would be extra sensitive to.
 
D

Dirk Bruere

I would think this is a good way to do it, but what about temperature
and part-to-part variances in spectrum of the noise? I cant tweak this
circuit at all, its got to roll off the assembly line ready to go. And
making the circuit from scratch is beyond my abilities, I'm just not
that good dealing with the junctions resistance and all the little
details which this kind of circuit would be extra sensitive to.
The only simple way I can think of doing is is digitising some pink
noise and replaying it. How much data memory do you have?

Dirk
 
K

Ken Smith

But you'll need more than a simple RC filter to mimic 3dB/octave.
First order filters give 6dB/o

The filter can be passive but it needs about as many parts as the number
of octaves.
 
D

Don Klipstein

The filter can be passive but it needs about as many parts as the number
of octaves.

Somehow, I remember seeing filters that convert white noise to noise
that is pink within +/- less than 1 dB throughout the audio spectrum with
a bit fewer parts than that... Then again I could have found to be
"conveniently simple" a filter circuit with a few resistors and capacitors
totalling could have been about as many 10 parts although I thought a bit
less than that.

But it is true - converting white noise to pink noise requires a 3
dB/octave slope which for entyire audio spectrum requires several of
what I think of as "shelf filters" - flat frequency response at very high
and very low frequencies but gain varying inversely with frequency over
some range. I have seen impressive "pink noise filter circuits" with
three "shelf filter" stages, and somehow I suspect that could use fewer
than 10 parts...

Now I try Google and get:

http://www.spectrum-soft.com/news/fall98/pink.shtm

A couple filters, one with 8 parts, and a couple spectral analysis plots
with the one from the 8-part circuit being pink noise +/- not much more
than .2 dB from 10 Hz to 29 KHz if I did not do any misinterpretations.

http://sound.westhost.com/project11.htm

A more complete pink noise generator circuit, with the filtering
achieved by 9 parts and looking good (within a dB) for 10 Hz to 20 KHz and
loking like well within half a dB of a straight line throughout most of
the audio spectrum.

http://www.qkits.com/serv/qkits/velleman/pages/k4301.asp

A kit, although I did not see a statement of how closely it approximates
pink noise nor a circuit showing the number of parts in the filter. But
it does appear to be a simple enough kit!

http://www.hobbytron.com/vk4301.html

Similar kit, possible the same one.

http://home.iprimus.com.au/vk3jaj/pinkfilt/pinkfj04.html

An "audio spectrum analyzer pink noise generator" circuit - where I see
9 parts that I see being filter components.

http://home.iprimus.com.au/vk3jaj/pinkfilt/pinkfj07.html

Another circuit with white and pink noise outputs, with the filter
section appearing to me to have 9 parts.

- Don Klipstein ([email protected])
 
A

Ancient_Hacker

oops, I didnt catch the fact that you want to make many of these, and
to tight tolerances. Exactly what are the design specs?

For pink noise, you will need a few more r-c sections, see:

http://www.web-ee.com/Schematics/Pink Noise/pink.htm

And the noise from the diode or B-E junction will vary a bit from
sample to sample. But at 7 cents a transistor, you can maybe afford to
do a 2-second test for each xistor and toss the weakest 33% of them?
Or use them for the output amp if the op-amp doesnt have enough oomph
to drive the headphones?

And if you're driving headphones, you probably don't need a very
precise 3db/octave filter. Your average headphones are anything but
flat, especially the popular ear-bud kind.
 
T

Tom Bruhns

Depending on the accuracy you want in the spectral content of the
"pink" noise, to do it digitally you'll need a random generator (white
noise) and "a few" stages of IIR biquads. You could use single-pole
filter stages, but as I recall when I did it years ago, I decided the
biquads were computationally slightly more efficient. (You may even
find my name on a set of pink filter pole and zero locations that's
still floating around in cyberspace. Every once in a while someone
writes to ask me about them.) Some of the poles are at a very tiny
fraction of the sample frequency, so have to be done with high
precision math for good results. I _seriously_ doubt you'll do it in
your Atmel at a couple hundred instructions per sample. In a DSP with
hw MAC you should be able to do a good job in a hundred instructions,
plus or minus--even fifty instructions would let you do a few poles &
zeros.

But...If you don't need super-accurate "pinkness" you could easily
generate a pseudorandom bitstream in the atmel (excellent and
repeatable "whiteness" and high amplitude, and ample bandwidth if
that's all the AVR is doing) and filter that with a few RC stages. You
can get 1% caps (C0G ceramics) and 1% or better resistors, which may
very well provide adequate or even ample accuracy and stability for
your purposes. The board area and placement cost will cost more than
the parts you put on it, most likely.

Cheers,
Tom
 
E

engineer

'scuse me, the title says "create pink noise real time".. and I know
what the author meant, but ,,

if I have a box which makes pinks noise, and i dont know what is inside
the box... but I turn on the power and out comes a pink noise signal.
... then to any observer, is the pink noise "real time" or not?

If I play back a recording of pink noise, is it measurably less pink
than than one created by a computational algorithm (in real time) ?

Just in terms of terminology, if I can compute 'real time' a very good
pink noise signal, it's equisite randomness will be conveniently in
relation to some clock in some extended context (real time).. it's very
randomness make the relation to such 'some clock' useless.. so how
could a 'truly' random signal be 'real time' in any meaningful way?

I take it the author probably meant 'when you press a key within a
milisecond or so, start such and such' ... but I thought it would be
useful for some to consider the juxtaposition of terms and why.

But to approximate pink noise real time.. I would consider
approximating white noise, possibly by some clever indexing of
randomized lists of primes which in turn index other lists of primes,
and apply some kind of filtering to make it pink... claiming a
marginally better randomness than other simple methods.

Of course this is trivial for many who post here, but I put in my
2.948001384 cents on it for those who'd enjoy some less formal chatter
on the subject.
 
Top