在处理中获取多个音频输入 [英] Getting Multiple Audio Inputs in Processing

查看:150
本文介绍了在处理中获取多个音频输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在编写一个Processing草图,该草图需要访问多个音频输入,但是Processing只允许访问默认行.我试图直接从Java Mixer(在Processing中访问)获取Lines,但是我仍然只从当前在我的机器上设置为默认值的任何行中获取信号.

I'm currently writing a Processing sketch that needs to access multiple audio inputs, but Processing only allows access to the default line in. I have tried getting Lines straight from the Java Mixer (accessed within Processing), but I still only get the signal from whichever line is currently set to default on my machine.

我已经开始考虑按照建议此处.但是,由于我是SuperCollider的新手,他们的文档和支持更多地集中在生成声音而不是访问输入上,因此下一步可能是与Beads和Jack一起玩,如建议的

I've started looking at sending the sound via OSC from SuperCollider, as recommended here. However, since I'm very new to SuperCollider and their documentation and support is more focused on generating sound than on accessing inputs, my next step will probably be to play around with Beads and Jack, as suggested here.

有人有(1)其他建议,还是(2)从SuperCollider或Beads/Jack获得多个输入以进行处理的具体示例?

Does anyone have (1) other suggestions, or (2) concrete examples of getting multiple inputs from either SuperCollider or Beads/Jack to Processing?

提前谢谢!

声音将用于增强自定义音乐的可视化效果(请考虑使用iTunes可视化程序,但更多针对歌曲).我们可以处理多个mp3;现在我需要的是能够从每个麦克风中获取一个float []缓冲区.希望有9种不同的麦克风,不过如果可行的话,我们会选择4种.

The sound will be used to power custom music visualizations (think the iTunes visualizer, but much more song specific). We have this working with multiple mp3s; now what I need is to able to get a float[] buffer from each mic. Hoping to have 9 different mics, though we'll settle for 4 if that is more doable.

对于硬件,此时,我们仅使用麦克风和XLR转USB电缆. (曾经考虑过前置放大器,但到目前为止已经足够了.)我目前在Windows上,但是我认为我们最终会切换到Mac.

For hardware, at this point, we are just using mics and XLR to USB cables. (Have considered a pre-amp, but so far this has been sufficient.) I am currently on Windows, but I think that we will ultimately switch to a Mac.

这是我尝试使用Beads的尝试(因为我先做一次,所以对笔记本电脑来说效果很好,但是耳机缓冲区全为0;如果我将它们切换并放在头戴式耳机的位置,则耳机缓冲区将是正确的,但笔记本电脑将包含全0):

Here was my attempt with just Beads (it works fine for the laptop, since I do that one first, but the headset buffer has all 0's; if I switch them and put the headset first, the headset buffer will be correct, but the laptop will contain all 0's):

void setup() {
    size(512, 400);

    JavaSoundAudioIO  headsetAudioIO = new JavaSoundAudioIO();
    JavaSoundAudioIO  laptopAudioIO = new JavaSoundAudioIO();

    headsetAudioIO.selectMixer(5);
    headsetAudioCon  = new AudioContext(headsetAudioIO);

    laptopAudioIO.selectMixer(4);
    laptopAudioCon  = new AudioContext(laptopAudioIO);

    headsetMic  = headsetAudioCon.getAudioInput();
    laptopMic  = headsetAudioCon.getAudioInput();
} // setup()

void draw() {
    background(100,0, 75);

    laptopMic.start();
    laptopMic.calculateBuffer();
    laptopBuffer   = laptopMic.getOutBuffer(0);

    for (int j = 0; j < laptopBuffer.length - 1; j++)
    {
        println("laptop; " + j + ": " + laptopBuffer[j]);
        line(j, 200+laptopBuffer[j]*50, j+1, 200+laptopBuffer[j+1]*50);
    }
    laptopMic.kill();

    headsetMic.start();
    headsetMic.calculateBuffer();

    headsetBuffer  = headsetMic.getOutBuffer(0);


    for (int j = 0; j < headsetBuffer.length - 1; j++)
    {
        println("headset; " + j + ": " + headsetBuffer[j]);
        line(j, 50+headsetBuffer[j]*50, j+1, 50+headsetBuffer[j+1]*50);
    }

    headsetMic.kill();
} // draw()

我添加杰克的尝试包含以下内容:

My attempt at adding Jack contains this line:

ac = new AudioContext(new AudioServerIO.Jack(), 44100, new IOAudioFormat(44100, 16, 4, 4));

但是我得到了错误:

Jun 22, 2016 9:17:24 PM org.jaudiolibs.beads.AudioServerIO$1 run
SEVERE: null
org.jaudiolibs.jnajack.JackException: Can't find native library
    at org.jaudiolibs.jnajack.Jack.getInstance(Jack.java:428)
    at org.jaudiolibs.audioservers.jack.JackAudioServer.initialise(JackAudioServer.java:102)
    at org.jaudiolibs.audioservers.jack.JackAudioServer.run(JackAudioServer.java:86)
    at org.jaudiolibs.beads.AudioServerIO$1.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:745)
Caused by: java.lang.UnsatisfiedLinkError: Unable to load library 'jack': Native library (win32-x86-64/jack.dll) not found in resource path ([file:/C:/Users/...etc...)

当我进入Jack时,我看不到我的麦克风(对我来说,这似乎是一个巨大的危险信号,尽管我对Jack完全陌生).该AudioContext是否应该显示为Jack中的输入?反之亦然-先在那儿找到我的麦克风,然后再将其从Jack送到Processing吗?

And when I'm in Jack, I don't see my mic (which seems like a huge red flag to me, though I am completely new to Jack). Should this AudioContext show up as an Input in Jack? Or vice versa -- find my mic there first and then get it from Jack to Processing?

(请原谅我的经验不足,并再次感谢您!我对Jack的了解不足,使我想知道是否应该重新访问SuperCollider ...)

(Forgive my inexperience, and thank you again! My lack of knowledge in Jack makes me wonder if I should revisit SuperCollider instead...)

推荐答案

几年前,我遇到了同样的问题,并且使用了JACK,JNAJack和Beads的组合.您可以按照以下串珠Google网上论坛线程以获取更多详细信息.

I had the same issue a few years ago and I used a combination of JACK, JNAJack and Beads. You can follow this Beads Google Group thread for more details.

当时我必须使用

At the that time I had to use this version of Beads (2012-04-23), but I hope those changes probably made it into the main project by now.

作为参考,这是我使用的基本类:

For reference, here is the basic class I used:

import java.util.Arrays;

import org.jaudiolibs.beads.AudioServerIO;

import net.beadsproject.beads.analysis.featureextractors.FFT;
import net.beadsproject.beads.analysis.featureextractors.PowerSpectrum;
import net.beadsproject.beads.analysis.segmenters.ShortFrameSegmenter;
import net.beadsproject.beads.core.AudioContext;
import net.beadsproject.beads.core.AudioIO;
import net.beadsproject.beads.core.UGen;
import net.beadsproject.beads.ugens.Gain;
import processing.core.PApplet;


public class BeadsJNA extends PApplet {

    AudioContext ac;
    ShortFrameSegmenter sfs;
    PowerSpectrum ps;

    public void setup(){
        //defining audio context with 6 inputs and 6 outputs - adjust this based on your sound card / JACK setup
        ac = new AudioContext(new AudioServerIO.Jack(),512,AudioContext.defaultAudioFormat(6,6));

        //getting 4 audio inputs (channels 1,2,3,4)
        UGen microphoneIn = ac.getAudioInput(new int[]{1,2,3,4});
        Gain g = new Gain(ac, 1, 0.5f);
        g.addInput(microphoneIn);
        ac.out.addInput(g);

        println("no. of inputs:  " + ac.getAudioInput().getOuts()); 

        //test get some FFT power spectrum data form the 
        sfs = new ShortFrameSegmenter(ac);
        sfs.addInput(ac.out);
        FFT fft = new FFT();
        sfs.addListener(fft);
        ps = new PowerSpectrum();
        fft.addListener(ps);
        ac.out.addDependent(sfs);

        ac.start();
    }
    public void draw(){
        background(255);
        float[] features = ps.getFeatures();
        if(features != null){
            for(int x = 0; x < width; x++){
              int featureIndex = (x * features.length) / width;
              int barHeight = Math.min((int)(features[featureIndex] *
                                                height), height - 1);
              line(x, height, x, height - barHeight);
            } 
        }
    }

    public static void main(String[] args) {
        PApplet.main(BeadsJNA.class.getSimpleName());
    }

}

这篇关于在处理中获取多个音频输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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