How did you maximize randomness in a S&H?

Started by Mark Hammer, January 27, 2018, 01:18:13 PM

Previous topic - Next topic

R.G.

Quote from: Mark Hammer on January 28, 2018, 02:32:00 PM
Just for the record, and so that people don't start searching for datasheets that don't exist, it's MM5837.
I actually looked the device up, as the numbers didn't look right to me either. And I accidentally found the MM5437, which does exist, and is a 23 stage generator. I suspect that National did this as a better successor to the 17 stage MM5837, which has worse thump problems because of fewer stages.

QuoteWhether what sounds noisy also yields acceptable randomness when sampled in a discrete step-wise fashion is an entirely different thing. 

I think it is also fair to consider that part of what makes a chip like that sound white-noisey is the very fact that the pseudo-random sequence spooled out IS in steps. 
I think you may be going down a path that is reasonable to think about, but has a flawed foundation. The random digital sequence does have the "corner effect", where the sharp edges of the waveforms are generated by harmonic contributions up to infinity, but it's misleading to think of the content as being just a one or a zero. That's true if you sample the raw dsigital waves, but as a practical matter, you're always going to do some filtering of the raw digital down to a high-frequency-limited analog signal to sample and hold. You can do this with a few resistors and caps, or an active filter. Another possibiltiy is to go digital on our sample and hold. You just run the digital noise source through a shift register with an output latch and tell the latch to "sample and hold". It freezes the digital word there, and that's your random value. The "D-A" can be just a batch of weighted resistors, although there are R-2R networks available through Mouser for cheap.

That sounds odd, but is a similar thing to filtering the serial data stream to analog then sampling the analog voltage. In a uC setup, you can do the same thing by using a controller with more output pins, and just have the sample/hold pin be an input, and the sampled data word appear on the output pins. Keeps it to a single chip.

Quote
For something like a S&H unit, what one strives for is something different between the previous center-frequency and current one.  Part of that involves the degree of contrast in the random/noise source, which is why there is a trimmer. [...]  For something like the FSH-1, what we are really looking for is a degree of contrast beyond mere left vs right, and more along the lines of now it's in Madagascar, now it's in Moldova, now in Uruguay, now in Cambodia, etc.  In other words, the degree of randomness aimed at needs to be a complement to the purpose.  If unpredictable alternation between 2 states is enough, then its enough.    If something that isn't the same as the last 3 states is enough, then it's enough.  If the rate at which state-changes occur is slow enough that one has a harder time "autocorrelating" across  them, then randomness needs are reduced.
Thing is, a PR stream does in fact generate all the possible steps between 0 and 1 if you either sample a multi-bit slice of it or analog lowpass filter it. Think of it this way; each step is 1 or 0, but every 8-bit chunk of that stream is between 0 and 255, even if you only consider a one-bit shift in the sequence.This is what makes PR generators so useful for crypto. So if you convert this stream to analog by simple lowpass filtering, you can just look at the Fourier Transform for what you get out. And what you get out is a really good flat spectrum noise source. An analog integrator filter (i.e. resistors and caps) is actually doing one or more integrations of the serial stream of ones and zeros. To make this all come true in the analog world, you have to have the stream be VERY fast compared to the analog filtered version. That's what I alluded to when I was muttering about overclocking compared to the top frequencies where you wanted flat-spectrum noise.

You can get different colors of noise out of the flat-spectrum stream. In most cases, for something like I imagine you're after with the S/H, you'd probably like flicker noise. Flicker noise sounds almost but not quite repetitive. It makes your ear think there's a repeat starting, but it never quite repeats. It's a bit less repetitive than ocean waves, for instance. You can get that out of flat spectrum noise by fairly simple filtering.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Mark Hammer

Well, I'll be damned.  The MM5437 does exist.  There's another datasheet for the collection, and another chip to keep my eyes peeled for in the delete/surplus bin.  :icon_lol:

My assumption, albeit naive rather then exquisitely well-informed, about the "white noisey" quality ofdigital shift registers is that in the world of BBDs we go to great lengths to clean up the aliasing that comes from high-frequency (but not high enough) sampling, that can add appreciably to audible hiss.  If that "stairstep" aspect creates artifacts that sound to us like hiss, then for me it stood to reason that something like the 5837/5437 or some CMOS shift-register alternative would indeed sound like white noise to the listener.

But I have to emphasize that there is a difference, and an important one at that, between a noise source heard AS noise, and a noise source as a source of data to use for secondary purposes.  So, if I'm trying to simulate the sound of waves lapping up on shore, then a 5837, fed to a lowpass filter and VCA, modulated by a suitable LFO, is probably going to do a bang-up job, and I sincerely doubt that any superior source of random information will do an audibly better job.  If I am dipping into the output of such a chip for "random" information, it's a bit like drawing a card from a deck comprised of hearts and diamonds, automatically re-inserting the drawn card into the deck and shuffling once.  Yes, the next card may not be the same as the last one drawn, but over time it will begin to feel fairly repetitive, and lose sense of randomness.

Which brings us to a bend in the road.  How random is the mixed product of multiple unsynced LFOs?  For example, Ken Stone's "Psycho LFO".  Do they have anything - apart from the ability to change the product by simple changes to one or more individual LFOs - on other sources of randomness?

blackieNYC

#22
My opinion is based only on two pseudo-random builds, but I think with pseudo-random, like mixed LFOs, you're going to find you can tune in some sweet spots. (In one case I found it and kept the adjustments only as internal trimmers.)The more LFO's the easier this might be. Or not. You'll want the LFO frequencies to be dissonant, and all quite slow. "Random" isn't always going to give you that. (do we need to call it True Random now?). I'd like to mix LFOs with adjustable mix levels as well as frequency. And you could have one LFO weighted a bit higher that the others to sound a bit like S&H but with a bit of a throb in there. That said, my stock maestro noise-LFO does seem to sound nice, if I could get the thing working.
When programming randomness (huh?) in a chip as an LFO, do you limit the bandwidth to be under 10Hz or so?
  • SUPPORTER
http://29hourmusicpeople.bandcamp.com/
Tapflo filter, Gator, Magnus Modulus +,Meathead, 4049er,Great Destroyer,Scrambler+, para EQ, Azabache, two-loop mix/blend, Slow Gear, Phase Royal, Escobedo PWM, Uglyface, Jawari,Corruptor,Tri-Vibe,Battery Warmers

Mark Hammer

The algorithmic aspects are unknown to me, but my Line 6 Liqui-Flange has a S&H type sound that they label "step".  It steps the delay time, instead of engaging in a continuous sweep, yielding a tone that is very hard to distinguish from a filter controlled in a similar fashion.  The sweep width pot is used to set the degree of contrast obtained, and the initial delay-time setting does what you'd expect.  Can't seem to find a decent video illustrating it in action.

With or without a decent sample, I imagine it presents a strong argument for what RG, electricdruid, and digitallarry have been pitching.  And that is that a small PIC, appropriately programmed, can deliver up degrees of "randomness", fine-tuned to the task at hand.

In the meantime, I'm finding out that the "droop" feature I included in my FSH-1 requires a much higher-value resistance than I initially thought.  The idea is that the JFETs and cap normally hold the sampled voltage from the noise source, to step the filter through different center frequencies.  If one affords the cap holding that voltage an opportunity to bleed off, the filter frequency will slip down, until the next sampled voltage is held, providing a "chooooo-chooooo-chooooo" sound (obviously beginning the slide from different starting points).  I found that the resistance values I had been using to provide that bleed-off were so low as to lose too much of the sampled voltage.  The end result was that the filter-frequency would be set so high that it ended up being just a bunch of bubbly nonsense in the background, like a poorly tuned radio, rather than a manipulation of the tone of the instrument.  Conserving enough of the sampled noise-voltage to provide a pleasing droop required use of a much higher-value resistor in parallel with the holding cap.  At last count, I'm up to 12M7 (10M+2M7), thought I think I may have to go even higher.  It IS a useful effect, though, and sounds decidedly different than the straight untinkered S&H.  Worth implementing.

R.G.

Quote from: Mark Hammer on January 29, 2018, 11:45:55 AM
But I have to emphasize that there is a difference, and an important one at that, between a noise source heard AS noise, and a noise source as a source of data to use for secondary purposes.  [...] over time it will begin to feel fairly repetitive, and lose sense of randomness.
You're absolutely right. That touches a number of issues with PR sources. First, they compete with human auditory memory. That's why both E.D. and I mentioned the repeat time. National Semi did the MM5*37s at a time when getting 17 or 23 shift register stages on a chip was a workmanlike thing to do. Today, that little amount of logic is laughable. So where a 17 bit shift register generates two-to-the-17th minus one possible stages - that's 131,071 possible states. If you're generating 16-bit audio, you have to clock it 16 times for a new, unrelated-to-the-previous-one value to appear, so you have to clock it at least 16x the highest frequency you want it to be flat to. In practice, you ought to clock it higher than that, just like with sampled audio. The common wisdom I've read says to make the clock 20-50 times the highest flat-audio frequency you want, and to filter the output with a filter that cuts of at maybe 5% of the clock rate.  That excludes any of the funny edge effects and evens out any clock leftovers, so you get what closely approximates analog audio, not digital.


QuoteWhich brings us to a bend in the road.  How random is the mixed product of multiple unsynced LFOs?  For example, Ken Stone's "Psycho LFO".  Do they have anything - apart from the ability to change the product by simple changes to one or more individual LFOs - on other sources of randomness?
They are of course, not random at all in the formal sense of the word. They consist entirely of the interactions of those oscillators, and are periodic at the least common multiple of the periods. Still, it's easy and simple to whip up, and the results can sound OK, especially when people sometimes like some predictability to their modulation.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

garcho

#25
I just so happened to have made a FSH-1 recently, as in a few days ago, I liked most of what I got out of most transistors, including some oddballs. Right now have an OTA LPF on my breadboard. I'm very happy with Electric Druid's TAPLFO random wave form. It's random within limits that make it musical. I like when a "random" function still implies some type of musical tempo, maybe it's just my brain averaging everything out in an attempt to find a pattern but sometimes I can "feel" random LFO mod at say 30-300Hz.
  • SUPPORTER
"...and weird on top!"

Rob Strand

#26
QuoteYou're absolutely right. That touches a number of issues with PR sources. First, they compete with human auditory memory. That's why both E.D. and I mentioned the repeat time. National Semi did the MM5*37s at a time when getting 17 or 23 shift register stages on a chip was a workmanlike thing to do. Today, that little amount of logic is laughable. So where a 17 bit shift register generates two-to-the-17th minus one possible stages - that's 131,071 possible states. If you're generating 16-bit audio, you have to clock it 16 times for a new, unrelated-to-the-previous-one value to appear, so you have to clock it at least 16x the highest frequency you want it to be flat to. In practice, you ought to clock it higher than that, just like with sampled audio. The common wisdom I've read says to make the clock 20-50 times the highest flat-audio frequency you want, and to filter the output with a filter that cuts of at maybe 5% of the clock rate.  That excludes any of the funny edge effects and evens out any clock leftovers, so you get what closely approximates analog audio, not digital.

The spectra of an LFSR (PRBS) is explained here,
https://www.edn.com/design/test-and-measurement/4422710/The-basics-of-digital-signal-spectra

In particular look at figure 4.

Ideally you want white noise which has a flat spectra.

If you make the clock frequency high enough, the left hand side of the red graph on figure 4 becomes flat over a wider frequency range.  If that range covers upto say 20kHz then the source is substantially white noise over the audio band.

The stuff above f0 (= clock frequency) is the "junk" that most people would intuitively think of as the "digital" glitchy part.   Normally you would pass the output through a low pass filter to remove it.  When you do that the concept of digital is gone in the same way that it is gone in sampled audio systems.

If you think about it, the situation isn't that much different to filtering out the high frequency junk from the output of a BBD.

As a side note: The spacing between the lines in figure 4 represents the repetition frequency of the sequence ie. the repetition rate you hear when the cycle is too short.  A longer sequence (more bits) will push those lines closer together.
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

amz-fx

Quote from: Mark Hammer on January 29, 2018, 11:45:55 AM
How random is the mixed product of multiple unsynced LFOs?  For example, Ken Stone's "Psycho LFO".

That type of noise generator was notably used in the TR606 Drumatix by Roland. It is random enough to sound like noise for cymbal and snare sounds. To my ears it has a bit of a metallic sound but overall it is not too bad.

regards, Jack

R.G.

Quote from: Rob Strand on January 29, 2018, 06:32:07 PM
The spectra of an LFSR (PRBS) is explained here,
[The-basics-of-digital-signal-spectra]

In particular look at figure 4.

Ideally you want white noise which has a flat spectra.
Thanks for the link, Rob, but I was dragged through that repeatedly over the years. I was after a simple and intuitive way to explain just the flat spectrum noise stuff to folks who haven't bee dragged through itr - and obviously didn't do a great job at.

I'm surprised that no one has come up with the flat noise<=> impulse response stuff yet.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

Rob Strand

#29
QuoteI was after a simple and intuitive way to explain just the flat spectrum noise stuff to folks who haven't bee dragged through itr - and obviously didn't do a great job at.
It's a tough job.  A lot of stuff in digital audio is hard to understand for "normal people".  You need some "minimal" ninja training to get off the ground.  But when "minimal" means a book full of equations it doesn't give you much hope.

Like why do I get ripples when I sweep a sine wave too fast.  To a normal person all the frequencies go in, and the level is the same. It's because of
https://en.wikipedia.org/wiki/Chirp_spectrum
Eeek  :icon_eek:
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

Mark Hammer

Quote from: amz-fx on January 29, 2018, 07:09:34 PM
Quote from: Mark Hammer on January 29, 2018, 11:45:55 AM
How random is the mixed product of multiple unsynced LFOs?  For example, Ken Stone's "Psycho LFO".

That type of noise generator was notably used in the TR606 Drumatix by Roland. It is random enough to sound like noise for cymbal and snare sounds. To my ears it has a bit of a metallic sound but overall it is not too bad.

regards, Jack
The old ETI Cymbal synthesizer used the quasi-ring-modulation of multiple oscillators (actually, ring modulation of the already ring-modulated output of multiple oscillators) to produce a metallic broad-spectrum clang.  The designer, Bob Penfold, notes "The oscillators all operate at fairly low audio frequencies, and have squarewave outputs that are rich in harmonics.  The result of this is that a vast range of new frequencies are generated by the ring modulation, giving a signal that has a definite metallic sound to it, but is a form of noise signal due to the vast number of output frequency components."

PRR

> filter out the low frequencies.

Sure, simple; but where?

And when did the TL072 datasheet grow to 67 pages?



The sheet says the 1/f corner is 250Hz. In fact it varies with process from sand to final epoxy. The slope is pretty sure, but the intercept has to be set-on-test, and lf hiss spectra is not a routine audio measurement.

I guess if you accept near-flat rather than quite-flat, a fixed 200Hz low-cut is unlikely to be very wrong.

  • SUPPORTER

Rob Strand

#32
QuoteAnd when did the TL072 datasheet grow to 67 pages?
News to me too.

QuoteI guess if you accept near-flat rather than quite-flat, a fixed 200Hz low-cut is unlikely to be very wrong.
That's as good as you can do.

I found these:

1) This one is transistors, BC107 etc. 
The variability and inconsistency is quite eye opening. 
I didn't see this type of thing except at high current (where it's very 1/f).
Click on the "Download" at the bottom, then you have to way.  If you go to another browser window the counter stops.
https://docslide.com.br/documents/1f-noise-of-avalanche-noise.html
2) Using Zeners.
Quite different results between the Author and Jim Williams' recommendation.
https://www.edn.com/design/analog/4420926/White-noise-source-flat-from-1Hz-to-100kHz
3) Using a transistor (he says zener but it's a 2N2222), an MM5837, and an LM336
http://www.ciphersbyritter.com/NOISE/NOISRC.HTM
I didn't have much success using zeners.  I think I wrote down what voltage was best somewhere.

Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

R.G.

Wide variability in odd, non-specified characteristics is the dark underbelly of having nearly any transistor replace any other.

The fact that any device that makes the min/max specs can be and actually >>IS<< one of the devices specified on the data sheet means that a "BC107" or "2N5088" can be from any set of silicon processes. The noise from zenering the base-emitter and any other odd misuses of the transistor may be anything, depending on the process line - which is not specified any more (National did it once, a long time ago, while they still existed) but no more.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.

reddesert

Quote from: amz-fx on January 29, 2018, 07:09:34 PM
Quote from: Mark Hammer on January 29, 2018, 11:45:55 AM
How random is the mixed product of multiple unsynced LFOs?  For example, Ken Stone's "Psycho LFO".

That type of noise generator was notably used in the TR606 Drumatix by Roland. It is random enough to sound like noise for cymbal and snare sounds. To my ears it has a bit of a metallic sound but overall it is not too bad.

regards, Jack

Here's an interesting paper on the TR-808 cymbal circuit, which uses 6 Schmitt trigger oscillators at incommensurate audio frequencies (not LFO, but idea is to generate a rich spectrum of "noise"): "The TR-808 Cymbal: a Physically-Informed, Circuit-Bendable, Digital Model," https://quod.lib.umich.edu/cgi/p/pod/dod-idx/tr-808-cymbal-a-physically-informed-circuit-bendable-digital.pdf

amz-fx

Here is the schematic to the TR-606. The noise generator circuit is in the bottom right of the page:

http://machines.hyperreal.org/manufacturers/Roland/TR-606/schematics/roland.TR-606.schem-6.gif

regards, Jack

Rob Strand

#36
QuoteWide variability in odd, non-specified characteristics is the dark underbelly of having nearly any transistor replace any other.

The fact that any device that makes the min/max specs can be and actually >>IS<< one of the devices specified on the data sheet means that a "BC107" or "2N5088" can be from any set of silicon processes.
Very true. 

Back in the day there were companies that sold transistors and diodes specifically for noise generation.  They would have to be tested for noise goodness.  I suspect they were expensive. Also RF noise sources have different requirements to Audio.
Someone still makes them: (but checkout the frequency range)
https://www.microsemi.com/product-directory/rf-discretes/3148-avalanche-noise-generator-diodes
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

ElectricDruid

One odd feature of the MN5837 that no-one has mentioned yet is that the clock rate it used depended on the supply voltage. The data sheet stated "between 24KHz and 56KHz", and the best case rate (from an audio point of view) of 56KHz on a -15V supply is what gives the 2.4 seconds repeat figure (2^17 / 56000 = 2.34). But even 56KHz is pretty poor as a output rate for a 1-bit noise source because that Sinc curve drops off pretty sharply to that first null at f0.

Another feature of LFSRs that hasn't been mentioned is that if you use them for generating numbers (8 bit numbers for example, from 0 to 255) then each number is equally likely to turn up - the probability distribution is flat. If you produce these numbers as held output voltage levels (like the TAPLFO "random" wave does) then you've got a S&H waveform where any value is equally likely.

If you add the outputs of several generators (or repeatedly add numbers from the same generator) then you can rapidly approximate a Gaussian (bell shaped) distribution where central values are much more likely than extreme outliers. Five or six numbers is enough, and even 3 or 4 isn't bad. For some things, that might be what you want. This would produce a different flavour of S&H output. Although I've played with gaussian noise, I've never tried it. Might have to give it a go now.

Tom



Rob Strand

#38
QuoteAnother feature of LFSRs that hasn't been mentioned is that if you use them for generating numbers (8 bit numbers for example, from 0 to 255) then each number is equally likely to turn up - the probability distribution is flat.
LFSR's aren't too good for generating numbers. Well unless you have an very large length then you can get away with anything.  The number 0 is missing on LFSR's.

QuoteIf you add the outputs of several generators (or repeatedly add numbers from the same generator) then you can rapidly approximate a Gaussian (bell shaped) distribution where central values are much more likely than extreme outliers. Five or six numbers is enough, and even 3 or 4 isn't bad. For some things, that might be what you want. This would produce a different flavour of S&H output. Although I've played with gaussian noise, I've never tried it. Might have to give it a go now.

There's a number of transformations to create gaussian distributions from uniform distributions.  One common way is to use the uniform distribution for the phase and magnitude then compute x =r*cos(theta); something like that.  It's a well know process called the Box-Muller Transform.  The uniform distribution has a limited span of values but gaussian distribution can have large peaks; a log function stretches the peaks.   IIRC if the distribution tails are important you might need to do more.

A lot of computers use this method.   Modern day versions use prime numbers for m, some 2^m-1.  They also combine two sequences together.
https://en.wikipedia.org/wiki/Linear_congruential_generator
Send:     . .- .-. - .... / - --- / --. --- .-. -
According to the water analogy of electricity, transistor leakage is caused by holes.

R.G.

Quote from: Rob Strand on January 30, 2018, 05:52:16 PM
QuoteAnother feature of LFSRs that hasn't been mentioned is that if you use them for generating numbers (8 bit numbers for example, from 0 to 255) then each number is equally likely to turn up - the probability distribution is flat.
LFSR's aren't too good for generating numbers. Well unless you have an very large length then you can get away with anything.  The number 0 is missing on LFSR's.
Depends on your scoring polynomial for "good".  In a world of $0.50 PICs, there's no good reason for short LFSRs any more. It's easy enough to use enough bits to hit cycle times of millions of years. So it comes very close to generating any random number you like. There are other techniques the crypto guys keep digging through to make the effective length longer. Hmmm, now that I think about it, for crypto anything you want your resulting cyphers to be "white", that meaning that the cypher tokens appear to be equally likely.

As noted, you have to mess with it to get gaussian. Not all that tough.

And you can have your choice of a LFSR with the all "0"s missing or the all "1"s missing. Note that this is not the all zero or all 1 sub word, but the single state out of two-to-the-N-minus-one where all of the register contents are the forbidden state. In fact, that missing state >>IS<< the forbidden state of all one logical value that would lock up the register and keep it from continuing.
R.G.

In response to the questions in the forum - PCB Layout for Musical Effects is available from The Book Patch. Search "PCB Layout" and it ought to appear.