Created
March 27, 2012 23:21
-
-
Save Sciss/2221425 to your computer and use it in GitHub Desktop.
SerializeSynthGraph.scala
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
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 ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
It suffices to have
trait Lazy extends Serializable
. -- It just won't work in the REPL / ScalaInterpreterPane for some reason -- probably class loader issues.