Skip to content

Instantly share code, notes, and snippets.

@Sciss
Created March 27, 2012 23:21
Show Gist options
  • Save Sciss/2221425 to your computer and use it in GitHub Desktop.
Save Sciss/2221425 to your computer and use it in GitHub Desktop.
SerializeSynthGraph.scala
import java.io._
import de.sciss.synth._; import ugen._
trait SomeOut
// it seems crucial that the UGenSource.SingleOut is annotated @serializable
// for some reason. While `SomeOut` doesn't need that.
@serializable abstract class SingleOut( val name: String ) extends SomeOut
case class LFSaw (rate: Rate, freq: GE, iphase: GE) extends SingleOut( "LFSaw" )
val baos = new ByteArrayOutputStream()
val oos = new ObjectOutputStream( baos )
oos.writeObject( LFSaw( audio, 441, 0 ))
val bais = new ByteArrayInputStream( baos.toByteArray )
val ois = new ObjectInputStream( bais )
val saw = ois.readObject.asInstanceOf[ LFSaw ]
@Sciss
Copy link
Author

Sciss commented Mar 28, 2012

It suffices to have trait Lazy extends Serializable. -- It just won't work in the REPL / ScalaInterpreterPane for some reason -- probably class loader issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment