Processing Sound Library doesn't work

I wanted to implement some music into my game, and everything actually works, but when I start the programm it takes about 12 seconds until the standard grey background disappears, and I keep getting the following message in my code. Why does that happen?

Okt 27, 2018 5:20:49 PM com.jsyn.devices.javasound.JavaSoundAudioDevice <init>
INFORMATION: JSyn: default output latency set to 80 msec for Windows 10
Okt 27, 2018 5:20:49 PM com.jsyn.engine.SynthesisEngine start
INFORMATION: Pure Java JSyn from, rate = 44100, RT, V16.8.0 (build 463, 2017-10-16)
Okt 27, 2018 5:20:58 PM com.jsyn.engine.SynthesisEngine$EngineThread run
INFORMATION: JSyn synthesis thread in finally code.

This is my code:

import processing.sound.*;

SoundFile laserSound;
SoundFile music;

laserSound = new SoundFile(this, "laser.mp3");
music = new SoundFile(this, "music.mp3");;

Also I’m new here so it’s probably something stupid :wink:

1 Like

I think the problem is that you are trying to start the music at the wrong time.
Processing sketches have 3 different time periods: first one is initializing stuff, second one is everything that happens in setup(), and third is the draw() cycle.

It’s generally advised to initialize objects and do anything only inside of setup(), or draw() (or any other function that you define), but not in the initializing stage. I think that replacing your code with this should make it work:

import processing.sound.*;

SoundFile laserSound;
SoundFile music;

void setup(){
  laserSound = new SoundFile(this, "laser.mp3");
  music = new SoundFile(this, "music.mp3");;

Sorry, forgot to put setup into the example code :sweat_smile: everything below the variables is in void setup().

Okay so I changed the file type from mp3 to wav and now it starts way faster, but the message is still the same…

Also I just found out that the problem seems to be acuring when the variables are initialized.

I‘m not 100% sure, But what you See as a Problem is probably only Information you Receive from the library. Though usually this is more like : this.library initiallized correctly and is working Fine
Or something similar.

1 Like

Maybe… Altough it’s written in red…? :sweat_smile: That probably doesn’t mean anything in Programming, does it? :stuck_out_tongue:

Well, you can test it by only having the Import Statement and setup() and draw() without any initialization. And if that doesn‘t do anything, add the init, then the .play to See When it Starts Sendung this message

I did that before. It starts as soon as I initiallize the variables.

And you are sure that those are the required variables?

The soundFile variables :stuck_out_tongue:

It‘s the Jsyn library from philburk, right?

It’s the official one from the Processing Foundation…? :sweat_smile:

There‘s no such constructor as (this, soundfile), But i‘ll take a closer Look at it.
// ignore that xD got the wrong one

Okay XD Thanks for taking a closer look XD

Okay, I tried first initializing the laser variable, then the music variable. It gave me the same output with the same amount of lines eventough i was only initializing (god I hate this word) one word at a time. That’s at least something right? XD

Ok, i took a quick Look at the Source Code for the library, but the constructor only Prints 2 error Messages and only in case of files not found (which are „unable to find/decode“) so there shouldn‘t be a Problem. Do the Sounds Play or is the Message the only Problem?

By the way, it is the jsyn library from philburk.
Here‘s where the first Message is generated

You can find the reason for the other messages by following their relative Path. You can See it in the Message Text.
Should‘ve tried to look for that earlier :sweat_smile:

Both sounds play without any trouble.

Following their relative path? How do I do that? And how’s that going to help me? :sweat_smile: Should I look thnigs like “com.jsyn.engine.SynthesisEngine” up in the code of the library?

You See the com.devices.javasound.javasoundAudioDevice Text in the first line? The Same is in all 3 Lines Starting with Dates. Just follow the Same path in GitHub and you can See what the error says in the constructor of the class you found. In any case, you don‘t have to do that, since i did it yesterday and as i said, Theres no Problem. The Text appears When the constructor is loaded successfully. So you don‘t have to sorry about it. It‘s just what the library does. Just ignore it. Or if it really annoys you, you can try to change it in the library, But i wouldn‘t recommend doing so :sweat_smile: