Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
31
Task/Active-object/SuperCollider/active-object.sc
Normal file
31
Task/Active-object/SuperCollider/active-object.sc
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
(
|
||||
a = TaskProxy { |envir|
|
||||
envir.use {
|
||||
~integral = 0;
|
||||
~time = 0;
|
||||
~prev = 0;
|
||||
~running = true;
|
||||
loop {
|
||||
~val = ~input.(~time);
|
||||
~integral = ~integral + (~val + ~prev * ~dt / 2);
|
||||
~prev = ~val;
|
||||
~time = ~time + ~dt;
|
||||
~dt.wait;
|
||||
}
|
||||
}
|
||||
};
|
||||
)
|
||||
|
||||
// run the test
|
||||
(
|
||||
fork {
|
||||
a.set(\dt, 0.0001);
|
||||
a.set(\input, { |t| sin(2pi * 0.5 * t) });
|
||||
a.play(quant: 0); // play immediately
|
||||
2.wait;
|
||||
a.set(\input, 0);
|
||||
0.5.wait;
|
||||
a.stop;
|
||||
a.get(\integral).postln; // answers -7.0263424372343e-15
|
||||
}
|
||||
)
|
||||
Loading…
Add table
Add a link
Reference in a new issue