Skip to content

Instantly share code, notes, and snippets.

trait Expr[+A]
trait Value
trait AudioValue extends Value
trait Elem extends Expr[Value]
trait AudioElem extends Elem with Expr[AudioValue]
import collection.mutable.{SortedSet => MSet}
val s = MSet(10 -> "a", 10 -> "b", 3 -> "c", 3 -> "c", 3 -> "d", 44 -> "a", 0 -> "a")
// -> 0, 3, 3, 10, 10, 44
val t = MSet(10 -> "a", 10 -> "b", 3 -> "c", 3 -> "c", 3 -> "d", 44 -> "a", 0 -> "a")(Ordering.by(_._1))
// -> 0, 3, 10, 44 . in other words, key inequality does _not_ matter, only ordering
import javax.swing._
import java.awt._
val styles = Vector("square", "gradient", "bevel", "textured", "roundRect", "recessed", "help", "segmented", "segmentedRoundRect", "segmentedCapsule", "segmentedTextured", "segmentedGradient")
val p = new JPanel(new FlowLayout())
styles.foreach { style =>
val b = new JButton()
if (style != "help") b.setText(style)
b.putClientProperty("JButton.buttonType", style)
if (style.startsWith("segmented"))
play {
val env = IEnvGen.kr(IEnv(0, Env.Seg(3, 1, linShape) :: Nil, 0), MouseX.kr(0,1))
env.poll(1)
}
/////////
def test(off: Double, dur: Double, fadeIn: Double, fadeOut: Double) {
val x = gui {
// Note this is still cubic interpolation, unfortunately VDiskIn doesn't have an interp argument.
// So you don't get as cripsy sound as with linear interp (would need BufRd and annoying buffer management).
val p = "/Volumes/data/hhrutz/Mnemo/Misc130428_3/superjam/rec/|fsc9.aif"
val spec = io.AudioFile.readSpec(p)
val b = Buffer.cue(path = p, numChannels = spec.numChannels)
val r = Buffer.alloc(numFrames = 32768, numChannels = spec.numChannels)
val rate = 0.5
val dur = spec.numFrames / (rate * spec.sampleRate)
val q = "/Users/hhrutz/Desktop/test.aif"
import reflect.runtime.{universe => ru}
val m = ru.runtimeMirror(getClass.getClassLoader)
case class Bar(i: Int)
val tpe = ru.typeOf[Bar]
val classBar = tpe.typeSymbol.asClass
val cm = m.reflectClass(classBar)
val ctor = tpe.declaration(ru.nme.CONSTRUCTOR).asMethod
val ctorm = cm.reflectConstructor(ctor)
@Sciss
Sciss / ComboBoxEvents.scala
Created June 5, 2013 14:48
ComboBox has no proper docs. Everytime I use it, I forget how to put the correct reactions.
import scala.swing._
new Frame {
contents = new ComboBox(Seq("one", "two")) {
listenTo(selection)
reactions += {
case event.SelectionChanged(_) => println(selection.item)
}
}
pack()
{
"class" : "EvalWindowed",
"data" : {
"window" : {
"class" : "WindowEvents",
"data" : {
"size" : 5,
"step" : 2
}
},
trait Sys {
type Global
}
object Settings {
def apply(sys: Sys)(glob: sys.Global): Settings { type S = sys.type } =
new Settings {
type S = sys.type
val system: S = sys
val global: sys.Global = glob
boot()
val in = play { Out.ar(0, "bus".ar(0)) }
in.mapa("bus" -> 40)
val out1 = play { Out.ar(40, WhiteNoise.ar(0.25)) }
val out2 = play { Out.ar(40, SinOsc.ar(400) * LFPulse.ar(4) * 0.5) }
in.moveAfter(out2) // mapa / InFeedback doesn't mix bus signals with different time stamps :-(
in.free(); out1.free(); out2.free()