This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
:::::::: OSC messages :::::::: | |
[ "/flock_type", "bees" | "birds" | "fish" ] | |
[ "/flock", (float) pos_x, (float) pos_y (float) velo_angle, (float) velo_mag, (float) density, (float) curvature ] | |
where pos_x, pos_y, velo_mag, density and curvature are normalised to interval: [0 ... 1] | |
where velo_angle is in radians | |
[ "/predator", (int) num, (float) distance ] | |
where num >= 0 | |
where distance is normalised to interval: [0 ... 1] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// from Emden Gansner | |
// https://mailman.research.att.com/pipermail/graphviz-interest/2010q2/007101.html | |
// requires GraphViz 2.28.0 (fails with 2.26.3 at least) | |
BEGIN { | |
double tw[node_t]; // width of tree rooted at node | |
double nw[node_t]; // width of node | |
double xoff[node_t]; // x offset of root from left side of its tree | |
double sp = 36; // extra space between left and right subtrees | |
double wd, w, w1, w2; | |
double x, y, z; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// for Scala 2.10.0-M4 | |
import language.experimental.macros | |
import import scala.reflect.makro._ | |
// ScalaCollider skeleton | |
sealed trait MaybeRate | |
object UndefinedRate extends MaybeRate | |
sealed trait Rate extends MaybeRate | |
object audio extends Rate | |
object control extends Rate |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> def retImpl(c: Context)(b: c.Expr[Boolean]): c.Expr[Any] = { | |
| import c.universe._ | |
| val Literal(Constant(bool: Boolean)) = b.tree | |
| if (bool) c.reify(0) else c.reify(false) | |
| } | |
retImpl: (c: scala.reflect.makro.Context)(b: c.Expr[Boolean])c.Expr[Any] | |
scala> def ret(b: Boolean) = macro retImpl | |
ret: (b: Boolean)Any |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package benchmark | |
object Bench1 extends App { | |
def time(f: => Unit) = { | |
val start = System.nanoTime() | |
f | |
System.nanoTime() - start | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package benchmark | |
object Bench2 extends App { | |
val num = args.headOption.map(_.toInt).getOrElse(1000) | |
def time(f: => Unit) = { | |
val start = System.nanoTime() | |
f | |
System.nanoTime() - start |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(1) :::::: Scala 2.9.2 :::::: | |
[info] Running benchmark.Bench1 | |
Running benchmarks for n = 1000 | |
while1 took 630.9814 µs per run | |
while2 took 71.3434 µs per run | |
for1 took 5487.2262 µs per run | |
for2 took 7332.3932 µs per run | |
[success] Total time: 147 s, completed Jul 24, 2012 3:40:24 PM |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package benchmark | |
object Bench3 extends App { | |
val num: Int = 1000 | |
def time[A](f: => A) : (A, Long) = { | |
val start = System.nanoTime() | |
val res = f | |
res -> (System.nanoTime() - start) | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// to be called from the class output folder as cwd, traverses that folder | |
// for class files, calls javap on each, and writes the results to text | |
// files relative to a base directory given as parameter -d <outputDir> | |
// | |
// e.g. | |
// cd scala-2.10.0-M5 | |
// mkdir ~/Desktop/m5 | |
// scala /path/to/Disassemble -d ~/Desktop/m5 | |
// ../scala-2.10.0-M6 | |
// mkdir ~/Desktop/m6 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// posted sc-user nov 2012 | |
SynthDef(\elastic , { arg t_trig = 1, freq = 4; | |
var signal, in ; | |
t = K2A.ar( t_trig) > 0; | |
m = Spring.ar(ToggleFF.ar(t), 100, 0.6); | |
in = LocalIn.ar(1) * 0.098; | |
n = Spring.ar(m + in , 3, 0.001); | |
h = Spring.ar(n, 0.5 , 0.000026); |