Skip to content

Instantly share code, notes, and snippets.

@Sciss
Sciss / ScalaCollider_UGens_Database.txt
Created March 2, 2014 20:39
Some notes from December 2012, not sure they are still useful
::: ScalaCollider data base :::
: Features :
- association of plugin files (e.g. CuspN -> ChaosUGens)
- default argument values:
- integer graph element
- integer scalar (e.g. for "numChannels")
- string (e.g. Poll label)
- floating point graph element; possibility of "inf" values
// january 2011
thisProcess.recvOSCfunc = { arg ... args; args.postln }
thisProcess.recvOSCfunc = nil
r = OSCresponderNode( nil, '/2/push1', { arg time, resp, msg;
if( msg[ 1 ] == 1, {
"Dang!".postln;
});
}).add;
trait TxnLike[S <: Sys[S]] {
def readVar[A](in: DataInput[S#Tx])(implicit peer: Reader[S#Tx, A]): S#Var[A]
}
object VarLike {
implicit def reader[S <: Sys[S], A](implicit peer: Reader[S#Tx, A]) = new Reader[S#Tx, S#Var[A]] {
def read(in: DataInput[S#Tx])(implicit tx: S#Tx): S#Var[A] =
tx.readVar[A](in)
}
}
import scala.swing._
import Swing._
val f = new Frame {
val sl = new Slider {
listenTo(this)
reactions += {
case event.ValueChanged(_) =>
println(s"adjusting? $adjusting")
implicit class EndingOps(val in: java.io.DataInput) extends AnyVal {
def readIntLE(): Int = {
val i0 = in.readInt()
val b0 = (i0 >> 24) & 0xFF
val b1 = (i0 >> 16) & 0xFF
val b2 = (i0 >> 8) & 0xFF
val b3 = (i0 ) & 0xFF
val i1 = (b3 << 24) | (b2 << 16) | (b1 << 8) | b0
i1
}
trait Baz[-C, M]
object Foo {
def empty[V, A](implicit m: Baz[A, V]): Foo[V, A] = ???
implicit def barBaz[V, A](implicit m: Baz[A, V]): Baz[Bar[V, A], V] = ???
case class Single[V, A](measure: V, a: A) extends Foo[V, A] {
def append(b: A)(implicit m: Baz[A, V]): Foo[V, A] = Deep(empty[V, Bar[V, A]])
}
$ sbt
[info] Loading global plugins from /<myhome>/.sbt/0.13/plugins
[info] Loading project definition from /<myhome>/Documents/devel/LucreSwing/project
[info] Set current project to LucreSwing (in build file:/<myhome>/Documents/devel/LucreSwing/)
> clean
[success] Total time: 0 s, completed Mar 23, 2014 11:04:59 PM
> compile
[info] Updating {file:/<myhome>/Documents/devel/LucreSwing/}lucreswing...
[info] Resolving jline#jline;2.11 ...
[info] Done updating.
e = NetAddr("127.0.0.1", 17737);
n = 10;
/*
[ 1, 18 ]
[ 2, 19 ]
[ 3, 20 ]
[ 4, 21 ]
[ 5, 23 ]
@Sciss
Sciss / extViewSaveImage.sc
Created April 1, 2014 20:39
Wiping my old computer. Backup this just in case.
+ JSCView {
saveAsImage { arg fileName, format, all = true;
var w, h, pixelFormat, bImg, gImg, imageIO, file, comp, meth;
w = jBounds.width;
h = jBounds.height;
format = format ?? { fileName.splitext[ 1 ]};
pixelFormat = if( format.asSymbol === \png, 2, 1 ); // TYPE_INT_ARGB vs. TYPE_INT_RGB
bImg = JavaObject( 'java.awt.image.BufferedImage', server, w, h, pixelFormat );
@Sciss
Sciss / mkCompanion.scala
Created April 1, 2014 21:29
Wiping old computer. Make a backup of this one.
package de.sciss.lucre.macros
import scala.annotation.StaticAnnotation
import scala.reflect.macros.{BlackboxContext => Context}
import language.experimental.macros
trait Foo[A]
class mkCompanion extends StaticAnnotation {
def macroTransform(annottees: Any*) = macro mkCompanionMacro.impl