Kona and Sporth
On Kona
Kona! What a language!
I first found Kona half a year ago while looking up terse programming programming languages. I wanted to find languages that could be expressive in a 140-character tweet or less. I found myself intrigued with the unusual aesthetics of Kona and the APL family of languages; there seemed to be many musical applications. At the time, Kona touched upon abstractions of music that I wasnt readly to deal with; Soundpipe was in its infancy, and Sporth was not even born yet. I was still at the atomic level, and more infrastructure needed to be laid out and realized.
Kona and Sporth
Kona (and K for that matter) has the distinction of being centered around "lists" and array-based processing. For me, that means
What I wanted from Kona was to be able to compile Kona code instead of Sporth to generate ftable code.
When I first looked at the codebase for Kona, I was both in awe and horrified at what I saw. Being fearless and determined, I jumped in and ended up being able to implement their API in Sporth in under an hour. While the codebase is quite unusual, it is quite consistent, and properly documented.
Building Kona for Sporth
At the moment, building Kona in Sporth is a little bit of a hack. Kona must be built before compiling Sporth. Once that is done, you must enable it in config.mk and specify where the Kona directory is.
A Major Scale in Kona
After a few days with Kona, I figured out how to build a major scale. The code looks like this:
s:0 2 4 5 7 9 11;
do:{(s@(!x)!#s)+(12*((!x)%#s))};
do 24
Some brief analysis:
- 's' is our array
- 'do' is our function
- 'x' is a variable for length
- (!x)!#s creates a orderded sequence (1, 2, 3, ...) of x size wrapped around length of #s s@ reaches for a particular index
- (12 * ((!x)%#s))) adds octaves (every time it reaches the end of the array, add 12)
Kona to ftable
At the moment, Kona code can only be used to generate Sporth ftables. Using the major scale kona code from above, we can build a sequencer using a fm oscillator and a trigger-sequencer:
# Generate major scale
"maj" "s:0 2 4 5 7 9 11;do:{(s@(!x)!#s)+(12*((!x)%#s))+48};do 14" kona
cycle through generated table
0.1 dmetro dup 0 pset
frequency from tseq
0 "maj" tseq mtof
amplitude
0.3
carrier
1
randomized modulator
0 p 1 4 trand floor
randomized mod index
0 p 0 4 trand
fm
Some Readings
Here are some articles on K I found.
I believe that the K, and APL family of languages is worth looking into, even if you don't plan on doing anything with it. It's chock-full of interesting people and ideas.
Whitney (creator K) on the design and aesthetics of K
Humorous Anecdote about Whitney and his ideas for an OS in K