Sound analysis?

Spec.

Using the Processing Sound library,

  • code:

Configure a high quality sample.
Initiate recording.
Generate a pulse / sine wave @ hz for time.
Stop recording for time.
Display waveform (scalable)

Purpose.

Analysis of:

Impulse delay matching between L/R external drivers.
Adjusting impulse delay / amplitude of L/R / levels real-time via displayed waveform.
Matching impulse phase / delay / amplitude between L/R and Sub.

Can anyone make a start on this?? …

Irigima.

Hi @IRIGIMA and welcome back to the forum!

I encourage you to share what you’ve already tried, even if it’s just a small test sketch or a first attempt. That way others can understand where you’re stuck and give you more useful feedback.

(Raphaël)

1 Like
import processing.sound.*;

AudioIn mic;
Waveform waveform;


int samples = 1500;
int flag=0;
int px;

float sensitivity = 0.02;
float p, p1, p2;

void setup() {
  size(500, 500);
  background(0);
 
 frameRate(120);
 
  Pulse pulse;
  pulse=new Pulse(this);
  pulse.play(20,1);

  // Initialize mic input
  mic = new AudioIn(this, 0);
  mic.start(); // Start capturing, but not playing back

  // Set up waveform analyzer with desired sample count
  waveform = new Waveform(this, samples);
  waveform.input(mic);
}

void draw() {
  background(0);
  stroke(0, 255, 0);
  noFill();
 
 

  // Analyze current audio buffer into waveform.data
  waveform.analyze();
 
  flag=0;
  px=0;

  // Draw waveform points
  beginShape();
  for (int i = 0; i < (width-1); i++) {

   
    p1=abs(waveform.data[i]);
    p2=abs(waveform.data[i+1]);
    p=abs(p1-p2);
   
    if(p>=sensitivity){
    flag=1;
    }
   
    if(p<sensitivity){
    p=0;
    }
   
    else{
    p=p1;
    }
   
    if (flag==1){
      px=px+30;
    }
   
    float y =height/2-(p*2000);
   
    vertex(px, y);
  }
 
 
    endShape();

}

Current code:

1: Emits / generates short impulses through both left and right speakers simultaneously (mono) at given Hz from a true pulse waveform.
2: Samples and displays output from (1) using a trigger val eliminating any unwanted background noise.
3: Shows amplitude of (2) from input mic, including reflections / pulsed wave interference (constructive / de-constructive).
4: Constructive will result in higher output peaks (meaning (1) is left / right is in phase, de-constructive - left / right is out of phase (lower output peaks). (Adjusting left / right speaker placement / distance will ensure phase matching)
(Additional peaks will show reverb / reflections from (1) )

Hopefully makes sense??
Needs the Sound library to function, so testing will need installation).

Thanks,
Irigima.