Polyglot SuperCollider

Polyglot SuperCollider is an experiment in collating SuperCollider work from multiple languages.

PolyglotGraphBrowser is a simple interface for browsing the resulting archive.

It currently knows about graphs written in:

  • .fs = Forth
  • .hs = Haskell
  • .scala = Scala
  • .scd = SuperCollider
  • .sch = Scheme (Haskell Syntax)
  • .scm = Scheme
  • .st = Smalltalk

Polyglot SuperCollider is research quality, it has minimal documentation and though it’s written in SuperCollider and doesn’t need other language interpreters some functions require external processes that aren’t included here.

PolyglotGraphBrowser is at http://rd.slavepianos.org/t/sc3-rdl

There is an archive of graphs at http://rd.slavepianos.org/t/hsc3-graphs (in the “db” directory) and a program for autogenerating the archive.

There are some demonstration videos at http://rd.slavepianos.org/?t=sc3-rdl&e=md/video.md

Best,
Rohan

3 Likes

It looks interesting but I have a hard time understanding what this does with the information you provided. Is it an interface to speak with scsynth with different languages? Really intrigued!

Hello

Sort of. It’s two things really.

One is an archive of SuperCollider graphs written in various languages, each paired with the .scsyndef file it compiles to.

You can make your own, or you can use the one at:

https://gitlab.com/rd--/hsc3-graphs/

The archive is in the “db” directory.

The actual polyglot part is the program at:

https://gitlab.com/rd--/hsc3-graphs/-/blob/master/cmd/graphs.hs

which knows how to parse files from various languages into fragments, collect the resulting graph definitions, and run the various language interpreters to generate the .scsyndef files.

The other part is a simple browser for this kind of archive.

You can scan through or search the graph texts, read them, listen to them.

If you install some utility programs you can also make graph drawings, generate textures, make user interfaces, a few other things.

The browser part is at:

https://gitlab.com/rd--/sc3-rdl

I’ve added a .quark file which might make it easier to install.

I made this as a way of collecting related materials that were scattered across various projects and languages into the one place, and also to maybe have a framework for placing future work into.

It’s just an experiment.

Best,
Rohan

Hi Rohan,

cool project, and thanks for including Scala. I’m not 100% sure how the code is parsed, as you mentioned “language interpreter”. Does it support the full language syntax? Out of curiosity, I notice that you write out the .apply methods in Scala and use terminal semicolons, e.g.

// https://twitter.com/redFrik/status/456384156159574016
val n = Seq.apply(3,12,4,1,6,2).map(x => x.reciprocal);
val a = GE.fromFloatSeq(n);
val s = Lag3.ar(SinOsc.ar(n, 0), SinOsc.ar(GE.const(2.67).pow(n), 0).abs) * 99;
val f = ((SinOsc.ar((1 / a) / 9, a) > 0) * 20 + 99) / a;
SplayAz.ar(2, SinOsc.ar(HPF.ar(Ringz.ar(s, f)), 0)) * 0.25

which could be written (with the necessary imports)

val n: GE = Seq(3,12,4,1,6,2).map(_.reciprocal)
val s = Lag3.ar(SinOsc.ar(n, 0), SinOsc.ar(2.67.pow(n), 0).abs) * 99
val f = ((SinOsc.ar((1 / n) / 9, n) > 0) * 20 + 99) / n
SplayAz.ar(2, SinOsc.ar(HPF.ar(Ringz.ar(s, f)), 0)) * 0.25

(conversion from Seq[Double] to GE is a bit clunky, that’s why the : GE annotation is explicit here).

I guess I have to download the repositori(es) and try it out myself.

Regards, .h.h.

BTW, going back to the original tweet:

a=SinOsc;play{Splay ar:a.ar(HPF.ar(Ringz.ar(a.ar(b=1/[3,12,4,1,6,2]).lag3(a.ar(2.67**b).abs)*99,a.ar(1/b/9,b)>0*20+99/b)))}// #SuperCollider

with some polyfills (I guess I should add these) :slight_smile:

object Splay { 
  def ar(in: GE): GE = SplayAz.ar(2, in / NumChannels(in).sqrt) 
}

implicit class MoreOps(in: GE) {
  def lag3(t: GE): GE = Lag3.ar(in, t)
}

one can write

val a=SinOsc;play{val b=(1:GE)/Seq(3,12,4,1,6,2);Splay.ar(a ar HPF.ar(Ringz.ar(a.ar(b).lag3(a.ar(2.67 pow b).abs)*99,((a.ar(1/b/9,b)>0)*20+99)/b)))}// #ScalaCollider

which is 165 over 140 chars :wink:

I’m trying cabal install, and it gives me

Warning: hsc3-graphs.cabal:0:0: Unsupported cabal-version. See
https://github.com/haskell/cabal/issues/4899.
cabal: Failed parsing "./hsc3-graphs.cabal".

If I understand the linked issue correctly, it might be that the required cabal is newer? I’m on Debian stable, so that’s cabal 2.2 while the build file wants 2.4, perhaps that’s the reason? End of July will be Debian bullseye :slight_smile:

I just tried editing the hsc3-graphs.cabal, after that I see

Resolving dependencies...
cabal: Could not resolve dependencies:
[__0] trying: hsc3-graphs-0.20 (user goal)
[__1] next goal: hsc3-lisp (dependency of hsc3-graphs)
[__1] rejecting: hsc3-lisp-0.15 (conflict: hsc3-graphs => hsc3-lisp==0.20.*)
After searching the rest of the dependency tree exhaustively, these were the
goals I've had most trouble fulfilling: hsc3-graphs, hsc3-lisp

The 0.15 seems to come from hackage? So I need to add a different repository or publish my own versions 0.20 of hsc3-lisp, perhaps?

Hello,

Ah, thanks!

I’m completely new to Scala so I’m trying to write things out in full (as it were) to start with.

I guess the opposite of concision.

And yes all the Haskell SuperCollider things need cabal-2.4 or later.

I think you could run the gnostic cabal install cabal-install command, maybe afer a cabal update?

Or you could get a binary, I think this one is built on debian stable.

But you don’t need that just to run the browser, only if you want to process more graphs…

You do need various things to make all the menu items work, but play and stop will work all by themselves!

Best,
Rohan