我目前正在编写需要访问多个音频输入的Processing sketch,但Processing只允许访问默认行。我尝试直接从Java Mixer获取Lines(在Processing中访问),但是我仍然只能从我的机器上当前设置为默认值的任何一行获取信号。
我已经开始考虑按照建议的here从SuperCollider通过OSC发送声音。但是,由于我对SuperCollider非常陌生,他们的文档和支持更多地集中在生成声音而不是访问输入,我的下一步可能是按照建议的here使用Beads和Jack。
是否有人有(1)其他建议,或(2)从SuperCollider或Beads / Jack获取多个输入到处理的具体示例?
提前谢谢!
编辑:声音将用于为自定义音乐可视化提供动力(想想iTunes可视化工具,但更多的歌曲特定)。我们有多个mp3工作;现在我需要的是能够从每个麦克风获得一个float []缓冲区。希望有9种不同的麦克风,但如果更可行的话我们会满4分。
对于硬件,此时我们只使用麦克风和XLR到USB电缆。 (考虑过前置放大器,但到目前为止这已经足够了。)我目前在Windows上,但我认为我们最终会切换到Mac。
这是我对Beads的尝试(它适用于笔记本电脑,因为我先做了那个,但耳机缓冲器全部为0;如果我切换它们并将耳机放在第一位,耳机缓冲将是正确的,但笔记本电脑将包含所有0):
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()
我尝试添加杰克包含这一行:
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...)
当我在杰克的时候,我没有看到我的麦克风(这对我来说似乎是一个巨大的红旗,虽然我对杰克来说是全新的)。这个AudioContext应该在Jack中显示为输入吗?反之亦然 - 首先找到我的麦克风,然后从杰克那里拿到麦克风?
(原谅我的经验不足,再次感谢你!我对Jack缺乏了解,让我想知道我是否应该重新考虑SuperCollider ......)
答案 0 :(得分:0)
几年前我遇到了同样的问题,我使用了JACK,JNAJack和Beads的组合。您可以按照此Beads Google Group thread了解详情。
当时我不得不使用this version of Beads(2012-04-23),但我希望这些更改可能已经成为主要项目。
供参考,这是我使用的基础课程:
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());
}
}