Go Down

Topic: Arduino Realtime Audio Processing (Read 47826 times) previous topic - next topic


Hi Brandon,
i just want to try to give some answers to your questions

1. 8/10 Bit ADC
at higher sampling rates the accuracy of the ADC decrease ( the datasheet says so but what resolution at what samplerate is not clear) but we can use 8 bit only anyway because int arithmetic and storing int sample values would be to slow and the space in ram is limited anyway

2. PORTB = PORTB | 1
 this is a faster substitution for digitalWrite(pin8 , Hi); it was just for debugging purposes , i connectet a scope to that pin to observe the timeing of the interrupt process.

3.  div32  
i did not use  the ADC interrupt here, the timer 2 controls the ADC speed. we have a PWM output on timer2 so sampling and DAC output is synchronized to PWM. div32 divides the 62 KHz interrupt by 2 div 16 again by two to sample channel 0 and 5 alternately so we have a effective sample rate of 15 KHz per channel.



Hey folks.  First off, thanks for all the great work so far.  I'm excited to see how this ends up.  I've actually gotten my setup working sort of.   ;)  

I couldn't seem to get any op-amp setup to work.  Tried LM741s and 201s and nothing I did seemed to work.  I was about to buy new parts on the assumption that mine were shot when I just tried running the guitar through a cap with a 2.5V offset.  This worked.  Here's a pic of what I did:

The output side of the Arduino is just the 8-bit DAC from earlier with a 20K to GND off pin0 not the 10K that's displayed.

Here's a sample of audio I recorded quickly:

My question is where is that static/artifacting coming from?  Is it the clock from the DAC in the audible spectrum?  I didn't notice static when I was testing the DAC with code from the shield page, though the output was pretty high when playing back a sine wav.  Is the ADC getting junk from running the guitar in the way I am?  Also the signal attenuation is pretty bad.  I lose maybe 30% of my volume playing through this thing.  I assume the volume loss is due to not actively buffering through an op-amp, so I'll try to get one to work next, I just wanted to make sure everything was functioning.


petyrstretz, I think the cap placed where it is is removing the DC offset before it gets to the Arduino, meaning your audio is going above and below Ground. Since Arduino's analog ins can't "see" below ground, this would clip your waveform in half. This accounts for both the attenuation and the noise (though I would actually expect a lot more noise, so I might be wrong).

You might be better off turning the circuit around, putting the cap on the input side and the DC offset on the Arduino side of the cap.


mattgilbertnet, you are absolutely right.  Must have been sleeping sitting up.  ;)  OK, so I rearranged the cap so it was on the guitar side and switched to 510K resistors as the 100K ones were cutting the input signal of the guitar down.  I also added a 4.7uF electrolytic cap to the output to remove the offset before sending it into my sound card.  The issue I now have is, besides the output still being staticy, is there is a big loss in the peak to peak of the input vs. the output.  See the scope output below:

Trace A is the DAC output, at the jack
Trace B is the input at the ADC, you can see the 2.5V offset now, though it's more like 2.2V

Is this loss due to code?  Am I still driving the ADC wrong?  I looked at the datasheet and nothing really jumped out at me.  Also should the output be inverted?


I took a couple more scope shots.  it seems the sound input of my Macbook is loading down the DAC output. A is the input, B is the output.
Scope shot with circuit connected to laptop input:

Scope shot at output with line-in disconnected:

I'll have to try and buffer the output but it's still half the PtP of the input.

Go Up