# Processing Sound Library doesn't work

**URL:** https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928
**Category:** Libraries
**Created:** [October 27, 2018, 3:29pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928 "2018-10-27T15:29:36Z")
**Posts on this page:** 20
**Page:** 1

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 27, 2018, 3:29pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/1 "2018-10-27T15:29:36Z")

</div>

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?

```auto
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:

```auto
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 😉

---

<div class="post-metadata">

### Author: ![Architector\_4](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/architector_4/32/813_2.png) [@Architector\_4](https://discourse.processing.org/u/Architector_4)
#### Post date: [October 27, 2018, 3:54pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/2 "2018-10-27T15:54:55Z")

</div>

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:

```auto
import processing.sound.*;

SoundFile laserSound;
SoundFile music;

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

```

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 27, 2018, 7:48pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/3 "2018-10-27T19:48:23Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 27, 2018, 7:57pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/4 "2018-10-27T19:57:23Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [October 27, 2018, 7:59pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/5 "2018-10-27T19:59:58Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 27, 2018, 8:02pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/6 "2018-10-27T20:02:48Z")

</div>

Maybe… Altough it’s written in red…? 😅 That probably doesn’t mean anything in Programming, does it? 😛

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [October 27, 2018, 8:04pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/7 "2018-10-27T20:04:45Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 27, 2018, 8:06pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/8 "2018-10-27T20:06:09Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [October 27, 2018, 8:07pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/9 "2018-10-27T20:07:09Z")

</div>

And you are sure that those are the required variables?

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 27, 2018, 8:07pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/10 "2018-10-27T20:07:53Z")

</div>

The soundFile variables 😛

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [October 27, 2018, 8:09pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/11 "2018-10-27T20:09:18Z")

</div>

It‘s the Jsyn library from philburk, right?

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 27, 2018, 8:10pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/12 "2018-10-27T20:10:08Z")

</div>

It’s the official one from the Processing Foundation…? 😅

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [October 27, 2018, 8:13pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/13 "2018-10-27T20:13:18Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 27, 2018, 8:14pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/14 "2018-10-27T20:14:58Z")

</div>

Okay XD Thanks for taking a closer look XD

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 27, 2018, 8:19pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/15 "2018-10-27T20:19:36Z")

</div>

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

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [October 27, 2018, 8:27pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/16 "2018-10-27T20:27:12Z")

</div>

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?

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [October 27, 2018, 8:30pm UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/17 "2018-10-27T20:30:20Z")

</div>

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

> <https://github.com/philburk/jsyn/blob/master/src/com/jsyn/devices/javasound/JavaSoundAudioDevice.java>

  
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 😅

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 28, 2018, 7:05am UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/18 "2018-10-28T07:05:18Z")

</div>

Both sounds play without any trouble.

---

<div class="post-metadata">

### Author: ![Schred](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/schred/32/13146_2.png) [@Schred](https://discourse.processing.org/u/Schred)
#### Post date: [October 28, 2018, 7:10am UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/19 "2018-10-28T07:10:41Z")

</div>

> [@Lexyth](#):
>
> You can find the reason for the other messages by following their relative Path. You can See it in the Message Text.

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?

---

<div class="post-metadata">

### Author: ![Lexyth](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/lexyth/32/7403_2.png) [@Lexyth](https://discourse.processing.org/u/Lexyth)
#### Post date: [October 28, 2018, 11:55am UTC](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928/20 "2018-10-28T11:55:08Z")

</div>

> [@Schred](#):
>
> 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](http://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.

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 😅

[Next page](https://discourse.processing.org/t/processing-sound-library-doesnt-work/4928.md?page=2)
