如何从与Java API声麦克风捕捉声音? [英] How to capture sound from microphone with java sound API?

查看:1496
本文介绍了如何从与Java API声麦克风捕捉声音?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本教程 http://download.oracle.com/javase/tutorial/声音/ capturing.html
不包括如何选择麦克风。

The tutorial http://download.oracle.com/javase/tutorial/sound/capturing.html does not cover how to select microphone.

我列举混频器具有以下code

I am enumerating mixers with the following code

System.out.println("Searching for microphones");
for(Mixer.Info mixerinfo : AudioSystem.getMixerInfo()) {
    mixer = AudioSystem.getMixer(mixerinfo); 

    //System.out.println(mixerinfo.toString());
    if( mixer.isLineSupported(Port.Info.MICROPHONE) ) {
        mixers.add(mixer);
        System.out.println(Integer.toString(mixers.size()) + ": " + mixerinfo.toString());
    }
}

即。通过麦克风输入presense。但接下来,有一个搅拌机,我不能让行读取。

i.e. by presense of microphone input. But next, having a mixer, I can't get line to read.

如果我用 mixer.getTargetLineInfo(),我收到的数组有一个信息,它传递给时 mixer.getLine 返回类型为 com.sun.media.sound.PortMixer $ PortMixerPort ,这是不ducumented的对象

If I use mixer.getTargetLineInfo(), I receive an array of one Info, which when passing to mixer.getLine returns an object of type com.sun.media.sound.PortMixer$PortMixerPort, which is not ducumented.

如果我用 mixer.getTargetLines()我得到一个空数组。

If I use mixer.getTargetLines() I get an empty array.

如果我创造我自己的 DataLine.Info 并把它传递到调音台的函数getline ,我得到不受支持的异常。

If I create my own DataLine.Info and pass it to the mixer's getLine, I get unsupported exception.

那么,该怎么办?

推荐答案

提供每个声音线的视觉再现,在沿 AudioPlotPanel 或简单的 RMS量。它不应该把用户太长的身影,他们的岳得尔通过声线。 ;)

Left-field suggestion.

Provide a visual rendering of each sound line, in a component along the lines of the AudioPlotPanel or a simpler RMS volume. It should not take the user too long to figure which sound line they are yodeling through. ;)

这篇关于如何从与Java API声麦克风捕捉声音?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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