Java:从2个不同的麦克风输入中独立捕获音频 [英] Java: Independently Capturing Audio From 2 Different Mic Inputs

查看:292
本文介绍了Java:从2个不同的麦克风输入中独立捕获音频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在进行一项研究,其中两个参与者在讨论多个主题时将各自佩戴不同的麦克风.我需要能够使用Java分析每个参与者的音频输入-分别捕获两个音频输入流.我不能将两个输入流结合起来进行分析.

I am running a study where two participants will each wear a different microphone while discussing multiple topics. I need to be able to analyze each participant's audio input in Java — capturing two audio input streams independently. I cannot combine both input streams for analysis.

有人知道我是否可以用Java做到这一点,怎么做?

Does anyone know if I can do this in Java, and how?

我遇到了,其中指出仅通用一个输入端口可以一次打开,但是也可以使用音频输入混合器来混合来自多个端口的音频."

I have come across this, which states "Commonly, only one input port can be open at a time, but an audio-input mixer that mixes audio from multiple ports is also possible."

谢谢

编辑1 : 捕获和分析必须实时进行.

Edit 1: The capture and analysis has to be done in real-time.

编辑2 : 我正在使用Windows 7 64位操作系统.我的声卡只有一个麦克风端口.我有两个类似于的USB音频适配器.如果我不能用Java完成此任务,那么什么是替代解决方案呢?建议使用USB库.我将对音频数据进行的分析是确定每个扬声器的发声率(他们在讲话多少).

Edit 2: I am using a Windows 7 64-bit operating system. My sound card has only one microphone port. I have two USB audio adapters that are similar to this. If I cannot accomplish this in Java, what is a good alternative solution? Using a USB library has been suggested. The analysis that I will perform on the audio data is to determine the utterance rate of each speaker (how much they are talking).

结论: 通过使用Java中的线程,我能够同时读取两个TargetDataLines.我的两个USB音频适配器都对Java可见.

Conclusion: I was able to read from two TargetDataLines simultaneously by using threads in Java. Both of my USB audio adapters were visible to Java.

推荐答案

我自己尚未完成此操作,因此请参考以下内容,而不是给出答案. (我更喜欢音乐合成和音频效果以进行实时播放,例如游戏声音.)

I haven't done this myself, so take the following as a suggestion more than an answer. (I'm more into music synthesis and audio effects for real time playback such as game sound.)

您可能已经在本教程中阅读过,Java提供了一个名为AudioSystem的类,该类提供对给定计算机上可用的线路和端口的访问.如果您要使用的计算机具有两条麦克行,那么就有理由相信这两条行对Java都是可见的.与Java相比,输入限制更多地取决于硬件(所使用的声卡及其提供的麦克线路数量),驱动程序和操作系统.您可能需要购买允许同时进行多个输入的特殊声卡.

As you probably have already read in the tutorial, Java provides a class called AudioSystem which provides access to lines and ports that are available on a given computer. If the computer with which you wish to operate with has two mike lines, then there is every reason to believe that those two lines will both be made visible to Java. The input limitation depends more on the hardware (sound card being used and number of mike lines it offers) and drivers and OS than it does on Java. You may have to purchase a special sound card that allows simultaneous multiple inputs.

此外,我知道在OS级别(尤其是Linux的某些版本)上可能存在限制,一次只能允许一条输出线运行.这将限制Java可以看到的内容.但是我还没有真正在Windows操作系统上进行过探索.

Also, I know there can exist limits at the OS level (some flavors of Linux in particular) that only allow one output line to operate at a time. This would limit what Java can see. But I haven't really explored this with my Windows OS yet.

要从一行中读取数据,通常使用TargetDataLine类.通常通过while循环从该行中的缓冲区块中读取数据(例如一次读取1024个字节).过去,我有多个同时运行的TargetDataLines:数据源是各种Java软件合成器源.假设每个TDL被分配给不同的输入线,则可以从该循环中读取每个TDL,然后将相应的数据传递到不同的分析器. TargetDataLines会阻塞行-如果一行中没有数据准备就绪(通常处理速度快于可显示音频数据的速度)-然后程序会阻塞直到出现数据为止.

For reading data from a line, a TargetDataLine class is normally used. Data is usually read from this line in buffer blocks (e.g., 1024 bytes at a time) via a while loop. I have had multiple TargetDataLines operating simultaneously in the past: where the data source were various Java software synth sources. Assuming each TDL is assigned to a different input line, each can be read from within this loop, and the respective data then passed on to the different analyzers. TargetDataLines are blocking lines--if a line doesn't have data ready (usually processing goes much faster than audio data can be presented)--then the program blocks until the data is present.

Java具有许多实时DSP的能力.我不知道您想做的具体分析形式,但可能有独立来源提供的库.

Java is capable of much real-time DSP. I don't know the specific form of analysis you wish to do, but there are probably libraries available by independent sources.

这篇关于Java:从2个不同的麦克风输入中独立捕获音频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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