# Trouble With Sound File

**URL:** <https://discourse.processing.org/t/trouble-with-sound-file/9491>\
**Category:** Libraries\
**Created:** [March 20, 2019, 6:53pm UTC](https://discourse.processing.org/t/trouble-with-sound-file/9491 "2019-03-20T18:53:54Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mahubis](https://avatars.discourse-cdn.com/v4/letter/m/7ea924/32.png) [@Mahubis](https://discourse.processing.org/u/Mahubis)\
**Post date:** [March 20, 2019, 6:53pm UTC](https://discourse.processing.org/t/trouble-with-sound-file/9491/1 "2019-03-20T18:53:54Z")

</div>

```
    float x;
    float x2;
    float theta =0;
    
    void setup() {
      size(600, 600);
    }
    
      void draw() {
      background(255);
    
      fill(0);
      strokeWeight(2);
      rect(30, 200, 100, 100);
      line(30, 200, 400, 200);
      line(50, 300, 400, 300);
      line(30, 300, 30, 450);
      line(30, 450, 400, 450);
      line(400, 200, 400,550);
      line(380,550,420,550);
      line(390,560,410,560);
      line(395,570,405,570);
      
      
            String s = "SOURCE";
            textSize(20);
      fill(255);
      text(s, 40, 240, 100, 100);
      
      fill(50);
              textSize(20);
      text("Signal+", 150, 145); 
      fill(50, 102, 153);
      fill(50);
      text("Signal -", 150, 375);
      fill(50, 102, 153, 51);
      fill(50);
      textSize(15);
      text("The source is split into two identical signals.", 10, 500);
      text("The negative signal is inverted to be fully", 10, 520);
      textSize(12);
      text("Here the negative signal.", 420, 100);
      text("is inverted again, which", 420, 120);
      text("causes phase cancelation", 420, 140);
      text("to be applied to the noises", 420, 160);
      text("on the positive & negative", 420, 180);
      text("lines, cleaning the output", 420, 200);
      text("signal", 470, 220);
      
      
      
      text(".", 10, 540);
      fill(50, 102, 153, 51);
      fill(50);
      text("Noise", 300, 100);
        fill(50, 102, 153, 51);
        textSize(32);
      fill(50);
      text("Balanced Cables Explained", 100, 60);
      

      fill(255);
      stroke(0);
      
      strokeWeight(5);
      
      beginShape(TRIANGLES);
    vertex(400,300);
    vertex(400,200);
    vertex(550, 250);
    endShape();
      
      line(381,551,421,551);
      line(391,561,411,561);
      line(396,571,406,571);
      
    
      fill(127);
      rect(260, 145, 150, 90); //grey rectangle 1
      
      rect(260, 245, 150, 90); //grey rectangle 2
      
      float lX=130;
      float lY=200;
      float lY2=300;
      float lX3=260;
      float lY3=300;
      //float lX4=260;
                      
      println(x);
      theta=theta +0.05;
      float y = theta;
      
      for (int i = 0; i<=13; i++) {
        x = sin(y);
        x2= -sin(y);

        line((i*10)+130, 200+(50*x), lX, lY);
        line((i*10)+130, 300+(50*x2), lX, lY2);
        line((i*10)+260, 200+(50*x), lX3, lY);
                                                   //line((i*10)+260, 300+(50*x), lX4, lY2);
        line((i*10)+260, 300+(50*x), lX3, lY3);
                        
        lX= (i*10)+130;
        lY = 200+(50*x);
        lY2 = 300+(50*x2);
        lX3 = (i*10)+260;
        lY3 = 300+(50*x);
        //lX4 = (i*10)+300;
        y+=.9;
        
        import processing.sound.*;
        SoundFile file;
        
        file = new SoundFile(this,"BUS RIDE.mp3");
        file.play();

```

Hi guys,

I’m trying to play this mp3 file but I keep getting this error message:  
Could not run the sketch (Target VM failed to initialize). For more information, read revisions.txt and Help ? Troubleshooting  
I updated my nvidia drivers as there was no option to rollback. Anyone know how to fix this?  
Thanks.

---

<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:** [March 21, 2019, 2:15am UTC](https://discourse.processing.org/t/trouble-with-sound-file/9491/2 "2019-03-21T02:15:19Z")

</div>

in your code possibly the last 2 } } are missing?

the last lines,  
4 lines about sound,  
you read ( load song from data/ ) and start a sound.  
but that is inside DRAW and inside a FOR 13

so you actually try to read and start that song 780 times per second.  
( what i think is that none of the 4 lines should be inside DRAW )

> as this question is about play a sound only, pls  
> play first in a extra little “project” to get that running.

and for your sinus i hope what i answered  
[Need Help Animating This Drawing](https://discourse.processing.org/t/need-help-animating-this-drawing/9446) ,  
can help.

---

<div class="post-metadata">

**Author:** ![kevinstadler](https://avatars.discourse-cdn.com/v4/letter/k/bc79bd/32.png) [@kevinstadler](https://discourse.processing.org/u/kevinstadler)\
**Post date:** [March 22, 2019, 5:26am UTC](https://discourse.processing.org/t/trouble-with-sound-file/9491/3 "2019-03-22T05:26:38Z")

</div>

Also, even more importantly, the lines

> [@Mahubis](#):
>
> import processing.sound.\*;  
> SoundFile file;

should come at the _very_ beginning of the file, even before the setup() method!
