# Analyzing two SoundFile objects at the same time

**URL:** <https://discourse.processing.org/t/analyzing-two-soundfile-objects-at-the-same-time/14616>\
**Category:** Libraries\
**Created:** [October 11, 2019, 4:59pm UTC](https://discourse.processing.org/t/analyzing-two-soundfile-objects-at-the-same-time/14616 "2019-10-11T16:59:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Brunehilde](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/brunehilde/32/6387_2.png) [@Brunehilde](https://discourse.processing.org/u/Brunehilde)\
**Post date:** [October 11, 2019, 4:59pm UTC](https://discourse.processing.org/t/analyzing-two-soundfile-objects-at-the-same-time/14616/1 "2019-10-11T16:59:54Z")

</div>

Hi there, I was setting up a test scene to, well, test stuff, when I stumbled across this problem : it would seem that I can’t analyze two SoundFile objects at the same time. I’ve tried with a WhiteNoise and an AudioIn and it works well with those, but using two SoundFile seems to make the sound library pouty. Here’s a simplified version of the code:

```auto
int bands = 512;
float[] lS = new float[bands];
float[] rS = new float[bands];
FFT lFft;
FFT rFft;
SoundFile left;
SoundFile right;

void setup()
{
  /*Things that weren't of particular interest were omitted*/
  lFft = new FFT(this, bands);
  rFft = new FFT(this, bands);

  left = new SoundFile("left.wav");
  left.play();
  right = new SoundFile("right.wav");
  right.play();

  lFft.input(left);
  rFft.input(right);
}

void draw()
{
  background(255);
  lFft.analyze(lS);
  rFft.analyze(rS);
  
  for(int i = 0; i < bands; i++)
  {
    line(i, height, i, height - lS[i]*height*5 );
    line(i, 0, i, rS[i]*height*5);
  } 
}

```

The output, which should consist of moving black lines at the top and bottom, ends up looking like this:

 ![image](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/3/361ca1aa672ab6dee2919f8116029650ef011e6d.png)  
Thanks in advance for your help 🙂

---

<div class="post-metadata">

**Author:** ![norsob](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/norsob/32/5726_2.png) [@norsob](https://discourse.processing.org/u/norsob)\
**Post date:** [October 11, 2019, 6:38pm UTC](https://discourse.processing.org/t/analyzing-two-soundfile-objects-at-the-same-time/14616/2 "2019-10-11T18:38:37Z")

</div>

did you include “size”. in setup?

---

<div class="post-metadata">

**Author:** ![Brunehilde](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/brunehilde/32/6387_2.png) [@Brunehilde](https://discourse.processing.org/u/Brunehilde)\
**Post date:** [October 11, 2019, 7:11pm UTC](https://discourse.processing.org/t/analyzing-two-soundfile-objects-at-the-same-time/14616/3 "2019-10-11T19:11:32Z")

</div>

Yep, else I wouldn’t have a visual output at all, that’s why I omitted it.

---

<div class="post-metadata">

**Author:** ![kll](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/kll/32/964_2.png) [@kll](https://discourse.processing.org/u/kll)\
**Post date:** [October 11, 2019, 8:25pm UTC](https://discourse.processing.org/t/analyzing-two-soundfile-objects-at-the-same-time/14616/4 "2019-10-11T20:25:20Z")

</div>

actually here no problem:

 ![Sound_FFT_2songs](https://canada1.discourse-cdn.com/flex036/uploads/processingfoundation1/original/2X/c/c08929fa45fc6367ca53431ce00b83a14e0ddd52.png)

but i used .loop() ? your song 2 is short?
