CMIX < some_score.filewill use Minc to parse the score and make the appropriate function calls to run RTcmix. There are other options, including the ability to run RTcmix from perl, python, imbedded within another application, or through a TCP/IP socket. Minc is also used to parse buffer-scripts in the Max/MSP rtcmix~ object and in the iRTcmix package for iOS devices.
Minc takes most of its functionality from the "C" programming language, including flow-of-control features such as for and while loops, if decision-constructs, etc. See the RTcmix tutorial (especially the later sections about algorithmic composition) for examples of Minc use. The biggest differences between Minc and "C" is the lack of pre- and post-fix operators in Minc (i.e. "i++" or "--counter") and the absence of semicolons as line/statement terminators (note: semicolons are still required in "for(...)" statements). Semicolons may be used at the end of Minc lines, but they are not required (they are simply ignored).
Some other useful features of Minc:
for (i = 0; i < 7; i += 2) { ...and
while (asympt > 0.001) { asympt *= 0.5; ...}will be parsed correctly.
a = { 1, 2, 3, 4, 5 } INSTRUMENT(a[3], a[0], ...) b = {} // note that "b" is dimensioned by use for (i = 0; i < 10; i += 1) b[i] = i * 3Minc arrays can also contain 'mixed' data types:
afloat = 1.2345 astring = "hey hey!" b = { 123, afloat, "ho ho", astring }Arrays can also contain pfield-handle handles for tables, etc.:
e = {} x = 1 for (i = 0; i < 10; i += 1) { e[i] = maketable("random", 1000, "linear", min=x, max=x*2, seed=x*3) x *= 2 }Arrays can be passed into maketable consructions:
d = { 0,0, 1,1, 3,1, 5.5,0 } env = maketable("line", 1000, d)Array elements may also include other arrays. However, to access the sub-arrays, a 'temp' array variable is necessary:
arr1 = { 1, 2, 3, 4, 5, 6, 7 } arr2 = { 77, 87, 97, 107 } superarr = { arr1, arr2 } temparr = superarr[0] for (i = 0; i < len(arr1); i += 1) { print(temparr[i]) }'temparr' in the above code temporarily represents the 'arr1' array. Note that arrays of different lengths may be stored in a 'super' array.
The
len
built-in function is used to determine the length of an array
(as well as lengths of other Minc data-types).
/* a comment may be between two slash-asterisk markers */ /* and it may also span several lines */ // anything after two backslashes on a line will be construed as a comment
aval = somecalculation(anotherval, something_else) thisone = thatone + those ANINSTRUMENT(with, many, different, parameters)In addition, operations and functions may be imbedded (or 'nested'):
INSTRUMENT(somefunction(var1, var2), val^3.2, aval, 3.1654, func1(func2(array[3])))Unfortunately, Minc does not have the capability to define and use on-the-fly functions at present.
if ((val > 2.0) && < (val2 != 0)) { ... }Note that the "do-until" and "switch" statements are not supported in Minc.
a = { 1, 2, 3, 4, 5, 6 } print(a) // print can handle arrays foo = "foo"; bar = "bar" afloat = 1.2345; astring = "blah" b = { 123, afloat, "blabber", astring, a, foo + bar } // an array can embed other arrays // also note the string concat with '+' operator numitems = len(b) // get length of array printf("array b: %d items: %l\n", numitems, b) // printf for ints and lists (i.e., arrays) printf("afloat=%f, astring=%s\n", afloat, astring) // printf for floats and strings idx = index(b, 345) // Return a zero-based index into array (arg 1) of item (arg 2) print(idx)
Minc, has two modes of operation: batch and interactive (the default). The only difference between them is that loops cannot be executed in interactive mode. To run in batch mode a -b flag must be specified on the Cmix command line, and all data must be entered either by redirecting input from a file, or by typing all data followed by a <cntrl-D>. Comments are inclosed by /* and */ as in C. Any user function which returns a value can return that value to Minc if it is declared as a type double and introduced in the profile.c file.
The following is Lars Graf's formal statement of the language:
Order of precedents: || && = != < > <= >= + - * / ** ^ CASTS Syntax: prg: stml stml : stmt | stml stmt | stmt ; | stml stmt ; stmt: float idl /* declare ids */ | id = exp | IF bexp stmt | IF bexp stmt ELSE stmt | WHILE bexp stmt | FOR ( stmt , bexp , stmt ) stmt | id ( expl ) /* a call to a cmix function */ | { stml } idl: id /* like: fnct_name(arg1,arg2,arg3) */ | idl , id id: any letter/digit/"_" combination, but start with letter expl: exp | exp ',' expl | or no function argument bexp: exp | ! bexp | bexp && bexp | bexp || bexp | bexp = bexp /* note the comparison of booleans */ | exp < exp | exp > exp | exp != exp | exp <= exp | exp >= exp | TRUE | FALSE exp: exp ** exp | - exp | exp * exp | exp / exp | exp + exp | exp - exp | ( bexp ) | any number: e.g. 34 -645.34 234.E23 ... Note: 1) Semicolon andare optional. 2) '=' is used for assignments and boolean expressions. 3) False = 0; True = 1(or nonzero). Samples: /* this is a legal comment */ float foo,x; if i=3 && foo>4 say_mumble( foo**i , i-foo*3) else mumble_foo() while x=3 { this_is_a_cmix_function_call() x= 5 * (foo=i) /* this is slime */ while true nested_loops_are_possible() } for (x=1, x <= 10,x=x+1) dispatch(x) Minc also has the following facilities: 1) function calls can return values e.g. i = rand(j) NOTE: those are calls to your own C-functions. You may adjust your dispatcher and your functions accordingly The function must be introduced in the profile, and must be of type double. 2) assignment statements have the value of the assignment. e.g. i = j = 5 while (i=j) == 5 { mumblings .. } 3) strings can be passed as arguments. e.g. file_id = open("name of file",2) printf("some string %f %f0,i,j) /* of course, the dispatcher has to know about printf */ NOTE: the string pointer is passed as a double; to convert back, you have to first cast it into an integer, and then you have to cast the integer into a char*. 4) use '=' for assigment; and '==' as the booleam equal operator. Here is a simple example file: open("sf/bigsound",0,0) open("sf/bigmix",1,2) sfclean(1) float a,b,c,d a=2 b=3 c=28000 d=-4 sound(a,b,c,1,22*19,d=d-a) sound(a=a+2, b+.1, 99, d=d-a+2)