Pages: [1] 2   Go Down
Author Topic: Arduino Realtime Audio Processing  (Read 6841 times)
0 Members and 1 Guest are viewing this topic.
0
Offline Offline
Newbie
*
Karma: 0
Posts: 30
Arduino rocks
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

http://interface.khm.de/index.php/lab/experiments/arduino-realtime-audio-processing/

I have one question about the input circuitry. I would like to know how you adjust the 10k trimpot to set the DC offset to 127?

- run the loopback test sketch
- open the serial monitor window with 57600 baud
- after reset the actual value is shown "ADC offset=127"

this is the code section in setup()
  . 
  Serial.print("ADC offset=");     // trim to 127
  ii=badc1; 
  Serial.println(ii);
 .

martin
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34229
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Not sure what you are not getting.

You run this code and with no audio going in you getba stream of numbers in the monitor window. As you turn the pot these numbers will change, when you get the number 127 you stop turning the knob and never touch it again.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 7
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

What changes should i make if the input audio signals from a USB port of a computer?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34229
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

What changes should i make if the input audio signals from a USB port of a computer?
You can't recieve audio down the UBB port from a computer with the arduino unless you convert the audio into values that you can send down the serial port with some application on the PC.
Logged

Offline Offline
Edison Member
*
Karma: 34
Posts: 1318
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

I don't know anything about that project...    But 127 doesn't seem right, and I don't even think it's possible with that circuit (assuming you are directly reading the ADC).

The Arduino has a 10-bit ADC.  That means you can read values between zero an 1023.   The normal half-way bias-point for AC audio signals would be 511 or 512.  Are you getting readings around 500?

If I calculate the minimum reading from turning the offset pot all the way down, I get 1023 x 100K/210K = 487.  (And, I get a calculated maximum of around 536.) 
« Last Edit: April 01, 2013, 01:16:55 pm by DVDdoug » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Ive built it and it works. It actually sounds pretty good minus a kind of distortion in the background. Anyone have any idea what that is? or how to get rid of it?
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34229
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

It is sampling noise, improve the filter on the output. Consider a 2nd or 4th order filter with a faster drop off.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Thats what I thought. I will look into it unless you have a suggested schematic.
Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Heres a quick youtube video to show the sound: 
https://www.youtube.com/watch?v=eG9oAqeh8Z0

I tried an active highpass filter and it seems no different then the origonal one.
http://www.nogaqrp.org/projects/PGR/af_low_pass_filter_construction_detail.jpg
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34229
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quote
I tried an active highpass filter and it seems no different then the origonal one
You need a low pass filter not a hgh pass one.
You also need it to have either a lower break frequency or higher order.
It could be that your noise is aliasing, in which case you need a low pass filter on the front end as well.
But in the video it sounds like sampling noise. Remember it is only 10 bits and the sample rate is not great.
« Last Edit: October 28, 2013, 02:56:24 am by Grumpy_Mike » Logged

Offline Offline
Newbie
*
Karma: 0
Posts: 24
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Sorry it was late, I meant lowpass. The filter I made is supposed to have a 1KHz cutoff. What to you reccomend?

The author of the project e-mailed me back and said it is quantization noise which will be more significant with low sound levels. I know nothing about this so any help is greatly appreciated.
Logged

Manchester (England England)
Online Online
Brattain Member
*****
Karma: 627
Posts: 34229
Solder is electric glue
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

Quantization noise comes about because of the difference between the real analogue level and the one you get as a result of digitising the analogue. This is reduced by using more bits in the analogue to digital converter or the digital to analogue converter at the output end.
Without adding extra hardware there is little you can do about this. The output is only 8 bits because of the way it uses PWM where as the input is 10 bits from the A/D converter. So you can add a D/A on the back end and reduce this a bit. However the best way is to use one with an SPI interface. There is one in the Lady Ada wave shield. I have used this in my "translator" for the Maker fair in Rome.
http://youtu.be/pL0pMAPkkVw
The schematic of the audio out bit is attached.


* D-A.png (11.22 KB, 470x193 - viewed 207 times.)
Logged

Offline Offline
Sr. Member
****
Karma: 0
Posts: 351
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

DC_Offset in this code is the Offset value used to make it a ONLY POSITIVE values for the pwm ( as its easier to work with this kind of signal calculations mimicking nature's laws ... ) As PWM will only work with values up to 255 the middle point is 127( a wave travels between +1 and -1 , with ZERO being the middle point). Does that make more sense ?! So DC_Offset is the value that offsets the result into a positive number( or zero), which is also the same as the value for the amplitude calculations( did you notice is also 127?! dc_offset +127= space wherethe wave will travel...its a cheap way of calculating it in the discrete domain ).
Hope it helps!
I tried to break down some of the techniques here. Hope it helps complement it a bit !
http://dubworks.blogspot.co.uk/p/blog-page.html
« Last Edit: October 28, 2013, 03:44:18 pm by iyahdub » Logged

10 LET Loop=Infinite
20 GO TO 10

Offline Offline
Jr. Member
**
Karma: 2
Posts: 97
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

that sounds pretty good.  if you want a reference design for aliasing filters, here is one that works pretty well.
http://wiki.openmusiclabs.com/wiki/StompShield

there is a sound sample on there as well, so you can see if it will be any improvement over what you have.
Logged

VIT, Vellore
Offline Offline
Newbie
*
Karma: 0
Posts: 2
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

On compiling the program given in 'arduino_audio_loopback' i am getting an error as " TCCR2A not declared" . plz hlp...
Logged

Pages: [1] 2   Go Up
Jump to: