Skip to content

Instantly share code, notes, and snippets.

@Sciss
Last active December 12, 2015 00:28
Show Gist options
  • Save Sciss/4684168 to your computer and use it in GitHub Desktop.
Save Sciss/4684168 to your computer and use it in GitHub Desktop.
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 )
}
val src = g.sources
val prod = src.collect { case x: Product => x }
val non = src diff prod // -> empty
prod.map(_.productPrefix)
prod.map(_.productArity)
sealed trait LazyArg
case object IntArg extends LazyArg
case object StringArg extends LazyArg
case object GEArg extends LazyArg
case object LazyAsArg extends LazyArg
case object RateArg extends LazyArg
case class UnknownArg(c: Class[_]) extends LazyArg
val m: Map[LazyArg, Any] = prod.flatMap(_.productIterator).collect({
case i: Int => IntArg -> i
case s: String => StringArg -> s
case ge: GE => GEArg -> ge
case lz: Lazy => LazyAsArg -> lz
case r: Rate => RateArg -> r
case x => UnknownArg(x.getClass) -> x
}).toMap
m.keys.foreach(println)
// -> RateArg, GEArg, Unknown: BinaryOp...., UnaryOp....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment