Reputation: 85
I have a bit of code that is supposed to play a music file when run.
import processing.sound.*;
SoundFile soundtrack;
void setup(){
soundtrack = new SoundFile(this, "space_music.wav");
//soundtrack.play();
}
void draw(){}
When I run the code, the rest works fine except for the soundtrack initialization. An error message pops up that says
Error: Soundfile doesn't exist. Pleae check path
When I uncomment the soundtrack.play(), the code just straight up refuses to run. This also happens when the soundtrack.play() is in the draw loop. I double checked to make sure the file names match. Am I doing something wrong?
Upvotes: 2
Views: 6686
Reputation: 21
Hey you need to create a dir(folder) named "data" in the same dir(folder) of your .pde file
Upvotes: 0
Reputation: 88
First, you need to make sure you are using the latest software and Sound Library from processing.
Adding sound library from processing using Sketch > Import Library... > Sound is the best to make sure all is correct and library is installed properly.
Then you must specify the full path or the directory or location of the sound file. You can't just add "space_music.wav". You have to completely put the exact location of that file.
example: Your processing .pde file is on
C:\My Documents\Processing\project_1\project.pde
and your sound file is on
C:\My Documents\Processing\project_1\soundfile.mp3
Then you have to write
soundtrack = new SoundFile(this, "C:\My Documents\Processing\project_1\soundfile.mp3");
Upvotes: 0
Reputation: 88
You need to install the sound library first.
Sketch > import library... > search for sound > install sound library
Upvotes: 1