Trouble With Sound File

#1
    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.

1 Like
#2

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 ,
can help.

2 Likes
#3

Also, even more importantly, the lines

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

1 Like