Has anyone used SuperCollider from Kotlin?

Hi hi :slight_smile:

During the last 3 years I’ve been using Kotlin which has become the language I enjoy most (among 30 others I tried over the years), so I was wondering if there’s a way to do SuperCollider from it. I was happy to discover ScalaCollider, which I can add to my Kotlin project with just one line

implementation("de.sciss:scalacollider_3:2.7.4")

but the next thing I heard was that Scala doesn’t mix well with other JVM languages. The IDE shows errors in the code and the tooltips do not help me figuring out how to fix them (probably because the Scala code was not meant to be accessed this way).

Next thing that comes to mind is How I ported 10K lines of Scala to Kotlin in one week?! | HackerNoon but I have zero experience with Scala.

Is there anyone here who might be interested in using Kotlin to produce sound? Any success trying to do that?

I really enjoy kotlin as well (I use it for Android development at my day job). I haven’t tried for SC yet though. I’m short on time at the moment, but I’ll want to try this as well.
Josh

1 Like

Check out PunKt, a live coding environment in Kotlin that uses SuperCollider: GitHub - pjagielski/punkt: Live coding music library/environment for Kotlin

2 Likes

PunKt looks great but I’m more into sound than rhythm. I hope some day it allows creating synths too :slight_smile:

I hear ya, I was dreaming of using SuperCollider inside of OPENRNDR. I don’t know much about any JVM languages, but from what I’ve gathered it seems it is possible to call Scala from Kotlin, if you first compile the Scala to bytecode and then include that in your Kotlin project…

Maybe @Sciss has some thoughts on this?

1 Like

I should try again. In my first post above I showed how I added ScalaCollider to my OPENRNDR project. That works, and it adds the bytecode. The issue is that the API provided by the scala jar file is not easy to explore from the IDE when writing Kotlin, and I wasn’t even sure how to create the data types it expects. I should ask the author of the library Sciss, yes XD

1 Like

Hey, sorry just noticing the post now. Always good to @ me for ScalaCollider things.

As has been noted, you won’t have much fun trying to use a Scala library from Kotlin (the opposite by the way, is true too; you can’t meaningfully use a Kotlin library in Scala).

Personally, I find Scala a lot better and Kotlin a sort of subset of Java and Scala. I don’t think it will be trivial to port ScalaCollider nicely to Kotlin, although if you start from scratch, you could use the UGen XML database.

best, .h.h.

1 Like

Hi :slight_smile: Thank you for your message. Are you aware of language features used in ScalaCollider that don’t have equivalents in Kotlin? Could the file names and folder structure be the same in a Kotlin version, even if the content of the files is different? That sounds a bit easier than starting from scratch :slight_smile:

Hi. The ScalaCollider code is relatively straight forward and, unlike SoundProcesses for example, does not use many advanced language (type system) features, so I don’t see why you couldn’t translate it to Kotlin. As said, I wouldn’t do it for the UGen files as they are already synthetically generated; perhaps only for testing, before you write a generator yourself.

1 Like