Beginner who is desperate for help! Audio keeps crashing

edited June 2017 in Library Questions

Im completely new to processing and am in a desperate need for help.. Each time I click my mouse, the sound file doesnt not play and it all crashes; with a error stating :

Error: Soundfile doesn't exist. Pleae check path java.lang.NullPointerException at processing.sound.SoundFile.channels(Unknown Source) at processing.sound.SoundFile.play(Unknown Source) at POSSIBLYNEEDSSOUND.mousePressed(POSSIBLYNEEDSSOUND.java:79) at processing.core.PApplet.mousePressed(PApplet.java:2759) at processing.core.PApplet.handleMouseEvent(PApplet.java:2692) at processing.core.PApplet.dequeueEvents(PApplet.java:2609) at processing.core.PApplet.handleDraw(PApplet.java:2450) at processing.awt.PSurfaceAWT$12.callDraw(PSurfaceAWT.java:1547) at processing.core.PSurfaceNone$AnimationThread.run(PSurfaceNone.java:316)

If someone can please help that would be greatly appreciate. Thanks

import processing.sound.*;

SoundFile tone;

void setup(){ size(1300,1300); noFill(); background(0); smooth();

tone = new SoundFile(this, "sample.mp3");

}

void mousePressed(){

tone = new SoundFile(this, "sample.mp3");

//tone.play();

}

void mouseReleased(){

//tone.stop();

}

Tagged:

Answers

  • edited June 2017 Answer ✓

    Can any forum goer confirm if this code works in your machine? It doesn't work in mine, Processing 3.3.3 and Win 10. After confirmation, i could do a follow up in github.


    @geelad7

    Please edit your post (gear icon in the top right corner of your post), select your code and hit ctrl+o to format your code. Make sure there is an empty line above and below your code.

    You need to make sure you have the mp3 file in the proper folder. When you are in the Processing IDE, open your sketch and then hit ctrl+k. This will open a window showing your folders. This folder is called the sketch folder (of your current sketch) In that folder, you need to have a folder named data and inside this folder you put your mp3 file. Is that what you did?

    Now, I confirm this code doesn't work. You will need to use the minim library. I have provided a sample code below.

    Kf

    import ddf.minim.*;
    
    Minim minim;
    AudioPlayer song;
    
    void setup() {
      minim = new Minim(this);
      song = minim.loadFile("sample.mp3");
      //song.play();
    }
    
    void draw() {
    }
    
    void mousePressed() {
      song.play();
    }
    
    void mouseReleased() {
      song.pause();
    }
    
  • edited June 2017 Answer ✓

    Soundfile doesn't exist. Please check path

    Have you checked the path? The more file should be in the data directory within your sketch folder. You can drag and drop it or add it via the menu option. The filename should match exactly.

Sign In or Register to comment.