# Sound analysis?

**URL:** https://discourse.processing.org/t/sound-analysis/47060
**Category:** Libraries
**Created:** [August 31, 2025, 10:23pm UTC](https://discourse.processing.org/t/sound-analysis/47060 "2025-08-31T22:23:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![IRIGIMA](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/irigima/32/8951_2.png) [@IRIGIMA](https://discourse.processing.org/u/IRIGIMA)
#### Post date: [August 31, 2025, 10:23pm UTC](https://discourse.processing.org/t/sound-analysis/47060/1 "2025-08-31T22:23:29Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![ProcessingOrg](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/processingorg/32/18341_2.png) [@ProcessingOrg](https://discourse.processing.org/u/ProcessingOrg)
#### Post date: [September 1, 2025, 9:48am UTC](https://discourse.processing.org/t/sound-analysis/47060/2 "2025-09-01T09:48:20Z")

</div>

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)

---

<div class="post-metadata">

### Author: ![IRIGIMA](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/irigima/32/8951_2.png) [@IRIGIMA](https://discourse.processing.org/u/IRIGIMA)
#### Post date: [September 6, 2025, 12:41am UTC](https://discourse.processing.org/t/sound-analysis/47060/3 "2025-09-06T00:41:52Z")

</div>

```auto
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();

}

```

---

<div class="post-metadata">

### Author: ![IRIGIMA](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/irigima/32/8951_2.png) [@IRIGIMA](https://discourse.processing.org/u/IRIGIMA)
#### Post date: [September 6, 2025, 1:15am UTC](https://discourse.processing.org/t/sound-analysis/47060/4 "2025-09-06T01:15:39Z")

</div>

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.
