Skip to content

Instantly share code, notes, and snippets.

// libraryDependencies += "net.databinder.dispatch" %% "dispatch-core" % "0.9.4"
import dispatch._
val q = url("http://www.freesound.org/api/sounds/search")
.addQueryParameter("q", "barking")
.addQueryParameter("api_key", "074c0b328aea46adb3ee76f6918f8fae")
val p = Http.configure(_ setFollowRedirects true)(q OK as.String)
p() // -> this needs to be fed into a JSON parser
// does this work out?
trait Txn[S <: Sys] {
def newVar[A](init: A): S#Vr[A]
}
trait Var[Tx, A] {
def get(implicit tx: Tx): A
def set(value: A)(implicit tx: Tx): Unit
}
object Generator {
def apply[A](head: A)(next: A => A) : Generator[A] = Impl(head, next)
private final case class Impl[A](override val head: A, next: A => A)
extends Generator[A] {
protected def underlying = this
}
}
sealed trait Generator[A]
extends IterableView[A, Generator[A]] with IterableViewLike[A, Generator[A], Generator[A]] {
@Sciss
Sciss / hexcolor.scala
Created January 20, 2013 21:04
string interpolation test for hex (css style) colors
implicit class HexColor(val sc: StringContext) extends AnyVal {
def rgb(args: Any*) = sc.parts match {
case Seq(t) =>
require(t.length == 6, "must have length 6")
val i = Integer.parseInt(t, 16)
new java.awt.Color(i)
case _ => sys.error("Parts are unsupported")
}
}
IDE:
editor:
blinkDuration: 300
colors:
evaluatedCode: !textFormat
color: "#000000"
background: "#f8a200"
lineNumbers: !textFormat
color: "#808080"
background: "#141f2e"
val g = SynthGraph {
val f1 = "freq1".kr(0.4)
val f2 = "freq2".kr(8)
val d = "detune".kr(0.90375)
val f = LFSaw.ar(f1).madd(24, LFSaw.ar(List(f2, f2*d)).madd(3, 80)).midicps // glissando function
val x = CombN.ar(SinOsc.ar(f)*0.04, 0.2, 0.2, 4) // echoing sine wave
Out.ar( 0, x )
}
object Bar {
private var graphFun: Function0[Any] = () => ()
def graph: () => Any = graphFun
def graph_=(fun: => Any) {
graphFun = () => fun
}
def boing() = graphFun()
}
Bar.graph = { println("Hallo") }
val bDur = Buffer.alloc(s, numFrames = 2)
val bLvl = Buffer.alloc(s, numFrames = 3)
bDur.setn(Vector(1f,2f))
bLvl.setn(Vector(3f, 8f, 5f))
val x = gui {
val level = Dbufrd(bLvl.id, Dseries(0, 1, inf))
val dur = Dbufrd(bDur.id, Dseries(0, 1, inf))
val res = DemandEnvGen.ar(levels = level, durs = dur)
val b = Buffer.alloc(s, numFrames = 3)
b.setn(Vector(0.2f,0.5f,1.2f))
val x = gui {
val durs = Dbufrd(b.id, Dseries(0,1,inf))
val lvl = Dseq(Seq(1,0),inf)
val sig = DemandEnvGen.ar(levels = lvl, durs = durs, shapes = stepShape.id)
val trig = sig absdif Delay1.ar(sig)
trig // .poll(trig, "bang")
~jar = "itextpdf-5.4.0.jar";
~url = "http://search.maven.org/remotecontent?filepath=com/itextpdf/itextpdf/5.4.0/" ++ ~jar;
~tmp = PathName.tmp ++ ~jar
("curl" + ~url + ">" ++ ~tmp).systemCmd;
g = SwingOSC.default;
g.reboot;
g.addClasses("file:" ++ ~tmp);
GUI.swing;