基于 Peter Brinkmann 的示例类,我在 Eclipse 中运行 libpd 和处理。但我似乎并不完全了解如何将来自 Android 麦克风的音频输入转换为 Pure Data。
当我在实际或虚拟设备上运行它时,我收到一堆错误消息:
E/AudioRecord(1079): 无法获取记录源 1 的音频输入
E/AudioRecord-JNI(1079):创建 AudioRecord 实例时出错:初始化检查失败。
这是主要的类:
package com.noisepages.nettoyeur.processing.sample;
import org.puredata.android.io.AudioParameters;
import org.puredata.android.processing.PureDataP5Android;
import processing.core.PApplet;
/**
* @author Peter Brinkmann (peter.brinkmann@gmail.com)
*/
public class PdP5Sample extends PApplet {
PureDataP5Android pd;
int zipId = com.noisepages.nettoyeur.processing.sample.R.raw.patch; // Processing masks R
int ins = AudioParameters.suggestInputChannels();
int sampleRate = AudioParameters.suggestSampleRate();
public void setup() {
pd = new PureDataP5Android(this, sampleRate, ins, 2);
pd.unpackAndOpenPatch(zipId, "audiotest.pd");
pd.start();
}
public void draw() {
background(0);
fill(mouseY, mouseX, 0);
stroke(mouseY, mouseX, 0);
ellipseMode(CENTER);
ellipse(mouseX, mouseY, 100, 100);
}
public void stop() {
pd.release();
super.stop();
}
/*
// Implement methods like the following if you want to receive messages from Pd.
// You'll also need to subscribe to receive symbols you're interested if you want
// to receive messages.
public void pdPrint(String s) {
// Handle string s, printed by Pd
}
public void receiveBang(String source) {
// Handle bang sent to symbol source in Pd
}
public void receiveFloat(String source, float x) {
// Handle float x sent to symbol source in Pd
}
public void receiveSymbol(String source, String sym) {
// Handle symbol sym sent to symbol source in Pd
}
*/
// boilerplate
public int sketchWidth() { return this.screenWidth; }
public int sketchHeight() { return this.screenHeight; }
public String sketchRenderer() { return PApplet.OPENGL; }
}