0

I've been trying to add some music to a sketch I'm making, unfortunately a sound library error keeps popping up saying it's unable to find the file even though my sound files are in the data folder, have the same name and doesn't seem to have syntax errors.

import processing.sound.*;
SoundFile[] backMusic = new SoundFile [4];
PImage[] dnFrames = new PImage[10];
int sIndex = 0;
int musicIndex = 0;
String[] credits;

void setup() {
  size(800, 800);
  frameRate(15); 
  backMusic [0] = new SoundFile(this, "00.mp3");
  backMusic [1] = new SoundFile(this, "01.mp3");
  backMusic [2] = new SoundFile(this, "02.mp3");
  backMusic [3] = new SoundFile(this, "03.mp3");
  backMusic[musicIndex].play();
  
  PImage dn = loadImage("spritesheet.png");
  dn.resize(3000, 600);
  for(int n = 0; n < 10; n++){
    dnFrames[n] = dn.get(n*dn.width/10, 0, dn.width/10, dn.height);
  }
  credits = loadStrings("Credits.txt");
  textSize(40);
}

void draw() {
  if(frameCount < 250)
    sceneOne(frameCount);
  else
    sceneTwo(frameCount - 250);    
}

void keyPressed() {
  if(key == 'm' || key == 'M') {
    musicIndex = musicIndex + 1;
    }
  }  

The error looks like this:

May 12, 2022 9:50:18 PM com.jsyn.devices.javasound.JavaSoundAudioDevice <init>
INFO: JSyn: default output latency set to 80 msec for Windows 10
Sound library error: unable to find file 00.mp3
Sound library error: unable to find file 01.mp3
Sound library error: unable to find file 02.mp3
Sound library error: unable to find file 03.mp3
NullPointerException
NullPointerException
NullPointerException
NullPointerException
NullPointerException
NullPointerException
Could not run the sketch (Target VM failed to initialize).
For more information, read Help ? Troubleshooting.

I do have two other tabs but they have nothing to do with the sound files.

maryam
  • 1
  • 1
  • Better to load your files/images as resources: https://technojeeves.com/index.php/aliasjava1/78-loading-files-as-resources-in-java-with-netbeans https://technojeeves.com/index.php/aliasjava1/80-loading-files-as-resources-in-java-with-eclipse – g00se May 12 '22 at 20:02
  • Sorry about that, I tried using wav files before to see if it would work and once it didn't I came here, I had only changed the code back and didn't run it again. I've changed it now. – maryam May 12 '22 at 20:52
  • Strange, I was expecting data folder to work. Does it work if you have the .mp3 files one folder up (in the main sketch folder) ? – George Profenza May 12 '22 at 23:27
  • Nope, not even then – maryam May 13 '22 at 07:15

0 Answers0