Audio Shield: LineIN glitches when capturing audio (audio block data has spikes)

Status
Not open for further replies.

superslot

Member
Hi,
I have a very naive question but I can't find a answer so far... so .. looking for some help from the experts
:)

I have a Teensy3.1 with the Audio Shield.
I setup the board as from the examples, my purpose is to capture audio at 44.1 from LineIN.
I don't need audio out.

Code:
  // Enable the audio shield and set the input/output volume.
  audioShield.enable();
  audioShield.adcHighPassFilterDisable();
  
  audioShield.inputSelect(AUDIO_INPUT_LINEIN);
  audioShield.lineInLevel(0,1); //2.2Vpp
    
  audioShield.autoVolumeDisable();
  
  //don't need audio output, mute level
  audioShield.volume(0);

I noticed weird gliches on the audio in, so I connected BOTH the L+R to GND with a wire and I simply run one printf in the main loop

Code:
  HWSERIAL.println(peak1.read() ,DEC);

I was expecting a flat value, but I see something weird:
from time (in a somewhat regular pattern...) I get a zero value (sort of)
...
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
0.0001220
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
0.0000915
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
-1.0000000
0.0001220
-1.0000000


is this correct?
since the input is grounded I was not expecting these glitches.
maybe I did setup the shield in a wrong way?

Note: I did this test because when capturing audio I cannot get a "clean" signal,
I have always some spike at regular intervals on the input stream, seems to be every 256 samples or so...
:-(


I have no peripherals connected,
just the usb cable to my laptop.
 
interesting ... apparenlty adding a small delay on the main loop makes the peak results clean (but I still need to fix the audio in)

Code:
  HWSERIAL.println(peak1.read(),DEC);
  delay(10);

If I use a value smaller than 10. ... same problem.
:-(
 
I think that there's a little misunderstanding about how the peak object works. The peak object is set up to calculate the difference between the maximum sample and the minimum sample in the last audio block (128 samples). After you've read the peak value for a given block, the read() method will return -1 until a the peak value for a new block is available. What you're seeing is the peak to peak noise signal (results with are very close to 0) whenever the peak object has analyzed a new block, and then -1 until the next block is analyzed.

If you want to look at the raw audio data, the queue object is more what you're looking for.
 
Status
Not open for further replies.
Back
Top