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 www.softsynth.com, 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");
music.play();
Also Iām new here so itās probably something stupid
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");
music.play();
}
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.
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
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
Following their relative path? How do I do that? And howās that going to help me? 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