DSPRelated.com
Forums

Generate Pink Noise Efficiently

Started by Robert Scott March 19, 2013
>This reminds me of one I heard once called "continuously rising tone."
It's called a shepard tone and that is an absolutely fabulous idea! http://en.wikipedia.org/wiki/Shepard_tone I still think the OPs idea is great, but I may have to do some shepard tone experiments when I get a minute.
On Thu, 21 Mar 2013 17:17:31 -0400, rickman <gnuarm@gmail.com> wrote:

>On 3/20/2013 7:54 PM, glen herrmannsfeldt wrote: >> rickman<gnuarm@gmail.com> wrote: >> >>> Maybe there is another way of thinking about this. Instead of creating >>> noise and then shaping the spectrum, why not generate a tone with noise >>> in the frequency content? >> >> That is that I was trying to think of, but didn't. I had some ideas >> of adding and subtracting LFSR outputs, but that didn't seem to get >> close. >> >>> I think if you add phase noise to a sine generator it will do something >>> like you want, no? The sine generator can be easily tuned. The noise >>> amplitude may have to be adjusted for the frequency to give a constant >>> relative bandwidth. >> >> OK, so run a phase accumulator, add the output of an LFSR, and >> then into a sine LUT. Or use the LFSR output as input to the phase >> accumulator. > >That's what I'm thinking. I'm just not sure what it will sound like and >the sound is the key. > > >> But back to my previous thought. If you take two uniform random >> numbers and add them, then the sum is not uniform. The more you >> add, the closer you get to Gaussian shape. A favorite way to generate >> random Gaussians is to add uniformly distributed random numbers, >> multiply by a constant (which might be 1) then subtract the mean. >> >> The LFSR needs AND, table lookup, and XOR. A few of those and some >> adders doesn't take much (computational) work. >> >> If you add that to a constant, and use the constant as input to the >> phase accumulator, the mean phase increment can change instantly. >> I would have to think at least a little bit to know what the >> power spectrum would look like. >> >> Actually, I just realized that this is what they do to reduce RFI >> from computers. A single frequency clock has a nice big peak in >> its power spectrum. By randomizing the clock rate, even a little >> bit, the spectrum is spread out and much less of a problem. > >That is what I was mentioning. I've never been convinced that this is >an entirely valid way of meeting an RFI spec. If the frequency is just >being moved during the measurement period, does that mean the amplitude >is reduced? I don't think so.
What do you mean by "moved"? Jitter reduces or extends the period on, potentially, a cycle-by-cycle basis. It's easily argued that that "moves" the frequency. That's essentially the mechanism that spreads the energy. It does, and that's why it's done. In order to meet Part 15 radiation limits for Unintentional Radiation it is often necessary to spread the peak energy of the clock (or whatever the radiating signal is, usually a clock), which can be done by applying a little bit of phase modulation in the form of randomized jitter. The total signal energy doesn't go down, but the peak spreads out, and if it spreads the energy enough that the peak drops below the Part 15 limits it's done its job.
> At any given moment the amplitude is >still the higher value. So whether it impacts other equipment (the >purpose of the RFI spec) depends on how fast the frequency is being >moved. I remember reading a spec on a PCI bus chip with a spread >spectrum PLL clock the dither rate was rather low to minimize the jitter >on the clock period. So in reality this was just a moving tone, not >really a "spread" signal. Think in terms of frequency hopping. A >frequency hopper still interferes the same as a stationary transmitter, >just less often.
Which means the integrated power over time at that frequency goes down, which is what you want. How finely or coarsely does frequency need to be defined or integrated over time? In the US the definitions that matter for radiation can be found in the FCC regs.
>If the computer clock period was *randomly* distorted I would call that >truly spread spectrum because at no time would there be a significant >tone. I expect they don't do this for any number of practical reasons. > > >>> As it turns out, there are a number of ways of easily generating a tone >>> from a phase sequence. >> >> You mean like a sine LUT with or without interpolation? >> >> And speed vs. time trade-off in table size vs. interpolation. > >I meant literally that there are a number of ways of doing that. >Recently someone gave me a link to a very nice paper by Jouko Vankka of >Helsinki University on DDS techniques. It covers several approaches >LUT, CORDIC, complex oscillator. I think any of these could have a >random phase/frequency modulated on it.
DDS are often used that way.
>BTW, I doubt interpolation would be needed for this project. The >rounding would just result in more noise... lol > >-- > >Rick
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
Can I make a suggestion?   If not, ignore the following:

Most tuners want to be able to hear what they're doing during the
tuning process.   Your stated method may work, but it may have
problems if the frequencies you are using for the feedback interfere
at all with the frequencies or harmonics of the string being tuned.
Tuning with some non-related, or, worse, tonally-related audio
feedback could be really aggravating if not done with significant care
to the design.

Instead, maybe amplify something already used, which is the beat note
between the string being tuned and the desired tone.   That's natural
and well-known to tuners, and if amplified a bit (i.e., synthesized)
could provide better feedback than what you've described.   Getting
the last few cents or fraction of a cent may require something else
since the beat note gets too low, but I thought I'd throw this out
there anyway.   Maybe the noise tone, appropriately placed
frequency-wise for a specific note, could do the job of tuning to the
last cent or so.


On Thu, 21 Mar 2013 19:16:13 GMT, no-one@notreal.invalid (Robert
Scott) wrote:

>Thanks for all the great suggestions. I will to do some >experimentation with these ideas to see which works best. > >For those who are curious about the application, it is for blind piano >tuners. I already have a line of electronic piano tuning apps for >sighted piano tuners. These applications feature a strobe-like >display that rotates left or right for flat or sharp. The goal for >the user is to tune the piano until strobe pattern stops moving. The >strobe display provides immediate analog feedback to the user. > >I now want to adapt these applications for use by blind piano tuners. >Just like sighted piano tuners these guys sense the need to make their >job easier by using an electronic aid. The most obvious method is to >generate a tone of the correct pitch and have the user match it. But >that method is not very accurate for reasons that I don't want to go >into now. It would be better if a blind-accessible version of the >strobe display could be provided. > >I plan on using an audio output stream to synthesize this strobe >display information. The user would wear headphones so that the >synthesized sound would not feed back into the microphone which is >listening to the piano. I plan on mapping the strobe display position >to the center frequency of this filtered noise signal I have been >talking about. When the frequency is moving upward that corresponds >to the strobe display indicating "sharp". When the frequency moves >downward, the note is "flat". Obviously there is a wrap-around event >that happens when the frequency gets to the end of the design range. >But I don't think this is too disconcerting, and the user should be >able to derive the same information that a sighted user would get from >looking at a strobe display, and just as quickly. The feedback must >be immediate or else use becomes too frustrating. That rules out any >kind of synthesized voice reading numbers that the user has to parse. >The reason I have chosen to use filtered noise rather than a simple >tone is that the user may also want to listen to the piano directly >and combine aural tuning skills with the electronically enhanced >tuning. By using filtered noise I prevent any spectrally pure >competition to the piano sounds. It is why a piano tuner can tune a >piano in a crowded restraunt with lots of talking going on, but he >will have a much harder time if there is music playing in the >background. So now you know the whole story. > >Robert Scott >Hopkins, MN >
Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
>Can I make a suggestion? If not, ignore the following: > >Most tuners want to be able to hear what they're doing during the >tuning process. Your stated method may work, but it may have >problems if the frequencies you are using for the feedback interfere >at all with the frequencies or harmonics of the string being tuned. >Tuning with some non-related, or, worse, tonally-related audio >feedback could be really aggravating if not done with significant care >to the design. > >Instead, maybe amplify something already used, which is the beat note >between the string being tuned and the desired tone. That's natural >and well-known to tuners, and if amplified a bit (i.e., synthesized) >could provide better feedback than what you've described. Getting >the last few cents or fraction of a cent may require something else >since the beat note gets too low, but I thought I'd throw this out >there anyway. Maybe the noise tone, appropriately placed >frequency-wise for a specific note, could do the job of tuning to the >last cent or so.
Thats a pretty good idea. The tuner would play the note into a microphone. The task would then generate the deviation from the true pitch using your standard tuning algorithm. The signal from the mic could then be amplitude modulated with a low frequency proportional to the deviation. I like that for a couple of reasons. First, you aren't listening to the true pitch, which is kind of annoying. Second, you have control over the beat frequency, meaning you can arbitrarily increase the beat making it easier to detect small deviations that the normal beat would make hard to catch. Hell, I can see and I would consider using that.
On 3/21/13 7:30 PM, dszabo wrote:
>> Can I make a suggestion? If not, ignore the following: >> >> Most tuners want to be able to hear what they're doing during the >> tuning process. Your stated method may work, but it may have >> problems if the frequencies you are using for the feedback interfere >> at all with the frequencies or harmonics of the string being tuned. >> Tuning with some non-related, or, worse, tonally-related audio >> feedback could be really aggravating if not done with significant care >> to the design. >> >> Instead, maybe amplify something already used, which is the beat note >> between the string being tuned and the desired tone. That's natural >> and well-known to tuners, and if amplified a bit (i.e., synthesized) >> could provide better feedback than what you've described. Getting >> the last few cents or fraction of a cent may require something else >> since the beat note gets too low, but I thought I'd throw this out >> there anyway. Maybe the noise tone, appropriately placed >> frequency-wise for a specific note, could do the job of tuning to the >> last cent or so. > > Thats a pretty good idea. The tuner would play the note into a microphone. > The task would then generate the deviation from the true pitch using your > standard tuning algorithm. The signal from the mic could then be amplitude > modulated with a low frequency proportional to the deviation. > > I like that for a couple of reasons. First, you aren't listening to the > true pitch, which is kind of annoying. Second, you have control over the > beat frequency, meaning you can arbitrarily increase the beat making it > easier to detect small deviations that the normal beat would make hard to > catch. > > Hell, I can see and I would consider using that.
you can get an affordable programmable audio products like an Eventide Harmonizer and likely put that together with predefined DSP components that you connect. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
Eric Jacobsen <eric.jacobsen@ieee.org> wrote:
> On Thu, 21 Mar 2013 17:17:31 -0400, rickman <gnuarm@gmail.com> wrote:
>>> rickman<gnuarm@gmail.com> wrote:
(big snip, then I wrote)
>>> Actually, I just realized that this is what they do to reduce RFI >>> from computers. A single frequency clock has a nice big peak in >>> its power spectrum. By randomizing the clock rate, even a little >>> bit, the spectrum is spread out and much less of a problem.
>>That is what I was mentioning. I've never been convinced that this is >>an entirely valid way of meeting an RFI spec. If the frequency is just >>being moved during the measurement period, does that mean the amplitude >>is reduced? I don't think so.
> What do you mean by "moved"? Jitter reduces or extends the period > on, potentially, a cycle-by-cycle basis. It's easily argued that that > "moves" the frequency. That's essentially the mechanism that spreads > the energy.
Seems to me that he is asking about the RFI spec. itself. Sometimes the actual specification doesn't measure what is really important, but we have to meet it anyway. Now, one reason for an RFI spec. is to reduce audible noise in nearby radio receivers. AM is much more sensitive than FM, but at high enough levels it will probably affect FM, too. (Besides, FM is closer to CPU clock rates.) In that case, the modulation needs to be somewhat faster than AF, but still slow compared to the actual clock frequency.
> It does, and that's why it's done. In order to meet Part 15 > radiation limits for Unintentional Radiation it is often necessary to > spread the peak energy of the clock (or whatever the radiating signal > is, usually a clock), which can be done by applying a little bit of > phase modulation in the form of randomized jitter. The total signal > energy doesn't go down, but the peak spreads out, and if it spreads > the energy enough that the peak drops below the Part 15 limits it's > done its job.
But spread when measured (windowed) over what time scale? If you measure from t=-infinity to +infinity, like the Fourier transform, then it could be plenty spread out, and yet over human time scales very narrow.
>> At any given moment the amplitude is >>still the higher value. So whether it impacts other equipment (the >>purpose of the RFI spec) depends on how fast the frequency is being >>moved. I remember reading a spec on a PCI bus chip with a spread >>spectrum PLL clock the dither rate was rather low to minimize the jitter >>on the clock period. So in reality this was just a moving tone, not >>really a "spread" signal. Think in terms of frequency hopping. A >>frequency hopper still interferes the same as a stationary transmitter, >>just less often.
> Which means the integrated power over time at that frequency goes > down, which is what you want. How finely or coarsely does frequency > need to be defined or integrated over time? In the US the > definitions that matter for radiation can be found in the FCC regs.
The usual reason for the FCC limits is home radio and TV receivers, especially ones with a plastic case. (No RF shield.) It only has to be fast enough to be inaudible or not visible on a TV picture.
>>If the computer clock period was *randomly* distorted I would call that >>truly spread spectrum because at no time would there be a significant >>tone. I expect they don't do this for any number of practical reasons.
On the other hand, a pseudo-random number generator may be random over short periods, but not over longer, audio frequency, periods. Some time ago, I was working on debugging a digital circuit with 66MHz ADCs and other high clock frequencies on board. It was connected to a PC with a wireless mouse. Sometimes the mouse wouldn't work, especially when too close to the board being debugged. I suspect, though, that isn't what the FCC had in mind. -- glen
On 3/21/2013 6:57 PM, Eric Jacobsen wrote:
> On Thu, 21 Mar 2013 17:17:31 -0400, rickman<gnuarm@gmail.com> wrote: >> >> That is what I was mentioning. I've never been convinced that this is >> an entirely valid way of meeting an RFI spec. If the frequency is just >> being moved during the measurement period, does that mean the amplitude >> is reduced? I don't think so. > > What do you mean by "moved"? Jitter reduces or extends the period > on, potentially, a cycle-by-cycle basis. It's easily argued that that > "moves" the frequency. That's essentially the mechanism that spreads > the energy.
You should have read further down. The spread spectrum PCI chip I looked at simply modulated the frequency with a sine or sawtooth. It wasn't "jittered". Yes, the energy was "spread", but it may well have still be large enough at any given point to interfere with comms, etc.
> It does, and that's why it's done. In order to meet Part 15 > radiation limits for Unintentional Radiation it is often necessary to > spread the peak energy of the clock (or whatever the radiating signal > is, usually a clock), which can be done by applying a little bit of > phase modulation in the form of randomized jitter. The total signal > energy doesn't go down, but the peak spreads out, and if it spreads > the energy enough that the peak drops below the Part 15 limits it's > done its job.
That's my point. Meeting FCC regs this way may or may not help reduce RFI. Spreading the peak on an instrument is not the same thing as spreading the peak in "reality".
>> At any given moment the amplitude is >> still the higher value. So whether it impacts other equipment (the >> purpose of the RFI spec) depends on how fast the frequency is being >> moved. I remember reading a spec on a PCI bus chip with a spread >> spectrum PLL clock the dither rate was rather low to minimize the jitter >> on the clock period. So in reality this was just a moving tone, not >> really a "spread" signal. Think in terms of frequency hopping. A >> frequency hopper still interferes the same as a stationary transmitter, >> just less often. > > Which means the integrated power over time at that frequency goes > down, which is what you want. How finely or coarsely does frequency > need to be defined or integrated over time? In the US the > definitions that matter for radiation can be found in the FCC regs.
No, I don't care about "integrated" power. I care about interference. -- Rick
On Mar 21, 7:30&#4294967295;pm, "dszabo" <62466@dsprelated> wrote:
> >Can I make a suggestion? &#4294967295; If not, ignore the following: > > >Most tuners want to be able to hear what they're doing during the > >tuning process. &#4294967295; Your stated method may work, but it may have > >problems if the frequencies you are using for the feedback interfere > >at all with the frequencies or harmonics of the string being tuned. > >Tuning with some non-related, or, worse, tonally-related audio > >feedback could be really aggravating if not done with significant care > >to the design. > > >Instead, maybe amplify something already used, which is the beat note > >between the string being tuned and the desired tone. &#4294967295; That's natural > >and well-known to tuners, and if amplified a bit (i.e., synthesized) > >could provide better feedback than what you've described. &#4294967295; Getting > >the last few cents or fraction of a cent may require something else > >since the beat note gets too low, but I thought I'd throw this out > >there anyway. &#4294967295; Maybe the noise tone, appropriately placed > >frequency-wise for a specific note, could do the job of tuning to the > >last cent or so. > > Thats a pretty good idea. &#4294967295;The tuner would play the note into a microphone. > &#4294967295;The task would then generate the deviation from the true pitch using your > standard tuning algorithm. &#4294967295;The signal from the mic could then be amplitude > modulated with a low frequency proportional to the deviation. > > I like that for a couple of reasons. &#4294967295;First, you aren't listening to the > true pitch, which is kind of annoying. &#4294967295;Second, you have control over the > beat frequency, meaning you can arbitrarily increase the beat making it > easier to detect small deviations that the normal beat would make hard to > catch. > > Hell, I can see and I would consider using that.
I agree with what Eric said.. and I think you can achieve this "simply" by passing the reference tone and the variable tone through some non-linearity which will produce the beat frequency and then suitable filtering to emphasize the low frequency difference tone compared to the two original tones. The down side I see to this (another pun) is that the difference freq doesn't tell you the sign of the error,,,, i.e sharp or flat, but having zero beated tones often, the hand ear feedback is very effective and you can easily tune for a zero beat, if you can hear it well. Mark
On Fri, 22 Mar 2013 16:16:59 -0400, rickman <gnuarm@gmail.com> wrote:

>On 3/21/2013 6:57 PM, Eric Jacobsen wrote: >> On Thu, 21 Mar 2013 17:17:31 -0400, rickman<gnuarm@gmail.com> wrote: >>> >>> That is what I was mentioning. I've never been convinced that this is >>> an entirely valid way of meeting an RFI spec. If the frequency is just >>> being moved during the measurement period, does that mean the amplitude >>> is reduced? I don't think so. >> >> What do you mean by "moved"? Jitter reduces or extends the period >> on, potentially, a cycle-by-cycle basis. It's easily argued that that >> "moves" the frequency. That's essentially the mechanism that spreads >> the energy. > >You should have read further down. The spread spectrum PCI chip I >looked at simply modulated the frequency with a sine or sawtooth. It >wasn't "jittered". Yes, the energy was "spread", but it may well have >still be large enough at any given point to interfere with comms, etc. > > >> It does, and that's why it's done. In order to meet Part 15 >> radiation limits for Unintentional Radiation it is often necessary to >> spread the peak energy of the clock (or whatever the radiating signal >> is, usually a clock), which can be done by applying a little bit of >> phase modulation in the form of randomized jitter. The total signal >> energy doesn't go down, but the peak spreads out, and if it spreads >> the energy enough that the peak drops below the Part 15 limits it's >> done its job. > >That's my point. Meeting FCC regs this way may or may not help reduce >RFI.
Define RFI.
> Spreading the peak on an instrument is not the same thing as >spreading the peak in "reality".
When you get to define your own reality, nobody else can help you from theirs.
>>> At any given moment the amplitude is >>> still the higher value. So whether it impacts other equipment (the >>> purpose of the RFI spec) depends on how fast the frequency is being >>> moved. I remember reading a spec on a PCI bus chip with a spread >>> spectrum PLL clock the dither rate was rather low to minimize the jitter >>> on the clock period. So in reality this was just a moving tone, not >>> really a "spread" signal. Think in terms of frequency hopping. A >>> frequency hopper still interferes the same as a stationary transmitter, >>> just less often. >> >> Which means the integrated power over time at that frequency goes >> down, which is what you want. How finely or coarsely does frequency >> need to be defined or integrated over time? In the US the >> definitions that matter for radiation can be found in the FCC regs. > >No, I don't care about "integrated" power. I care about interference.
Define "interference", then. The FCC regs are, in general, reasonably good at being consistent. e.g., not only is potentially "interfering" equipment required to keep radiation below the Part 15 Unintentional Radiator requirements, but receivers are required to tolerate "interference" below the Part 15 Unintentional Radiator requirements. So, from that standpoint, spreading clocks or other energy sources that would otherwise exceed the Part 15 limit is a very effective mitigation strategy, which, again, is why it is so commonly done. Also, the regs do also define test methodology, including the appropriate resolution bandwidths, integration times, etc., for various requirements in order to make them sensible. It is quite easy, as you have demonstrated, to retreat to a different, unstated, definition of terms, but that makes the point pretty moot. So, if you have a different definition of "interference", then you either have to define it specifically so that those so inclined can respond intelligently, or...? Eric Jacobsen Anchor Hill Communications http://www.anchorhill.com
OK, here is the method that I ended up using.  I generate a square
wave of random period, or rather a random half-period.  I start with a
randon number uniformly distribute between 400 and 655.  This number
is multiplied by a value that ranges from 635 nsec to 1134 nsec,
depending on the parameter value I am trying to communicate.  The
resulting time is the length of the next square wave Hi or Low time.
After that time I toggle the output and generate another random number
for the next half-period.  The result sounds about right.

The spectrum of the frequency-jittered square wave is not just a
single wide peak but has significant harmonics that are also
spread-spectrum.  But the overall sensation of rising or falling pitch
is conveyed, much like the Shepard Tones mentioned earlier.

Robert Scott
Hopkins, MN