[AVR/ARM]White noise audio generator.

Status
Not open for further replies.

David_

Advanced Member level 2
Joined
Dec 6, 2013
Messages
573
Helped
8
Reputation
16
Reaction score
8
Trophy points
1,308
Location
Sweden
Visit site
Activity points
12,242
Hello.
I am trying to construct a with noise generator to play sound in earphones or speakers in order to find out if white noise is beneficial to people with ADD(Attention Deficit Disorder) and I have a arduino due which contains a SAM3X8E AVR/ARM flash microcontroller.

It has a True Random Number Generator(TRNG) which outputs a 32bit word every 84 clock cycles, and it has a 12bit DAC(DACC, two channels).
The DACC clock is the master clock(84MHz) divided by to so 42MHz and every conversion takes 25 clock cycles, which I interpret as 50 master clock cycles.

Anyway, am I wrong in thinking that I can use the TRNG to generate random values with white gaussian distribution and tailor that value to a 12bit range and then drive headphones or speakers through some buffer with the DAC?

I have read and I am reading but I don't understand how I would actually use the TRNG for this purpose, does anyone have any suggestions?

All inputs are much appreciated.
I have determined that a digital generator is the way to go since that should allow greater means of adjusting the sound to something that can help me, I really hope this will work in some manner to help me study or not get distracted so easily and it will be interesting to see what effects this can have. I'm also interested to see what effect this can have on tinnitus.
Does anyone ave any experience with these kind of things?

Regards
David
 

I have made PRSG with white noise usin a clock shift register and XOR feedback taps for an MLS pattern, then filter the white into Pink Noise for acoustic slope of -3dB /octave rather than Brown Noise -6dB/octave. This requires several partial -6dB/oct. RC neworks.

I have also used a diode for white noise similar to the circuit below.




Many others have done this in software.
 

What are you view on analog vs digital noise generation?
I am basing my understanding on loosely gathered info since I have jet to get a good grasp of what is actually the fine points of noise generation.

I have matlab with a student license and first I thought to make some noise in matlab and run a model on the Due but I have hit a brick wall that I cannot get around, no matter if i use arduino Uno, Mega or Due I get the same error message from windows.
With the Due I get "arm-none-eabi-gcc.exe - programerror and a explanation that the program can't launch correctly due to (0x0000142). The same problem with the 8-bit µCs but it says avr-????-gcc.exe or something in that neighborhood. I've searched the net for a solution but all I can gather is that it is something wrong in some .dll file or some other registers, I have no idea how to resolv it and ATMEL studio and arduino IDE is working fine.
I wil open a thread somewhere asking for help I guess.

Though I am using matlab to get a understanding of white noise in general because it helps to know the thing I am trying to synthesize, right...

I just bought a bag of 2N3904 NPN transistors so I will implement the schematic you posted to have a start for comparison, and then I can read the noise with the Dues 12bit ADC and analyses the signal with matlab, that should be educational.

The "clock shift register and XOR feedback taps for an MLS pattern" you've mentioned, that can be implemented in software alone right?
Thats the picture I have gotten from the web but that is a large leap from my current grasp of programming, might I ask if you have any code I can get a whim from what it entails?

I clearly do not understand white gaussian noise, but I think that your example would be something like a linear-feedback shift register (LFSR)?
But if such a contraption would be used as a pseudo-random generator it should not be needed since I have a true random number generator at hand.
At one hand as I read about it it seams that if I could extract a 12bit value from every generated 32bit value from TRGN those would have the same probability density... And they would be uncorrelated to each other and could be used as white noise.

Is that right?

I have no knowledge about this and this seams like a to simple solution but if every value was produced between 0 and 4095, at did not relate to each other. Then just by supplying the DAC with these numbers I would have a source for white noise?

I am forgetting the sample rate, and now my lack of knowledge will show. What determines the bandwidth...
I am reading but I just don't get it,

If my solution can work then I need to find a suitable timing for the random words and the DAC output sample rate, hmm....
I think I am way of and need to start from the beginning again.
 

i would go with the analog solution. The digital one has a loop cycle time depending on length of maximal sequence.

that will be noticeable and maybe good , but most likely annoying.

You are correct in your assumptions about software synthesis but nothing better than true thermal noise of a diode.


https://www.google.ca/search?q=prsg+matlab+random
 

Allright, then I will focus on the analog solution.
Making adjustible filters to play around with is fun anyway.
I shall check the link you posted when the sun has gone up an I've had some sleep, thanks for you input. Most usefull.

Thanks.
 

I don't know which process is generating your random numbers, but in common terminology, digital random generators are considered as pseudo random rather than true random. https://en.wikipedia.org/wiki/TRNG

I presume, you can make pseudo random noise sequences with less obvious periodocity than the simple linear feedback shift register mentioned by SunnySkyguy. Recent electronic instruments and sound processing tools have it, I believ. With an improved pseudo random generator, the digital generation method may be preferable and is surely more versatile, at least if further digital sound manipulation steps like filtering are intended.
 

I see your purpose is for ADHD, which I found is supprted by research. In my experience I used loud rock music to focus on studying for exams and when I was in Gr2 a dentist was experimenting with loud music to replace local anesthetic. It worked.

https://www.theglobeandmail.com/lif...as-effective-as-drugs-for-adhd/article623388/

I would try an MP3 player with ear buds on a recorded sound loop first. Vacuum,cleaner noise levels would be disruptive.

Perhaps the study was done with White noise which is more Shhh sounding and Brown Noise more of a rumble might be equally effective without loss of attention when studying.

PRSG noise sounds more like,running water with the cycle time like the beat of a train on tracks, clickety clack.., clock*'sequence length. but when averaged is pseudo random. You may want to experiment with the beat interval or cadence.

REF
**broken link removed**
https://www.phy.mtu.edu/~suits/LFSR.html


Choose the biggest Maximal Length Sequence you can implement such as 32 bit or more. Also remember the initial condition using all zeros and or ones depends on the polarity. If the feedback is non inverted or inverted, the initial condition is the complement of the illegal condition. I.e. all ones or zeros.
 

Thanks for all the advice, I have no understanding regarding probability theory what so ever which makes this very difficult.
I am reading but its a completely new field for me.
I tried a solution with arduino IDE and the Due boards as follows
Code:
uint32_t Noise;

void setup() {
  //setup True Random Number Generator
  pmc_enable_periph_clk(ID_TRNG);       //enable TRNG clock
  TRNG->TRNG_IDR = TRNG->TRNG_IMR;      //disable Data Ready Interrupt
  TRNG->TRNG_CR = TRNG_CR_KEY(0x524e47) //security key 
                  | TRNG_CR_ENABLE;     //enable TRNG 
  
  //setup DAC Channel 0
  pmc_enable_periph_clk(ID_DACC);            //enable DACC clock
  DACC->DACC_CR = DACC_CR_SWRST;             //reset DAC
  DACC->DACC_MR = DACC_MR_TRGEN_DIS          //start free-running mode
                  | DACC_MR_USER_SEL_CHANNEL0//enable DAC0
                  | DACC_MR_REFRESH (0x2)    //set Refresh Period 48,7µS
                  | DACC_MR_STARTUP_24;      //36,5µS startup
  DACC->DACC_IDR = DACC->DACC_IMR;           //disable interrupts
  DACC->DACC_IER = 0x1;                      //enable TXRDY
  DACC->DACC_CHER = DACC_CHER_CH0 << 0;      //enable channel 0

}

void loop() {
    while (! (TRNG->TRNG_ISR & TRNG_ISR_DATRDY))
        ;
    Noise = TRNG->TRNG_ODATA;
    DACC->DACC_CDR = (Noise >> 20);
}

It works but its kind of unpleasant but it does some good, but I don't even know how to define the noise being put out through a small 8Ω speaker.
I have never worked with sound or audio before but I buffer the DAC0 output with a unity-gain opamp that is driving the base of a NPN bjt, collector to speaker (-) terminal and emitter to GND. With a pot for volume controll.

Is there any possibility to apply some digital filter or signal processing to this approach?
Of course there are, I prussume thats a silly question but I havent the first clue of where to begin.
Any pointers anyone?

I will peruse this more and I will update my progress here but for the time being I really need the benefits of noise and I found this:
https://mynoise.net/appGuide.php

We shall see and this seams very promising, it might be perfect but I am still going to continue this project as I want to learn the theory behind it an all. And to take my first step into digital signal processing, that entails to be tons of fun when I get over the door from... I don't know if that is a real saying but its a direct translation from Swedish, as the researcher in the article posted I thought to see if I can get a hold of him and see if he has any useful information.

I will write about the effects of sound treatment such as this if there are any worth while writing about.

Thanks for all inputs.
Regards David
 

Status
Not open for further replies.
Cookies are required to use this site. You must accept them to continue using the site. Learn more…