在处理过程中,我制作了一个“Play Amazing Notes”按钮,以使用 OSC(打开声音控制)向卡盘(用于播放音符)发送信号,但是当我运行处理脚本时,它会显示这些错误消息。
ControlP5 2.2.6 infos, comments, questions at http://www.sojamo.de/libraries/controlP5
play Note
Dec 04, 2016 11:47:23 PM controlP5.ControlBroadcaster printMethodError
SEVERE: An error occured while forwarding a Controller event, please check your code at playNote
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at controlP5.ControlBroadcaster.invokeMethod(Unknown Source)
at controlP5.ControlBroadcaster.callTarget(Unknown Source)
at controlP5.ControlBroadcaster.broadcast(Unknown Source)
at controlP5.Controller.broadcast(Unknown Source)
at controlP5.Button.setValue(Unknown Source)
at Kandeze_SendOscMessage.createControls(Kandeze_SendOscMessage.java:51)
at Kandeze_SendOscMessage.setup(Kandeze_SendOscMessage.java:34)
at processing.core.PApplet.handleDraw(PApplet.java:2387)
at processing.opengl.PSurfaceJOGL$DrawListener.display(PSurfaceJOGL.java:871)
at jogamp.opengl.GLDrawableHelper.displayImpl(GLDrawableHelper.java:692)
at jogamp.opengl.GLDrawableHelper.display(GLDrawableHelper.java:674)
at jogamp.opengl.GLAutoDrawableBase$2.run(GLAutoDrawableBase.java:443)
at jogamp.opengl.GLDrawableHelper.invokeGLImpl(GLDrawableHelper.java:1293)
at jogamp.opengl.GLDrawableHelper.invokeGL(GLDrawableHelper.java:1147)
at com.jogamp.newt.opengl.GLWindow.display(GLWindow.java:759)
at com.jogamp.opengl.util.AWTAnimatorImpl.display(AWTAnimatorImpl.java:81)
at com.jogamp.opengl.util.AnimatorBase.display(AnimatorBase.java:452)
at com.jogamp.opengl.util.FPSAnimator$MainTask.run(FPSAnimator.java:178)
at java.util.TimerThread.mainLoop(Timer.java:555)
at java.util.TimerThread.run(Timer.java:505)
Caused by: java.lang.NullPointerException
at Kandeze_SendOscMessage.playNote(Kandeze_SendOscMessage.java:61)
... 24 more
OscP5 0.9.8 infos, comments, questions at http://www.sojamo.de/oscP5
### [2016/12/4 23:47:23] PROCESS @ OscP5 stopped.
### [2016/12/4 23:47:23] PROCESS @ UdpClient.openSocket udp socket initialized.
### [2016/12/4 23:47:24] ERROR @ UdpServer.start() IOException, couldnt create new DatagramSocket @ port 12000 java.net.BindException: Address already in use: Cannot bind
### [2016/12/4 23:47:24] INFO @ OscP5 is running. you (192.168.0.103) are listening @ port 12000
我的处理代码如下所示:
import controlP5.*;
import oscP5.*;
import netP5.*;
OscP5 oscP5;
NetAddress dest;
ControlP5 cp5;
void setup(){
size(200,210,P3D);
background(0);
createControls();
//setUp Osc sending
oscP5 = new OscP5(this,12000);
dest = new NetAddress("127.0.0.1",6449);
}
void draw(){
background(0);
smooth();
}
void createControls(){
cp5 = new ControlP5(this);
cp5.addButton("playNote")
.setValue(0)
.setCaptionLabel("Play Amazing Notes")
.setPosition(10,10)
.setSize(180,50);
}
void playNote(){
println("play Note");
OscMessage msg=new OscMessage("/playNote");
oscP5.send(msg,dest);
}
Chuck 代码是:
Mandolin m=> dac;
OscIn oin;
OscMsg msg;
6448 => oin.port;
"/playNote" => oin.addAddress;
while(true){
oin => now;
while (oin.recv(msg))
{
msg.address @=> string address;
if(msg.address=="/playNote")
{
Math.random2f(48,70) => float note;
note => Std.mtof => m.freq;
}
}
}