k2cli is the command line interface to Kronos, the Just in Time compiler for musical signal processing. In this technology preview, it is a 32-bit Windows executable. Extensive platform support is coming later.

A command line overview can be accessed by using the switch -h

PS C:\Users\Vesa\Kronos.Preview1> .\k2cli.exe -h
K2CLI 0.1
(c) 2011 Vesa Norilo

Usage: k2cli [options] [files...]
[files...] will be parsed and imported before evaluation of <expression>

  -h or --help                        :  display this help
  -p or --profile                     :  report timing information for compilation and execution
  -i or --infer                       :  perform type inferral on expression and report
  -q or --quiet                       :  suppress output apart from result
  -e <expr> or --expression <expr>    :  evaluate the expression <expr>
  -w <path> or --write <path>         :  write audio output to file <path>
  -l <count> or --loop <count>        :  repeat the execution <count> times
  --console <expr>                    :  print reactive output of <expr>
  --audio-out <expr>                  :  derive a real time audio stream from <expr>
  --setup                             :  enumerate available hardware and compilers
  --audio-dev <out> <in>              :  use device indices <out> and <in> for audio i/o
  --break                             :  insert breakpoint for debugging

The quickest way to talk to Kronos is to use the interactive mode. Launch the application without any switches and enter a mathematical expression like so:

PS C:\Users\Vesa\Kronos.Preview1> .\k2cli.exe
K2CLI 0.1
(c) 2011 Vesa Norilo

Type 'k2cli -h' for help. Enter an expression to evaluate or nothing to quit.

EXPR>1 + 1
1 + 1 => 2

Note the whitespace around all tokens. All infix functions, +, -, * and / have the same requirement. Without whitespace, infix characters are considered to be part of a symbol. For example


Is a valid function call, not a difference of four variables Make, Love, Not and War. I realize some people will hate me for this, but I prefer the code to look this way. You can always drop infix functions altogether and write

Add(Mul(3 5) 2)

To compute 3*5+2.

Importing files

You can import functions from a text file. By convention, all Kronos sources have the extension ‘.k’, but the compiler doesn’t really care. Let’s write a simple function and save it as ‘myfunc.k’

/* myfunc.k */
	Take-Square = x * x

Now we can ask the command line interface to load up our file and use our function.

PS C:\Users\Vesa\Kronos.Preview1> .\k2cli.exe .\myfunc.k
K2CLI 0.1
(c) 2011 Vesa Norilo

Take-Square(3) => 9

Fantastic! In part 2, we will cover programming basics.

No Comment.

Add Your Comment

five − 5 =