Skip to content

Instantly share code, notes, and snippets.

// ScalaCollider -- tested on 48 kHz SC 3.8.0
play {
def one = {
RandSeed.ir()
val v0 = LFDNoise0.ar(500.0)
val v1 = LFDNoise3.ar(v0)
val v2 = 39.39295
val v3 = 6911.0312
val v4 = LFDNoise3.ar(v3)
val v5 = 40.62856
// Copyright by Ron Kuivila. Provided for research purposes only.
/* "electric wind" simple installation
This is a simplified version of the electronics for "Electric Wind", a piece for flute and electronics.
The basic principle of the piece is simple: two signals play in separate channels.
Whenever their instantaneous levels match and their derivatives are within a specified range,
they trade channels. This creates modulation patterns similar to switched tone codes, but
directly reflecting the tuning relation of the tones and their relative amplitude.
PATH
remote: .
specs:
minimal-mistakes-jekyll (4.9.0)
jekyll (~> 3.6)
jekyll-data (~> 1.0)
jekyll-feed (~> 0.9.2)
jekyll-gist (~> 1.4)
jekyll-paginate (~> 1.1)
jekyll-scholar (~> 5.11.0)
// Simon Schäfer in Scala-IDE gitter
val outputDir = new VirtualDirectory("<virtualdir>", None)
val settings = new Settings(err ⇒ Console.err.println(err))
settings.outputDirs.setSingleOutput(outputDir)
settings.usejavacp.value = true
settings.source.value = ScalaVersion("2.12.1")
val reporter = new StoreReporter
val compiler = new Global(settings, reporter)
import compiler._

Existing Systems

(Apologies for "opinionated" remarks; this is just helpers for my memory)

Scaled

  • org: https://github.com/scaled/
  • JavaFX based editor, mostly Scala code-base with Java'ish feel, some Java
  • supports multiple languages
  • uses custom build system (pacman)
import java.io.File
// quick semi-autotranslation from a Java snippet on SO
// get all classes with a package prefix
def getClasses(packageName: String): List[Class[_]] = {
val classLoader = Thread.currentThread.getContextClassLoader
assert(classLoader != null)
val path = packageName.replace('.', '/')
val resources = classLoader.getResources(path)
var dirs = List.empty[File]
def cauchyCDF(gamma: Double = 1.0, x0: Double = 0.0) = (x: Double) =>
1.0/math.Pi * math.atan((x-x0) / gamma) + 0.5
val f = cauchyCDF()
(-6.0 to 6.0 by 0.1).map(f).plot()
// y - 0.5 = 1.0/math.Pi * math.atan((x-x0) / gamma)
//
val dirIn = file("/data/projects/Maeanderungen/materials/audio_work")
(dirIn/"rhizom").children.map { fIn =>
import sys.process._
val fOut = dirIn/"rhizom_mp3"/s"${fIn.replaceExt("mp3").name}"
Seq("lame", "--noreplaygain", "-b", "256", "-h", fIn.path, fOut.path).!!
}
// cf. https://stackoverflow.com/questions/13343260/telnet-like-connection-to-server-in-scala
class Connector(socket: java.net.Socket, handler: String => Unit) {
private val out = new java.io.PrintStream(socket.getOutputStream)
private val in = new java.io.BufferedReader(new java.io.InputStreamReader(socket.getInputStream))
private val receiver = new Thread {
override def run(): Unit = {
// var done = false
// while (!done) {
// val n = in.read()