Repetitive click

Status
Not open for further replies.

GeppettoLab

Active member
Hi!
I have a little problem with my software.
I use Teensy 3.1 and audio board, acquiring the audio signal from a condenser Mic and a. From the main out of this one I go in the Line input of the audio board, trough a jack, connecting the 3 wires ( + - and GND).
I compute an FFT and i sum the values of the different bins in four different ranges. With this values I control the amplitude of 4 frequency (under 20Hz) and trough the headphones jack I go in an amplifier that control a big woofer.
In this way I convert the audio frequencies in infrasound frequency that can be seen in the movement of the subwoofer.
It's great, it works well, with huge movements but...
If I start the sketch the subwoofer is silent and respond correctly to my inputs, but when the input signal clips (I can control it from the mixer leds) the sub start to emit a repetitive click ( 4 for second) and doesn't stop until I restart the sketch.
And when I make noise in the Mic, the resulting movement of the subwoofer produces a distorted audio that is well percivable and it's very similar to the input (but it should be produced only that infrasound frequency!)
Have you an idea of which problem can be?
I think that for some frequency leaking I perceive this last noise but that cannot explain the repetitive click.
I suppose it can be an amplitude problem but reducing the output the clik is still there.
Can you help me?

This is the code in which I analyze only the first bin sum and produce only one frequency
Code:
#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

const int myInput = AUDIO_INPUT_LINEIN;
//const int myInput = AUDIO_INPUT_MIC;

// Create the Audio components.  These should be created in the
// order data flows, inputs/sources -> processing -> outputs
//
AudioInputI2S          audioInput;         // audio shield: mic or line-in
AudioSynthWaveformSine sinewave2;
AudioSynthWaveformSine sinewave6;
AudioSynthWaveformSine sinewave10;
AudioSynthWaveformSine sinewave14;


AudioSynthWaveformSine *sinewaves[4]={&sinewave2,&sinewave6,&sinewave10,&sinewave14};
AudioAnalyzeFFT1024    myFFT;
AudioMixer4            mixer1;
AudioOutputI2S         audioOut;        // audio shield: headphones & line-out

// Connect either the live input or synthesized sine wave
AudioConnection patchCord1(audioInput, 0, myFFT, 0);
AudioConnection patchCord2(sinewave2, 0, mixer1, 0);
AudioConnection patchCord3(sinewave6, 0, mixer1, 1);
AudioConnection patchCord4(sinewave10, 0, mixer1, 2);
AudioConnection patchCord5(sinewave14, 0, mixer1, 3);

AudioConnection patchCord6(mixer1, 0, audioOut, 0);

AudioControlSGTL5000 audioShield;

int fib[5] = {3,13,55, 200, 233};
float smo[4] = {0.00,0.00,0.00,0.00};
float inc = 0.01;
float gainMix = 0.1;


void setup() {
  // Audio connections require memory to work.  For more
  // detailed information, see the MemoryAndCpuUsage example
  AudioMemory(12);

  // Enable the audio shield and set the output volume.
  audioShield.enable();
  audioShield.inputSelect(myInput);
  audioShield.volume(0.9);
  audioShield.lineInLevel(1);
  audioShield.lineOutLevel(13);
  audioShield.unmuteLineout();

  // Configure the window algorithm to use
  myFFT.windowFunction(AudioWindowHanning1024);

  sinewave2.frequency(20);
  sinewave6.frequency(11);
  sinewave10.frequency(15);
  sinewave14.frequency(20);

  sinewave2.amplitude(0.0);
  sinewave6.amplitude(0.0);
  sinewave10.amplitude(0.0);
  sinewave14.amplitude(0.0);

  
  mixer1.gain(0,gainMix);
  mixer1.gain(1,gainMix);
  mixer1.gain(2,gainMix);
  mixer1.gain(3,gainMix);
  
}

void loop() {
  float n;
  float m;
  int i;
  int y;

  if (myFFT.available()) {
    // each time new FFT data is available
    // print it all to the Arduino Serial Monitor
    Serial.print("FFT: ");
    for (i=0; i<1; i++) {
      m=0;
      for (y=fib[i]; y<fib[i+1]; y++) {
        m = m + myFFT.read(y);
      }
      n = m-inc;
      if (n >= 0.01) {
        Serial.print("| ");Serial.print(n); Serial.print(" - ");
        if (smo[i]<n){
          smo[i] += inc;
        }else if (smo[i]>n){
          smo[i] -= inc;
        }
        //smo[i]=n;
        Serial.print(smo[i]);
        Serial.print(" ");
        sinewaves[i]->amplitude(smo[i]);
      } else {
          if(smo[i] != 0) smo[i] -= inc;
          if(smo[i] <0) smo[i] = 0;
          Serial.print("| ");Serial.print(n); Serial.print(" - ");
          Serial.print(smo[i]); // don't print "0.00"
          Serial.print(" ");
          sinewaves[i]->amplitude(smo[i]);
      }
    }
    Serial.println();
  }
}

Thanks!!
Luca
 
In these days I tried more my software. I excluded three sinusoids, using only the 8 HZ sine, and I excluded the relative mixer gains.
In these way i can perceive a scratching noise, as before not related to the volume of the audio input but lower than before.
I notice that this noise is produced only when the amplitude of the sine waves moves from a value to another, expecially when it is low (if the amplitude stay to 1 the noise is not present).
I supposed that this noise can be related to the stepped variation of the amplitude. I modify the inc variable from 0.01 to 0.007 (to mantain a visible response of the subwoofer to the signal variation) and noise was reduced but not eliminated.
Then I tried the same hardware with the ToneSweep example to exclude an hardware problem.
In this way the noise is not present (but in the Tone Sweep example there isn't an amplitude variation.

Then, could be this variaton that produce the noise? How can i fix it?

Moreover, when I tried the ToneSweep example I had connected the teensy in the same way as before. During the sweep I clapped my hands near the Mic causing a clip of the audio input and the subwoofer start to produce the repetitive click!! Even if the software doesn't consider the audio input!
How it can be possible? Is that a problem of the audio input itself?

Thanks
Luca
 
I modified the AudioMemoryUsageMax() with no results. I still have these problems..
After all the other tests (even some example), i have that click when i clap in the mic and a scratch to volume variation.

Suggestions?
 
The SGTL5000 chip that is the heart of the Teensy Audio Board has a bunch of features that often have bad side-effects. One such feature that is problematic is the built-in high-pass filter that gets applied by the SGTL5000 to the mic and line inputs. In my opinion, it has all sorts of problems. For me, I find that it adds all sorts of noise to the system. I bet that it also responds strangely if you saturate/clip the input signal. I don't like it at all.

I would suggest that you disable this filter and see if it affects your problem in any way. Maybe it'll have no effect, maybe it'll have a huge effect. Give it a try and see what you find.

The command that you want to add is: audioShield.adcHighPassFilterDisable(); You should put it in your setup(), maybe like this:

Code:
  // Enable the audio shield and set the output volume.
  audioShield.enable();
  audioShield.inputSelect(myInput);
  audioShield.volume(0.9);
  audioShield.lineInLevel(1);
  audioShield.lineOutLevel(13);
  audioShield.adcHighPassFilterDisable();  // THIS HERE IS THE ADDED LINE!!!
  audioShield.unmuteLineout();

Good luck,

Chip
 
Thanks for the hint, but it doesn't work.
There is no significative change.
I will try to modify again some parameters.
 
Hi, I used the dacVolumeRamp().
The click problem seem to be resolved, and the noise at low level is reduced (but not resolved).
I will try to change my woofer!
 
Status
Not open for further replies.
Back
Top