Problems with sound in Java and USB sound card
I've been using Java for a college software dev开发者_如何转开发elopment class, and recently we have been doing some work with building an MP3 player.
My problem is that the sound in Java does not play correctly. I'm on Ubuntu 10.10 and I have a laptop, but i'm using an external sound card (USB, because my built in sound doesn't sound very good). Problem is that Java always plays sound though my laptops internal soundcard (even though Ubuntu lists the internal sound as being off), so I hear sound from my little laptop speakers and not the speakers hooked up to my soundcard.
I can get it to play though the soundcard by using the aoss program but its a pain to do this. I'm using alsa on my system with a USB soundcard, it works fine with other sound programs and music players, any ideas on how to fix this problem? I'm happy to provide any information that anyone needs or would find helpful. Thanks!
Caveat: I am not familiar with JavaSound.
Based on the provided example code, it looks like the
DataLine.Info info = new DataLine.Info(SourceDataLine.class, audioFormat);
line is the one that requests the playback mechanism, and that the audioformat you provide matches the built-in sound card.
You need to find out what mechanisms are available to you for selecting a given one explicitly, instead of just the first one which is "good enough".
精彩评论