trigger sound just once not every frame [Processing-SuperCollider using OpenObject Quark]
in
Contributed Library Questions
•
1 year ago
hello,
here i try to make simple loop in Processing and trigger sound via OSC in SuperCollider using OpenObject Quark
the problem is in scene1 i want to trigger sound just once not every frame
how to achieve this?
//SuperCollider
(
OpenObject.start;
Ndef(\wn,{|t_trig|WhiteNoise.ar(0.1!2)*EnvGen.kr(Env.perc(0.03,0.3),t_trig)});
Ndef(\wn).publish(\test);
)
here i try to make simple loop in Processing and trigger sound via OSC in SuperCollider using OpenObject Quark
the problem is in scene1 i want to trigger sound just once not every frame
how to achieve this?
//SuperCollider
(
OpenObject.start;
Ndef(\wn,{|t_trig|WhiteNoise.ar(0.1!2)*EnvGen.kr(Env.perc(0.03,0.3),t_trig)});
Ndef(\wn).publish(\test);
)
- //Processing
import netP5.*;
import oscP5.*;
NetAddress sc;
OscP5 osc;
int startTime;
void setup(){
size(768,576);
frameRate(12);
rectMode(CENTER);
osc= new OscP5(this, 12000);
sc= new NetAddress("127.0.0.1", 57120);
osc.send("/oo", new Object[] {"test","play"}, sc);
}
void draw(){
background(0);
fill(255);
noStroke();
int m = millis() - startTime;
//scene1
if(m<2000){
rect(width/2,height/2,width,height);
osc.send("/oo", new Object[] {"test","set", "t_trig",1}, sc);
//scene2
} else if (m<3000){
rect(width/2,height/2,width*0.5,height*0.5);
}
else if(m<5000){
startTime=millis();
}
}
void stop ()
{
osc.send("/oo", new Object[] {"test", "stop"}, sc);
}
1