我想在MouseDown中使用SuperCollider,并且有一个helluva的时间。是否只有mouseDownAction才能真正处理任何事情?我希望能够在屏幕上单击anywhere,并将鼠标坐标打印到post窗口:
Server.default=s=Server.local;
s.boot;
s.mouseDownAction = { x = {|t_poll=0| var x_val, y_val;
x_val = {MouseX.kr};
y_val = {MouseY.kr};
Poll.kr(t_poll, [x_val, y_val], ["x_val", "y_val"]);
}.play };
s.mouseUpAction = { x.set(\t_poll,1) };
当然,这是行不通的,因为mouseDownAction似乎被保留为“View”类的属性,即只在特定窗口内单击,如下所示,虽然并不完全符合我想要的代码:
w = Window.new("Mouse Coordinates", Rect(1300,600,50,50));
b = Button.new(w,Rect(10,10,40,25)).states_([["off"],["on"]]);
b.mouseDownAction = { x = {|t_poll=0| var x_val, y_val;
x_val = {MouseX.kr};
y_val = {MouseY.kr};
Poll.kr(t_poll, [x_val, y_val], ["x_val", "y_val"]);
}.play };
b.mouseUpAction = { x.set(\t_poll,1) };
w.front;
有些事我想知道:
谢谢!
发布于 2020-12-29 17:16:40
鼠标按钮https://doc.sccode.org/Classes/MouseButton.html有一个Ugen。
下面是链接帮助文件中的示例:
(
SynthDef( \mousexyb, { |out=0|
var mousex, mousey, mousebutton;
mousex = MouseX.kr( 500, 1000 ); // this will determine the frequency of the sound (minimum value, maximum value, warp, lag)
mousey = MouseY.kr( 0, 0.3 ); // this will determine the amplitude of the sound
mousebutton = MouseButton.kr( 0, 1, 2 ); // this will turn the sound on or off (minimum value, maximum value, lag)
Out.ar( out, SinOsc.ar( mousex, 0, mousey ) * mousebutton );
}).add
)
您可以做的是让服务器在按下按钮时生成OSC消息,并让语言监听该消息。
https://stackoverflow.com/questions/65376372
复制相似问题