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
| // 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 | |
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
| // 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 | |
| } |
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
| 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]] { |
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
| 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") | |
| } | |
| } |
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
| IDE: | |
| editor: | |
| blinkDuration: 300 | |
| colors: | |
| evaluatedCode: !textFormat | |
| color: "#000000" | |
| background: "#f8a200" | |
| lineNumbers: !textFormat | |
| color: "#808080" | |
| background: "#141f2e" |
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
| 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 ) | |
| } |
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
| object Bar { | |
| private var graphFun: Function0[Any] = () => () | |
| def graph: () => Any = graphFun | |
| def graph_=(fun: => Any) { | |
| graphFun = () => fun | |
| } | |
| def boing() = graphFun() | |
| } | |
| Bar.graph = { println("Hallo") } |
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
| 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) |
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
| 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") |
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
| ~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; |