finnkuusisto / TinySound

Simple library for playing sounds and music in Java
http://finnkuusisto.github.com/TinySound
BSD 2-Clause "Simplified" License
99 stars 26 forks source link

OS X 10.11 El Capitan: Using deprecated Carbon Component Manager + No sound #27

Open MrARM opened 8 years ago

MrARM commented 8 years ago

When attempting to play a sound i would get the following message: 2016-03-27 19:33:25.576 java[54461:581471] 19:33:25.576 WARNING: 140: This application, or a library it uses, is using the deprecated Carbon Component Manager for hosting Audio Units. Support for this will be removed in a future release. Also, this makes the host incompatible with version 3 audio units. Please transition to the API's in AudioComponent.h.

also no sound would play using the following code ran from a SWT form package com.sound; import kuusisto.tinysound.Sound; import kuusisto.tinysound.TinySound; public class sound { public static void sound(String phrase) throws Exception{ TinySound.init(); Sound sound = TinySound.loadSound("res/sound.wav"); if(phrase.equalsIgnoreCase("playsound1")){ System.out.println("the sound played"); sound.play(); } TinySound.shutdown(); } } (Sensitive info removed)

finnkuusisto commented 8 years ago

I finally got a chance to test it out on a Mac. Mind you, the Mac I used is running Yosemite, but I didn't see anything like the first message. I'm wondering if it might have something to do with your Java install. What version of Java are you using?

For the second issue, the reason the sound isn't playing is because TinySound.shutdown() is called before the mixer has a chance to even send the sound to the speakers. You should be able to hear your sound by adding a Thread.sleep(1000) in this example after you call play(). In general though, you don't want to TinySound.init() and TinySound.shutdown() every time you load and play sounds. Those are meant to be called when your application starts and when it shuts down respectively. In a nutshell, init() sets up a thread to run a mixer and send audio to the speakers, and shutdown() winds all that down along with attempting to clear out all the loaded audio files and such. Does that make sense?

belzaaron commented 8 years ago

Do we have an update on possible solutions? As the TinySound Library seems great, and I'd like to use it in a couple projects I've got.

finnkuusisto commented 8 years ago

Are you experiencing a related issue? You'll see in my response that I was unable to reproduce the warning message, and the problem with no sound playing was a result of init() and shutdown() being used incorrectly.