# Song Code Not Running not sure how to fix

**URL:** <https://discourse.processing.org/t/song-code-not-running-not-sure-how-to-fix/6621>\
**Category:** Libraries\
**Created:** [December 15, 2018, 3:31am UTC](https://discourse.processing.org/t/song-code-not-running-not-sure-how-to-fix/6621 "2018-12-15T03:31:57Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![starkid](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@starkid](https://discourse.processing.org/u/starkid)\
**Post date:** [December 15, 2018, 3:31am UTC](https://discourse.processing.org/t/song-code-not-running-not-sure-how-to-fix/6621/1 "2018-12-15T03:31:57Z")

</div>

I’m trying to get this code to run but I’m getting an error saying bufferSize does not exist and .in & .left cannot be recognized/exist. Not sure how to fix this error any suggestions? I’m trying to move the wave length according to the frequency of the shuffled song. Thanks. (put \*\* HERE for where I have errors)

```auto
//minim is the audio library allowing for us to play and pull the music in
import ddf.minim.*;
Minim minim;
AudioPlayer player;

boolean playeurInit = false;// que leplayer n'est pas lancé
boolean stop = true;
 
StringList tableau;
int current=0;

Star[] stars = new Star[100];
float speed;
color c;

int linesX = 40; 
int linesY = 26; 
float magnitude;
boolean voice = false;
float stepsX, stepsY, radius, intensity, movement, last_sum, scale, factor, wave, sum;

void setup() {
  fullScreen();
  noSmooth();
  

  for (int i = 0; i < stars.length; i++) {
     stars[i] = new Star(); 
}  
 
  
minim = new Minim(this);
 
  tableau=new StringList();
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
 
  shufflePlayList();
  String son = tableau.get(current++);
  println(son);
  player = minim.loadFile(son);
  player.pause();

**HERE
factor = float(width)/tableau.bufferSize();
}

noCursor just makes the cursor diappeared
void draw(){ 
  noCursor();
 

{ 
  speed = map(mouseX, 0, width, 0, 20);
  background(0);
  

  translate(width/2, height/2);
  

 for (int i = 0; i < stars.length; i++) {
   stars[i].update();
   stars[i].show();
}
}
 
 {

   translate(-width /2, -height /2); 
   c = color(170 + wave/2, wave*5, 255,255);
  fill(random(0,255), random(0,255), random(0,255));
   stroke(random(0,255), random(0,255), random(0,255));
   strokeWeight(2);
   sum = 0; 
   
**** HERE

  for (int i = 0; i < tableau.bufferSize() - 1; i++)
  {
    if (voice) {
      line(i*factor, height/2 + in.left.get(i)*last_sum + 1, i*factor+1, height/2 + in.left.get(i+1)*last_sum + 2);
      sum += abs(in.left.get(i));
    } else {
     line(i*factor, height/2 + tableau.left.get(i)*last_sum + 1, i*factor+1, height/2 + tableau.left.get(i+1)*last_sum + .05);
     sum += abs(tableau.left.get(i));
    }
  }
}

  last_sum = sum;
    {
     

  fill(random(0,255), random(0,255), random(0,255));

  ellipse(width /2, height /2, 500, 500);
  noStroke();
}

 {

  ellipseMode(CENTER);
  fill (0);
  ellipse(width /2 -50,height /2 -50, 460, 450);
  noStroke();
 }
{

   strokeWeight(2); 
}
if (!stop) {
 
    if (player.isPlaying() == false) {
 
      if (current==tableau.size()-1) {
        shufflePlayList();
      }
 
      String son = tableau.get(current++);
      player = minim.loadFile(son);
      player.play();      
      playeurInit = true;
    }
}
  }
  void mouseReleased() {
  if (stop == true) {
    stop = false;
  } else {
    stop = true;
    if (player.isPlaying() == true ) {
      player.pause();
    }
  }
}
 
void stop() {
  player.close();
  minim.stop();
  super.stop();
}
 
void shufflePlayList() {
  current=0;
  tableau.shuffle();
}

```

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [December 15, 2018, 9:40am UTC](https://discourse.processing.org/t/song-code-not-running-not-sure-how-to-fix/6621/2 "2018-12-15T09:40:07Z")

</div>

@starkid===  
there are a lot of errors in your code:

- your tableau is an array of String: bufferSize() does not mean nothing for it! - You have to apply buffersize() to your player: player.bufferSize()

- you cannot getlinein (left, right or mixed ) without importing minim audioInput and instantiating it:

`AudioInput in;`  
`in = minim.getLineIn(Minim.STEREO, 2048, 44100);`

---

<div class="post-metadata">

**Author:** ![starkid](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@starkid](https://discourse.processing.org/u/starkid)\
**Post date:** [December 15, 2018, 5:44pm UTC](https://discourse.processing.org/t/song-code-not-running-not-sure-how-to-fix/6621/4 "2018-12-15T17:44:42Z")

</div>

I imported minim audioInput and instantiated it and also changed it to bufferSize() but I’m still getting errors that I’m not sure how to fix. I’m getting an error saying that global variable left does not exist and an error saying expecting EOF, found “in”. For the EOF error I selected all my code and pressed CTRL T to format the code and try to find any extra or missing curly braces but I’m not sure where the error is for the braces. Any suggestions on how to fix them?

```auto
import ddf.minim.*;
AudioInput in;
Minim minim;
AudioPlayer player;

boolean playeurInit = false;
boolean stop = true;
 
StringList tableau;
int current=0;

Star[] stars = new Star[100];
float speed;
color c;

int linesX = 40; 
int linesY = 26; 
float magnitude;
boolean voice = false;
float stepsX, stepsY, radius, intensity, movement, last_sum, scale, factor, wave, sum;

in = minim.getLineIn(Minim.STEREO, 2048, 44100);

wave jagged
void setup() {
  fullScreen();
  noSmooth();
  

  for (int i = 0; i < stars.length; i++) {
     stars[i] = new Star(); 
}  
 
  
minim = new Minim(this);
 

  tableau=new StringList();
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
  tableau.append("PUT SONG NAME HERE.mp3");
 
  shufflePlayList();
  String son = tableau.get(current++);
  println(son);
  player = minim.loadFile(son);
  player.pause();
factor = float(width)/player.bufferSize();
}

void draw(){ 
  noCursor();
 

{ 
  speed = map(mouseX, 0, width, 0, 20);
  background(0);
  

  translate(width/2, height/2);

 for (int i = 0; i < stars.length; i++) {
   stars[i].update();
   stars[i].show();
}
}
 
 {

   translate(-width /2, -height /2); 
   c = color(170 + wave/2, wave*5, 255,255);
  fill(random(0,255), random(0,255), random(0,255));
   stroke(random(0,255), random(0,255), random(0,255));
   strokeWeight(2);
   sum = 0; 
   

  for (int i = 0; i < player.bufferSize() - 1; i++)
  {
    if (voice) {
      line(i*factor, height/2 + in.left.get(i)*last_sum + 1, i*factor+1, height/2 + in.left.get(i+1)*last_sum + 2);
      sum += abs(in.left.get(i));
    } else {
     line(i*factor, height/2 + tableau.left.get(i)*last_sum + 1, i*factor+1, height/2 + tableau.left.get(i+1)*last_sum + .05);
     sum += abs(tableau.left.get(i));
    }
  }
}

  last_sum = sum;
    {
     

  fill(random(0,255), random(0,255), random(0,255));

  ellipse(width /2, height /2, 500, 500);
  noStroke();
}

 {

  ellipseMode(CENTER);
  fill (0);
  ellipse(width /2 -50,height /2 -50, 460, 450);
  noStroke();
 }
{

   strokeWeight(2); 
}
if (!stop) {
 
    if (player.isPlaying() == false) {
 
 
      if (current==tableau.size()-1) {
        shufflePlayList();
      }
 
      String son = tableau.get(current++);
      player = minim.loadFile(son);
      player.play();      
      playeurInit = true;
    }
}
  }
  void mouseReleased() {
  if (stop == true) {
    stop = false;
  } else {
    stop = true;
    if (player.isPlaying() == true ) {
      player.pause();
    }
  }
}
 
void stop() {
  player.close();
  minim.stop();
  super.stop();
}
 
void shufflePlayList() {
  current=0;
  tableau.shuffle();
}

```

---

<div class="post-metadata">

**Author:** ![starkid](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@starkid](https://discourse.processing.org/u/starkid)\
**Post date:** [December 15, 2018, 5:58pm UTC](https://discourse.processing.org/t/song-code-not-running-not-sure-how-to-fix/6621/5 "2018-12-15T17:58:04Z")

</div>

I imported minim audioInput and instantiated it and also changed it to bufferSize() but I’m still getting errors that I’m not sure how to fix. I’m getting an error saying that global variable left does not exist and an error saying expecting EOF, found “in”. For the EOF error I selected all my code and pressed CTRL T to format the code and try to find any extra or missing curly braces but I’m not sure where the error is for the braces. Any suggestions on how to fix them? Thanks a ton!

```auto

import ddf.minim.*;
AudioInput in;
Minim minim;
AudioPlayer player;

boolean playeurInit = false;
boolean stop = true;

StringList tableau;
int current=0;

Star[] stars = new Star[100];
float speed;
color c;

int linesX = 40; 
int linesY = 26; 
float magnitude;
boolean voice = false;
float stepsX, stepsY, radius, intensity, movement, last_sum, scale, factor, wave, sum;

in = minim.getLineIn(Minim.STEREO, 2048, 44100);

void setup() {
  fullScreen();
  noSmooth();

  for (int i = 0; i < stars.length; i++) {
    stars[i] = new Star();
  }  

  minim = new Minim(this);

  tableau=new StringList();
  tableau.append("NAME OF SONG.mp3");
  tableau.append("NAME OF SONG.mp3");
  tableau.append("NAME OF SONG.mp3");
 tableau.append("NAME OF SONG.mp3");
 tableau.append("NAME OF SONG.mp3");
 tableau.append("NAME OF SONG.mp3");
 

  shufflePlayList();
  String son = tableau.get(current++);
  println(son);
  player = minim.loadFile(son);
  player.pause();
  factor = float(width)/player.bufferSize();
}

void draw() { 
  noCursor();

  { 
    speed = map(mouseX, 0, width, 0, 20);
    background(0);

   
    translate(width/2, height/2);

    for (int i = 0; i < stars.length; i++) {
      stars[i].update();
      stars[i].show();
    }
  }

  {

    translate(-width /2, -height /2); 
    c = color(170 + wave/2, wave*5, 255, 255);
    fill(random(0, 255), random(0, 255), random(0, 255));
    stroke(random(0, 255), random(0, 255), random(0, 255));
    strokeWeight(2);
    sum = 0; 

    for (int i = 0; i < player.bufferSize() - 1; i++)
    {
      if (voice) {
        line(i*factor, height/2 + in.left.get(i)*last_sum + 1, i*factor+1, height/2 + in.left.get(i+1)*last_sum + 2);
        sum += abs(in.left.get(i));
      } else {
        line(i*factor, height/2 + tableau.left.get(i)*last_sum + 1, i*factor+1, height/2 + tableau.left.get(i+1)*last_sum + .05);
        sum += abs(tableau.left.get(i));
      }
    }
  }

  last_sum = sum;
  {

    fill(random(0, 255), random(0, 255), random(0, 255));

 
    ellipse(width /2, height /2, 500, 500);
    noStroke();
  }

  {

    ellipseMode(CENTER);
    fill (0);
    ellipse(width /2 -50, height /2 -50, 460, 450);
    noStroke();
  }
  {

    strokeWeight(2);
  }
  if (!stop) {

    if (player.isPlaying() == false) {

      if (current==tableau.size()-1) {
        shufflePlayList();
      }

      String son = tableau.get(current++);
      player = minim.loadFile(son);
      player.play();      
      playeurInit = true;
    }
  }
}
void mouseReleased() {
  if (stop == true) {
    stop = false;
  } else {
    stop = true;
    if (player.isPlaying() == true ) {
      player.pause();
    }
  }
}

void stop() {
  player.close();
  minim.stop();
  super.stop();
}

void shufflePlayList() {
  current=0;
  tableau.shuffle();
}
}

```

---

<div class="post-metadata">

**Author:** ![akenaton](https://avatars.discourse-cdn.com/v4/letter/a/a88e4f/32.png) [@akenaton](https://discourse.processing.org/u/akenaton)\
**Post date:** [December 15, 2018, 6:04pm UTC](https://discourse.processing.org/t/song-code-not-running-not-sure-how-to-fix/6621/6 "2018-12-15T18:04:11Z")

</div>

@starkid====  
not time enough to look at your code in details (for eof)  
yet i can see at first sight that your way to instantiate in is wrong  
you have to write this line of code inside setup, && after minim is instatiated: ```

`minim = new Minim(this);`  
`in = minim.getLineIn(Minim.STEREO, 2048, 44100);`

```auto

```

```auto

```

---

<div class="post-metadata">

**Author:** ![starkid](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@starkid](https://discourse.processing.org/u/starkid)\
**Post date:** [December 15, 2018, 6:15pm UTC](https://discourse.processing.org/t/song-code-not-running-not-sure-how-to-fix/6621/8 "2018-12-15T18:15:08Z")

</div>

Oh right, I don’t know why I didn’t put it inside setUp. Got it to work now thanks a ton!
