以用JAVA声卡的控制权 [英] Taking control of the soundCard with JAVA

查看:672
本文介绍了以用JAVA声卡的控制权的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图建立在Java中的调音台。在此混频器,每个滑块将是一条线,仿佛它是一个物理调音台。但是,我对粘粘的搜索***后阅读 Oracle文档 ,我并没有真正发现任何帮助我。

I'm trying to build a "mixing console" in JAVA. In this mixer, each "slider" would be a line, as if it was a physical mixing console. But, after my search on Goo*** and read the oracle documentation, I didn't really find anything to help me.

首先,我列出可用的混合器(见code结尾),并愉快地,它列出我所有的声卡,并找到了线与线了。但后来,我有什么做的?

First, I list the mixers available (see code at the end) and happily, it list all my soundcards and find the line in and line out. But then, what I have to do ?

我的目标是打造虚拟的线,将捕捉来自任意行(麦克风)的声音或线路输出(声音捕获在VLC饰),让我再就可以工作,重新注入其在另一条线。当然,我会为每个这是中,哪些线路设置是走出去
使用示例:

My aim is to create "virtual line" that will catch the sound from any line in (microphone) or line out (capture of the sound played in VLC), allowing me to "work on it" and then, reinject it in another line. Of course, I will have to set for each line which is the "in" and which is the "out" Examples of use :


  • 3物理的(话筒)行会赶上,然后在水平调整,然后在一个虚拟的线,将被称为合唱,并为虚拟线会在我的主要物理线路输出所谓的被重新注入回注大师的水平。

  • 3 physical lines in (microphones) would be catch, then "level adjusted" then reinjected in a virtual line that would be called "chorus" and this virtual line would be reinjected in my main physical line out called "Master level".

通过VLC(例如一首歌曲的旋律),这是通常播放的歌曲直接发送到主了,被逮住,像一个拦截,然后我决定设置重新注入前的水平它在我的主,并将其与麦克风混合。因此,它可以让我调整同乐级歌手的水平。

the song played by VLC (the melody of a song for example), which is usually directly send to the main "out, is catched, like an "interception". Then I decide to setup the level before reinject it in my Master and mix it with the microphone. So, it will allow me to adjust the singer level with the music level.

那么,谁可以帮我开始和进展?感谢您的所有帮助。

So, who could help me to start and progress ? Thank you for all your help.

下面是code,列出我的搅拌机:

Here is the code that list my mixers :

import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Control;
import javax.sound.sampled.Line;
import javax.sound.sampled.Mixer;

public class Mixers {

Mixers() {      
    try {
        //List of the mixers from the system
        Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo();
        //Characteristics of each mixer
        for (Mixer.Info info : mixerInfo) {
            System.out.println("\n"+info+ " - Description : "+info.getDescription());
            Mixer mix=AudioSystem.getMixer(info);

            //Controles available for this mixer
            for (Control c:mix.getControls()) {
                System.out.println ("\t Control supported by this mixer : "+c);
            }
            //Sources available for this mixer
            for (Line.Info i : mix.getSourceLineInfo()) {
                System.out.println("\t Source line available : "+i);

                //Controls available for this Source
                for (Control c : AudioSystem.getLine(i).getControls()) {
                    System.out.println ("\t\t ==> Controls supported by this source : "+c);
                }
            }
            // TargeLines available for this mixer
            for (Line.Info i : mix.getTargetLineInfo()) {
                System.out.println("\t Target line available : "+i);

                //Controls available for this Target
                for (Control c : AudioSystem.getLine(i).getControls()) {
                    System.out.println ("\t\t Controls supported by this target : "+c);
                }
            }               
        }
    } catch (Exception e) {
        e.printStackTrace();
    }               
}

}

再次感谢谁看了我的文章,直到最后,给我一个解决方案的开始。

Thanks again to anyone who read my post until the end and give me the start of a solution.

萨科

推荐答案

如果可以做到这一点,我认为你是想下一步就是要能够从不同混音器读取数据,并执行操作每个上框架的基础。 Java教程捕获音频指的是从外线读取数据。本教程使用文件和文件格式转换器有例如code的节目如何让个别帧。根据头阅读声音文件就是例子code这一点。最重要的一点是由以下注释标记:

If this can be done, I think the next step that you are wanting is to be able to read data from the various mixers and perform operations on a "per frame" basis. The Java Tutorial Capturing Audio refers to reading data from outside lines. The tutorial Using Files and Format Converters has example code that shows how to get to the individual frames. Under the header "Reading Sound Files" is example code for this. The most important point is marked by the following comment:

// Here, do something useful with the audio data that's 
// now in the audioBytes array...

在你的情况,你有多个auiodBytes阵列,一个是你输入的每一行。

In your case, you would have multiple auiodBytes arrays, one for each line you are inputting.

要混合,来自不同线路的PCM帧数据可以一起加入。字里行间音量控制可以通过使用一个乘法器,例如,从0(沉默)范围内的一个因素为1(最大音量)来完成。

To mix, the PCM frame data from the different lines can be added together. Volume control between the lines can be done via using a multiplier, e.g., a factor that ranges from 0 (silence) to 1 (full volume).

必须注意不改变太多乘法器在单个帧,否则引入数据的不连续性引起的点击。所以小号$ P $垫在多个帧上的任何改变了。在乘数线性变化并不完全一致听到音频电平。我认为,第3度指数分布通常用于线性值和实际听起来像这些值相当于乘数之间的转换。你可能希望把最小和最大功能,以确保PCM数据永不熄灭大部分本款的范围-1和1之外是混合约精点,如有不同意见,以什么是最好的做法。

Care must be taken not to change the multiplier by too much in a single frame, else the discontinuity introduced into the data causes a click. So spread any changes out over multiple frames. Linear changes in the multiplier do not exactly match heard audio levels. I think a 3rd degree exponential distribution is often used for converting between linear values and equivalent multipliers that actually sound like those values. You might want to put in min and max functions to ensure the PCM data never goes outside of the range -1 and 1. Much of this paragraph is about fine points of mixing and subject to differing opinions as to what are the best practices.

有计算器上告诉如何从字节流格式转换为PCM和背部等职位。据我所知,javax.sound.sampled中,该code源,依靠本土code很多,是相当低的水平。我已经能够做很多以这种方式混合,虽然我靠我自己的数据源,而不是外线,你正在尝试做的。我不知道如何将这些外线的管理,特别是如果你想拥有,而你在玩的混合导致您的计算机无法播放它们。

There are other posts on stackoverflow that tell how to convert from your byte-stream format to PCM and back. As far as I know, javax.sound.sampled, the source for this code, relies very much on native code and is quite low level. I've been able to do a lot with mixing in this manner, though I rely on my own data sources, not outside lines as you are trying to do. I don't know how those outside lines are managed, especially if you wish to have your computer not play them while you are playing your resulting mix.

这篇关于以用JAVA声卡的控制权的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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