Hello. Let me start by saying I haven’t programmed with Kotlin yet; I have some experience with Java and C#, building a couple of simple Android apps, and for my next idea I heard it’s advisable to go with Kotlin.
My idea involves being able to input musical notations of sorts, with the app both providing an audible response while inputting new notes and when replaying earlier parts already composed. To my understanding a standard way of doing that is creating MIDI messages that are fed to a player running soundfont samples, but I don’t really know where to begin.
Using the knowledge I already have with object-oriented programming I think I figured a reasonable way of storing and handling all of the different notational data, but how to execute it for musical playback I don’t know yet.
Thank you for the suggestion. I need to read about this OPENRNDR thing, though. I did find some library published years ago that should enable playing MIDI and soundfont using Java, should it usually be easy to port to Kotlin?
For the kind of code I write I find it easy to convert Java to Kotlin, but I guess it depends on your experience. The IDE does most of the conversion automatically when I paste Java into a Kotlin file, then I clean it up and make it more idiomatic.
Thank you. I still need to try (haven’t started with the coding yet so it’s still just concept speaking), but perhaps it will work with that soundfont player as is. Does it provide feedback about the snippets which it couldn’t convert or does it just not behave as expected and then it’s up to you to inspect what went wrong?
By “porting” the Java library do you mean that you want to use it from Kotlin or do you want to actively develop the library, preferable in Kotlin language? I ask because you don’t need to port anything to use Java library in a Kotlin project. You just… use it. Kotlin and Java are interoperable with each other.
I mean you can freely use Java code/library from your Kotlin code. Or you can mix Java and Kotlin in a single project, so class A is in Java and class B is in Kotlin.
It is for situations when you have Java code, you would like to modify it, but you prefer working in Kotlin. Or maybe if you develop a project in Java, then you would like to port it entirely to Kotlin, to not see Java at all. Or you just copy snippets of code from one place (or StackOverflow) to another.
I personally very rarely convert any code, I sometimes do this in “snippets” case.
OK, good to know. I did read Google plans to convert all of their own apps to Kotlin so I thought it might be an entire process that needs to be meticulously done.
As far as the JVM knows, there’s no such thing as Kotlin, or Java, or Scala, or Groovy, or Clojure — all it sees is Java bytecode, with no sure way to know what it was compiled from. So as long as a library is available (on the classpath), then you can use its classes from Kotlin code, whatever language it was written in.
(This is of course how Kotlin code can call Java code, and vice versa. Though the Kotlin designers have put a lot of effort into making the interoperability as seamless as possible.)