Skip to content

Instantly share code, notes, and snippets.

Avatar

Hanns Holger Rutz Sciss

View GitHub Profile
@Sciss
Sciss / library,js
Created Dec 27, 2020 — forked from aknuds1/library,js
Emscripten - how to pass an array of floating point numbers from JavaScript to a C callback, to let the latter fill it with data.
View library,js
// "use strict";
var LibraryTst = {
initialize: function (callback) {
callback = Runtime.getFuncWrapper(callback, 'vi')
var numBytes = 2 * Float32Array.BYTES_PER_ELEMENT
var ptr = Module._malloc(numBytes)
try {
callback(ptr)
View TrigHold_Fun.scala
val OVR = 6
val F = OVR * 8
val SR = 48000.0
val mod1 = LFSaw(111.1 / (SR * OVR)).linLin(-1, 1, 10, 40)
val mod2 = LFSaw( 11.1 / (SR * OVR)).linLin(-1, 1, 190, 720)
val mod3 = LFSaw( 22.2 / (SR * OVR)).linLin(-1, 1, 11, 42)
val h = TrigHold(Metro(mod3 * F), (ArithmSeq(4, 1) % mod1) * F, Metro(mod2 * F))
val r = Resample(h, factor = 1.0/OVR) * 0.8
val l = LeakDC(r).drop(300)
//Plot1D(l, 400)
View ListDependencies.scala
// output of 'sbt dependencyTree'
val e = scala.io.Source.fromFile(userHome/"Downloads"/"dep.txt")
.getLines.toList.filter(_.contains("+-de.sciss"))
.map { ln =>
val i = ln.indexOf("+-") + 2
val j = ln.indexOf(" ", i)
val k = ln.lastIndexOf(":", if (j < 0) ln.length else j)
ln.substring(i, k)
}
.sorted.distinct
View SJS_missingTypes.md

Classes

  • java.io.BufferedInputStream
  • java.io.BufferedOutputStream
  • java.io.File
  • java.io.RandomAccessFile
  • java.io.FileInputStream
  • java.util.concurrent.ScheduledExecutorService
  • java.util.concurrent.ScheduledFuture
  • java.util.concurrent.Executors
View RewriteScalaTestShouldBe.scala
// midiRatio( 10.5) shouldBe 1.8340080864049 +- eps
val fIn = file("/home/hhrutz/Documents/devel/Numbers/src/test/scala/de/sciss/numbers/DoubleSpecOLD.scala")
val lnIn = scala.io.Source.fromFile(fIn).getLines.toList
val lnOut = lnIn.map { ln =>
if (ln.contains("shouldBe")) {
val i_eps = ln.indexOf("+-")
val hasEps = i_eps > 0
val t_shd = " shouldBe "
val i_shd = ln.indexOf(t_shd)
val ln1 = if (!hasEps) ln else ln.substring(0, i_eps)
View delete-ghpages.sh
#!/bin/bash
# run this with personal-access-token (repo scope) as argument
# cf. https://stackoverflow.com/questions/53452910/how-to-remove-a-github-environment
env=github-pages
token=$1
repo=Mellite
user=Sciss
if [ $# -eq 0 ]
then
View JoinPDFs.scala
val mainSq = (userHome / "Downloads" / "rb").children(f => f.extL == "pdf" && f.base.startsWith("p-")).sorted(File.NameOrdering)
mainSq.foreach(f => println(f.base))
def runMain(): Unit = {
val out = userHome / "Downloads" / "rb" / "main.pdf"
require (!out.exists())
import scala.sys.process._
val cmd = Seq("pdftk") ++ mainSq.map(_.path) ++ Seq("cat", "output", out.path)
val code: Int = cmd.!
require (code == 0)
View JoinPDFs.scala
val mainSq = (userHome / "Downloads" / "rb").children(f => f.extL == "pdf" && f.base.startsWith("p-")).sorted(File.NameOrdering)
mainSq.foreach(f => println(f.base))
def runMain(): Unit = {
val out = userHome / "Downloads" / "rb" / "main.pdf"
require (!out.exists())
import scala.sys.process._
val cmd = Seq("pdftk") ++ mainSq.map(_.path) ++ Seq("cat", "output", out.path)
val code: Int = cmd.!
require (code == 0)
View ConvertJPGtoPDF.scala
val inSq = (userHome / "Downloads" / "rb").children(_.extL == "jpg")
def run(): Unit =
inSq.foreach { in =>
val out = in.replaceExt("pdf")
require (!out.exists())
import scala.sys.process._
val code: Int = Seq("convert", in.path, out.path).!
require (code == 0)
}
View ResampleLayerFFTFilter3.scala
def snd = AudioFileIn("in")
val dur = 60.0
//val pch = Seq(0.5, 1, 1.5, 2, 4)
val pch1 = Seq(0.6, 0.8, 1.0, 1.2, 1.4)
val pch2 = Seq(0.8, 0.9, 1.0, 1.1, 1.2)
val pch = pch1 zip pch2
val freq0 = 200.0 // 100
val freq1 = 5000.0
val gain0 = 128.0