不支持Java声音格式 [英] Java Sound format not supported

查看:98
本文介绍了不支持Java声音格式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用以下代码时: http://pastebin.com/5iVnttiP

我收到此错误:

javax.sound.sampled.LineUnavailableException: line with format PCM_SIGNED 16000.0 Hz, 16 bit, stereo, 4 bytes/frame, little-endian not supported.
    at com.sun.media.sound.DirectAudioDevice$DirectDL.implOpen(Unknown Source)
    at com.sun.media.sound.AbstractDataLine.open(Unknown Source)
    at com.sun.media.sound.AbstractDataLine.open(Unknown Source)
    at com.AIComputer.model.Recorder.<init>(Recorder.java:124)
    at com.AIComputer.AIComputer.main(AIComputer.java:7)

现在,我进行了一些研究,发现并非所有的声卡都支持每种格式,但是在运行此演示时:

Now I did some research and found out that not all sound cards support every format, however when running this demo: http://java.sun.com/products/java-media/sound/samples/JavaSoundDemo/ I managed to produce a recording using the exact same parameters (linear, 16000, 16, signed, little endian, stereo).

我不知道我在这里做错了什么(也是因为我还是Java编码的初学者).

I have no idea what I'm doing wrong here (also since I'm still a beginner at Java coding).

任何帮助将不胜感激!

推荐答案

您能说从您的代码的哪一行抛出此异常吗?

Can you say from which line on YOUR code this exception is thrown?

文档的LineUnavailableException说

The docs of LineUnavailableException says

这种情况最常发生在另一个应用程序已经在使用请求的行的情况下.

This situation arises most commonly when a requested line is already in use by another application.

您将在代码中打开两行.当您尝试打开第二个时,第一个的存在会阻止它.

You're opening two lines in your code. When you try to open the second one, the existence of the first one blocks it.

这篇关于不支持Java声音格式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆