User Guides v3.0

Functions

Cantabile's expression engine supports the following functions. See also the Variable Reference and Sys-ex Expressions.

Supported Functions

.NET Math functions
All the static functions of the .NET Math class
ASCII(str)
ASCII-7 encodes a string, returning a byte array
clamp(value,min,max)
Clamps a value between a specified range
formatGain(value [, muteString])
Formats a scalar gain value to decibels string. If less than approx -60b returns -∞ or the muteString if supplied.
formatDb(value [, muteString])
Formats a decibel value to a string. If less than approx -60b returns -∞ or the muteString if supplied.
fromDb(value [, limit])
Converts a decibel value to scalar. If limit specified and value < limit returns zero.
formatMidiNote(value)
Formats a MIDI note number using Cantabile current settings for display note names.
formatNumber(value, formatString)
Formats a number using a C# double format specifier. eg: formatNumber(123.123456, "N2") to format to 2 decimal places.
formatProgramNumber(value)
Formats a program number according to current Cantabile settings for displaying program numbers.
hi7(x)
returns the high-7 bits of a 14-bit number
hibyte(x)
returns the high-8 bits of a 16-bit number
length(x)
returns the number of elements in an array, the number of characters in a string or 1 for other types.
lo7(x)
returns the low-7 bits of a 14-bit number
lobyte(x)
returns the low-8 bits of a 16-bit number
int(x), uint(x), long(x), ulong(x), short(x), ushort(x), byte(x), sbyte(x)
converts a value to a specified integer type (typically used for forcing a floating point value to integer)
midivarlen(x)
encodes a multi-byte integer using 7-bit MIDI variable length encoding.
strcat(a,b)
joins two strings together, although the + operator can also be used to join strings.
strpart(str, i)

splits a string on semicolon ; characters and returns the ith part, or an empty string if not enough parts are available.

eg: strpart("Apples;Pears;Bananas", 1) returns "Pears".

substr(str,pos)
returns a sub-string of str starting at character pos. If pos is negative, returns the end of the string
substr(str,pos,length)
returns a length characters from str starting at character pos. If pos is negative, returns the end of the string
toDb(value [, limit])
Converts a scalar gain value to decibels. If limit specified and value < limit returns negative infinity.
RolandCheckSum(array)
calculates the Roland sys-ex checksum of an array. (The array is flattened to a byte array using the same rules as for sys-ex expressions)
UTF7(str)
UTF-7 encodes a string, returning a byte array
UTF8(str)
UTF-8 encodes a string, returning a byte array
UTF16(str)
UTF-16 (little endian) encodes a string, returning a byte array
UTF16_be(str)
UTF-16 (big endian) encodes a string, returning a byte array